Rjavenger commited on
Commit
7a59dab
·
verified ·
1 Parent(s): d578ee5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from utils import load_model, predict_image
3
+
4
+ # Load model once
5
+ model = load_model("model/best_classification_model.pth", num_classes=3)
6
+ class_names = ['COVID', 'Normal', 'Viral Pneumonia']
7
+
8
+ def classify_xray(img):
9
+ prediction = predict_image(img, model, class_names)
10
+ return f"🧠 Predicted: {prediction}"
11
+
12
+ # Gradio UI
13
+ title = "🩻 COVID-19 Chest X-ray Classifier"
14
+ description = """
15
+ Upload a Chest X-ray image and let the AI classify it as:
16
+ - **COVID**
17
+ - **Normal**
18
+ - **Viral Pneumonia**
19
+ <br><br>
20
+ 🧠 Powered by ResNet18 + PyTorch
21
+ """
22
+
23
+ demo = gr.Interface(
24
+ fn=classify_xray,
25
+ inputs=gr.Image(type="filepath", label="Upload Chest X-ray"),
26
+ outputs=gr.Textbox(label="Prediction"),
27
+ title=title,
28
+ description=description,
29
+ examples=["examples/x-ray.jpg"],
30
+ theme="soft", # use "huggingface" or "default" if preferred
31
+ )
32
+
33
+ if __name__ == "__main__":
34
+ demo.launch()