Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +4 -13
streamlit_app.py
CHANGED
|
@@ -9,8 +9,8 @@ import os
|
|
| 9 |
from PIL import Image # Needed to display image in Streamlit
|
| 10 |
|
| 11 |
# --- Configuration ---
|
| 12 |
-
|
| 13 |
-
IMG_SIZE =
|
| 14 |
# Define the expected model filename
|
| 15 |
MODEL_FILENAME = 'skin_lesion_model.keras'
|
| 16 |
# Define class names based on the training script output
|
|
@@ -110,19 +110,10 @@ if model is not None:
|
|
| 110 |
# Display result
|
| 111 |
st.success(f'Prediction: **{label}**')
|
| 112 |
st.metric(label="Confidence", value=f"{confidence:.2%}")
|
| 113 |
-
# Optional: Display confidence breakdown
|
| 114 |
-
# st.write("Confidence Scores:")
|
| 115 |
-
# st.write({name: f"{pred:.2%}" for name, pred in zip(CLASS_NAMES, model.predict(processed_image)[0])})
|
| 116 |
else:
|
| 117 |
st.error("Prediction failed. Please check the logs or try a different image.")
|
| 118 |
else:
|
| 119 |
st.error("Image preprocessing failed. Please ensure the image is valid.")
|
| 120 |
else:
|
| 121 |
-
|
| 122 |
-
st.warning("Model could not be loaded. Please check the setup.")
|
| 123 |
-
|
| 124 |
-
# --- How to Run ---
|
| 125 |
-
# Save this code as a Python file (e.g., app.py)
|
| 126 |
-
# Ensure 'skin_lesion_model.keras' is in the same directory.
|
| 127 |
-
# Install libraries: pip install streamlit numpy tensorflow Pillow
|
| 128 |
-
# Run from terminal: streamlit run app.py
|
|
|
|
| 9 |
from PIL import Image # Needed to display image in Streamlit
|
| 10 |
|
| 11 |
# --- Configuration ---
|
| 12 |
+
|
| 13 |
+
IMG_SIZE = 224
|
| 14 |
# Define the expected model filename
|
| 15 |
MODEL_FILENAME = 'skin_lesion_model.keras'
|
| 16 |
# Define class names based on the training script output
|
|
|
|
| 110 |
# Display result
|
| 111 |
st.success(f'Prediction: **{label}**')
|
| 112 |
st.metric(label="Confidence", value=f"{confidence:.2%}")
|
|
|
|
|
|
|
|
|
|
| 113 |
else:
|
| 114 |
st.error("Prediction failed. Please check the logs or try a different image.")
|
| 115 |
else:
|
| 116 |
st.error("Image preprocessing failed. Please ensure the image is valid.")
|
| 117 |
else:
|
| 118 |
+
|
| 119 |
+
st.warning("Model could not be loaded. Please check the setup.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|