gm19900510 / Pytorch_Retina_License_Plate

轻量级的车牌检测项目(支持车牌四角定位、矫正对齐)
160 stars 55 forks source link

训练时有无车牌数据会报错 #10

Open autm09 opened 3 years ago

autm09 commented 3 years ago

Traceback (most recent call last): File "train.py", line 165, in train() File "train.py", line 134, in train loss_l, loss_c, loss_landm = criterion(out, priors, targets) File "xxxx/anaconda3/envs/new/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(*input, **kwargs) File "xxxx/Pytorch_Retina_License_Plate/layers/modules/multibox_loss.py", line 119, in forward loss_c = F.cross_entropy(conf_p, targets_weighted, reduction='sum') File "xxxx/anaconda3/envs/new/lib/python3.6/site-packages/torch/nn/functional.py", line 2056, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "xxxx/anaconda3/envs/new/lib/python3.6/site-packages/torch/nn/functional.py", line 1871, in nll_loss ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index) RuntimeError: invalid argument 2: non-empty vector or matrix expected at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:31 您好,我在照着指引尝试训练时遇到了这样的问题 查了一下,好像是因为负样本在计算loss时会出错,但是我不知道该怎么修改 去掉所有负样本后不再报错了 可是负样本不是专门生成用来提升训练效果的吗? 或者这个错误是因为其他的原因? 求解答,谢谢您

yangh-zzf-itcast commented 1 year ago

multibox_loss hello你好,请问你解决了嘛?

zxm97 commented 1 year ago

multibox_loss hello你好,请问你解决了嘛?

https://github.com/biubug6/Pytorch_Retinaface/pull/128/commits/034f4aa0a2e244e361e7f6b0b3548c8966de3e0f#diff-a615ce76ee3f43281156122196c7656acb790693eb5285ca6b92424d1214e014 这个试过吗