willwim commited on
Commit
664b8d6
Β·
verified Β·
1 Parent(s): 55a7eb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -72
app.py CHANGED
@@ -375,59 +375,66 @@ def adr_predict(x):
375
 
376
  # ── UI ─────────────────────────────────────────────────────────────────────────
377
  custom_css = """
378
- /* ── Global container ── */
379
- .gradio-container {
380
- font-family: 'Inter', system-ui, sans-serif;
 
 
381
  background: #f4f6f9 !important;
 
382
  }
383
 
384
- /* Force entire page background white */
385
- body, .gradio-container, .main {
386
- background: #f4f6f9 !important;
 
 
 
 
 
 
387
  }
388
 
389
- /* ── Section header labels ── */
390
- .section-label {
 
 
 
 
 
 
391
  font-size: 0.72em !important;
392
  font-weight: 700 !important;
393
  letter-spacing: 0.1em !important;
394
  text-transform: uppercase !important;
395
  color: #888 !important;
396
- margin-bottom: 6px !important;
397
- margin-top: 0 !important;
398
  padding: 0 !important;
399
- background: none !important;
400
- border: none !important;
401
  }
402
 
403
- /* ── Uniform white card applied to every output panel ── */
404
- .card {
405
- background: #ffffff !important;
406
- border: 1px solid #e2e6ea !important;
407
- border-radius: 12px !important;
408
- padding: 20px !important;
409
- box-shadow: 0 1px 4px rgba(0,0,0,0.07) !important;
410
- color: #111 !important;
411
- }
412
-
413
- /* Gradio Label widget β€” force white card look */
414
- .card .label-container,
415
  .card [data-testid="label"],
416
- .label-wrap {
417
- background: #ffffff !important;
 
 
418
  border: none !important;
419
  box-shadow: none !important;
420
- color: #111 !important;
421
  padding: 0 !important;
 
422
  }
423
 
424
- /* Gradio Label bars text */
425
- .label-wrap span, .label-wrap p, .label-wrap div {
 
 
426
  color: #111 !important;
427
  }
428
 
429
- /* Textbox card */
430
- .card textarea, .card input {
 
431
  background: #fafafa !important;
432
  color: #111 !important;
433
  border: 1px solid #dde1e7 !important;
@@ -435,49 +442,41 @@ body, .gradio-container, .main {
435
  }
436
 
437
  /* Examples table */
438
- .card .examples table {
 
 
439
  background: #ffffff !important;
440
  color: #111 !important;
 
441
  }
442
 
443
- /* Button */
444
  .run-btn {
445
  width: 100% !important;
446
  margin-top: 10px !important;
447
  }
448
 
449
- /* Markdown section headers */
450
- .section-header p {
451
- font-size: 0.72em !important;
452
- font-weight: 700 !important;
453
- letter-spacing: 0.1em !important;
454
- text-transform: uppercase !important;
455
- color: #888 !important;
456
- margin: 0 0 8px 0 !important;
457
- }
458
-
459
  footer { visibility: hidden; }
460
  """
461
 
462
- with gr.Blocks(title="ADR Detector", css=custom_css, theme=gr.themes.Base()) as demo:
463
 
464
  # ── Header ────────────────────────────────────────────────────────────────
465
- with gr.Column(elem_classes="card", style="margin-bottom:18px; text-align:center;"):
466
  gr.Markdown(
467
- "<h1 style='margin:0 0 6px 0; color:#1a1a2e; font-size:1.8em;'>"
468
  "Adverse Drug Reaction (ADR) Detector</h1>"
469
- "<p style='margin:0; color:#555; font-size:0.97em;'>"
470
  "Analyze clinical text for potential medication-related severity "
471
  "and key medical entities.</p>"
472
  )
473
 
474
  # ── Row 1: Input (left) | Classification + Severity (right) ──────────────
475
- with gr.Row(equal_height=False):
476
  with gr.Column(scale=1):
477
  with gr.Column(elem_classes="card"):
478
  gr.Markdown(
479
- "<p style='font-size:0.72em; font-weight:700; letter-spacing:0.1em; "
480
- "text-transform:uppercase; color:#888; margin:0 0 10px 0;'>Clinical Input</p>"
481
  )
482
  prob1 = gr.Textbox(
483
  label="Clinical Observations",
@@ -488,10 +487,7 @@ with gr.Blocks(title="ADR Detector", css=custom_css, theme=gr.themes.Base()) as
488
  submit_btn = gr.Button("Run Analysis", variant="primary", elem_classes="run-btn")
489
 
490
  with gr.Column(elem_classes="card"):
491
- gr.Markdown(
492
- "<p style='font-size:0.72em; font-weight:700; letter-spacing:0.1em; "
493
- "text-transform:uppercase; color:#888; margin:0 0 10px 0;'>Examples</p>"
494
- )
495
  gr.Examples(
496
  examples=[
497
  ["A 42 year-old male developed a severe migraine and elevated blood pressure "
@@ -508,35 +504,23 @@ with gr.Blocks(title="ADR Detector", css=custom_css, theme=gr.themes.Base()) as
508
 
509
  with gr.Column(scale=1):
510
  with gr.Column(elem_classes="card"):
511
- gr.Markdown(
512
- "<p style='font-size:0.72em; font-weight:700; letter-spacing:0.1em; "
513
- "text-transform:uppercase; color:#888; margin:0 0 10px 0;'>Classification</p>"
514
- )
515
  label = gr.Label(label="Severity Probability")
516
 
517
  with gr.Column(elem_classes="card"):
518
- gr.Markdown(
519
- "<p style='font-size:0.72em; font-weight:700; letter-spacing:0.1em; "
520
- "text-transform:uppercase; color:#888; margin:0 0 10px 0;'>Severity Rating</p>"
521
- )
522
  severity_out = gr.HTML(label="Severity Rating")
523
 
524
  # ── Row 2: Medical Entities (left) | SHAP (right) ────────────────────────
525
- with gr.Row(equal_height=False):
526
  with gr.Column(scale=1):
527
  with gr.Column(elem_classes="card"):
528
- gr.Markdown(
529
- "<p style='font-size:0.72em; font-weight:700; letter-spacing:0.1em; "
530
- "text-transform:uppercase; color:#888; margin:0 0 10px 0;'>Medical Entities</p>"
531
- )
532
  htext_out = gr.HTML(label="NER Mapping")
533
 
534
  with gr.Column(scale=1):
535
  with gr.Column(elem_classes="card"):
536
- gr.Markdown(
537
- "<p style='font-size:0.72em; font-weight:700; letter-spacing:0.1em; "
538
- "text-transform:uppercase; color:#888; margin:0 0 10px 0;'>Model Logic (SHAP)</p>"
539
- )
540
  shap_out = gr.HTML(label="Feature Importance")
541
 
542
  # ── Footer ────────────────────────────────────────────────────────────────
@@ -551,4 +535,4 @@ with gr.Blocks(title="ADR Detector", css=custom_css, theme=gr.themes.Base()) as
551
  outputs=[label, severity_out, shap_out, htext_out],
552
  )
553
 
554
- demo.launch()
 
375
 
376
  # ── UI ─────────────────────────────────────────────────────────────────────────
377
  custom_css = """
378
+ /* ── Global background ── */
379
+ body,
380
+ .gradio-container,
381
+ .main,
382
+ .contain {
383
  background: #f4f6f9 !important;
384
+ font-family: 'Inter', system-ui, sans-serif !important;
385
  }
386
 
387
+ /* ── Uniform white card ── */
388
+ .card {
389
+ background: #ffffff !important;
390
+ border: 1px solid #e2e6ea !important;
391
+ border-radius: 12px !important;
392
+ padding: 20px !important;
393
+ box-shadow: 0 1px 4px rgba(0,0,0,0.07) !important;
394
+ color: #111 !important;
395
+ margin-bottom: 12px !important;
396
  }
397
 
398
+ /* Header card centred */
399
+ .header-card {
400
+ text-align: center !important;
401
+ margin-bottom: 18px !important;
402
+ }
403
+
404
+ /* ── Card section label ── */
405
+ .card-label {
406
  font-size: 0.72em !important;
407
  font-weight: 700 !important;
408
  letter-spacing: 0.1em !important;
409
  text-transform: uppercase !important;
410
  color: #888 !important;
411
+ margin: 0 0 10px 0 !important;
 
412
  padding: 0 !important;
 
 
413
  }
414
 
415
+ /* Strip inner Gradio borders inside cards */
416
+ .card > .form,
 
 
 
 
 
 
 
 
 
 
417
  .card [data-testid="label"],
418
+ .card .label-container,
419
+ .card .label-wrap,
420
+ .card .prose {
421
+ background: transparent !important;
422
  border: none !important;
423
  box-shadow: none !important;
 
424
  padding: 0 !important;
425
+ color: #111 !important;
426
  }
427
 
428
+ /* Label bar text */
429
+ .card .label-wrap span,
430
+ .card .label-wrap p,
431
+ .card .label-wrap div {
432
  color: #111 !important;
433
  }
434
 
435
+ /* Textbox */
436
+ .card textarea,
437
+ .card input[type="text"] {
438
  background: #fafafa !important;
439
  color: #111 !important;
440
  border: 1px solid #dde1e7 !important;
 
442
  }
443
 
444
  /* Examples table */
445
+ .card .examples table,
446
+ .card .examples td,
447
+ .card .examples th {
448
  background: #ffffff !important;
449
  color: #111 !important;
450
+ border-color: #e2e6ea !important;
451
  }
452
 
453
+ /* Run button full width */
454
  .run-btn {
455
  width: 100% !important;
456
  margin-top: 10px !important;
457
  }
458
 
 
 
 
 
 
 
 
 
 
 
459
  footer { visibility: hidden; }
460
  """
461
 
462
+ with gr.Blocks(title="ADR Detector") as demo:
463
 
464
  # ── Header ────────────────────────────────────────────────────────────────
465
+ with gr.Column(elem_classes="card header-card"):
466
  gr.Markdown(
467
+ "<h1 style='margin:0 0 6px 0; color:#1a1a2e; font-size:1.8em; text-align:center;'>"
468
  "Adverse Drug Reaction (ADR) Detector</h1>"
469
+ "<p style='margin:0; color:#555; font-size:0.97em; text-align:center;'>"
470
  "Analyze clinical text for potential medication-related severity "
471
  "and key medical entities.</p>"
472
  )
473
 
474
  # ── Row 1: Input (left) | Classification + Severity (right) ──────────────
475
+ with gr.Row():
476
  with gr.Column(scale=1):
477
  with gr.Column(elem_classes="card"):
478
  gr.Markdown(
479
+ "<p class='card-label'>Clinical Input</p>"
 
480
  )
481
  prob1 = gr.Textbox(
482
  label="Clinical Observations",
 
487
  submit_btn = gr.Button("Run Analysis", variant="primary", elem_classes="run-btn")
488
 
489
  with gr.Column(elem_classes="card"):
490
+ gr.Markdown("<p class='card-label'>Examples</p>")
 
 
 
491
  gr.Examples(
492
  examples=[
493
  ["A 42 year-old male developed a severe migraine and elevated blood pressure "
 
504
 
505
  with gr.Column(scale=1):
506
  with gr.Column(elem_classes="card"):
507
+ gr.Markdown("<p class='card-label'>Classification</p>")
 
 
 
508
  label = gr.Label(label="Severity Probability")
509
 
510
  with gr.Column(elem_classes="card"):
511
+ gr.Markdown("<p class='card-label'>Severity Rating</p>")
 
 
 
512
  severity_out = gr.HTML(label="Severity Rating")
513
 
514
  # ── Row 2: Medical Entities (left) | SHAP (right) ────────────────────────
515
+ with gr.Row():
516
  with gr.Column(scale=1):
517
  with gr.Column(elem_classes="card"):
518
+ gr.Markdown("<p class='card-label'>Medical Entities</p>")
 
 
 
519
  htext_out = gr.HTML(label="NER Mapping")
520
 
521
  with gr.Column(scale=1):
522
  with gr.Column(elem_classes="card"):
523
+ gr.Markdown("<p class='card-label'>Model Logic (SHAP)</p>")
 
 
 
524
  shap_out = gr.HTML(label="Feature Importance")
525
 
526
  # ── Footer ────────────────────────────────────────────────────────────────
 
535
  outputs=[label, severity_out, shap_out, htext_out],
536
  )
537
 
538
+ demo.launch(theme=gr.themes.Base(), css=custom_css)