C2 W4 Optional Exercise - Rock Paper Scissors on Raspberry Pi: got FLOAT32, expected UINT8

I am trying to solve the W4 optional exercise, TFLite for Raspberry Pi.

I am running it on an old Raspberry Pi 3, therefore, 32 bit ARM. Also, 1 GB RAM.

I worked on my solution, and I got an error, so, I tried the model solution, but I am getting exactly the same error:

path=./mobilenet_v1_1.0_224_quant.tflite
Traceback (most recent call last):
File “/home/pi/test/C2_W4_Assignment_Solution.py”, line 56, in
interpreter.set_tensor(input_details[0][‘index’], input_data)
File “/home/pi/.local/lib/python3.9/site-packages/tflite_runtime/interpreter.py”, line 720, in set_tensor
self._interpreter.SetTensor(tensor_index, value)
ValueError: Cannot set tensor: Got value of type FLOAT32 but expected type UINT8 for input 88, name: input

As no link on the assignment page, I Googled for a tflite model, and I found this one: Image classification  |  TensorFlow Lite
Have I downloaded a wrong model, not compatible with the Raspberry Pi interpreter?

1 Like

The compatibility issue is with tensor data type, you have used float32 but you are suppose to use “UINT8” for input

https://www.tensorflow.org/api_docs/python/tf/experimental/numpy/uint8

Regards
DP

1 Like

But the model solution uses exactly the same, therefore, that would be wrong, am I right?

1 Like

I am not sure I get this. Are you doing an assignment work or personal project?

I will tag your course mentor.

@Jamal022 Can you please look into this.

Regards
DP

2 Likes

Sorry, I just found the issue, my mistake:

The model solution (and my solution) were right, the issue is that I took a tflite model file from the TensorFlow page, I had forgotten than the model to use was the one on the C2_W2 optional exercise for Android…
Once I used that model, the course one (‘converted_model.tflite’), everything worked perfectly OK.

Sorry for the inconveniences, and thank you very much in any case

2 Likes