tensorflow-lite-rest-server icon indicating copy to clipboard operation
tensorflow-lite-rest-server copied to clipboard

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

Open Adesoji1 opened this issue 4 years ago • 6 comments

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 avatar Feb 24 '21 12:02 Adesoji1

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

robmarkcole avatar Feb 25 '21 05:02 robmarkcole

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

haticeozdemir avatar Sep 07 '21 20:09 haticeozdemir

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

robmarkcole avatar Sep 08 '21 04:09 robmarkcole

Do you have posting your solution?

8 Eyl 2021 Çar 07:36 tarihinde Robin @.***> şunu yazdı:

@haticeozdemir https://github.com/haticeozdemir My guess is a greyscale image has been passed but RGB is expected by the model

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/robmarkcole/tensorflow-lite-rest-server/issues/41#issuecomment-914905437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK224NANGIZY4IQTEBE5BXLUA3R5BANCNFSM4YEMSDZQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

haticeozdemir avatar Sep 08 '21 16:09 haticeozdemir

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

tonytw1 avatar Aug 29 '22 10:08 tonytw1

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

robmarkcole avatar Aug 29 '22 10:08 robmarkcole