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

运行test.py报错 #1

Open
hopesala opened this issue Jul 16, 2020 · 1 comment
Open

运行test.py报错 #1

hopesala opened this issue Jul 16, 2020 · 1 comment

Comments

@hopesala
Copy link

下载了训练好的yolov3_ckpt_195.pth
修改了yolov3-custom.cfg里面
[yolo]节点下面的classes=2
不然int(空字符串的时候)报错
之后运行加载权重文件报错

Namespace(batch_size=8, class_path='data/custom/classes.names', conf_thres=0.001, data_config='config/custom.data', img_size=416, iou_thres=0.5, model_def='config/yolov3-custom.cfg', n_cpu=8, nms_thres=0.5, weights_path='checkpoints/yolov3_ckpt_195.pth')
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1741, in
main()
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/caochenghua/Documents/GitHub/Pytorch-Yolov3---Remote-sensing-image-master/test.py", line 83, in
model = Darknet(opt.model_def).to(device)
File "/Users/caochenghua/Documents/GitHub/Pytorch-Yolov3---Remote-sensing-image-master/models.py", line 241, in init
self.yolo_layers = [layer[0] for layer in self.module_list if hasattr(layer[0], "metrics")]
File "/Users/caochenghua/Documents/GitHub/Pytorch-Yolov3---Remote-sensing-image-master/models.py", line 241, in
self.yolo_layers = [layer[0] for layer in self.module_list if hasattr(layer[0], "metrics")]
File "/anaconda3/lib/python3.7/site-packages/torch/nn/modules/container.py", line 68, in getitem
return self._get_item_by_idx(self._modules.values(), idx)
File "/anaconda3/lib/python3.7/site-packages/torch/nn/modules/container.py", line 60, in _get_item_by_idx
raise IndexError('index {} is out of range'.format(idx))
IndexError: index 0 is out of range
请问这是什么原因呢?

@zigangzhao-ai
Copy link
Owner

可以把之前的config文件删掉,自己再重新生成一下试试

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

2 participants