AlexeyAB / darknet

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

Yolov3 Tiny calculate the anchor and Improve the detection #4125

Closed sctrueew closed 5 years ago

sctrueew commented 5 years ago

Hi @AlexeyAB , I've trained a model that I want to identify the fields. The bounding box is not right when the field is identified.

Number of images: ~500 Classes: 8 My iteration: ~20K Model: Yolov3Tiny mAP: 99% IOU: 88%

Ground truth: f2

Detected: f1

I used "calculate anchore" too but it didn't make much difference. I'm going to use it on CPU and I'd rather use the Tiny. How can I improve it?

Thanks in advance.

sctrueew commented 5 years ago

Hi ALexeyAB,

Could you please give me some advice?

Thanks

AlexeyAB commented 5 years ago

I used "calculate anchore" too but it didn't make much difference. I'm going to use it on CPU and I'd rather use the Tiny.

Did you calculate anchors Before or After training?

How can I improve it?

Check mAP with flag -iou_thresh 0.9 what map do you get?

sctrueew commented 5 years ago

Hi @AlexeyAB ,

Thank you for your reply. I used calculate anchores before training. and I've checked the -iou_thresh 0.9 : mAP is 15.23 % , -iou_thresh 0.8 : mAP is 85.72 %

AlexeyAB commented 5 years ago

Can you attach your cfg-file?

sctrueew commented 5 years ago

Hi @AlexeyAB,

This is my cfg and I've added a new class that my number of pre classes was 8 and now is 9.

YoloV3Tiny.txt

AlexeyAB commented 5 years ago

Add 2 lines to each of 3 [yolo] layers, and train again or continue training

iou_normalizer=0.5
iou_loss=giou

And change ignore_thresh = .7 to ignore_thresh = .9

sctrueew commented 5 years ago

Thanks, I changed it now and it's training. Can I use the model in OpencvDnn with this changes?

AlexeyAB commented 5 years ago

Yes.

If something will go wrong in OpenCV-dnn, just comment these two lines iou_normalizer=0.5 iou_loss=giou after training

sctrueew commented 5 years ago

Hi @AlexeyAB ,

Thank you very much for your suggestion. after the training I've checked the mAP again and the result is :

-iou_thresh 0.9 : mAP is 83.87 % , -iou_thresh 0.8 : mAP is 93.13 %

When can I change the iou_normalizer?, I think GIOU is better than IOU for me!? Can I use [iou_normalizer & iou_loss=giou] in SPP? Can I get higher mAP?

Thanks.

AlexeyAB commented 5 years ago

When can I change the iou_normalizer?, I think GIOU is better than IOU for me!?

iou_normalizer is something like learning_rate for width & height of object. You can try to reduce this value, if there are two cases together: some of bboxes larger than truth and some of bboxes smaller than truth.

Can I use [iou_normalizer & iou_loss=giou] in SPP?

yes

Can I get higher mAP?

yes.

AlexeyAB commented 5 years ago

Also I added some changes. So you can try to download new version of Darknet and train with it.

sctrueew commented 5 years ago

Hi ALexeyAB,

Thanks for the reply. I'll try it. And about "Can I get higher mAP?" How? Is there a way to increase the accurate?

AlexeyAB commented 5 years ago

Use yolov3-spp.cfg with GIoU. But it will work much slower.

sctrueew commented 5 years ago

And the last question☺. Can I use EfficientNet in OpenCV-dnn? What networks are supported in OpenCV?

Thanks a lot.

AlexeyAB commented 5 years ago

OpenCV-dnn supports: yolov3-tiny, yolov3-tiny_3l, yolov3, yolov3-spp.

You can create an Issue for supporting EfficientNet in OpenCV-dnn https://github.com/AlexeyAB/darknet/blob/master/cfg/enet-coco.cfg

Like this issue: https://github.com/opencv/opencv/issues/15724

sctrueew commented 5 years ago

Thanks @ALexeyAB, I close this issue.

Arcitec commented 5 years ago

@AlexeyAB @zpmmehrdad OpenCV-DNN now supports the PRN networks. It will be included in the next release of OpenCV 3.x and 4.x. :-) Check the ticket Alexey linked to! It's a super good network. But gotta wait a bit for OpenCV to release its next version... ;-)

sctrueew commented 5 years ago

@VideoPlayerCode hi,

Thanks for informing

AlexeyAB commented 5 years ago

@VideoPlayerCode Do the plan to support EfficientNet? https://github.com/AlexeyAB/darknet/blob/master/cfg/enet-coco.cfg

yrc08 commented 5 years ago

Hi@zpmmehrdad I want to ask how to find the anchor box of my data set. Thanks

sctrueew commented 5 years ago

@yrc08 Hi,

You can use this command: darknet.exe detector calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416

yrc08 commented 5 years ago

@zpmmehrdad ,Hi Thank you very much for your quick answer,but I also want to ask if I can get the anchors value directly by the above command. Thanks!

sctrueew commented 5 years ago

@zpmmehrdad ,Hi Thank you very much for your quick answer,but I also want to ask if I can get the anchors value directly by the above command.

Yes, after run the command, a text file is created with called anchors.txt

yrc08 commented 5 years ago

@zpmmehrdad ,Hi Thank you for your reply.