sehatguard commited on
Commit
5404885
·
verified ·
1 Parent(s): 95a5bef

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the pre-trained model (you can replace this with any healthcare model from Hugging Face)
5
+ model = pipeline("text-classification", model="mrm8488/bert-tiny-finetuned-sms-spam-detection")
6
+
7
+ # Function to diagnose based on symptoms
8
+ def diagnose(symptoms):
9
+ prediction = model(symptoms)
10
+ return f"Possible diagnosis: {prediction[0]['label']}"
11
+
12
+ # Triage function based on symptoms
13
+ def triage(symptoms):
14
+ if "chest pain" in symptoms or "shortness of breath" in symptoms:
15
+ return "Urgent: Seek immediate medical attention."
16
+ elif "fever" in symptoms and "cough" in symptoms:
17
+ return "Mild: Likely a viral infection, monitor symptoms."
18
+ else:
19
+ return "Non-urgent: No immediate concern."
20
+
21
+ # Combine Diagnosis and Triage
22
+ def full_check(symptoms):
23
+ diagnosis = diagnose(symptoms)
24
+ severity = triage(symptoms)
25
+ return diagnosis, severity
26
+
27
+ # Create the Gradio interface
28
+ iface = gr.Interface(fn=full_check, inputs="text", outputs=["text", "text"], title="Sehat Guard - Symptom Checker")
29
+
30
+ # Launch the app
31
+ iface.launch()