ModuleNotFoundError: No module named ‘xxx‘ | 愚笨的解决方法 |
【摘要】
这种报错,有时候就是莫名其妙吖吖吖
运行的代码:
https://github.com/xinntao/BasicSR
具体报错如下:
Traceback (most recent ...
这种报错,有时候就是莫名其妙吖吖吖
运行的代码:
https://github.com/xinntao/BasicSR
具体报错如下:
Traceback (most recent call last):
File "basicsr/test.py", line 12, in <module>
from basicsr.data import create_dataloader, create_dataset
ModuleNotFoundError: No module named 'basicsr'
- 1
- 2
- 3
- 4
- 5
其实仔细,观察这个 报错是 不应该有的,所以根本原因推测应该是当前环境依赖项没有完全适配的问题;但是依赖项这个自己一时并不清楚如何下手处理;
临时解决方法:
添加父目录的代码如下:
import sys
sys.path.append("/home/墨理三生/project/project21/videoSR/EDVR/BasicSR-master/")
- 1
- 2
- 3
第二波报错如下:
2021-01-20 08:08:32,618 INFO: Generate data info for VideoTestDataset - Vid4
2021-01-20 08:08:32,620 INFO: Dataset VideoTestDataset - Vid4 is created.
2021-01-20 08:08:32,621 INFO: Number of test images in Vid4: 171
Traceback (most recent call last):
File "basicsr/test.py", line 65, in <module>
main()
File "basicsr/test.py", line 52, in main
model = create_model(opt)
File "/home/zql/project/project21/two/EDVR-master/basicsr/models/__init__.py", line 38, in create_model
model = model_cls(opt)
File "/home/zql/project/project21/two/EDVR-master/basicsr/models/edvr_model.py", line 17, in __init__
super(EDVRModel, self).__init__(opt)
File "/home/zql/project/project21/two/EDVR-master/basicsr/models/sr_model.py", line 23, in __init__
self.net_g = define_network(deepcopy(opt['network_g']))
File "/home/zql/project/project21/two/EDVR-master/basicsr/models/archs/__init__.py", line 45, in define_network
net = dynamic_instantiation(_arch_modules, network_type, opt)
File "/home/zql/project/project21/two/EDVR-master/basicsr/models/archs/__init__.py", line 40, in dynamic_instantiation
return cls_(**opt)
File "/home/zql/project/project21/two/EDVR-master/basicsr/models/archs/edvr_arch.py", line 336, in __init__
num_feat=num_feat, deformable_groups=deformable_groups)
File "/home/zql/project/project21/two/EDVR-master/basicsr/models/archs/edvr_arch.py", line 52, in __init__
deformable_groups=deformable_groups)
TypeError: object() takes no parameters
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
这个报错,网上通常查不到具体原因;
也就是说,通常大概率还是 环境问题;
对于我所运行的代码,后来发现自己少执行了一个步骤:
python setup.py develop
- 1
执行该命令,等待5分钟左右即可,看到最终输出大致如下:
Searching for oauthlib==3.1.0
Best match: oauthlib 3.1.0
Adding oauthlib 3.1.0 to easy-install.pth file
Using /home/墨理三生/anaconda3/envs/torch14/lib/python3.6/site-packages
Finished processing dependencies for basicsr==1.2.0+unknown
- 1
- 2
- 3
- 4
- 5
- 6
- 7
说明这一命令的执行是在梳理项目的环境依赖;
这时,再执行,测试命令,这个错误便消失了;
python basicsr/test.py -opt options/test/EDVR/test_EDVR_L_x4_SR_Vid4.yml
- 1
发现可以正常测试,最终输出如下:
2021-01-20 09:13:33,273 INFO: Loading EDVR model from experiments/pretrained_models/EDVR/EDVR_L_x4_SR_Vimeo90K_official-162b54e4.pth.
2021-01-20 09:13:33,430 INFO: Model [EDVRModel] is created.
2021-01-20 09:13:33,430 INFO: Testing Vid4...
2021-01-20 09:13:33,430 WARNING: nondist_validation is not implemented. Run dist_validation.
Test walk:47/47: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 171/171 [01:12<00:00, 2.36frame/s]
2021-01-20 09:14:45,918 INFO: Validation Vid4
# psnr: 25.8258 # calendar: 22.2793 # city: 26.4529 # foliage: 24.9289 # walk: 29.6420
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
文章来源: positive.blog.csdn.net,作者:墨理学AI,版权归原作者所有,如需转载,请联系作者。
原文链接:positive.blog.csdn.net/article/details/112871608
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)