Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,11 +9,27 @@ import joblib
|
|
| 9 |
KNN_MODEL_PATH = './knn_pharyngitis_model.pkl'
|
| 10 |
EXTRACTOR_PATH = './mobilenetv2_feature_extractor.h5'
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Load the saved models
|
| 13 |
-
st.
|
| 14 |
-
knn = joblib.load(KNN_MODEL_PATH)
|
| 15 |
-
feature_extractor = load_model(EXTRACTOR_PATH)
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Function to preprocess the uploaded image
|
| 19 |
def preprocess_image(image):
|
|
@@ -30,8 +46,7 @@ def classify_image(image):
|
|
| 30 |
return "Pharyngitis" if prediction[0] == 1 else "No Pharyngitis"
|
| 31 |
|
| 32 |
# Streamlit app UI
|
| 33 |
-
st.
|
| 34 |
-
st.write("Upload an image to classify it as 'Pharyngitis' or 'No Pharyngitis'.")
|
| 35 |
|
| 36 |
uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"])
|
| 37 |
|
|
@@ -41,6 +56,13 @@ if uploaded_file is not None:
|
|
| 41 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 42 |
|
| 43 |
# Classify the image
|
| 44 |
-
st.write("Classifying...")
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
KNN_MODEL_PATH = './knn_pharyngitis_model.pkl'
|
| 10 |
EXTRACTOR_PATH = './mobilenetv2_feature_extractor.h5'
|
| 11 |
|
| 12 |
+
# Display a welcome message and note
|
| 13 |
+
st.title("Pharyngitis Classification App")
|
| 14 |
+
st.write("""
|
| 15 |
+
**Please wait while the models are being loaded.**
|
| 16 |
+
""")
|
| 17 |
+
|
| 18 |
# Load the saved models
|
| 19 |
+
with st.spinner("Please wait for a while..."):
|
| 20 |
+
knn = joblib.load(KNN_MODEL_PATH)
|
| 21 |
+
feature_extractor = load_model(EXTRACTOR_PATH)
|
| 22 |
+
|
| 23 |
+
st.success("Models loaded successfully!")
|
| 24 |
+
|
| 25 |
+
# Display additional information
|
| 26 |
+
st.markdown("""
|
| 27 |
+
### Note:
|
| 28 |
+
- This application predicts whether the uploaded throat image shows signs of *pharyngitis* or not.
|
| 29 |
+
- **Accuracy:** Approximately 80%.
|
| 30 |
+
- **Disclaimer:** This tool is not a substitute for a medical professional's advice.
|
| 31 |
+
Please consult a physician if you experience any throat-related issues.
|
| 32 |
+
""")
|
| 33 |
|
| 34 |
# Function to preprocess the uploaded image
|
| 35 |
def preprocess_image(image):
|
|
|
|
| 46 |
return "Pharyngitis" if prediction[0] == 1 else "No Pharyngitis"
|
| 47 |
|
| 48 |
# Streamlit app UI
|
| 49 |
+
st.write("### Upload an image to classify it as 'Pharyngitis' or 'No Pharyngitis'.")
|
|
|
|
| 50 |
|
| 51 |
uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"])
|
| 52 |
|
|
|
|
| 56 |
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 57 |
|
| 58 |
# Classify the image
|
| 59 |
+
st.write("### Classifying...")
|
| 60 |
+
with st.spinner("Analyzing the image..."):
|
| 61 |
+
prediction = classify_image(image)
|
| 62 |
+
st.success(f"Prediction: **{prediction}**")
|
| 63 |
+
|
| 64 |
+
# Footer with a link to your LinkedIn profile
|
| 65 |
+
st.markdown("""
|
| 66 |
+
---
|
| 67 |
+
Made with ❤️ by [Haris](https://www.linkedin.com/in/h4r1s)
|
| 68 |
+
""")
|