WongKinYiu / ScaledYOLOv4

Scaled-YOLOv4: Scaling Cross Stage Partial Network
GNU General Public License v3.0
2.02k stars 572 forks source link

How to display confidence scores on predicted images #321

Open ChrisGoettfert opened 3 years ago

ChrisGoettfert commented 3 years ago

Hey,

The inferences of my model only show the name of the Class but not the confidence. Confidence for me is neither displayed anywhere.

From Yolov5, YoloR etc. confidence was always in the picture, but for ScaledYolov4 it is not the case.

I use the following command:

!python detect.py --weights ./runs/exp0_yolov4-csp-results/weights/best_yolov4-csp-results.pt --img 416 --conf 0.4 --source ../test/images

this would be the result:

image

this is how I want it to be (from YOLOv5):

image

jackhu-bme commented 3 years ago

It's very easy,you can do that simply by change one sentence in detect.py. change line 110 "label = '%s' % (names[int(cls)])"to this: label = '%s%.3f' % (names[int(cls)],conf.item()) Then it will show the confidence.The number 3 can be changed acccoding to your needs.

jackhu-bme commented 3 years ago

if you want 0.95,change number 3 to 2

jackhu-bme commented 3 years ago

@ChrisGoettfert

ChrisGoettfert commented 3 years ago

Hey @Jack-Hu-2001,

It worked like a charm! Thank you very much!