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

hello-world example can't load model (TFMIC-30) #87

Open
maxgerhardt opened this issue Jun 29, 2024 · 3 comments
Open

hello-world example can't load model (TFMIC-30) #87

maxgerhardt opened this issue Jun 29, 2024 · 3 comments
Assignees

Comments

@maxgerhardt
Copy link

Running ESP-IDF 4.x + Arduino-ESP32 2.x and trying the hello-world example, the output is wrong. It seems the interpreter loads the model but then interpreter->input(0); and interpreter->output(0); returns vectors that have an extremely high zero-point and a scale of either 0 or -nan. This ofc makes the quantized x & y values wrong, too. Specifically, the output y is always 0.

Quantized x: -1 input zero point 1073421472 scale -nan
Quantized y: -48 output zero point 1073421456 scale 0.000000
x_value: 0.000000, y_value: -0.000000

Quantized x: -1 input zero point 1073421472 scale -nan
Quantized y: -48 output zero point 1073421456 scale 0.000000
x_value: 0.314159, y_value: -0.000000

This is running on a regular ESP32 dev board with no PSRAM. Example projects see https://github.com/maxgerhardt/pio-esp32-tfmicro-example, it uses PlatformIO for compilation. Any help is appreciated.

@github-actions github-actions bot changed the title hello-world example can't load model hello-world example can't load model (TFMIC-30) Jun 29, 2024
@maxgerhardt
Copy link
Author

maxgerhardt commented Jun 29, 2024

Note: Manually fixing input and output quantization with values read from the model and https://netron.app/ still leads to wrong model output.

  int8_t x_quantized = x * 40.69345526012819f + 128;
//..
  float y = (y_quantized - 4) * 0.008472034707665443f;

There must be something wrong when TFlite or Flatbuf decodes the model...

Quantized x: 12 input zero point 1073421424 scale -nan
Quantized y: 16 output zero point 1073421408 scale 0.000000
x_value: 3.455752, y_value: 0.101664

Quantized x: 25 input zero point 1073421424 scale -nan
Quantized y: 16 output zero point 1073421408 scale 0.000000
x_value: 3.769912, y_value: 0.101664

Also, updating the platform to use ESP-IDF 5.1.4 did not help, it's the same output pretty much.

@vikramdattu
Copy link
Collaborator

Hi @maxgerhardt did you try the example from esp-tflite-micro without Arduino? https://github.com/espressif/esp-tflite-micro/tree/master/examples/hello_world
Do you find results with this problematic too?

@vikramdattu vikramdattu self-assigned this Jul 8, 2024
@Inmoresentum
Copy link

I am having the same issue when testing out the provided hello word example. I am also using PlatformIO with espidf framework (no arduino). I am wondering if this is an issue with the tflite micro interpreter or the model itself?

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

3 participants