ashishkgpian commited on
Commit
4bd7a10
·
verified ·
1 Parent(s): 95c4177

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -30
app.py CHANGED
@@ -12,20 +12,22 @@ classifier = pipeline(
12
  # Load ICD9 codes data
13
  icd9_data = pd.read_csv('D_ICD_DIAGNOSES.csv')
14
 
 
15
 
16
- icd9_data.columns = ['ROW_ID', 'short_codes', 'SHORT_TITLE', 'LONG_TITLE']
17
  def preprocessing(test_df) :
18
  test_df.loc[
19
- test_df['short_codes'].str.startswith("V"), 'short_codes'] = test_df.short_codes.apply(
20
  lambda x: x[:4])
21
  test_df.loc[
22
- test_df['short_codes'].str.startswith("E"), 'short_codes'] = test_df.short_codes.apply(
23
  lambda x: x[:4])
24
- test_df.loc[(~test_df.short_codes.str.startswith("E")) & (
25
- ~test_df.short_codes.str.startswith("V")), 'short_codes'] = test_df.short_codes.apply(
26
  lambda x: x[:3])
27
  return test_df
28
 
 
 
29
  icd9_data = preprocessing(icd9_data)
30
 
31
  def classify_symptoms(text):
@@ -46,21 +48,44 @@ def classify_symptoms(text):
46
  except Exception as e:
47
  return f"Error processing classification: {str(e)}"
48
 
49
- # Enhanced CSS with violet theme and better text contrast
50
  custom_css = """
 
 
 
 
 
 
51
  .gradio-container {
52
- max-width: 1200px !important;
53
- margin: auto !important;
54
- padding: 2rem !important;
 
 
 
 
55
  background-color: #f5f3f7 !important;
56
  }
57
  .main-container {
58
  text-align: center;
59
  padding: 1rem;
60
- margin-bottom: 2rem;
61
  background: #ffffff;
62
- border-radius: 10px;
63
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
  h1 {
66
  color: #4a148c !important;
@@ -75,18 +100,18 @@ h3 {
75
  .input-container {
76
  background: white !important;
77
  padding: 2rem !important;
78
- border-radius: 10px !important;
79
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
80
- margin-bottom: 1.5rem !important;
81
  }
82
  textarea {
 
83
  background: white !important;
84
  color: #000000 !important;
85
  border: 2px solid #7b1fa2 !important;
86
  border-radius: 8px !important;
87
  padding: 1rem !important;
88
  font-size: 1.1rem !important;
89
- min-height: 120px !important;
 
90
  }
91
  .submit-btn {
92
  background-color: #6a1b9a !important;
@@ -103,32 +128,26 @@ textarea {
103
  .output-container {
104
  background: white !important;
105
  padding: 2rem !important;
106
- border-radius: 10px !important;
107
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
108
  }
109
  .output-container pre {
110
  background: #f8f9fa !important;
111
  color: #000000 !important;
112
  border-radius: 8px !important;
113
  padding: 1rem !important;
 
 
114
  }
115
  .examples-container {
116
  background: white !important;
117
  padding: 1.5rem !important;
118
- border-radius: 10px !important;
119
  margin-top: 1rem !important;
120
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
121
- }
122
- .example-text {
123
- color: #000000 !important;
124
  }
125
  .footer {
126
  text-align: center;
127
- margin-top: 2rem;
128
  padding: 1rem;
129
  background: white;
130
- border-radius: 10px;
131
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
132
  color: #4a148c;
133
  }
134
  """
@@ -138,12 +157,11 @@ with gr.Blocks(css=custom_css) as demo:
138
  gr.Markdown(
139
  """
140
  # 🏥 Clinical Symptom ICD9 Classifier
141
-
142
  """
143
  )
144
 
145
- with gr.Row():
146
- with gr.Column(elem_classes=["input-container"]):
147
  input_text = gr.Textbox(
148
  label="Clinical Symptom Description",
149
  placeholder="Enter detailed patient symptoms and clinical observations...",
@@ -151,7 +169,7 @@ with gr.Blocks(css=custom_css) as demo:
151
  )
152
  submit_btn = gr.Button("Analyze Symptoms", elem_classes=["submit-btn"])
153
 
154
- with gr.Row(elem_classes=["output-container"]):
155
  output = gr.JSON(
156
  label="Suggested ICD9 Diagnostic Codes with Descriptions"
157
  )
 
12
  # Load ICD9 codes data
13
  icd9_data = pd.read_csv('D_ICD_DIAGNOSES.csv')
14
 
15
+ icd9_data.columns = ['ROW_ID', 'ICD9_CODE', 'SHORT_TITLE', 'LONG_TITLE']
16
 
 
17
  def preprocessing(test_df) :
18
  test_df.loc[
19
+ test_df['ICD9_CODE'].str.startswith("V"), 'ICD9_CODE'] = test_df.ICD9_CODE.apply(
20
  lambda x: x[:4])
21
  test_df.loc[
22
+ test_df['ICD9_CODE'].str.startswith("E"), 'ICD9_CODE'] = test_df.ICD9_CODE.apply(
23
  lambda x: x[:4])
24
+ test_df.loc[(~test_df.ICD9_CODE.str.startswith("E")) & (
25
+ ~test_df.ICD9_CODE.str.startswith("V")), 'ICD9_CODE'] = test_df.ICD9_CODE.apply(
26
  lambda x: x[:3])
27
  return test_df
28
 
29
+
30
+
31
  icd9_data = preprocessing(icd9_data)
32
 
33
  def classify_symptoms(text):
 
48
  except Exception as e:
49
  return f"Error processing classification: {str(e)}"
50
 
51
+ # Enhanced CSS with full-screen layout and violet theme
52
  custom_css = """
53
+ html, body {
54
+ margin: 0 !important;
55
+ padding: 0 !important;
56
+ height: 100% !important;
57
+ overflow: hidden !important;
58
+ }
59
  .gradio-container {
60
+ width: 100vw !important;
61
+ height: 100vh !important;
62
+ max-width: none !important;
63
+ margin: 0 !important;
64
+ padding: 0 !important;
65
+ display: flex !important;
66
+ flex-direction: column !important;
67
  background-color: #f5f3f7 !important;
68
  }
69
  .main-container {
70
  text-align: center;
71
  padding: 1rem;
 
72
  background: #ffffff;
73
+ }
74
+ #component-1 {
75
+ height: 100% !important;
76
+ display: flex !important;
77
+ flex-direction: column !important;
78
+ }
79
+ .block {
80
+ flex-grow: 1 !important;
81
+ display: flex !important;
82
+ flex-direction: column !important;
83
+ }
84
+ .input-container, .output-container {
85
+ flex-grow: 1 !important;
86
+ display: flex !important;
87
+ flex-direction: column !important;
88
+ justify-content: center !important;
89
  }
90
  h1 {
91
  color: #4a148c !important;
 
100
  .input-container {
101
  background: white !important;
102
  padding: 2rem !important;
103
+ margin: 0 !important;
 
 
104
  }
105
  textarea {
106
+ width: 100% !important;
107
  background: white !important;
108
  color: #000000 !important;
109
  border: 2px solid #7b1fa2 !important;
110
  border-radius: 8px !important;
111
  padding: 1rem !important;
112
  font-size: 1.1rem !important;
113
+ min-height: 200px !important;
114
+ flex-grow: 1 !important;
115
  }
116
  .submit-btn {
117
  background-color: #6a1b9a !important;
 
128
  .output-container {
129
  background: white !important;
130
  padding: 2rem !important;
131
+ flex-grow: 1 !important;
132
+ overflow-y: auto !important;
133
  }
134
  .output-container pre {
135
  background: #f8f9fa !important;
136
  color: #000000 !important;
137
  border-radius: 8px !important;
138
  padding: 1rem !important;
139
+ max-height: 100% !important;
140
+ overflow-y: auto !important;
141
  }
142
  .examples-container {
143
  background: white !important;
144
  padding: 1.5rem !important;
 
145
  margin-top: 1rem !important;
 
 
 
 
146
  }
147
  .footer {
148
  text-align: center;
 
149
  padding: 1rem;
150
  background: white;
 
 
151
  color: #4a148c;
152
  }
153
  """
 
157
  gr.Markdown(
158
  """
159
  # 🏥 Clinical Symptom ICD9 Classifier
 
160
  """
161
  )
162
 
163
+ with gr.Row(style="flex-grow: 1;"):
164
+ with gr.Column(elem_classes=["input-container"], scale=1):
165
  input_text = gr.Textbox(
166
  label="Clinical Symptom Description",
167
  placeholder="Enter detailed patient symptoms and clinical observations...",
 
169
  )
170
  submit_btn = gr.Button("Analyze Symptoms", elem_classes=["submit-btn"])
171
 
172
+ with gr.Row(elem_classes=["output-container"], style="flex-grow: 1;"):
173
  output = gr.JSON(
174
  label="Suggested ICD9 Diagnostic Codes with Descriptions"
175
  )