Hasnain-Ali commited on
Commit
1a7ea3b
Β·
verified Β·
1 Parent(s): a484285

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -25
app.py CHANGED
@@ -57,11 +57,11 @@ def generate_expert_analysis(condition, symptoms):
57
  prompt = f"""As a {specialist_title.lower()}, explain {condition} to a patient experiencing these symptoms: "{symptoms}".
58
 
59
  Structure the response into:
60
- 1. **Biological Process**
61
- 2. **Immediate Treatment**
62
- 3. **Long-term Care**
63
- 4. **Emergency Signs**
64
- 5. **Diet Plan**
65
  Use professional yet simple language. **No AI disclaimers or generic advice**.
66
  """
67
 
@@ -84,13 +84,13 @@ def create_medical_report(symptoms):
84
  expert_analysis = generate_expert_analysis(diagnosis, translated_symptoms)
85
 
86
  full_report = (
87
- f"**Medical Report**\n\n"
88
- f"**Patient Symptoms:** {translated_symptoms}\n"
89
- f"**Primary Diagnosis:** {diagnosis}\n"
90
- f"**Affected System:** {system}\n"
91
- f"**Consult:** {specialist}\n\n"
92
- f"**Expert Analysis:**\n{expert_analysis}\n\n"
93
- "**Key Questions for Your Doctor:**\n"
94
  "1. Is this condition acute or chronic?\n"
95
  "2. What medication options are suitable?\n"
96
  "3. What lifestyle changes help manage this condition?\n"
@@ -109,8 +109,8 @@ def create_medical_report(symptoms):
109
  # Gradio UI Setup
110
  def show_section(selected):
111
  return (
112
- gr.update(visible=selected == "Home"),
113
- gr.update(visible=selected == "Diagnosis")
114
  )
115
 
116
  with gr.Blocks() as interface:
@@ -118,19 +118,28 @@ with gr.Blocks() as interface:
118
  with gr.Column(scale=1):
119
  gr.Markdown("## πŸ₯ MedExpert")
120
  gr.Markdown("AI-powered medical diagnosis system.")
121
- nav_buttons = gr.Radio(["Home", "Diagnosis"], value="Home")
122
 
123
  with gr.Column(scale=4):
124
- with gr.Column(visible=True) as home_section:
125
- gr.Markdown("## 🌟 Welcome to MedExpert")
126
- gr.Markdown("### Your Intelligent Health Companion")
127
  gr.Markdown("""
128
- - Symptom Analysis & Diagnosis
129
- - Mental Health Support
130
- - Medical Report Generation
131
- """)
132
-
133
- with gr.Column(visible=False) as diagnostic_section:
 
 
 
 
 
 
 
 
 
 
134
  gr.Markdown("## 🩺 Symptom Analyzer")
135
  symptoms_input = gr.Textbox(label="Describe your symptoms", placeholder="e.g., headache, fever, nausea...")
136
  analyze_btn = gr.Button("Analyze Symptoms", variant="primary")
@@ -142,4 +151,4 @@ with gr.Blocks() as interface:
142
  nav_buttons.change(show_section, inputs=[nav_buttons], outputs=[home_section, diagnostic_section])
143
 
144
  # Run Interface
145
- interface.launch()
 
57
  prompt = f"""As a {specialist_title.lower()}, explain {condition} to a patient experiencing these symptoms: "{symptoms}".
58
 
59
  Structure the response into:
60
+ 1. Biological Process :
61
+ 2. Immediate Treatment :
62
+ 3. Long-term Care :
63
+ 4. Emergency Signs :
64
+ 5. Diet Plan :
65
  Use professional yet simple language. **No AI disclaimers or generic advice**.
66
  """
67
 
 
84
  expert_analysis = generate_expert_analysis(diagnosis, translated_symptoms)
85
 
86
  full_report = (
87
+ f"Medical Report :\n\n"
88
+ f"Patient Symptoms: {translated_symptoms}\n"
89
+ f"Primary Diagnosis: {diagnosis}\n"
90
+ f"Affected System: {system}\n"
91
+ f"Consult:** {specialist}\n\n"
92
+ f"Expert Analysis:\n{expert_analysis}\n\n"
93
+ "Key Questions for Your Doctor:\n"
94
  "1. Is this condition acute or chronic?\n"
95
  "2. What medication options are suitable?\n"
96
  "3. What lifestyle changes help manage this condition?\n"
 
109
  # Gradio UI Setup
110
  def show_section(selected):
111
  return (
112
+ gr.update(visible=selected == "🏠 Home"),
113
+ gr.update(visible=selected == "πŸ” Diagnosis")
114
  )
115
 
116
  with gr.Blocks() as interface:
 
118
  with gr.Column(scale=1):
119
  gr.Markdown("## πŸ₯ MedExpert")
120
  gr.Markdown("AI-powered medical diagnosis system.")
121
+ nav_buttons = gr.Radio(["🏠 Home", "πŸ” Diagnosis"], value="Home")
122
 
123
  with gr.Column(scale=4):
124
+ with gr.Group(visible=True) as home_section:
125
+ gr.Markdown("## 🌟 Welcome to MedExpert – Your AI-Powered Health Assistant πŸ₯πŸ€–")
 
126
  gr.Markdown("""
127
+ ### πŸ† Why Choose MedExpert?
128
+ - βœ… **Instant Symptom Analysis** πŸ€’
129
+ - βœ… **AI-Powered Medical Insights** 🧠
130
+ - βœ… **Expert Recommendations** 🩺
131
+ - βœ… **Generate and Download Medical Reports** πŸ“„
132
+ """, elem_id="home-intro")
133
+ gr.Markdown("---")
134
+ gr.Markdown("""
135
+ ### πŸ’‘ **How It Works?**
136
+ 1️⃣ **Describe your symptoms** ✍️
137
+ 2️⃣ **AI analyzes & suggests a possible condition** 🧬
138
+ 3️⃣ **Get expert analysis & a downloadable report** πŸ“Š
139
+ """)
140
+ gr.Markdown("πŸ” Click on **Diagnosis** above to start your health checkup!")
141
+
142
+ with gr.Group(visible=False) as diagnostic_section:
143
  gr.Markdown("## 🩺 Symptom Analyzer")
144
  symptoms_input = gr.Textbox(label="Describe your symptoms", placeholder="e.g., headache, fever, nausea...")
145
  analyze_btn = gr.Button("Analyze Symptoms", variant="primary")
 
151
  nav_buttons.change(show_section, inputs=[nav_buttons], outputs=[home_section, diagnostic_section])
152
 
153
  # Run Interface
154
+ interface.launch()