Nadera03 commited on
Commit
c417f09
·
verified ·
1 Parent(s): 445f8b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -8
app.py CHANGED
@@ -1,8 +1,74 @@
1
- import gradio as gr
2
-
3
- def diagnose(symptoms):
4
- return f"Based on symptoms: {symptoms}, possible conditions are XYZ."
5
-
6
- demo = gr.Interface(fn=diagnose, inputs="text", outputs="text")
7
-
8
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+
4
+ # Symptom-based diagnosis function
5
+ def diagnose(symptoms):
6
+ symptom_disease_mapping = {
7
+ "fever, cold, flu": "Possible conditions: Common Cold, Influenza.",
8
+ "cough, fever, difficulty breathing": "Possible conditions: COVID-19, Pneumonia.",
9
+ "headache, nausea, dizziness": "Possible conditions: Migraine, Dehydration.",
10
+ "stomach pain, nausea, vomiting": "Possible conditions: Food Poisoning, Gastritis."
11
+ }
12
+
13
+ return symptom_disease_mapping.get(symptoms.lower(), "Not enough data, please consult a doctor.")
14
+
15
+ # Gut health analysis function
16
+ def gut_health_analysis(diet):
17
+ if "junk" in diet.lower():
18
+ return "Unhealthy gut! Try probiotic-rich foods like yogurt, kimchi, or kefir."
19
+ elif "fruits" in diet.lower() or "vegetables" in diet.lower():
20
+ return "Healthy gut! Your microbiome is balanced."
21
+ else:
22
+ return "Gut health status unclear. Maintain a fiber-rich diet."
23
+
24
+ # Retina scan function (Mock output)
25
+ def retina_scan(image):
26
+ return f"Retina scan result: No abnormalities detected. (For real diagnosis, consult a specialist)"
27
+
28
+ # Simple chatbot function
29
+ def chatbot(query):
30
+ responses = {
31
+ "hello": "Hello! How can I assist you?",
32
+ "what is ai": "AI (Artificial Intelligence) is the simulation of human intelligence by machines.",
33
+ "how to stay healthy": "Eat balanced meals, exercise daily, stay hydrated, and get enough sleep."
34
+ }
35
+ return responses.get(query.lower(), "I'm not sure about that. Please consult a doctor.")
36
+
37
+ # Creating Gradio UI
38
+ with gr.Blocks(theme="soft") as demo:
39
+ gr.Markdown("# 🔬 Diagnosify-AI: Your AI-powered Health Assistant")
40
+
41
+ # Symptom-based diagnosis
42
+ with gr.Row():
43
+ symptoms_input = gr.Textbox(label="Enter symptoms (comma separated)")
44
+ symptoms_output = gr.Textbox(label="Diagnosis Result", interactive=False)
45
+ diagnose_button = gr.Button("Diagnose")
46
+ diagnose_button.click(diagnose, inputs=symptoms_input, outputs=symptoms_output)
47
+
48
+ # Gut health analysis
49
+ with gr.Row():
50
+ diet_input = gr.Textbox(label="Describe your diet")
51
+ gut_output = gr.Textbox(label="Gut Health Status", interactive=False)
52
+ gut_button = gr.Button("Analyze Gut Health")
53
+ gut_button.click(gut_health_analysis, inputs=diet_input, outputs=gut_output)
54
+
55
+ # Retina scan
56
+ with gr.Row():
57
+ retina_input = gr.Image(label="Upload Retina Image")
58
+ retina_output = gr.Textbox(label="Retina Scan Report", interactive=False)
59
+ retina_button = gr.Button("Analyze Retina Scan")
60
+ retina_button.click(retina_scan, inputs=retina_input, outputs=retina_output)
61
+
62
+ # Simple chatbot
63
+ with gr.Row():
64
+ chat_input = gr.Textbox(label="Ask me anything")
65
+ chat_output = gr.Textbox(label="Bot Response", interactive=False)
66
+ chat_button = gr.Button("Ask")
67
+ chat_button.click(chatbot, inputs=chat_input, outputs=chat_output)
68
+
69
+ gr.Markdown("🔗 **Diagnosify-AI** - AI-powered medical insights at your fingertips!")
70
+
71
+ # Launching the app
72
+ demo.launch()
73
+
74
+