DreamStream-1 commited on
Commit
500e0dd
·
verified ·
1 Parent(s): 94be72b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -9
app.py CHANGED
@@ -251,11 +251,15 @@ def predict_disease(symptoms):
251
 
252
  return "\n".join(markdown_output)
253
 
254
- # Custom CSS for Styling
 
 
255
  custom_css = """
256
  body {
257
  font-family: 'Arial', sans-serif;
258
  background-color: #f0f4f7; /* Light background for better contrast */
 
 
259
  }
260
 
261
  h1 {
@@ -282,6 +286,9 @@ textarea, input {
282
  color: white;
283
  border-radius: 8px;
284
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2); /* Shadow on button */
 
 
 
285
  }
286
 
287
  .gr-button:hover {
@@ -292,6 +299,10 @@ textarea, input {
292
  background-color: #7f156b; /* Even darker shade on active */
293
  }
294
 
 
 
 
 
295
  .df-container {
296
  background: white;
297
  color: black;
@@ -304,6 +315,33 @@ textarea, input {
304
  overflow-y: auto;
305
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Light shadow for data frame */
306
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  """
308
 
309
  # Gradio Application Interface
@@ -312,13 +350,14 @@ with gr.Blocks(css=custom_css) as app:
312
 
313
  with gr.Tab("Well-Being Chatbot"):
314
  with gr.Row():
315
- user_input = gr.Textbox(label="Please Enter Your Message Here")
316
- location = gr.Textbox(label="Please Enter Your Current Location Here")
317
- query = gr.Textbox(label="Please Enter Which Health Professional You Want To Search Nearby")
318
 
319
- submit_chatbot = gr.Button(value="Submit Your Message", variant="primary")
320
-
321
- chatbot = gr.Chatbot(label="Chat History")
 
322
  sentiment = gr.Textbox(label="Detected Sentiment")
323
  emotion = gr.Textbox(label="Detected Emotion")
324
 
@@ -330,8 +369,9 @@ with gr.Blocks(css=custom_css) as app:
330
  app_function_chatbot,
331
  inputs=[user_input, location, query, chatbot],
332
  outputs=[chatbot, sentiment, emotion, suggestions_markdown, professionals, map_html],
 
333
  )
334
-
335
  with gr.Tab("Disease Prediction"):
336
  symptom1 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 1")
337
  symptom2 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 2")
@@ -339,7 +379,9 @@ with gr.Blocks(css=custom_css) as app:
339
  symptom4 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 4")
340
  symptom5 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 5")
341
 
342
- submit_disease = gr.Button(value="Predict Disease", variant="primary")
 
 
343
  disease_prediction_result = gr.Markdown(label="Predicted Diseases") # Use Markdown for predictions
344
 
345
  submit_disease.click(
@@ -347,6 +389,7 @@ with gr.Blocks(css=custom_css) as app:
347
  [symptom1, symptom2, symptom3, symptom4, symptom5]),
348
  inputs=[symptom1, symptom2, symptom3, symptom4, symptom5],
349
  outputs=disease_prediction_result,
 
350
  )
351
 
352
  # Launch the Gradio application
 
251
 
252
  return "\n".join(markdown_output)
253
 
254
+ from gradio.components import HTML
255
+
256
+ # Custom CSS for styling
257
  custom_css = """
258
  body {
259
  font-family: 'Arial', sans-serif;
260
  background-color: #f0f4f7; /* Light background for better contrast */
261
+ margin: 0;
262
+ padding: 0;
263
  }
264
 
265
  h1 {
 
286
  color: white;
287
  border-radius: 8px;
288
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2); /* Shadow on button */
289
+ display: flex;
290
+ align-items: center;
291
+ justify-content: center;
292
  }
293
 
294
  .gr-button:hover {
 
299
  background-color: #7f156b; /* Even darker shade on active */
300
  }
301
 
302
+ .gr-button .fa {
303
+ margin-right: 10px;
304
+ }
305
+
306
  .df-container {
307
  background: white;
308
  color: black;
 
315
  overflow-y: auto;
316
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Light shadow for data frame */
317
  }
318
+
319
+ @media (max-width: 768px) {
320
+ h1 {
321
+ font-size: 1.5rem;
322
+ padding: 10px;
323
+ }
324
+
325
+ .gr-button {
326
+ font-size: 0.9rem;
327
+ padding: 10px;
328
+ }
329
+
330
+ .gr-row {
331
+ flex-direction: column;
332
+ align-items: center;
333
+ }
334
+
335
+ textarea, input {
336
+ width: 100%;
337
+ margin-bottom: 10px;
338
+ }
339
+
340
+ .gr-chatbot {
341
+ max-height: 300px;
342
+ overflow-y: auto;
343
+ }
344
+ }
345
  """
346
 
347
  # Gradio Application Interface
 
350
 
351
  with gr.Tab("Well-Being Chatbot"):
352
  with gr.Row():
353
+ user_input = gr.Textbox(label="Please Enter Your Message Here", placeholder="Type your message here...", max_lines=3)
354
+ location = gr.Textbox(label="Please Enter Your Current Location Here", placeholder="E.g., New York", max_lines=1)
355
+ query = gr.Textbox(label="Please Enter Which Health Professional You Want To Search Nearby", placeholder="E.g., therapist", max_lines=1)
356
 
357
+ submit_chatbot = gr.Button(value="Submit Your Message", variant="primary", elem_id="submit-chatbot", icon="fa-paper-plane")
358
+
359
+ # Adding the loading prop for the chatbot button
360
+ chatbot = gr.Chatbot(label="Chat History", elem_id="chat-history", show_label=True)
361
  sentiment = gr.Textbox(label="Detected Sentiment")
362
  emotion = gr.Textbox(label="Detected Emotion")
363
 
 
369
  app_function_chatbot,
370
  inputs=[user_input, location, query, chatbot],
371
  outputs=[chatbot, sentiment, emotion, suggestions_markdown, professionals, map_html],
372
+ loading=True # Enable loading spinner on button click
373
  )
374
+
375
  with gr.Tab("Disease Prediction"):
376
  symptom1 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 1")
377
  symptom2 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 2")
 
379
  symptom4 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 4")
380
  symptom5 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 5")
381
 
382
+ submit_disease = gr.Button(value="Predict Disease", variant="primary", icon="fa-stethoscope")
383
+
384
+ # Adding the loading prop for the disease prediction button
385
  disease_prediction_result = gr.Markdown(label="Predicted Diseases") # Use Markdown for predictions
386
 
387
  submit_disease.click(
 
389
  [symptom1, symptom2, symptom3, symptom4, symptom5]),
390
  inputs=[symptom1, symptom2, symptom3, symptom4, symptom5],
391
  outputs=disease_prediction_result,
392
+ loading=True # Enable loading spinner on button click
393
  )
394
 
395
  # Launch the Gradio application