from ultralytics import YOLO import os # 1. Load your high-accuracy PC model model_path = 'best.pt' if not os.path.exists(model_path): print(f"Error: {model_path} not found.") else: model = YOLO(model_path) # 2. Export to TFLite with NMS and Quantization # 'int8' optimization allows the model to leverage mobile NPUs # 'nms' handles the overlapping box logic natively on-chip # Note: Exporting to TFLite with int8 might require dataset for calibration or it might use dynamic range quantization if no data is provided. # Ultralytics handle's calibration if 'data' is provided in export. model.export( format='tflite', int8=True, nms=True, imgsz=640, data='unified_dataset/data.yaml' # For quantization calibration ) print("Mobile assets generated in: best_saved_model/")