AlexeyAB / darknet

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

Multiple bounding box for same object #8166

Open iamrajee opened 2 years ago

iamrajee commented 2 years ago

I'm getting multiple bounding box for same object using yolov4 with default parameters, cfg and weights. I tried increasing beta_nms and decreaseing iou_thresh to extreme in yolov4.cfg but no luck. Screenshot from 2021-10-18 19-06-54 Screenshot from 2021-10-18 19-11-08

I will really appreciate any help.

bulatnv commented 2 years ago

@iamrajee

This is because Intersection over Union btw aeroplane 0.97 and 0.67 is small. First object is big, second is pretty small. As a result IoU < 0.4. You can try eliminating this double detections by calculating Intersection over Area of first and second detections.

All the best.

iamrajee commented 2 years ago

Thank you for your suggestion, I implemented NMS Algorithem on top of yolo bounding boxes and it worked. However I don't know why I couldn't get the similar result by modifying the in-build parameter in yolov4.cfg. I even set the 'iou_thresh' as low as 0.05 and beta_nms as high as 0.9 still no effect. Is there any other parameter that might affect this behaviour? Screenshot from 2021-10-20 18-12-29

bulatnv commented 2 years ago

@iamrajee This parameters for model train, not for prediction: https://github.com/AlexeyAB/darknet/wiki/CFG-Parameters-in-the-different-layers

iamrajee commented 2 years ago

Thank so much @bulatnv for the guidance. I will go through this and get back if I have any further queries.

tarun-ssharma commented 2 years ago

Hi @iamrajee . Did you refer any tutorial while writing custom NMS on top of darknet detector output? Can you share any reference?

I am facing the same issue of multiple bounding boxes. In some case, the bounding boxes are not even placed properly on the detected object.

elize-anu commented 2 years ago

@iamrajee Hi, Can you please provide the NMS algo which you've implemented over the yolo bounding boxes. I'm also facing the same multiple bounding boxes issue for yolo v4

iamrajee commented 2 years ago

@tarun-ssharma @elize-anu I had refered NMS code from here and this is how I had integrated into my code.