david8862 / keras-YOLOv3-model-set

end-to-end YOLOv4/v3/v2 object detection pipeline, implemented on tf.keras with different technologies
MIT License
640 stars 222 forks source link

Bad performance on detection for yolo v2 #108

Open dptn77 opened 4 years ago

dptn77 commented 4 years ago

Hi, I tried to inference for yolo v2(and yolo v2 tiny). I run the code below process.

1) Downloaded pre-trained weight for yolo v2 and convert to h5 $ python tools/model_converter/convert.py cfg/yolov2-voc.cfg weights/yolov2-voc.weights weights/yolov2-voc.h5 2) Demo for Object Detection $ python yolo.py --model_type yolo2_darknet --weights_path weights/yolov2-voc.h5 --anchors_path weights/yolov2-voc_anchors.txt --classes_path configs/voc_classes.txt --image

But, it worked bad performance. Bounding box is too many and very small. Attach files is a detection result for [dog.jpg]. dog_result

Although I used pre-trained model, why is it worked bad? I think that yolo2 post processing code needs to be modified. Appreciate for your help!

david8862 commented 4 years ago

@dptn77 seems you're using the anchor definition parsed from the official .cfg file, which follow the output feature map shape. I've changed this part and switch to following input image shape (*32) to align YOLOv2/v3 anchor definitions and postprocess. You can use the transformed anchor configs/yolo2-voc_anchors.txt and run cmd like

$ python yolo.py --model_type yolo2_darknet --weights_path weights/yolov2-voc.h5 --anchors_path configs/yolo2-voc_anchors.txt --classes_path configs/voc_classes.txt --image
dptn77 commented 4 years ago

Oh! it's worked well by changing to transformed anchor config file. Thank you for kind help!!