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

Image classification/"cannot set tensor: got value of type uint8 but expected type float32 for input 0, name: input_1 " #41

Open
Adesoji1 opened this issue Feb 24, 2021 · 6 comments

Comments

@Adesoji1
Copy link

Adesoji1 commented Feb 24, 2021

I am trying to expose my tflite image classification to web API but I keep getting the error message from fast API which says detail": "cannot set tensor: got value of type uint8 but expected type float32 for input 0, name: input_1 ". in addition, attached are the files for my web API, please how do I correct this sir, I believe there is something wrong in the codes.
Details for reproducing is found in step.txt
issue.zip

@Adesoji1 Adesoji1 reopened this Feb 24, 2021
@robmarkcole
Copy link
Owner

sound like your model is in the wrong format, see something like https://stackoverflow.com/questions/52530724/python-tensorflow-lite-error-cannot-set-tensor-got-tensor-of-type-1-but-expecte

Issues are not a place for code reviews except for on this codebase

@haticeozdemir
Copy link

Did you solve this error? If so, how did you solve it?

@robmarkcole
Copy link
Owner

@haticeozdemir My guess is a greyscale image has been passed but RGB is expected by the model

@haticeozdemir
Copy link

haticeozdemir commented Sep 8, 2021 via email

@tonytw1
Copy link

tonytw1 commented Aug 29, 2022

This example in the current (August 2022) TensorFlow documentation helped with this.

The calling code can ask the TensorFlow Lite interpreter if the model needs int or float inputs and converts if needed:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/examples/python/label_image.py

@robmarkcole robmarkcole reopened this Aug 29, 2022
@robmarkcole
Copy link
Owner

Thanks for highlighting @tonytw1 I will reopen in case anyone wants to create a pull request

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

4 participants