ultralytics / yolo-flutter-app

A Flutter plugin for Ultralytics YOLO computer vision models
https://ultralytics.com
GNU Affero General Public License v3.0
60 stars 22 forks source link

Export of cls model #41

Open JulieBender opened 1 month ago

JulieBender commented 1 month ago

When exporting a custom yolov8 cls model, the classification doesn't run in the app, it just opens the camera as have no detections. also says 0.0ms - 0.0FPS. I have tested the model in python code, and here it works just fine.

I have used this for exporting in a python script: model.export(format="mlmodel", imgsz=[320, 192], nms=True)

I get this error inside med x-code:

Thread 5: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.apple.mlassetio Code=1 "Failed to parse the model specification. Error: Unable to parse ML Program: at unknown location: Could not open /var/mobile/Containers/Data/Application/0157029F-2294-42DF-9422-4E1E0C40F43A/Library/Application Support/assets/weights/weight.bin" UserInfo={NSLocalizedDescription=Failed to parse the model specification. Error: Unable to parse ML Program: at unknown location: Could not open /var/mobile/Containe

You didn't provide any specific code snippets for exporting the cls models to ios in the readme section (as you did with all the other options). I assume that this error is because of a wrong model, as the app works fine with your model from the example.

I also tried to convert your yolov8m-cls, but that didn't work either.

JulieBender commented 1 month ago

I have already tried steps 1,3,4,5

Maybe I don't put the files in the right places, can you guide me on where to place the bin file, and specify it? In the example, I can't find your bin file or the path to it in the scripts. I also looked trough the documentation and can't really find any guides to the placement of these.

  1. Check File Paths: The error message indicates that the app is unable to open the weight.bin file. Ensure that all necessary files are correctly bundled with your app and that the paths are correctly specified. Double-check the file paths in your Xcode project to make sure they match the locations of the exported model files.

I have this LocalModel, and if I switch my custom cls model out with yours it works fine. my mlmodel is placed in the assets folder. Is it necessary to specify the bin file aswell?

Future<ImageClassifier> _initObjectClassifierWithLocalModel() async { final modelPath = await _copy('assets/model.mlmodel'); final model = LocalYoloModel( id: '', task: Task.classify, format: Format.coreml, modelPath: modelPath, );