ATllll commited on
Commit
f361624
·
verified ·
1 Parent(s): d24ca93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -13,7 +13,6 @@ def load_model():
13
  model = load_model()
14
 
15
  st.title("🫁 Pneumonia Detection from Chest X-ray Images")
16
-
17
  st.markdown("Upload your own X-ray or try one of the sample images below.")
18
 
19
  # === Sample Image Section ===
@@ -43,9 +42,12 @@ if image and st.button('🔍 Predict'):
43
  img_array = np.array(img) / 255.0
44
  img_array = np.expand_dims(img_array, axis=0)
45
 
46
- prediction = model.predict(img_array)
47
 
48
- if prediction[0][0] > 0.5:
 
 
 
49
  st.error("🩺 **Prediction: Pneumonia Detected**")
50
  else:
51
- st.success(" **Prediction: Normal**")
 
13
  model = load_model()
14
 
15
  st.title("🫁 Pneumonia Detection from Chest X-ray Images")
 
16
  st.markdown("Upload your own X-ray or try one of the sample images below.")
17
 
18
  # === Sample Image Section ===
 
42
  img_array = np.array(img) / 255.0
43
  img_array = np.expand_dims(img_array, axis=0)
44
 
45
+ prediction = model.predict(img_array)[0][0]
46
 
47
+ # Set thresholds to determine confidence
48
+ if prediction < 0.3:
49
+ st.success("✅ **Prediction: Normal**")
50
+ elif prediction > 0.7:
51
  st.error("🩺 **Prediction: Pneumonia Detected**")
52
  else:
53
+ st.warning("⚠️ Unable to confidently detect pneumonia. Please upload a clear chest X-ray image.")