Ask Your Question
2

opencv YOLOv2 vs darknet YOLOv2; is the results should be similar or different?

asked 2018-01-15 12:59:10 -0500

ZeroLogic gravatar image

This is the result of OpenCV YOLOv2 image description

While this is the result of using darknet YOLOv2 image description

May I know why opencv YOLOv2 is different from darknet's? Should both of the results are different? If I'm wrong in any way please do correct me.

cfg = "yolo.cfg" weights = "yolo.weights" names = "coco.names" threshold = 0.24

edit retag flag offensive close merge delete

Comments

Afaik OpenCV has YOLOv1 because it does not have these return layers that YOLOv2 needs and hence the lower accuracy?

StevenPuttemans gravatar imageStevenPuttemans ( 2018-01-16 00:58:19 -0500 )edit

https://github.com/pjreddie/darknet/i...

as mentioned here, AlexeyAB states that: Now Darknet Yolo v2 is added to the OpenCV: opencv/opencv#9705 You can use it from master-branch or since OpenCV 3.4.0 will be released.

so which one is right? is OpenCV's v1 or v2?

ZeroLogic gravatar imageZeroLogic ( 2018-01-16 02:56:18 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
5

answered 2018-01-16 03:13:58 -0500

dkurt gravatar image

Please add more details when you refer a public models. I've found at least 3 YOLOv2 at https://pjreddie.com/darknet/yolo/ and they aren't similar. I hope YOLOv2 trained on COCO dataset with input size 608x608 is used. Am I right? OpenCV's sample works with 416x416 images for now so you need to modify a source code a bit:

from

Mat inputBlob = blobFromImage(frame, 1 / 255.F, Size(416, 416), Scalar(), true, false);

to

Mat inputBlob = blobFromImage(frame, 1 / 255.F, Size(608, 608), Scalar(), true, false);

One more thing that corresponding .cfg file has a confidence threshold inside:

thresh = .6

I don't know why Darknet ignore it but OpenCV consider this value to threshold detections with a low confidence. So you have to modify it too. In example,

thresh = .1

The result:

image description

Hidden objects has confidences about 0.4, 0.29, 0.37.

edit flag offensive delete link more

Comments

2

noted, sorry for lack of information. thank you in highlighting the input size

ZeroLogic gravatar imageZeroLogic ( 2018-01-16 03:23:44 -0500 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2018-01-15 12:59:10 -0500

Seen: 1,089 times

Last updated: Jan 16 '18