feat: adding resnet and formatting updates
This commit is contained in:
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
import pandas as pd
|
||||
import tensorflow as tf
|
||||
from keras.preprocessing.image import ImageDataGenerator
|
||||
from tensorflow import keras
|
||||
import tensorflow as tf
|
||||
|
||||
# TODO: Move these to a config for the project
|
||||
input_shape = (224, 224, 3)
|
||||
@@ -25,16 +25,19 @@ for file in glob("./models/keras/*.hdf5"):
|
||||
path = Path(file)
|
||||
tflite_file = f'./models/tflite/models/{path.name[:-5] + ".tflite"}'
|
||||
if not Path(tflite_file).exists():
|
||||
keras_model = keras.models.load_model(file)
|
||||
|
||||
print(tflite_file)
|
||||
keras_model = tf.keras.models.load_model(file)
|
||||
keras_model.summary()
|
||||
print(keras_model.input)
|
||||
print(keras_model.layers)
|
||||
converter = tf.lite.TFLiteConverter.from_keras_model(keras_model)
|
||||
tflite_model = converter.convert()
|
||||
with open(tflite_file, 'wb') as f:
|
||||
f.write(tflite_model)
|
||||
# TODO: Verify the model performance after converting to TFLITE
|
||||
# interpreter = tf.lite.Interpreter(model_path=tflite_file)
|
||||
# single_acc, single_ll = get_metrics(single_gen, keras_model)
|
||||
# tf_single_acc, tf_single_ll = get_metrics(single_gen, tflite_model)
|
||||
#
|
||||
# print(single_acc, tf_single_acc)
|
||||
# print(single_ll, tf_single_ll)
|
||||
# TODO: Verify the model performance after converting to TFLITE
|
||||
# interpreter = tf.lite.Interpreter(model_path=tflite_file)
|
||||
# single_acc, single_ll = get_metrics(single_gen, keras_model)
|
||||
# tf_single_acc, tf_single_ll = get_metrics(single_gen, tflite_model)
|
||||
#
|
||||
# print(single_acc, tf_single_acc)
|
||||
# print(single_ll, tf_single_ll)
|
||||
|
||||
Reference in New Issue
Block a user