cfgpp commited on
Commit
20cd6c0
·
verified ·
1 Parent(s): 2699ba5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+ from PIL import Image
4
+ import torch
5
+ from utils.model_utils import load_model, predict
6
+ from utils.preprocessing import preprocess_image
7
+
8
+ st.set_page_config(page_title="X-ray Diagnosis Demo", layout="centered")
9
+ st.title("🩻 X-ray Multi-Label Diagnosis App (CheXNet)")
10
+
11
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
12
+ model_path = "model/dannynet-55-best_model_20250422-211522.pth"
13
+ model = load_model(model_path, device)
14
+
15
+ uploaded_file = st.file_uploader("Upload a chest X-ray", type=["jpg", "jpeg", "png"])
16
+
17
+ if uploaded_file:
18
+ image = Image.open(uploaded_file).convert("RGB")
19
+ st.image(image, caption="Uploaded X-ray", use_column_width=True)
20
+
21
+ img_tensor = preprocess_image(image)
22
+
23
+ probs = predict(model, img_tensor, device)
24
+
25
+ st.subheader("Predictions")
26
+ for disease, prob in probs.items():
27
+ st.write(f"**{disease}**: {prob:.4f}")