Open JanOsusky opened 3 weeks ago
Hello,
Thanks for reaching out with the details of your issue. It seems like you've done a thorough job in setting up and testing your model. Here are a couple of suggestions that might help resolve the issue:
Model Compatibility: Ensure that the best_int8.tflite
model is fully compatible with the Flutter environment. Sometimes, model operations supported in TensorFlow Lite might behave differently when deployed in a mobile environment.
Image Preprocessing: Verify that the image preprocessing in Flutter matches exactly with what your model expects. This includes scaling, normalization, and the format of the input image.
Debugging Output: Add debugging statements before and after the prediction call to check if the image is loaded correctly and to ensure that the model is actively being queried.
Model Loading: Double-check the paths specified in Flutter for loading the model and metadata. Ensure that these files are correctly placed in your project's assets folder and properly referenced in pubspec.yaml
.
Error Logs: Look into the logs for any error messages or warnings that could give more insight into what might be going wrong during the model loading or prediction phases.
If these steps don't resolve the issue, it might be helpful to isolate whether the problem lies with the model or the Flutter integration by testing with a different, pre-trained model. This can help determine if the issue is specific to the model or the setup.
Hello @pderrenger, Could you please guide me on how to verify the compatibility of a model with the Ultralytics YOLO Flutter application? I am looking to ensure that the models I intend to use are fully compatible with the application.
Thank you for your assistance
Hello @congngc,
Thank you for reaching out! Ensuring model compatibility with the Ultralytics YOLO Flutter application is crucial for seamless integration and optimal performance. Here are some steps you can follow to verify compatibility:
Model Export: Ensure you export your model using the correct format for TensorFlow Lite. The command you used seems correct:
!yolo export format=tflite model=/content/weights/best.pt imgsz=320 int8
Make sure the export process completes without errors.
Model Testing: Before integrating the model into your Flutter app, test it in a Python environment to ensure it works as expected. You've already done this with:
!yolo predict task=detect model=/content/weights/best_saved_model/best_int8.tflite source=/content/picture_852.jpeg imgsz=320 int8
This step helps confirm that the model performs well with your data.
Image Preprocessing: Verify that the image preprocessing in your Flutter app matches the preprocessing used during model training and testing. This includes resizing, normalization, and ensuring the image format is consistent.
Model and Metadata Paths: Double-check that the paths to your model and metadata files in your Flutter project are correct and that these files are included in your pubspec.yaml
:
assets:
- assets/best_int8.tflite
- assets/metadata.yaml
Debugging: Add debugging statements in your Flutter app to ensure the model is loaded correctly and that the image is being processed as expected. For example:
final detections = await objectDetector.detect(imagePath: 'assets/images/picture_852.jpeg');
print(detections); // Debugging output
Latest Versions: Ensure you are using the latest versions of the Ultralytics YOLO library and the Flutter dependencies. Updates often include bug fixes and improvements that could resolve compatibility issues.
If you continue to experience issues, providing a minimum reproducible example can be very helpful for further troubleshooting. You can find more details on creating one here: Minimum Reproducible Example.
Feel free to share any additional details or code snippets if you need further assistance. We're here to help! 😊
Hello, I am facing issue with my yolov8 finetuned on custom dataset stops giving predictions when I use it in my flutter app.
I used the command from readme for android:
!yolo export format=tflite model=/content/weights/best.pt imgsz=320 int8
Tested the model performance with:
!yolo predict task=detect model=/content/weights/best_saved_model/best_int8.tflite source=/content/picture_852.jpeg imgsz=320 int8
and got quite okay results
I downloaded the
best_int8.tflite
file and themetadata.yaml
file that got generated and imported them in my flutter projects add all the requirements (pubspec.yaml etc.). I loaded the model with this code:` final model = LocalYoloModel(
then run the detection fuction on a picture taken from the camera and later on hardcoded picture
final detections = await objectDetector.detect(imagePath: 'assets/images/picture_852.jpeg');
but only got an empty list. i also used the loading from the example at the pub.dev but still didnt make any difference. . Do you know where could be the issue?