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.24k stars 1.24k forks source link

A question about custom weights and tiny version of yolov3/v4 #73

Closed SirTapir closed 4 years ago

SirTapir commented 4 years ago

Can you convert a yolov3 or yolov4 model that was trained to detect custom object from Alexey's implementation to tflite?

What about the tiny version? Does this repo supports tiny yolo conversion?

sterlingrpi commented 4 years ago

Yes, this repo supports conversion to tflite. See the readme file for information. The example commands are as follows:

yolov4

python convert_tflite.py --weights ./data/yolov4.weights --output ./data/yolov4.tflite

yolov4 quantize float16

python convert_tflite.py --weights ./data/yolov4.weights --output ./data/yolov4-fp16.tflite --quantize_mode float16

yolov4 quantize int8

python convert_tflite.py --weights ./data/yolov4.weights --output ./data/yolov4-fp16.tflite --quantize_mode full_int8 --dataset ./coco_dataset/coco/val207.txt

Full int 8 quantization is hit or miss. I found that leaky_relu is not supported and had to swap it for regular relu and retrain https://github.com/hunglc007/tensorflow-yolov4-tflite/issues/53. Training tiny YOLO is not well supported. But I made it work with some rather crude (but simple) hacks https://github.com/hunglc007/tensorflow-yolov4-tflite/issues/53#issuecomment-636383441

SirTapir commented 4 years ago

@sterlingrpi What about conversion of tiny-yolov3? When I tried to use the tiny version on the android example, the bounding box that was drawn is not correct.

sterlingrpi commented 4 years ago

not sure. I know for training tiny it took a couple of hacks. but I got it mostly working

KuoEuran commented 2 years ago

@sterlingrpi Hi, do you know how to convert custom yolov4-tiny with depthwise separable convolution? tks

sterlingrpi commented 2 years ago

@KuoEuran looking at my project folder I was able to convert yolov3-tiny and yolov4 into tflite and int8 tflite. Sorry, no yolov4-tiny.

KuoEuran commented 2 years ago

@sterlingrpi Thank you for your replying, my question is not the model convert of yolo model, I want to convert the separable depthwise convolution which added in yolo model. Have you solved the problems before?

sterlingrpi commented 2 years ago

@KuoEuran I have not

KuoEuran commented 2 years ago

@sterlingrpi ok, I see, thanks