dikheng commited on
Commit
333ecba
·
1 Parent(s): e47e975

chore: remove AMD Benchmark tab — unrelated to medical use case

Browse files
Files changed (1) hide show
  1. app.py +4 -121
app.py CHANGED
@@ -574,86 +574,6 @@ def predict(image, symptoms: str, lang_choice: str, selected_regions):
574
  # Benchmark
575
  # ---------------------------------------------------------------------------
576
 
577
- _BENCH_PROMPTS = [
578
- "Describe a mild skin rash.",
579
- "What is contact dermatitis?",
580
- "Signs of superficial wound infection?",
581
- "Describe eczema symptoms briefly.",
582
- "What causes tinea corporis?",
583
- ]
584
-
585
-
586
- def run_benchmark(n_runs: int):
587
- import time as _time
588
- from src.model_loader import generate_response as _gen
589
-
590
- n_runs = int(n_runs)
591
- rows = []
592
- latencies = []
593
- throughputs = []
594
-
595
- for i in range(n_runs):
596
- prompt = _BENCH_PROMPTS[i % len(_BENCH_PROMPTS)]
597
- try:
598
- _, metrics = _gen(prompt)
599
- lat = metrics.get("latency_ms", 0)
600
- tps = metrics.get("tokens_per_sec", 0)
601
- tok = metrics.get("total_tokens", 0)
602
- latencies.append(lat)
603
- throughputs.append(tps)
604
- status = "✓"
605
- rows.append((i + 1, lat, tps, tok, status))
606
- except Exception as exc:
607
- rows.append((i + 1, "—", "—", "—", f"✗ {str(exc)[:40]}"))
608
-
609
- # Build table
610
- header = (
611
- "<tr style='border-bottom:1px solid #374151;'>"
612
- "<th style='padding:6px 12px; text-align:left; color:#6b7280; font-weight:500;'>#</th>"
613
- "<th style='padding:6px 12px; text-align:right; color:#6b7280; font-weight:500;'>Latency (ms)</th>"
614
- "<th style='padding:6px 12px; text-align:right; color:#6b7280; font-weight:500;'>Throughput (tok/s)</th>"
615
- "<th style='padding:6px 12px; text-align:right; color:#6b7280; font-weight:500;'>Total tokens</th>"
616
- "<th style='padding:6px 12px; text-align:center; color:#6b7280; font-weight:500;'>Status</th>"
617
- "</tr>"
618
- )
619
- body = ""
620
- for run_i, lat, tps, tok, status in rows:
621
- body += (
622
- f"<tr style='border-bottom:1px solid #1f2937;'>"
623
- f"<td style='padding:5px 12px; color:#9ca3af;'>{run_i}</td>"
624
- f"<td style='padding:5px 12px; text-align:right; color:#d1d5db;'>{lat:,}" + (" ms" if isinstance(lat, int) else "") + "</td>"
625
- f"<td style='padding:5px 12px; text-align:right; color:#d1d5db;'>{tps}</td>"
626
- f"<td style='padding:5px 12px; text-align:right; color:#d1d5db;'>{tok}</td>"
627
- f"<td style='padding:5px 12px; text-align:center; color:#6b7280; font-size:0.85rem;'>{status}</td>"
628
- f"</tr>"
629
- )
630
-
631
- summary = ""
632
- if latencies:
633
- avg_lat = round(sum(latencies) / len(latencies))
634
- avg_tps = round(sum(throughputs) / len(throughputs), 1)
635
- min_lat = min(latencies)
636
- max_lat = max(latencies)
637
- summary = (
638
- f"<div style='display:flex; gap:24px; flex-wrap:wrap; margin-top:14px; "
639
- f"padding:10px 14px; background:#1f2937; border-radius:8px;'>"
640
- f"<span style='font-size:0.78rem; color:#6b7280;'>Avg latency: <b style='color:#9ca3af;'>{avg_lat} ms</b></span>"
641
- f"<span style='font-size:0.78rem; color:#6b7280;'>Min: <b style='color:#9ca3af;'>{min_lat} ms</b></span>"
642
- f"<span style='font-size:0.78rem; color:#6b7280;'>Max: <b style='color:#9ca3af;'>{max_lat} ms</b></span>"
643
- f"<span style='font-size:0.78rem; color:#6b7280;'>Avg throughput: <b style='color:#9ca3af;'>{avg_tps} tok/s</b></span>"
644
- f"<span style='font-size:0.78rem; color:#6b7280;'>Runs: <b style='color:#9ca3af;'>{len(latencies)}/{n_runs}</b></span>"
645
- f"</div>"
646
- )
647
-
648
- return (
649
- f"<div style='font-family:monospace;'>"
650
- f"<table style='width:100%; border-collapse:collapse; font-size:0.82rem;'>{header}{body}</table>"
651
- f"{summary}"
652
- f"<div style='font-size:0.68rem; color:#374151; margin-top:8px;'>AMD Instinct™ MI300X · ROCm · vLLM</div>"
653
- f"</div>"
654
- )
655
-
656
-
657
  # ---------------------------------------------------------------------------
658
  # CSS
659
  # ---------------------------------------------------------------------------
@@ -708,20 +628,6 @@ footer { display: none !important; }
708
  #lang-col { min-width: 180px !important; max-width: 200px !important; }
709
  #lang-col label span { text-transform: none !important; font-size: 0.78rem !important; }
710
 
711
- /* ── Tabs: muted style, benchmark tab clearly secondary ─────────── */
712
- #main-tabs > .tab-nav { border-bottom: 1px solid #1f2937 !important; }
713
- #main-tabs > .tab-nav button {
714
- font-size: 0.82rem !important;
715
- color: #6b7280 !important;
716
- background: transparent !important;
717
- border: none !important;
718
- padding: 8px 16px !important;
719
- }
720
- #main-tabs > .tab-nav button.selected {
721
- color: #f9fafb !important;
722
- border-bottom: 2px solid #ED1C24 !important;
723
- }
724
- #bench-tab { opacity: 0.9; }
725
  """
726
 
727
  # ---------------------------------------------------------------------------
@@ -783,14 +689,10 @@ with gr.Blocks(css=CSS, theme=gr.themes.Base(), title="MediVision — AMD MI300X
783
  show_label=False,
784
  )
785
 
786
- with gr.Tabs(elem_id="main-tabs"):
787
-
788
- with gr.TabItem("Analysis"):
789
-
790
- # ── Main content ──────────────────────────────────────────────────────────
791
- with gr.Row(equal_height=False):
792
 
793
- with gr.Column(scale=1, min_width=300):
794
  input_img = gr.Image(
795
  type="filepath",
796
  label="Upload Medical Image",
@@ -830,25 +732,12 @@ with gr.Blocks(css=CSS, theme=gr.themes.Base(), title="MediVision — AMD MI300X
830
  label="Quick Examples",
831
  )
832
 
833
- with gr.Column(scale=1, min_width=340):
834
  output_html = gr.HTML(
835
  value=_empty_output_html("en"),
836
  label="Analysis Result",
837
  )
838
 
839
- # ── Benchmark tab ─────────────────────────────────────────────────────
840
- with gr.TabItem("⚙ AMD Benchmark", elem_id="bench-tab"):
841
- gr.HTML("""
842
- <div style='color:#6b7280; font-size:0.8rem; padding:8px 0 12px;'>
843
- Runs a series of short inference requests against the AMD Cloud backend and
844
- measures latency and throughput. Results reflect live MI300X + ROCm performance.
845
- </div>""")
846
- with gr.Row():
847
- bench_runs = gr.Slider(minimum=3, maximum=10, value=5, step=1,
848
- label="Number of runs", scale=2)
849
- bench_btn = gr.Button("▶ Run Benchmark", variant="secondary", scale=1)
850
- bench_out = gr.HTML(value="<div style='color:#4b5563; font-size:0.8rem; padding:16px 0;'>Click Run Benchmark to start.</div>")
851
-
852
  # ── Events ───────────────────────────────────────────────────────────────
853
 
854
  region_selector.change(
@@ -876,12 +765,6 @@ with gr.Blocks(css=CSS, theme=gr.themes.Base(), title="MediVision — AMD MI300X
876
  outputs=[lang_radio, input_img, symptoms_txt, submit_btn, region_selector, body_map_html, output_html, status_bar],
877
  )
878
 
879
- bench_btn.click(
880
- fn=run_benchmark,
881
- inputs=[bench_runs],
882
- outputs=[bench_out],
883
- )
884
-
885
  gr.HTML(FOOTER_HTML)
886
 
887
 
 
574
  # Benchmark
575
  # ---------------------------------------------------------------------------
576
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
  # ---------------------------------------------------------------------------
578
  # CSS
579
  # ---------------------------------------------------------------------------
 
628
  #lang-col { min-width: 180px !important; max-width: 200px !important; }
629
  #lang-col label span { text-transform: none !important; font-size: 0.78rem !important; }
630
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
  """
632
 
633
  # ---------------------------------------------------------------------------
 
689
  show_label=False,
690
  )
691
 
692
+ # ── Main content ──────────────────────────────────────────────────────────
693
+ with gr.Row(equal_height=False):
 
 
 
 
694
 
695
+ with gr.Column(scale=1, min_width=300):
696
  input_img = gr.Image(
697
  type="filepath",
698
  label="Upload Medical Image",
 
732
  label="Quick Examples",
733
  )
734
 
735
+ with gr.Column(scale=1, min_width=340):
736
  output_html = gr.HTML(
737
  value=_empty_output_html("en"),
738
  label="Analysis Result",
739
  )
740
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741
  # ── Events ───────────────────────────────────────────────────────────────
742
 
743
  region_selector.change(
 
765
  outputs=[lang_radio, input_img, symptoms_txt, submit_btn, region_selector, body_map_html, output_html, status_bar],
766
  )
767
 
 
 
 
 
 
 
768
  gr.HTML(FOOTER_HTML)
769
 
770