necho-backend / convert_model.py
RomRam1's picture
Create convert_model.py
5e09973 verified
Raw
History Blame Contribute Delete
570 Bytes
"""
Run this ONCE on your local Mac to convert keras_model.h5 → model.tflite
Usage: python convert_model.py
"""
import tensorflow as tf
print("Loading keras_model.h5 ...")
model = tf.keras.models.load_model("Model_old/keras_model.h5")
print("Converting to TFLite ...")
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
with open("Model/model.tflite", "wb") as f:
f.write(tflite_model)
print(f"✅ Saved Model/model.tflite ({len(tflite_model) // 1024} KB)")
print("Now upload Model/model.tflite to your HF Space.")