Become a leader in the IoT community!

Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.

Step 1 of 5

CREATE YOUR PROFILE *Required

OR
Step 2 of 5

WHAT BRINGS YOU TO DEVHEADS? *Choose 1 or more

Connect & collaborate 🀝with other tech professionals
Learn & Grow πŸ“š
Contribute Experience & Expertise πŸ”§
Step 3 of 5

WHAT'S YOUR INTEREST OR EXPERTISE? *Choose 1 or more

Hardware Design πŸ’‘
Embedded Software πŸ’»
Edge Networking ⚑
Step 4 of 5

Personalize your profile

Step 5 of 5

Read & agree to our COMMUNITY RULES

  1. We want this server to be a welcoming space! Treat everyone with respect. Absolutely no harassment, witch hunting, sexism, racism, or hate speech will be tolerated.
  2. If you see something against the rules or something that makes you feel unsafe, let staff know by messaging @admin in the "support-tickets" tab in the Live DevChat menu.
  3. No age-restricted, obscene or NSFW content. This includes text, images, or links featuring nudity, sex, hard violence, or other graphically disturbing content.
  4. No spam. This includes DMing fellow members.
  5. You must be over the age of 18 years old to participate in our community.
  6. You agree to our Terms of Service (https://www.devheads.io/terms-of-service/) and Privacy Policy (https://www.devheads.io/privacy-policy)
By clicking "Finish", you have read and agreed to the our Terms of Service and Privacy Policy.

Trouble Running Tflite Model on ESP32 for Temperature and Humidity Prediction

Hello, i am trying to run Tflite model on esp32, but am getting wrong output, am doing temperature and humidity prediction. Am new to this can you help me

  1. jas_mine0024#0000

    For example i expect temperature values between 20-30Β°C, but I’m getting negative numbers or very large values.

  2. wafa_ath#0000

    Can i ask , how did you train your model and how are you running it on the esp32

  3. jas_mine0024#0000

    So collect data of humidity and temperature with dht11 and train it with Tansorflow and convert it to tflite and am using tflite micro

  4. wafa_ath#0000

    Hi @jas_mine0024 , how are you getting the output and what is supposed to be!

  5. wafa_ath#0000

    Did you quantize your model?

  6. wafa_ath#0000

    So for running model on microcontroller it have to be in int8 format ( 8-bit integer) quantize format that because microcontroller have limited memory and processing power

  7. jas_mine0024#0000

    What’s that, sorry am new to this!

  8. jas_mine0024#0000

    Ow yes i was looking, i think i skipped this partπŸ˜… it’s show that my model is float32, i will convert it

  9. wafa_ath#0000

    Try this collab code for the quantization

    # Google Colab script to quantize a model to int8
    import tensorflow as tf
    import numpy as np
    
    # Load model
    model = tf.keras.models.load_model("your_model.h5")
    
    # Representative dataset
    def representative_dataset():
        for _ in range(100):
            yield [np.random.rand(1, 28, 28, 1).astype(np.float32)]
    
    # Convert model
    converter = tf.lite.TFLiteConverter.from_keras_model(model)
    converter.optimizations = [tf.lite.Optimize.DEFAULT]
    converter.representative_dataset = representative_dataset
    converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
    converter.inference_input_type = tf.int8
    converter.inference_output_type = tf.int8
    
    tflite_model = converter.convert()
    
    # Save model
    with open("model_int8.tflite", "wb") as f:
        f.write(tflite_model)
    
    print("Quantized model saved as model_int8.tflite")
    
  10. wafa_ath#0000

    Also you have to to normalize and quantize your input data

  11. jas_mine0024#0000

    I appreciate it @wafa_ath

  12. jas_mine0024#0000

    I’ve done that

  13. jas_mine0024#0000

    Am still getting wrong output

  14. jas_mine0024#0000

    I didn’t normalize and quantize my input data yet

  15. jas_mine0024#0000

    Not sure how to do that

  16. wafa_ath#0000

    You have to bring your mean and standard deviation first

  17. jas_mine0024#0000

    Mean and standard deviation…
    I have two input data one for temperature and one for humidity should i apply on both of them

  18. wafa_ath#0000

    Then apply this formula
    For normalizing
    float temp_scaled = (temp – mean) / std_dev

    Then for Quantize
    int8_t q = (int8_t) round(temp_scaled / 0.01795339770615101) – 12

  19. wafa_ath#0000

    Yes for both

  20. wafa_ath#0000

    You can use the data that you used for the training to extract this info

  21. wafa_ath#0000

    Mean= total data/member of the total data

  22. wafa_ath#0000

    St dv =√(data -mean)^2/member of total data

  23. jas_mine0024#0000

    Ow okay okay i get it , i will try that

  24. jas_mine0024#0000

    Finally am getting it right, that’s amazing thank you so much @wafa_ath

  25. wafa_ath#0000

    What do you think, did try to use it and compare it to other AI?

  26. wafa_ath#0000

    With the hype that Deepseek is making and with the new updates V3
    But Why does it make that hype !
    First it’s used cost effective method comparing to other model like open ai .
    Instead of relying on expensive human feedback for fine-tuning, DeepSeek uses automated reinforcement learning, which significantly reduces costs and speeds up training. Also it optimized its own hardware by bypassing Nvidia’s software limitations,
    By combining efficient training methods with smart hardware optimization it reduces the production cost

  27. jas_mine0024#0000

    Yes i tried it but the server is always busy, i know that faced open AI from the beginning too and it will be fixed with time, but what i don’t understand that why openAI didn’t used automated reinforcement learning to reduce the cost too or there is a catch !

  28. wafa_ath#0000

    The thing here is it better in solving mathematical problem but for openAI it’s trained to deal and handle human conversation

CONTRIBUTE TO THIS THREAD

Browse other questions tagged 

Leaderboard

RANKED BY XP

All time
  • 1.
    Avatar
    @Nayel115
    1620 XP
  • 2.
    Avatar
    @UcGee
    650 XP
  • 3.
    Avatar
    @melta101
    600 XP
  • 4.
    Avatar
    @chitour
    600 XP
  • 5.
    Avatar
    @lifegochi
    250 XP
  • 6.
    Avatar
    @Youuce
    180 XP