Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please add image classification example #10

Closed
Emon526 opened this issue Apr 27, 2023 · 15 comments
Closed

please add image classification example #10

Emon526 opened this issue Apr 27, 2023 · 15 comments

Comments

@Emon526
Copy link

Emon526 commented Apr 27, 2023

No description provided.

@Alexi-Zemcov
Copy link
Contributor

Hello @Emon526
In this PR i made the old good example work again.

This PR is not for a merge. It is rather to share a working example. So you can just download it from my fork.

It still has a lot of legacy code and I'd like to refactor it in the future, but for now.

@Emon526
Copy link
Author

Emon526 commented Apr 28, 2023

thanks a lot @Alexi-Zemcov but the author of tflite_flutter_helper mentioned not to use the package because the package is discontinued.i am looking for a alternative solution

@JSYRD
Copy link

JSYRD commented Apr 28, 2023

Hello @Emon526 ,
Are you trying to build tensors from images without using the package tflite_flutter_helper? I have some experience in making it.

@PaulTR
Copy link
Collaborator

PaulTR commented Apr 28, 2023

Got it. So this is definitely an example that I'd like to have together once everything is up to date, but in the meantime the logic should be close-ish to this Android sample.

As for the helper, the plan is to put something together that does exactly what that did, but with a richer feature set, via MediaPipe. By all means if you need a solution right now then the helper is still a solid option that'll get the job done with a bit of work into it (what Alexi did as an example) :)

@Alexi-Zemcov
Copy link
Contributor

Alexi-Zemcov commented Apr 28, 2023

By the way, I faced into the problem described in this comment.
am15h/tflite_flutter_plugin#133 (comment)

My .tflite model required grayscale image data in one channel. But in fact, as the tfLiteTensorByteSize method shows, I have 4 times more data.

Does anyone have any ideas what to do with this?

@JSYRD
Copy link

JSYRD commented Apr 28, 2023

By the way, I faced into the problem described in this comment. am15h/tflite_flutter_plugin#133 (comment)

My .tflite model accepts the required grayscale image data in one channel. But in fact, as the tfLiteTensorByteSize method shows, I have 4 times more data.

Does anyone have any ideas what to do with this?

Nice to meet you again, and my model also accepts the same as yours. My solution is export the lumi as a brand new tensor.

https://github.com/JSYRD/krccsnet/blob/master/lib/krccsnet_encoder.dart

In the function getEncoderInputTensor.
I'd be grateful if it's helpful.

@PaulTR
Copy link
Collaborator

PaulTR commented May 1, 2023

Also while this is in development, ML Kit might be a solid answer for you (even long term) - https://pub.dev/packages/google_mlkit_image_labeling

@Alexi-Zemcov
Copy link
Contributor

Alexi-Zemcov commented May 2, 2023

By the way, I faced into the problem described in this comment. am15h/tflite_flutter_plugin#133 (comment)
My .tflite model accepts the required grayscale image data in one channel. But in fact, as the tfLiteTensorByteSize method shows, I have 4 times more data.
Does anyone have any ideas what to do with this?

Nice to meet you again, and my model also accepts the same as yours. My solution is export the lumi as a brand new tensor.

https://github.com/JSYRD/krccsnet/blob/master/lib/krccsnet_encoder.dart

In the function getEncoderInputTensor. I'd be grateful if it's helpful.

Unfortunately it didn't work for my model. Now it trow StateError even earlier on the tfLiteInterpreterAllocateTensors method.
Perhaps I lack the depth of understanding of some basics to understand what is going wrong.

Update: I was wrong. @JSYRD, your example perfectly prepares the image to work with my model. But in my case, I had to replace input[0][0][ch][cw] = ... with input[0][ch][cw][0] = ... in the getEncodeInputTensor method .

@Alexi-Zemcov
Copy link
Contributor

Also while this is in development, ML Kit might be a solid answer for you (even long term) - https://pub.dev/packages/google_mlkit_image_labeling

Thank you very much! So now I will try this package, may be it will be easier way for me.

@luiscib3r
Copy link
Contributor

In this PR #49 I added an example of image classification using mobilenet. You can also check it in my fork https://github.com/luiscib3r/flutter-tflite/tree/develop/example/image_classification_mobilenet. Any questions, suggestions, or bug reports are welcome.

@luiscib3r
Copy link
Contributor

is done: https://github.com/tensorflow/flutter-tflite/tree/main/example/image_classification_mobilenet

@Emon526
Copy link
Author

Emon526 commented May 22, 2023

@luiscib3r thank you for the help.i think there is something wrong with my model .can you please provide me some documentation so that i can build my model

@luiscib3r
Copy link
Contributor

@Emon526 If you can send me any error messages you are getting while loading the model I might have a better idea. One tip that I follow with all models is to do getTensorInputs and getTensorOutputs and print their value, so I can clearly see the shape of the tensors and the type of data they accept. So then I transform the data I have based on what the model expects to receive.

@Emon526
Copy link
Author

Emon526 commented May 22, 2023

@luiscib3r i didn't getting any errors.but i am not getting the expected result.the model is trained by another developer. previously i was working with flutter_tflite package from pub.dev and i got the perfect result but now i cant do it.

@PaulTR
Copy link
Collaborator

PaulTR commented Jun 1, 2023

Can you try with version 0.9.1? That should be a direct clone of the original repo and will help narrow down app vs plugin issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants