Pytorch-yolov3: recall is high and precision is very small

Created on 18 Dec 2018  路  8Comments  路  Source: eriklindernoren/PyTorch-YOLOv3

Most helpful comment

Hi @hajlyx , I got the same problem in training my own dataset. Is there any progress after then?

I rewrite yolov3 in pytorch, and I recommend nn.BCEWithLogitsLoss as the classifier loss, it works well

All 8 comments

I met the same problem, did you solve it ?@hust-kevin

I think that loss_conf has something wrong, I trained a model using pjreddie's darknet code, everything goes well, and I loaded this model to continue training (using this repo), the terminal showed that loss_conf is about 31 when precision and recall is about 0.7. After training for a couple of batches the loss_conf decreased to 0.8 but the precision also decreased to 0.01. When I tested the model, it came out 27200 detections! Obviously 99% of them were false detection. And the objectness confs of these detections were about 0.999.

I think that loss_conf has something wrong, I trained a model using pjreddie's darknet code, everything goes well, and I loaded this model to continue training (using this repo), the terminal showed that loss_conf is about 31 when precision and recall is about 0.7. After training for a couple of batches the loss_conf decreased to 0.8 but the precision also decreased to 0.01. When I tested the model, it came out 27200 detections! Obviously 99% of them were false detection. And the objectness confs of these detections were about 0.999.

the loss_cls is not right, you must change pred_cls = torch.sigmoid(prediction[..., 5:]) # Cls pred.
to pred_cls = prediction[..., 5:] # Cls pred.

sigmoid is not need for nn.CrossEntropyLoss()

prediction[...,5:] in code are "the prob of each cls".
but low precision is caused by high fp.
And maybe high fp is caused by wrong conf.
so I think only changing this maybe not work...

I try to train model on my data,and meet same problem:
[Epoch 10/300, Batch 37/63] [Losses: x 0.044266, y 0.030875, w 0.077922, h 0.097630, conf 0.134416, cls 0.075356, total 0.460466, recall: 0.92308, precision: 0.10146]

Of course, I fix the code
pred_cls = prediction[..., 5:] # Cls pred.

But in test.py,it get a 'right' result.
Average Precisions:

  • Class '1' - AP: 0.7774741571204787
  • Class '2' - AP: 0.8802360897618701
  • Class '3' - AP: 0.608286984454941
  • Class '4' - AP: 0.889032905002481
  • Class '5' - AP: 0.4127312412363674
  • Class '6' - AP: 0.7600008860535177
    mAP: 0.7212937106049426

Hi @hajlyx , I got the same problem in training my own dataset. Is there any progress after then?

Hi @hajlyx , I got the same problem in training my own dataset. Is there any progress after then?

I rewrite yolov3 in pytorch, and I recommend nn.BCEWithLogitsLoss as the classifier loss, it works well

Hi @hajlyx , I got the same problem in training my own dataset. Is there any progress after then?

I rewrite yolov3 in pytorch, and I recommend nn.BCEWithLogitsLoss as the classifier loss, it works well

Thanks for your answer @fengxinjie ! But I solved this problem by adjusting the learning rate smaller than original(0.001 -> 0.0002). And, it's a bit silly mistake, I put the annotation files at wrong directory. Hope other people will not make mistake as I've done.

I would try this repo, P and R start high and go higher. You can plot your results as well.
https://github.com/ultralytics/yolov3

from utils import utils; utils.plot_results()
Alt

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MAP
nationalflag picture nationalflag  路  5Comments

codeyogi911 picture codeyogi911  路  4Comments

mayaghaei picture mayaghaei  路  4Comments

a954217436 picture a954217436  路  4Comments

alexandru-dinu picture alexandru-dinu  路  3Comments