hunglc007 / tensorflow-yolov4-tflite

YOLOv4, YOLOv4-tiny, YOLOv3, YOLOv3-tiny Implemented in Tensorflow 2.0, Android. Convert YOLO v4 .weights tensorflow, tensorrt and tflite
https://github.com/hunglc007/tensorflow-yolov4-tflite
MIT License
2.23k stars 1.24k forks source link

How to get tflite models of a size similar to the project on Android (20 MB) ? #400

Open carlosparra1998 opened 2 years ago

carlosparra1998 commented 2 years ago

Hello everyone.

I need to get a tflite model from the weight obtained with the workouts (.weight), but this weight occupies about 200 MB, so when transforming this into tflite it occupies 200 MB, and then I need a much less capacity, like the original that occupies only 20 MB.

Thanks.

mkj98 commented 2 years ago

the demo model used in the android app is YOLOv4-tiny model

  1. check this guide to train your model link

  2. after generating your whites file save the model with this command python save_model.py --weights ./data/yolov4-tiny.weights --output ./checkpoints/yolov4-tiny-416 --input_size 416 --model yolov4 --framework tflite --tiny

  3. convert your model to tflite using this command: python convert_tflite.py --weights ./checkpoints/yolov4-tiny-416 --output ./checkpoints/yolov4-tiny-416.tflite

  4. copy model to android assets folder.

  5. change the model file name on MainActvity and DetectorActivity.

  6. open YoloV4Classifier.java and change isTinyto true