ZJU-lishuang / yolov5_prune

yolov5 prune,Support V2, V3, V4 and V6 versions of yolov5
Apache License 2.0
556 stars 136 forks source link

IndexError: index 0 is out of range #59

Closed Louis24 closed 2 years ago

Louis24 commented 2 years ago

首先谢谢您的教程,我最近在看网络裁剪,然后找到了这 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 commented 2 years ago

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

Louis24 commented 2 years ago

好哦 多谢啦 我在出差 回去试试 您有qq微信嘛 我目前还有些问题

在准备面试 希望不吝赐教

Thank you very much.

Sincerely yours

Yexing Li


From: ZJU-lishuang @.> Sent: 19 October 2021 02:18 To: ZJU-lishuang/yolov5_prune @.> Cc: Louis @.>; Author @.> Subject: Re: [ZJU-lishuang/yolov5_prune] IndexError: index 0 is out of range (#59)

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

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ZJU-lishuang/yolov5_prune/issues/59#issuecomment-946432708, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEO2FABREAHVRICVKWUXUQ3UHULVXANCNFSM5FUTXAYA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ZJU-lishuang commented 2 years ago

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