[Python] YOLOv11 Model Converted to TFLite Not Producing Correct Output in TensorFlow

Discussão em 'Python' iniciado por Stack, Março 10, 2025.

  1. Stack

    Stack Membro Participativo

    I'm training an ALPR detection model using the dataset from Roboflow ALPR with YOLOv11, converted to TFLite using:

    import ultralytics as yolo
    !yolo detect export model=/content/runs/detect/yolov11_anpr/weights/best.pt imgsz=640 batch=1 format=tflite


    My Current Python Inference Code (Ultralytics YOLO) Both .pt and .tflite models work correctly in Ultralytics' inference pipeline:

    from PIL import Image
    from ultralytics import YOLO

    image = Image.open("/content/Screenshot From 2025-03-08 16-37-15.png")
    model = YOLO('/content/runs/detect/yolov11_anpr/weights/best_saved_model/best_float32.tflite')
    results = model(image)

    result = results[0]
    result.show()


    This successfully detects Persian numbers:

    [​IMG]

    Here's a visual representation of the successful detection using Ultralytics YOLO:

    Problem However, direct inference with TensorFlow (without Ultralytics) doesn't produce correct detections. The output data is incorrect or missing entirely.

    Questions: Why does inference using Ultralytics YOLO work, but direct TensorFlow inference doesn't? What preprocessing or post-processing steps am I missing for YOLOv11 TFLite inference with TensorFlow? Any insights or solutions to correctly use the TFLite model directly with TensorFlow would be greatly appreciated!

    you can download and test my tflite model with below link : https://drive.google.com/file/d/1p4CaFl9g2gPjGUd68xlr_EQlxz-umTre/view?usp=sharing

    Continue reading...

Compartilhe esta Página