Spaces:
Sleeping
Sleeping
fix: Update model loading to use .h5 format
Browse files- frontend/app.py +8 -14
frontend/app.py
CHANGED
@@ -59,17 +59,14 @@ if 'disease_model' not in st.session_state:
|
|
59 |
try:
|
60 |
# Check if running on Hugging Face Spaces
|
61 |
if 'HF_SPACE_ID' in os.environ:
|
62 |
-
model_path = 'FINAL_MODEL.
|
63 |
-
|
64 |
-
model_dir = os.path.dirname(extracted_model_path)
|
65 |
-
model_path = os.path.join(model_dir, 'FINAL_MODEL.keras')
|
66 |
-
st.session_state.disease_model = tf.keras.models.load_model(model_path)
|
67 |
else: # Assume running locally
|
68 |
-
model_path = 'FINAL_MODEL.
|
69 |
st.session_state.disease_model = tf.keras.models.load_model(model_path)
|
70 |
print("Disease model loaded successfully!")
|
71 |
except FileNotFoundError:
|
72 |
-
st.error("Disease classification model not found. Please ensure 'FINAL_MODEL.
|
73 |
st.session_state.disease_model = None
|
74 |
except PermissionError:
|
75 |
st.error("Permission error accessing 'model.weights.h5'. Please ensure the file is not being used by another process.")
|
@@ -112,16 +109,13 @@ if 'model_llm' not in st.session_state:
|
|
112 |
try:
|
113 |
# Check if running on Hugging Face Spaces
|
114 |
if 'HF_SPACE_ID' in os.environ:
|
115 |
-
model_path = 'FINAL_MODEL.
|
116 |
-
|
117 |
-
model_dir = os.path.dirname(extracted_model_path)
|
118 |
-
model_path = os.path.join(model_dir, 'FINAL_MODEL.keras')
|
119 |
-
disease_model = tf.keras.models.load_model(model_path)
|
120 |
else: # Assume running locally
|
121 |
-
model_path = 'FINAL_MODEL.
|
122 |
disease_model = tf.keras.models.load_model(model_path)
|
123 |
except FileNotFoundError:
|
124 |
-
st.error("Disease classification model not found. Please ensure 'FINAL_MODEL.
|
125 |
disease_model = None
|
126 |
except PermissionError:
|
127 |
st.error("Permission error accessing 'model.weights.h5'. Please ensure the file is not being used by another process.")
|
|
|
59 |
try:
|
60 |
# Check if running on Hugging Face Spaces
|
61 |
if 'HF_SPACE_ID' in os.environ:
|
62 |
+
model_path = 'FINAL_MODEL.h5' # Updated to .h5
|
63 |
+
st.session_state.disease_model = tf.keras.models.load_model(model_path)
|
|
|
|
|
|
|
64 |
else: # Assume running locally
|
65 |
+
model_path = 'FINAL_MODEL.h5' # Updated to .h5
|
66 |
st.session_state.disease_model = tf.keras.models.load_model(model_path)
|
67 |
print("Disease model loaded successfully!")
|
68 |
except FileNotFoundError:
|
69 |
+
st.error("Disease classification model not found. Please ensure 'FINAL_MODEL.h5' is in the correct directory.")
|
70 |
st.session_state.disease_model = None
|
71 |
except PermissionError:
|
72 |
st.error("Permission error accessing 'model.weights.h5'. Please ensure the file is not being used by another process.")
|
|
|
109 |
try:
|
110 |
# Check if running on Hugging Face Spaces
|
111 |
if 'HF_SPACE_ID' in os.environ:
|
112 |
+
model_path = 'FINAL_MODEL.h5' # Updated to .h5
|
113 |
+
disease_model = tf.keras.models.load_model(model_path)
|
|
|
|
|
|
|
114 |
else: # Assume running locally
|
115 |
+
model_path = 'FINAL_MODEL.h5' # Updated to .h5
|
116 |
disease_model = tf.keras.models.load_model(model_path)
|
117 |
except FileNotFoundError:
|
118 |
+
st.error("Disease classification model not found. Please ensure 'FINAL_MODEL.h5' is in the correct directory.")
|
119 |
disease_model = None
|
120 |
except PermissionError:
|
121 |
st.error("Permission error accessing 'model.weights.h5'. Please ensure the file is not being used by another process.")
|