bubbliiiing / mobilenet-yolov4-pytorch

这是一个mobilenet-yolov4的库,把yolov4主干网络修改成了mobilenet,修改了Panet的卷积组成,使参数量大幅度缩小。
MIT License
365 stars 104 forks source link

运行train.py为什么会数组越界异常呢...... #15

Closed qq1243196045 closed 3 years ago

qq1243196045 commented 3 years ago

Loading weights into state dict... Finished! Start Train Epoch 1/50: 0%| | 0/73 [00:01<?, ?it/s<class 'dict'>] Traceback (most recent call last): File "", line 1, in File "/home/white/software/pycharm-2021.1.3/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "/home/white/software/pycharm-2021.1.3/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/white/PycharmProjects/myolov4-lite/mobilenet-yolov4-lite-pytorch-main/train.py", line 277, in fit_one_epoch(net,yolo_loss,epoch,epoch_size,epoch_size_val,gen,gen_val,Freeze_Epoch,Cuda) File "/home/white/PycharmProjects/myolov4-lite/mobilenet-yolov4-lite-pytorch-main/train.py", line 69, in fit_one_epoch loss_item, num_pos = yolo_loss(outputs[i], targets) File "/home/white/anaconda3/envs/torch12/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/home/white/PycharmProjects/myolov4-lite/mobilenet-yolov4-lite-pytorch-main/nets/yolo_training.py", line 187, in forward mask, noobj_mask, t_box, tconf, tcls, box_loss_scale_x, box_loss_scale_y = self.get_target(targets, scaled_anchors,in_w, in_h,self.ignore_threshold) File "/home/white/PycharmProjects/myolov4-lite/mobilenet-yolov4-lite-pytorch-main/nets/yolo_training.py", line 343, in get_target tcls[b, best_n, gj, gi, target[b][i, 4].long()] = 1 IndexError: index 8 is out of bounds for dimension 4 with size 7

qq1243196045 commented 3 years ago

debug了一上午发现问题了。分类为7类,但是target[i:5]标签出现了8以上,原因是voc_annotation.py中类别列表没有改成自己的。

bubbliiiing commented 3 years ago

是的