File size: 4,970 Bytes
504c12a
 
 
0f6aea4
dac144a
504c12a
49bbde9
 
504c12a
 
 
 
7b6c7f6
 
 
 
 
 
f83ddbf
49bbde9
888c965
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6b40ba
 
 
 
 
888c965
 
 
 
 
 
dac144a
7b6c7f6
49bbde9
7b6c7f6
dac144a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6b40ba
 
 
 
 
 
dac144a
 
eb439f3
 
 
 
 
9ed6bea
5758cda
 
 
 
 
 
 
 
9ed6bea
504c12a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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):
    # Read the markdown file and convert it to HTML
    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)]

# data_types = sorted(df["data_type"].dropna().unique())
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>
        """)
        # Add your prompt submission code here
    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()