PyTorch_YOLOv4 icon indicating copy to clipboard operation
PyTorch_YOLOv4 copied to clipboard

为什么训练时map、r、p都不为0,但是运行test.py时就全都为0?

Open whuabin opened this issue 2 years ago • 24 comments

训练时: Snipaste_2022-03-23_15-52-19

测试时:Snipaste_2022-03-23_15-50-44 这是什么原因?

whuabin avatar Mar 23 '22 07:03 whuabin

我使用的是master分支的代码

whuabin avatar Mar 23 '22 08:03 whuabin

你的Targets是0。

xiaohenghuang avatar Apr 09 '22 05:04 xiaohenghuang

为什么训练的时候不是0但是test的时候是0啊.. test的图片和标注文件都有的

whuabin avatar Apr 09 '22 05:04 whuabin

训练的是val,和test有区别。

你是用的test.py做“测试”吗

xiaohenghuang avatar Apr 09 '22 06:04 xiaohenghuang

哦哦 我说错了 应该说运行test.py的时候计算出来的targets和p、r、map都是0 刚刚我发现好像是模型返回的东西有问题 image image

whuabin avatar Apr 09 '22 06:04 whuabin

请问你知道这是啥问题吗

whuabin avatar Apr 09 '22 06:04 whuabin

我在想是不是pytorch版本问题 问一下你的版本都是啥啊?

whuabin avatar Apr 09 '22 06:04 whuabin

可是你为什么要运行test.py呢?你要是看code,test.py是会被train.py调用的。你做inference也是用detect.py。

xiaohenghuang avatar Apr 09 '22 06:04 xiaohenghuang

不是 我就是想用训练好的模型来计算map、p这类评价指标

whuabin avatar Apr 09 '22 07:04 whuabin

你的Targets是0, 看看你测试集的标注是否对应上

Joker9194 avatar Apr 11 '22 14:04 Joker9194

did you solve this problem

LiuXiaoYu2030 avatar Apr 12 '22 13:04 LiuXiaoYu2030

or you need check the .cfg, I use the worse cfg file also face the problem.

Joker9194 avatar Apr 13 '22 02:04 Joker9194

did you solve this problem

还没有解决

whuabin avatar Apr 13 '22 09:04 whuabin

你的Targets是0, 看看你测试集的标注是否对应上

应该对应上了啊 因为我数据集是直接划分成训练集和测试集的,既然训练集能够显示出targets数量,那测试集应该也没问题啊 而且我使用yolov5来训练过 可以显示target数量和p、r、map等值

whuabin avatar Apr 13 '22 10:04 whuabin

我使用u版 v3 和v5都没出现过这个问题

whuabin avatar Apr 13 '22 10:04 whuabin

你的Targets是0, 看看你测试集的标注是否对应上

应该对应上了啊 因为我数据集是直接划分成训练集和测试集的,既然训练集能够显示出targets数量,那测试集应该也没问题啊 而且我使用yolov5来训练过 可以显示target数量和p、r、map等值

我自己没有遇到过这个问题,你可以在这两行调试一下看看:

https://github.com/WongKinYiu/PyTorch_YOLOv4/blob/eb5f1663ed0743660b8aa749a43f35f505baa325/test.py#L100-L101

看看path的值以及dataloader的情况

Joker9194 avatar Apr 13 '22 10:04 Joker9194

请问解决了吗

ZeWu0307 avatar Apr 23 '22 11:04 ZeWu0307

我今天也出现了这个问题,问题的主要原因是我使用test的时候,cfg文件和我训练时的cfg文件不一致导致的,看看是不是因为这个问题。

Joker9194 avatar Apr 25 '22 04:04 Joker9194

我也是这种结果,然后定位到模型推理的时候,结果为nan

maidouxiaozi avatar Apr 25 '22 09:04 maidouxiaozi

你们有发现和解决这个问题吗?

maidouxiaozi avatar Apr 25 '22 09:04 maidouxiaozi

你们有发现和解决这个问题吗?

我发现了啊 但是没有解决 你试试上面说的方法吧

whuabin avatar Apr 26 '22 06:04 whuabin

@whuabin 请问您现在解决了吗

maidouxiaozi avatar May 25 '22 06:05 maidouxiaozi

Perhaps skipping the learning step in the train.py may be useful. I try to input the correct model, dataset, and the specific weight (such as best.pt) to the learning-step-skipped code, and get the same P, R, [email protected], [email protected]:.95 values from the output result. As a result, one of the reason why the output value from test.py is not the same as the output in training steps is that the whole model is not the same from both testing (like hyperparameter or another variable in model).

ISLab-Eden avatar Nov 12 '22 14:11 ISLab-Eden

我也遇到同样的问题,训练时val的p,r,map都是正常的,单独运行test时,同样的验证集,结果全为0.原因可能是这样,train时我把半精度关掉了,因为我的破卡不支持,会出错。所以我把test里面的半精度也关掉了,然后就不是0了,但是得出的结果很差。

lqin0818 avatar Dec 07 '22 01:12 lqin0818