Spaces:
Sleeping
Sleeping
ashishkgpian
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -20,55 +20,120 @@ def classify_symptoms(text):
|
|
20 |
except Exception as e:
|
21 |
return f"Error processing classification: {str(e)}"
|
22 |
|
23 |
-
#
|
24 |
custom_css = """
|
25 |
.gradio-container {
|
26 |
-
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
border-radius: 8px !important;
|
32 |
-
padding:
|
33 |
-
|
34 |
-
|
35 |
}
|
36 |
|
37 |
-
.
|
38 |
-
|
39 |
-
|
|
|
|
|
40 |
}
|
41 |
|
42 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
color: #2c3e50 !important;
|
44 |
-
|
45 |
-
|
|
|
|
|
46 |
}
|
47 |
|
48 |
-
footer {
|
49 |
text-align: center;
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
"""
|
55 |
|
56 |
with gr.Blocks(css=custom_css) as demo:
|
57 |
-
gr.Markdown(
|
58 |
-
"""
|
59 |
-
# MedAI: Clinical Symptom ICD9 Classifier
|
60 |
-
### AI-Powered Diagnostic Code Suggestion Tool
|
61 |
-
"""
|
62 |
-
)
|
63 |
-
|
64 |
with gr.Row():
|
65 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
input_text = gr.Textbox(
|
67 |
-
label="
|
68 |
-
placeholder="Enter detailed patient symptoms
|
69 |
-
lines=
|
|
|
70 |
)
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
examples = gr.Examples(
|
73 |
examples=[
|
74 |
["45-year-old male experiencing severe chest pain, radiating to left arm, with shortness of breath and excessive sweating"],
|
@@ -76,19 +141,22 @@ with gr.Blocks(css=custom_css) as demo:
|
|
76 |
["Diabetic patient reporting frequent urination, increased thirst, and unexplained weight loss"],
|
77 |
["Elderly patient with chronic knee pain, reduced mobility, and signs of inflammation"]
|
78 |
],
|
79 |
-
inputs=input_text
|
|
|
|
|
80 |
)
|
81 |
|
82 |
-
output = gr.JSON(label="Diagnostic Suggestions")
|
83 |
-
|
84 |
input_text.submit(fn=classify_symptoms, inputs=input_text, outputs=output)
|
85 |
|
86 |
-
gr.
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
92 |
|
93 |
if __name__ == "__main__":
|
94 |
demo.launch()
|
|
|
20 |
except Exception as e:
|
21 |
return f"Error processing classification: {str(e)}"
|
22 |
|
23 |
+
# Enhanced CSS for a more professional medical look
|
24 |
custom_css = """
|
25 |
.gradio-container {
|
26 |
+
max-width: 1200px !important;
|
27 |
+
margin: auto !important;
|
28 |
+
padding: 2rem !important;
|
29 |
+
background-color: #f0f4f7 !important;
|
30 |
}
|
31 |
|
32 |
+
#component-0 {
|
33 |
+
text-align: center;
|
34 |
+
padding: 1rem;
|
35 |
+
margin-bottom: 2rem;
|
36 |
+
background: #ffffff;
|
37 |
+
border-radius: 10px;
|
38 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
39 |
+
}
|
40 |
+
|
41 |
+
#component-0 h1 {
|
42 |
+
color: #2c3e50;
|
43 |
+
font-size: 2.5rem;
|
44 |
+
margin-bottom: 0.5rem;
|
45 |
+
}
|
46 |
+
|
47 |
+
#component-0 h3 {
|
48 |
+
color: #34495e;
|
49 |
+
font-size: 1.2rem;
|
50 |
+
font-weight: normal;
|
51 |
+
}
|
52 |
+
|
53 |
+
.input-container {
|
54 |
+
background: white !important;
|
55 |
+
padding: 2rem !important;
|
56 |
+
border-radius: 10px !important;
|
57 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
|
58 |
+
margin-bottom: 1.5rem !important;
|
59 |
+
}
|
60 |
+
|
61 |
+
.textbox textarea {
|
62 |
+
border: 2px solid #3498db !important;
|
63 |
border-radius: 8px !important;
|
64 |
+
padding: 1rem !important;
|
65 |
+
font-size: 1.1rem !important;
|
66 |
+
min-height: 120px !important;
|
67 |
}
|
68 |
|
69 |
+
.output-container {
|
70 |
+
background: white !important;
|
71 |
+
padding: 2rem !important;
|
72 |
+
border-radius: 10px !important;
|
73 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
|
74 |
}
|
75 |
|
76 |
+
.examples-container {
|
77 |
+
background: white !important;
|
78 |
+
padding: 1.5rem !important;
|
79 |
+
border-radius: 10px !important;
|
80 |
+
margin-top: 1rem !important;
|
81 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
|
82 |
+
}
|
83 |
+
|
84 |
+
.example-text {
|
85 |
+
font-size: 0.9rem !important;
|
86 |
color: #2c3e50 !important;
|
87 |
+
padding: 0.5rem !important;
|
88 |
+
border-radius: 4px !important;
|
89 |
+
background: #f8f9fa !important;
|
90 |
+
margin: 0.5rem 0 !important;
|
91 |
}
|
92 |
|
93 |
+
.footer {
|
94 |
text-align: center;
|
95 |
+
margin-top: 2rem;
|
96 |
+
padding: 1rem;
|
97 |
+
background: white;
|
98 |
+
border-radius: 10px;
|
99 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
100 |
+
}
|
101 |
+
|
102 |
+
.label {
|
103 |
+
font-size: 1.2rem !important;
|
104 |
+
color: #2c3e50 !important;
|
105 |
+
font-weight: 600 !important;
|
106 |
+
margin-bottom: 0.5rem !important;
|
107 |
}
|
108 |
"""
|
109 |
|
110 |
with gr.Blocks(css=custom_css) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
with gr.Row():
|
112 |
with gr.Column():
|
113 |
+
gr.Markdown(
|
114 |
+
"""
|
115 |
+
# 🏥 MedAI: Clinical Symptom ICD9 Classifier
|
116 |
+
### Advanced AI-Powered Diagnostic Code Assistant
|
117 |
+
"""
|
118 |
+
)
|
119 |
+
|
120 |
+
with gr.Row():
|
121 |
+
with gr.Column(elem_classes=["input-container"]):
|
122 |
input_text = gr.Textbox(
|
123 |
+
label="Clinical Symptom Description",
|
124 |
+
placeholder="Enter detailed patient symptoms and clinical observations...",
|
125 |
+
lines=5,
|
126 |
+
elem_classes=["textbox"]
|
127 |
)
|
128 |
|
129 |
+
with gr.Row():
|
130 |
+
output = gr.JSON(
|
131 |
+
label="Suggested ICD9 Diagnostic Codes",
|
132 |
+
elem_classes=["output-container"]
|
133 |
+
)
|
134 |
+
|
135 |
+
with gr.Row():
|
136 |
+
with gr.Column(elem_classes=["examples-container"]):
|
137 |
examples = gr.Examples(
|
138 |
examples=[
|
139 |
["45-year-old male experiencing severe chest pain, radiating to left arm, with shortness of breath and excessive sweating"],
|
|
|
141 |
["Diabetic patient reporting frequent urination, increased thirst, and unexplained weight loss"],
|
142 |
["Elderly patient with chronic knee pain, reduced mobility, and signs of inflammation"]
|
143 |
],
|
144 |
+
inputs=input_text,
|
145 |
+
label="Example Clinical Cases",
|
146 |
+
elem_classes=["example-text"]
|
147 |
)
|
148 |
|
|
|
|
|
149 |
input_text.submit(fn=classify_symptoms, inputs=input_text, outputs=output)
|
150 |
|
151 |
+
with gr.Row():
|
152 |
+
gr.Markdown(
|
153 |
+
"""
|
154 |
+
<div class="footer">
|
155 |
+
⚕️ <strong>Medical Disclaimer:</strong> This AI tool is designed to assist medical professionals in ICD9 code classification.
|
156 |
+
Always verify suggestions with clinical judgment and consult appropriate medical resources.
|
157 |
+
</div>
|
158 |
+
""",
|
159 |
+
)
|
160 |
|
161 |
if __name__ == "__main__":
|
162 |
demo.launch()
|