YOLOv4, YOLOv4-tiny Implemented in Tensorflow 2.3.
This repository shows how to convert YOLO v4, YOLOv3, YOLO tiny .weights to .pb, .tflite and trt format for tensorflow, tensorflow lite, tensorRT.
# CPU
conda env create -f conda-cpu.yml
# activate environment on Windows or Linux
conda activate tf-cpu
# activate environment on Mac
source activate tf-cpu
# GPU
conda env create -f conda-gpu.yml
# activate environment on Windows or Linux
conda activate tf-gpu
# activate environment on Mac
source activate tf-gpu
# CPU
pip install -r requirements.txt
# GPU
pip install -r requirements-gpu.txt
Note: If installing GPU version with Pip, you need to install CUDA and cuDNN in your system. You can find the tutorial for Windows here.
# Convert darknet weights to tensorflow
## yolov4
python save_model.py --weights ./data/path/to/weights/file --output ./checkpoints/save/folder/name --input_size 416 --model yolov4
## yolov4-tiny
python save_model.py --weights ./data/path/to/tiny/weights/file --output ./checkpoints/save/folder/name --input_size 416 --model yolov4 --tiny
If you want to run yolov3 or yolov3-tiny change --model yolov3
in command and also download corresponding YOLOv3 weights and and change --weights to ./data/yolov3.weights
# Run yolov4 on image
python detect-tiles.py
# Save tf model for tflite converting
python save_model.py --weights ./data/path/to/weights/file --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4 --framework tflite
# yolov4
python convert_tflite.py --weights ./checkpoints/save/folder/name --output ./checkpoints/save/folder/name/*.tflite
# yolov4 quantize float16
python convert_tflite.py --weights ./checkpoints/save/folder/name --output ./checkpoints/save/folder/name/*.tflite --quantize_mode float16
# yolov4 quantize int8
python convert_tflite.py --weights ./checkpoints/save/folder/name --output ./checkpoints/save/folder/name/*.tflite --quantize_mode int8
# Run demo tflite model
python detect-tiles-lite.py
People who don't want to compromise their data can download this repo and create a virtual environment shown above and run
python gui.py