Giter Site home page Giter Site logo

Comments (6)

jomoengineer avatar jomoengineer commented on June 1, 2024

I found a temp solution.
I copied the "Encode the Model in an Arduino Header File" code and the gesture_model.tflite file to a Linux box, created a content folder and made a shell and a python script to run the code.
Ex:

  • create_content.sh
#!/bin/bash

echo "const unsigned char model[] = {" > content/model.h
cat gesture_model.tflite | xxd -i      >> content/model.h
echo "};"                              >> content/model.h
  • get_header_size.py
#!/usr/bin/env python3

import os
model_h_size = os.path.getsize("./content/model.h")
print(f"Header file, model.h, is {model_h_size:,} bytes.")
print("\nOpen the side panel (refresh if needed). Double click model.h to download the file.")

I then copied the resulting model.h code to the Arduino IDE project and was able to complete the Gesture recognition tutorial.

This worked for the "TinyML Classify objects by color" tutorial as well.

from arduinotensorflowlitetutorials.

pra-dan avatar pra-dan commented on June 1, 2024

Please refer to this example on Google Collab. I hope it helps https://github.com/PrashantDandriyal/arduino_GSoC2020/blob/master/activity_tracker/activity_tracker_motionSense_gsoc20.ipynb

from arduinotensorflowlitetutorials.

jomoengineer avatar jomoengineer commented on June 1, 2024

Uh, the link you provided is a GitHub link. I'm not see how that address this issue.

from arduinotensorflowlitetutorials.

pra-dan avatar pra-dan commented on June 1, 2024

It is actually a link to the iPython notebook I shared to demonstrate how I obtained the header file-model and thought it may help you get over your errors.

from arduinotensorflowlitetutorials.

intratron avatar intratron commented on June 1, 2024

I got the same problem. The model.h file was blank. I managed to solve it in part, not in a very elegant way. But I hope it helps.

I was able to solve it. What I did was to verify the file using TextEdit on a Mac. I realized some of the lines/cells of the flex.csv and punch.csv files where either empty, mixed with another cell or a whole line of cells was out. Apparently when the data from the IMU is gathered to the Arduino's serial monitor it has some issues so when you copy it to a text file, those issues stays. See the line:

This is ok:
-0.37 | 0.395 | 1.931 | 284.363 | -9.46 | -77.026
-0.648 | 0.578 | 1.737 | 795.166 | 36.743 | -190.247
-0.238 | 0.815 | 1.104 | 1028.137 | 40.283 | -246.948

This is not ok:
-0.37 | 0.395 | 1.931 | 284.363-9.46 | (empty) | -77.026
-0.648 | 0.578 | 1.737 | 795.166 | 36.743 | -190.247 -0.238 | 0.815 | 1.104 | 1028.137 | 40.283 | -246.948

So I had to open the file in excel and manually fix every error in the cells, I took me like 5 minutes but that was the only way I managed to run the Tiny ML colab webpage and run the training, convert and encode functions. After doing this, the model.h file was generated with the data (911kb).

Not everything was ok though. I ran the sketch in Arduino IDE using the IMU_Classifier, adding a tab, pasting the model.h data in it. The Arduino serial monitor is responding but is giving me just a "nan" label instead of a float eg. 0.8987

So apparently I managed to solve the model.h problem but still I don't know whats the "nan" problem.

BTW I'm following this tutorial https://blog.arduino.cc/2019/10/15/get-started-with-machine-learning-on-arduino/

from arduinotensorflowlitetutorials.

JatinPendharkar avatar JatinPendharkar commented on June 1, 2024

@intratron im getting the same error. Did you find any solution for same ?
The Arduino serial monitor is responding but is giving me just a "nan" label instead of a float eg. 0.8987

from arduinotensorflowlitetutorials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.