Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,20 @@ import numpy as np
|
|
3 |
import cv2
|
4 |
from PIL import Image
|
5 |
import tensorflow as tf
|
|
|
6 |
|
7 |
# Function to load the model
|
8 |
-
@st.
|
9 |
def load_model():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
try:
|
11 |
-
model = tf.keras.models.load_model(
|
12 |
return model
|
13 |
except Exception as e:
|
14 |
st.error(f"Error loading model: {e}")
|
|
|
3 |
import cv2
|
4 |
from PIL import Image
|
5 |
import tensorflow as tf
|
6 |
+
import os
|
7 |
|
8 |
# Function to load the model
|
9 |
+
@st.cache_resource
|
10 |
def load_model():
|
11 |
+
# Ensure this path is correct relative to your deployment setup
|
12 |
+
model_path = 'path_to_your_saved_model.h5'
|
13 |
+
|
14 |
+
if not os.path.isfile(model_path):
|
15 |
+
st.error(f"Model file not found: {model_path}")
|
16 |
+
return None
|
17 |
+
|
18 |
try:
|
19 |
+
model = tf.keras.models.load_model(model_path)
|
20 |
return model
|
21 |
except Exception as e:
|
22 |
st.error(f"Error loading model: {e}")
|