Yolo-12-everything/onnx2tflite.py

13 lines
422 B
Python

from ultralytics import YOLO
# Load the YOLO11 model
model = YOLO("runs/detect/train/weights/best.pt")
# Export the model to TFLite format
model.export(format="tflite") # creates 'yolo11n_float32.tflite'
# Load the exported TFLite model
tflite_model = YOLO("runs/detect/train/weights/best.tflite")
# Run inference
results = tflite_model("datasets/valid/images/2007_000042_jpg.rf.dadefef10ec4b9422a1689f7ce40588e.jpg")