|
import gradio as gr |
|
import pandas as pd |
|
import os |
|
import markdown |
|
from about.custom_css import custom_css |
|
LEADERBOARD_DIR = "leaderboard_files" |
|
LEADERBOARD_FILE = os.path.join(LEADERBOARD_DIR, "leaderboard_data.csv") |
|
DESCRIPTION_FILE = "about/description.md" |
|
|
|
def load_leaderboard(): |
|
return pd.read_csv(LEADERBOARD_FILE) |
|
|
|
def load_description(DESCRIPTION_FILE): |
|
|
|
with open(DESCRIPTION_FILE, "r") as f: |
|
md_text = f.read() |
|
html_description = markdown.markdown(md_text, extensions=["tables"]) |
|
return html_description |
|
columns_fixed = ["Model Name", "Parameters", "Average Label", "Average Record"] |
|
|
|
df = load_leaderboard() |
|
all_columns = list(df.columns) |
|
columns_variable = [i for i in all_columns if i not in columns_fixed] |
|
|
|
shot_options = ["0 shot", "1 shot", "5 shots"] |
|
|
|
|
|
def get_columns_for_shots(selected_shots): |
|
if not selected_shots: |
|
return [] |
|
return [col for col in all_columns if any(shot in col for shot in selected_shots)] |
|
|
|
def get_columns_for_data(selected_data): |
|
if not selected_data: |
|
return [] |
|
return [col for col in all_columns if any(data in col for data in selected_data)] |
|
|
|
|
|
parameter_options = sorted(df["Parameters"].dropna().unique()) |
|
|
|
def filter_leaderboard(selected_params, selected_shots, selected_data): |
|
filtered = df.copy() |
|
print("Selected Shots:", selected_shots) |
|
if selected_params: |
|
filtered = filtered[filtered["Parameters"].isin(selected_params)] |
|
|
|
columns_by_shot = get_columns_for_shots(selected_shots) |
|
columns_by_data = get_columns_for_data(selected_data) |
|
additional_columns = [] |
|
for col in all_columns: |
|
if any(shot in col for shot in selected_shots) and any(data in col for data in selected_data): |
|
additional_columns.append(col) |
|
print("additional_columns:", additional_columns) |
|
cols_to_show = list(dict.fromkeys(columns_fixed + additional_columns)) |
|
|
|
print("COLUMNS TO SHOW:", cols_to_show) |
|
|
|
return filtered[cols_to_show] |
|
|
|
with gr.Blocks(css = custom_css) as demo: |
|
gr.HTML("<h1 style='text-align: center;'>π Medical Classification Leaderboard - Beta</h1>") |
|
gr.Image("./about/linguist.png", elem_id="linguist-image", show_label=False) |
|
gr.HTML(load_description(DESCRIPTION_FILE)) |
|
with gr.Tab("π
LLM Benchmark", elem_classes="custom-tab-buttons") as tabs: |
|
with gr.Row(): |
|
with gr.Column(): |
|
column_selector_data = gr.CheckboxGroup(label="π Select Columns to Display - Dataset", choices=["Chexpert Plus", "CT Rate"], value=["Chexpert Plus", "CT Rate"]) |
|
|
|
with gr.Column(): |
|
shot_filter = gr.CheckboxGroup(label="Select Shot Type", choices=shot_options, value=shot_options) |
|
param_filter = gr.CheckboxGroup(choices=parameter_options, label="Filter by Parameter Count", value=parameter_options) |
|
|
|
initial_data = filter_leaderboard(parameter_options, shot_options, ["Chexpert Plus", "CT Rate"]) |
|
leaderboard_table = gr.Dataframe(value=initial_data, label="π
Leaderboard", interactive=False, elem_id="leaderboard-table") |
|
column_selector_data.change(filter_leaderboard, inputs=[param_filter, shot_filter, column_selector_data], outputs=leaderboard_table) |
|
param_filter.change(fn=filter_leaderboard, inputs=[param_filter, shot_filter, column_selector_data], outputs=leaderboard_table) |
|
shot_filter.change(fn=filter_leaderboard, inputs=[param_filter, shot_filter, column_selector_data], outputs=leaderboard_table) |
|
|
|
with gr.Tab("π Submit Prompt or model here! ", elem_classes="custom-tab-buttons"): |
|
gr.Markdown("### Submit Your Model or Prompt") |
|
gr.HTML(""" |
|
<iframe src="https://docs.google.com/forms/d/e/1FAIpQLSeiAyvWT9uw7__vRII1LGiyBojcFNCMmREdVGlCC8mu_ENWKQ/viewform?usp=dialog?embedded=true" |
|
width="100%" height="1000" frameborder="0" marginheight="0" marginwidth="0"> |
|
Loading⦠|
|
</iframe> |
|
""") |
|
|
|
with gr.Tab("π€π€ Collaborate ", elem_classes="custom-tab-buttons"): |
|
gr.Markdown(""" |
|
### Collaborate with Us |
|
1. If you are interested in collaborating with us, to explore more on the datasets, prompts or models, feel free to reach out to me on the mail address [E-mail](mailto:[email protected])""") |
|
|
|
gr.HTML("<h3> To do</h3>") |
|
gr.HTML(""" |
|
<ul> |
|
<li><input type="checkbox" checked disabled> Launching the leaderboard</li> |
|
<li><input type="checkbox" disabled> Add link to the huggingface models</li> |
|
<li><input type="checkbox" disabled> Enhance the table layouts</li> |
|
<li><input type="checkbox" disabled> Add more datasets</li> |
|
<li><input type="checkbox" disabled> Add more prompting techniques</li> |
|
</ul> |
|
""") |
|
demo.launch() |
|
|