am15h/tflite_flutter_helper

How to get back Image File from Tensor Image

SatyamX64 opened this issue · 0 comments

I am not sure if this is the right Platform to ask, but can you please tell me how can I convert the File I get from ImagePicker into a format that is accepted by the Quantized MobileNet Tflite Model.
I run into this error when I send the File directly : "Cannot convert between a TensorFlowLite tensor with type UINT8 and a Java object of type [[F (which is compatible with the TensorFlowLite type FLOAT32)" and my App crashes.
So I decided to use the tflite_flutter_helper to Preprocess the Image I get from gallery before sending it to the Tflite Model, but I dont know how to do it properly.
The Tflite docs suggest that this is the required Input Format : "ByteBuffer sized 224 x 224 x 3 x PIXEL_DEPTH, where PIXEL_DEPTH is 4 for float model, and 1 for quantized model"

This is my code snippet : [https://gist.github.com/SatyamX64/0e4e4bd9898503df05431134a5953403]