tensorflow-yolov4-tflite icon indicating copy to clipboard operation
tensorflow-yolov4-tflite copied to clipboard

yolov4-tiny-3l issue resolved

Open aditya-5842 opened this issue 4 years ago • 10 comments

Made the required changes to make the repo work for yolov4-tiny-3l.

aditya-5842 avatar Mar 26 '21 22:03 aditya-5842

@aditya-5842 could you explain how you generate the weights file for your tiny3L? Can I use any of the pre trained darknet ones (https://github.com/AlexeyAB/darknet/releases) ?

ciklista avatar Jul 01 '21 08:07 ciklista

@aditya-5842 could you explain how you generate the weights file for your tiny3L? Can I use any of the pre trained darknet ones (https://github.com/AlexeyAB/darknet/releases) ?

Yes, you can use the pre-trained YOLO-Tiny model (https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.conv.29) to initialize the weights.

aditya-5842 avatar Jul 01 '21 15:07 aditya-5842

@aditya-5842 could you explain how you generate the weights file for your tiny3L? Can I use any of the pre trained darknet ones (https://github.com/AlexeyAB/darknet/releases) ?

Yes, you can use the pre-trained YOLO-Tiny model (https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.conv.29) to initialize the weights. getting the following error with the above weights file. Command was

python save_model.py --weights ./data/yolov4-tiny-conv.29  --output ./checkpoints/yolov4-tiny-3l --input_size 416 --model yolov4-tiny-3l --tiny

(sorry for the screenshot) image

ciklista avatar Jul 01 '21 15:07 ciklista

@aditya-5842 could you explain how you generate the weights file for your tiny3L? Can I use any of the pre trained darknet ones (https://github.com/AlexeyAB/darknet/releases) ?

Yes, you can use the pre-trained YOLO-Tiny model (https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.conv.29) to initialize the weights. getting the following error with the above weights file. Command was

python save_model.py --weights ./data/yolov4-tiny-conv.29  --output ./checkpoints/yolov4-tiny-3l --input_size 416 --model yolov4-tiny-3l --tiny

(sorry for the screenshot) image

Sorry, I could not give a detailed answer.

  • Like I mentioned above that use YOLOV4-Tiny pretrained to initialize the model. Then train the model on your data. You can use this notebook to train your own model.
  • Once training is over, you can use your saved weights to do the conversion. Please note that ./data/yolov4-tiny-conv.29 is not the full Tiny-3l model. It contains only starting layers of the YOLOV4 (tiny) model.

You can one of my trained model. This is for detecting the license-plate/s in image.

aditya-5842 avatar Jul 01 '21 16:07 aditya-5842

thanks for the clarification! Very helpful.

ciklista avatar Jul 02 '21 07:07 ciklista

@aditya-5842 any reason why you changed the __C.YOLO.ANCHORS_TINY in the config?

ciklista avatar Jul 02 '21 10:07 ciklista

@ciklista Look at line 17. It is anchor-boxes. YOLOV4-Tiny (i.e. by default Tiny-2l) has only 2 Yolo layers at the end and each layer YOLO layer needs 3 different anchor boxes. So total we need 6 boxes (3 *2=6). These anchors are going to be reshaped into 2 x 3 x 2 array. Each continuous pair will make a different anchor box and all anchor boxes should be different. If you notice anchor 81,82 is repeating in line 17, so it should be corrected.

Now I'm not sure I got the first two values of line 18. May be I did some google search and found these values. But it worked for me.

NOTE: Initially, with line 17 as anchors, my YOLOV4-Tiny was not working. https://github.com/hunglc007/tensorflow-yolov4-tflite/blob/13e6adc274c408a6f1fed83b836b7e6452024d93/core/config.py#L17-L18

aditya-5842 avatar Jul 03 '21 18:07 aditya-5842

you are right. The original anchors where drawing bounding boxes a little too large. Looking better with yours, thanks for the fix :) image

image

ciklista avatar Jul 16 '21 08:07 ciklista

Thank you for the contribution, just tested and it's working!

rafcy avatar Nov 22 '21 13:11 rafcy

@aditya-5842 Thank you for your great work, I have a question about the depthwise separable convolution convert from weights to tflite, do you have any idea about this?

KuoEuran avatar Feb 21 '22 07:02 KuoEuran