ScaledYOLOv4 icon indicating copy to clipboard operation
ScaledYOLOv4 copied to clipboard

How to display confidence scores on predicted images

Open ChrisGoettfert opened this issue 3 years ago • 4 comments

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

ChrisGoettfert avatar Aug 24 '21 13:08 ChrisGoettfert

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 avatar Aug 29 '21 14:08 jackhu-bme

if you want 0.95,change number 3 to 2

jackhu-bme avatar Aug 29 '21 14:08 jackhu-bme

@ChrisGoettfert

jackhu-bme avatar Aug 29 '21 14:08 jackhu-bme

Hey @Jack-Hu-2001,

It worked like a charm! Thank you very much!

ChrisGoettfert avatar Aug 31 '21 07:08 ChrisGoettfert