Delete convert_model.py
Browse files- convert_model.py +0 -28
convert_model.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
import tensorflow as tf
|
| 2 |
-
from tensorflow.keras.models import load_model
|
| 3 |
-
import pickle
|
| 4 |
-
import os
|
| 5 |
-
|
| 6 |
-
def convert_model():
|
| 7 |
-
try:
|
| 8 |
-
# Try to load the model
|
| 9 |
-
model = load_model('model.h5')
|
| 10 |
-
print("Model loaded successfully, converting to TensorFlow Lite...")
|
| 11 |
-
|
| 12 |
-
# Convert to TensorFlow Lite
|
| 13 |
-
converter = tf.lite.TFLiteConverter.from_keras_model(model)
|
| 14 |
-
tflite_model = converter.convert()
|
| 15 |
-
|
| 16 |
-
# Save the converted model
|
| 17 |
-
with open('model.tflite', 'wb') as f:
|
| 18 |
-
f.write(tflite_model)
|
| 19 |
-
|
| 20 |
-
print("Model converted to TensorFlow Lite successfully!")
|
| 21 |
-
return True
|
| 22 |
-
|
| 23 |
-
except Exception as e:
|
| 24 |
-
print(f"Error loading/converting model: {e}")
|
| 25 |
-
return False
|
| 26 |
-
|
| 27 |
-
if __name__ == "__main__":
|
| 28 |
-
convert_model()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|