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

IndexError: index 0 is out of range #59

Closed
Louis24 opened this issue Oct 9, 2021 · 3 comments
Closed

IndexError: index 0 is out of range #59

Louis24 opened this issue Oct 9, 2021 · 3 comments

Comments

@Louis24
Copy link

Louis24 commented Oct 9, 2021

首先谢谢您的教程,我最近在看网络裁剪,然后找到了这
https://blog.csdn.net/m0_53608998/article/details/117687416

在运行时发现少了很多文件,我就从

repo

https://github.com/ZJU-lishuang/yolov5_prune

缺省文件从下面找

https://github.com/ZJU-lishuang/yolov5-v4
https://github.com/ultralytics/yolov5

然后我直接裁剪发现
IndexError: index 0 is out of range

我重新训练的时候也是报错,请问是什么问题呢

Traceback (most recent call last):
File "train.py", line 520, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 86, in train
model = Model(opt.cfg or ckpt['model'].yaml, ch=3, nc=nc).to(device) # create
File "C:\Zero\Python\yolov5_prune-4\models\yolo.py", line 80, in init
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
File "C:\Zero\Python\yolov5_prune-4\models\yolo.py", line 110, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "C:\Zero\Python\yolov5_prune-4\models\yolo.py", line 130, in forward_once
x = m(x) # run
File "C:\Users\LOUIS\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "C:\Zero\Python\yolov5_prune-4\models\yolo.py", line 37, in forward
x[i] = self.mi # conv
File "C:\Users\LOUIS\Anaconda3\lib\site-packages\torch\nn\modules\container.py", line 164, in getitem
return self._modules[self._get_abs_string_index(idx)]
File "C:\Users\LOUIS\Anaconda3\lib\site-packages\torch\nn\modules\container.py", line 154, in _get_abs_string_index
raise IndexError('index {} is out of range'.format(idx))
IndexError: index 0 is out of range

Process finished with exit code 0

@ZJU-lishuang
Copy link
Owner

目前我又重新复现了该项目,补充了缺少的文件,可以重新尝试一下

@Louis24
Copy link
Author

Louis24 commented Oct 19, 2021 via email

@ZJU-lishuang
Copy link
Owner

网络结构没对上,旧版本只支持yolov5s模型

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