Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
61 |
-
2.
|
62 |
-
3.
|
63 |
-
4.
|
64 |
-
5.
|
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"
|
88 |
-
f"
|
89 |
-
f"
|
90 |
-
f"
|
91 |
-
f"
|
92 |
-
f"
|
93 |
-
"
|
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.
|
125 |
-
gr.Markdown("## π Welcome to MedExpert")
|
126 |
-
gr.Markdown("### Your Intelligent Health Companion")
|
127 |
gr.Markdown("""
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|