AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.73k stars 7.96k forks source link

Different result from darknet_image.py and ./darknet with Yolov4x-mish and Yolov4-csp #7294

Open Faultiness opened 3 years ago

Faultiness commented 3 years ago

Thanks for reading my issue.

I trained a model to classify objects with Yolov4x-mish and the result is quite good. But, when I tried to use the darknet_image.py to process the same image with the same *.weights, *.cfg, *.data, and thresh I used in the command line and the result is quite different.

I tried to use the method mentioned in #6854 but the result still can't match.

And, which might be really confused, I trained another model the Yolov4-custom then predict the same image with the same python code (not modified) and the result is the same with the command line output.

Does anyone have any ideas to solve this problem? And many thanks for your kind offer.

Faultiness commented 3 years ago

UPDATE:

I've noticed the same problem when I trained the Yolov4-csp model. The result of darknet_image.py and ./darknet cannot match and the confidence score can differ up to 60%.

However, when I switch to Yolov4-custom, the average confidence score different is lower than 1%. Which I can consider as accuracy loss when using .so lib.

Furthermore, when using cv2.dnn_DetectionModel() to load weights directly in python 3.7 with OpenCV 4.5 environment. The predicted result is similar to the output of darknet_image.py. Is it possible that an error in compiling the library files is causing such a large difference in results?

jpoberhauser commented 3 years ago

I am seeing very similar results to you @Faultiness. I am trying on a bunch of different images and the images where I see the biggest differences are large images where the width is much larger than the height.

I tried with custom model, but I see the differences in coco trained models too:

./darknet detector test cfg/coco.data cfg/yolov4-csp.cfg yolov4-csp.weights data/wideperson.jpg -thresh 0.25

person 85%

vs.

python darknet_images.py --input data/wideperson.jpg --weights yolov4-csp.weights --config_file cfg/yolov4-csp.cfg --data_file cfg/coco.data --thresh 0.25

person: 76.77%

I can send you the specific image if you need.

kk-manhnd commented 3 years ago

@Faultiness I have the same issue like you too, do u have any solution yet?

cv2000 commented 3 years ago

@kk-manhnd I had a similar issue that was solved by converting the color format before detection.

cv2.cvtColor(frame_rgb, cv2.COLOR_BGR2RGB)