0

I'm trying to use yolo4 in my android project but I'm having problems with conversion. The code from: https://pypi.org/project/yolov4/ has worked well on Google-Colab, though it had some problem with my CUDA version on Jupyter notebook.

I got conversion error from:

yolo.save_as_tflite("yolov4.tflite")

Error was long and I am not sure which part I should paste here.

Can someone recommend some alternative method to convert tflite version of yolo4 (preferably working on colab)?

vsminkov
  • 10,912
  • 2
  • 38
  • 50
freir96
  • 123
  • 2
  • 13

1 Answers1

0

If you would've posted important portion of the error, that would've been helpful. I'm guessing may be you're missing some dependencies/libraries.

Anyway to get tflite version of the Yolov4, I suggest you to use this repo.

Install Dependencies:

opencv-python==4.1.1.26
lxml
tqdm
tensorflow==2.3.0rc0
absl-py
easydict
matplotlib
pillow

Download yolov4.weights file: https://drive.google.com/open?id=1cewMfusmPjYWbrnuJRuKhPMwRe_b9PaT

Save darknet weights to tfmodel that's needed for tflite conversion:

python save_model.py --weights ./data/yolov4.weights --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4 --framework tflite

Convert to Yolov4 tflite version:

python convert_tflite.py --weights ./checkpoints/yolov4-416 --output ./checkpoints/yolov4-416.tflite

Additionally to test the converted tflite model:

python detect.py --weights ./checkpoints/yolov4-416.tflite --size 416 --model yolov4 --image ./data/kite.jpg --framework tflite
Venkatesh Wadawadagi
  • 2,793
  • 21
  • 34
  • The second command does not work for me. "Converting unsupported operation: Softplus" Could it be a problem with my GPU or the version of tensorflow? – freir96 Jul 21 '20 at 15:08
  • @freir96 As mentioned in the answer ensure you have installed all the dependencies with appropriate versions, especially note that you need `tensorflow==2.3.0rc0` for this to work. Also ensure that first command executes well without any error and produces corresponding outputs that's needed for second command to work. Note that this is all running on `CPU` only as we are using `tensorflow` and not `tensorflow-gpu`. – Venkatesh Wadawadagi Jul 21 '20 at 15:41