Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'yolox_s' and exps/example/custom/yolox_s.py doesn't contains class named 'Exp' #1536

Open
flyingfish7777 opened this issue Oct 11, 2022 · 4 comments

Comments

@flyingfish7777
Copy link

windows下使用pycharm,python解释器部署在SSH linux 服务器上, 运行train.py会出现以下错误

**### **Traceback (most recent call last):
File "/data3/xxx_dataset/YOLOX-main/yolox/exp/build.py", line 13, in get_exp_by_file
current_exp = importlib.import_module(os.path.basename(exp_file).split(".")[0])
File "/home/xxx/anaconda3/envs/yolox/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'yolox_s'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data3/xxx_dataset/YOLOX-main/tools/train.py", line 125, in
exp = get_exp(args.exp_file, args.name)
File "/data3/xxx_dataset/YOLOX-main/yolox/exp/build.py", line 40, in get_exp
return get_exp_by_file(exp_file)
File "/data3/xxx_dataset/YOLOX-main/yolox/exp/build.py", line 16, in get_exp_by_file
raise ImportError("{} doesn't contains class named 'Exp'".format(exp_file))
ImportError: exps/example/custom/yolox_s.py doesn't contains class named 'Exp'****

如果在linux服务器上通过命令行运行,则不会出现这个问题。

windows端以及linux端均已执行pip3 install -v -e . 并且成功。通过pych的linux解释器,运行其他网络比如yolov5等均正常运行。

@YinZhang98
Copy link

请问解决了吗

@flyingfish7777
Copy link
Author

很遗憾,这种部署的方法好像确实行不通。
所以我用pych 的远程开发模式连接这个项目了,这个问题就解决了

@xiaomaofeng
Copy link

try add sys.path.append('/root/your code path') in the train.py

@realfanyujun
Copy link

realfanyujun commented Oct 11, 2023

I also encountered this issue and here is how I solved:
comment this line in tools/train.py:

exp = get_exp(args.exp_file, args.name)

Simply copy the codes in yolox/exp/build.py to the place in tools/train.py where the above code is commented:

sys.path.append(os.path.dirname(exp_file))
current_exp = importlib.import_module(os.path.basename(exp_file).split(".")[0])
exp = current_exp.Exp()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants