Closed vladimirhorvat closed 4 years ago
Can you share your python script?
Oh, I used just your example: from yolov4.tf import YOLOv4 yolo = YOLOv4(tiny=True) yolo.classes = "/content/TensorFlow-2.x-YOLOv3/model_data/license_plate_names.txt" yolo.make_model() yolo.load_weights("/mydrive/yolo/backup/yolov4-tiny-obj_final.weights", weights_type="yolo") yolo.save_as_tflite("yolov4.tflite")
yolov4-tiny-obj_final.weights: https://drive.google.com/file/d/1-7W6dL49bu2u0gZTT_7Ooi9HvyEymoKb/view?usp=sharing yolov4-tiny-obj.cfg: https://drive.google.com/file/d/1wHyP2k6tW6qotuepE_tPsTLqrg3mG2HJ/view?usp=sharing
license_plate_names.txt contains just: custom
python3 -m pip show yolov4
What is your version?
0.16.0
test.py
from yolov4.tf import YOLOv4
yolo = YOLOv4(tiny=True)
yolo.classes = {0:"custom"}
yolo.make_model()
yolo.load_weights("/home/hhk7734/Downloads/yolov4-tiny-obj_final.weights", weights_type="yolo")
yolo.save_as_tflite("yolov4.tflite")
python3 test.py
it successfully converted.
python 3.6.9 version tensorflow 2.2.0 version
import tensorflow as tf
from yolov4.tf import YOLOv4
yolo = YOLOv4(tiny=True)
yolo.classes = {0:"custom"}
yolo.make_model()
yolo.load_weights("/home/hhk7734/Downloads/yolov4-tiny-obj_final.weights", weights_type="yolo")
converter = tf.lite.TFLiteConverter.from_keras_model(yolo.model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,
tf.lite.OpsSet.SELECT_TF_OPS]
tflite_model = converter.convert()
with tf.io.gfile.GFile("yolov4.tflite", "wb") as fd:
fd.write(tflite_model)
Please try this
It worked! Thanks!
Thanks for testing the code :)
Hi, thanks for this! I used AlexeyAB yolov4-tiny cfg, trained for 1 class. When trying to convert weights to tflite I get: