Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 2437

General discussion • Input shape changed wrong after converting model .h5 to .tflite

$
0
0
1. My topic
Image Classification to detect 7 different weather conditions deploy on Raspberry Pi4

2. Train model .h5 on ggcolab
- I'm using ResNet50 (deep learning) and 1 fully connected layer with Softmax function
- Input: (244, 244, 3) image (RGB)
- Output: one-hot encoding 7 classes (Ex: [0 0 1 0 0 0 0 0] => Rainy)
- epoch = 20 and accuracy is 90% (code below)
- Then I convert model .h5 to .tflite in order to run on RaspberryPi4

3. Problem
- input_details[0]['shape'] gave me input shape: " [1, 1, 1, 3] " which is wrong (correct one is [1, 244, 244, 3] )
- output_details[0]['shape'] gave me output shape: " [1, 7] " which is correct
=> model.tflite run wrong
How can I fix this bug? ( change input shape of model .tflite to exact input shape )

Link my code on github: https://github.com/VanBap/Adverse_Weather
Including:
File train model h5: Adverse_weather_detection_model.ipynb
File convert model from .h5 -> .tflite: convert.py
File run test model .tflite: run_tflite_model.py
Thank you so much!

Statistics: Posted by VanNgo — Wed Mar 27, 2024 8:50 am



Viewing all articles
Browse latest Browse all 2437

Trending Articles