spring98 / flutter-yolo-realtime-plugin

실시간 객체검출 플러그인 배포 (2023)
MIT License
7 stars 4 forks source link

custom model does not work ! #10

Open fransay opened 2 months ago

fransay commented 2 months ago

Hi @spring98 ,

I have fine tuned yolov5s.pt over a custom dataset, the resulting best.pt when loaded in the example app is not able to perform detection. Is there anything I am missing ? I have read the docs head to toe, followed the instructions on how to export the models. Though I must say, I have not yet exported the .mlmodel. Any help or advice on how to make it work ?

spring98 commented 2 months ago

Thank you for your interest in my plugin.

It would be great if you could provide some information!

  1. Are you using it on Android? Are you using it on iOS? mlmodel is for iOS only, so it is not needed if you do not use iOS.

  2. Did you export the .pt file through modified_export.py?

You must use the exported torchscript.

That is, best.pt > best.torchscript (export and using)

Afterwards, just change the name of the best.torchscript file to best.pt.

Sorry for confusing you. If you have any further problems, please reply!!

fransay commented 2 months ago

Hey @spring98 , thanks for the prompt response!

Ah got it, I am trying that now. Will keep you updated. Thanks.

fransay commented 2 months ago

The app crashes on inference. After model ingestion, and on start of the app, its crashes about 3 seconds later. Not able to perform detection, don't know why that happens though. Any help will be appreciated. Thank you.

spring98 commented 2 months ago

Does the code in the basic example not work?

And I think it would be helpful to have an image of the inference failure!!

fransay commented 2 months ago

The code in the example works fine with its weights. On start of the app, it crashes 3 seconds, there are no error logs in my console either. I've had delete my build folder and rebuilt the app, but it still occurs. I am using an honor x6a for this project with a mediatek helio chipset. I will get a different device and try a new build. All the same, I will keep this issue alive and updated until fully resolved. I love the learnings from the experiments!

Thank you.

spring98 commented 2 months ago

It's a little strange that the log doesn't appear.

Have you made sure you set List active Classes, List full Classes to match your custom model?

Anyway, I support your spirit of challenge, and if there are any other issues, please let me know!!

fransay commented 2 months ago

@spring98, I have carefully set all those classes to my custom labels. Yeah, its quite strange, but we are going figure it out. Sure, will keep you updated! Hope you have an awesome day, thanks for your time to. Much appreciation :pray:

fransay commented 2 months ago

@spring98 , I solved the hassle. During the conversion from best.pt > best.torchscript, one has to make sure they take note of the --img flag. The compatible img size of the raw best.pt must be exactly the same as that of the expected best.torchscript. And always remember to set the androidModelHeight and androidModelWidth to the same size as that of best.pt.

spring98 commented 2 months ago

Thank you for your hard work. Thank you for sharing!!

fransay commented 2 months ago

Thank you taking time to work on this to. Great plugin by all standards.