Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,7 @@ import os
|
|
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}")
|
@@ -17,6 +16,7 @@ def load_model():
|
|
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}")
|
@@ -54,11 +54,12 @@ def main():
|
|
54 |
|
55 |
st.write("")
|
56 |
st.write("Classifying...")
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
62 |
|
63 |
if __name__ == "__main__":
|
64 |
main()
|
|
|
8 |
# Function to load the model
|
9 |
@st.cache_resource
|
10 |
def load_model():
|
11 |
+
model_path = 'path_to_your_saved_model.h5' # Ensure this path is correct relative to your deployment setup
|
|
|
12 |
|
13 |
if not os.path.isfile(model_path):
|
14 |
st.error(f"Model file not found: {model_path}")
|
|
|
16 |
|
17 |
try:
|
18 |
model = tf.keras.models.load_model(model_path)
|
19 |
+
st.success("Model loaded successfully!")
|
20 |
return model
|
21 |
except Exception as e:
|
22 |
st.error(f"Error loading model: {e}")
|
|
|
54 |
|
55 |
st.write("")
|
56 |
st.write("Classifying...")
|
57 |
+
try:
|
58 |
+
prediction = predict(image, model)
|
59 |
+
predicted_class = np.argmax(prediction, axis=1)[0] # Adjust based on your model's output
|
60 |
+
st.write(f"Predicted class: {predicted_class}")
|
61 |
+
except Exception as e:
|
62 |
+
st.error(f"Error in prediction: {e}")
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
main()
|