You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everyone,
I'm new to Keras and TensorFlow and currently exploring them for a personal project focused on emotion detection from images.
I'm using:
Keras version: 3.9.2
TensorFlow version: 2.19.0
I'm trying to load a pre-trained model from a JSON file using the following code:
from tensorflow.keras.models import load_model, model_from_json
import os
MODEL_FOLDER_PATH = r"C:\Users\User\Project\Emotion_Analyzer\model"
JSON_FILE_NAME = "emotion_model.json"
H5_WEIGHTS_FILE_NAME = "emotion_model.h5"
JSON_PATH = os.path.join(MODEL_FOLDER_PATH, JSON_FILE_NAME)
WEIGHTS_PATH = os.path.join(MODEL_FOLDER_PATH, H5_WEIGHTS_FILE_NAME)
with open(JSON_PATH, 'r') as json_file:
loaded_model_json = json_file.read()
model = model_from_json(loaded_model_json)
model.load_weights(WEIGHTS_PATH)
model.summary()
However, I'm encountering the following error:
---> 12 model = model_from_json(loaded_model_json)
TypeError: Could not locate class 'Sequential'. Make sure custom classes are decorated with `@keras.saving.register_keras_serializable()`. Full object config:
After some research, I found that this issue likely stems from compatibility problems between the model's original version (Keras 2.4.0) and the version I'm currently using (3.9.2).
Could someone please guide me on how to resolve this error without downgrading to an older Keras version? emotion_model.json
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone,
I'm new to Keras and TensorFlow and currently exploring them for a personal project focused on emotion detection from images.
I'm using:
Keras version: 3.9.2
TensorFlow version: 2.19.0
I'm trying to load a pre-trained model from a JSON file using the following code:
However, I'm encountering the following error:
After some research, I found that this issue likely stems from compatibility problems between the model's original version (Keras 2.4.0) and the version I'm currently using (3.9.2).
Could someone please guide me on how to resolve this error without downgrading to an older Keras version?
emotion_model.json
Any help would be greatly appreciated!
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions