tensorflow-yolov4-tflite
tensorflow-yolov4-tflite copied to clipboard
How to convert custom yolov4 model to tensorflow?
I trained a custom yolov4 using darknet with 24 classes. Now how do i convert it to tensorflow and what all files should i change in order to do custom model conversion?? @hunglc007
Thanks in advance, SAI
Below is all you need to do --python save_model.py --weights ./checkpoints/yolov4 --output ./checkpoints/yolov4-416 --input_size 416--model yolov4
This will generate the saved model.
Dear @hadizand , Thanks for the reply but I think that comments work only in case of demo?
@saikrishnadas is the same with you that getting result of 2 files('model.index', 'model.data-00000-of-00001' after running custom model?
Dear @hadizand , Thanks for the reply but I think that comments work only in case of demo?
It also works for custom model if checkpoints folder contains the trained custom weights. For example, I used below command and it generated the saved model (I set the input size of 512, and it only contained 2 classes) python save_model.py --weights ./checkpoints/yolov4 --output ./checkpoints/yolov4-512 --input_size 512 --model yolov4
If someone wanted to deploy over android, it is necessary to set the tflite framework flag as follow flags.DEFINE_string('framework', 'tflite', 'define what framework do you want to convert (tf, trt, tflite)')
After doing so, convert_tflite.py could generate the custom tflite model for me. I deployed the custom tflite model over android device and it works fine.
I got an error when converting saved model to tflite like CUDA_ERROR_UNKNOWN: unknown error then Fatal Python error: Aborted. Did you get this error too?
I got an error when converting saved model to tflite like CUDA_ERROR_UNKNOWN: unknown error then Fatal Python error: Aborted. Did you get this error too?
I did not get that error. Probably you did some part of training on a device with GPU, and the rest on another device with CPU. Check if you are doing all process in the same device.
I have done with that error by upgrading my TensorFlow to 2.6. But when I downgrade TensorFlow to 2.4, that error show again. I use TensorFlow CPU
Hi, Thank you for a great repository. I am trying to execute the save_model.py file to generate tensorflow model and then converting it to tflite model using convert_tflite.py, all the programs execute successfully but the tflite model is of 245 Mb in space, which does not seem right. Can anyone please help out?
Command for pb conversion: python save_model.py --weights ./data/yolov4.weights --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4 --framework tflite
Command for tflite conversion: python convert_tflite.py --weights ./checkpoints/yolov4-416 --output ./checkpoints/yolov4-416.tflite
Python version: 3.7.0 Tensorflow version: 2.3.1 (CPU) System: i5 11th gen Windows 10 CPU Thank you.