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("

πŸ† Medical Classification Leaderboard - Beta

") 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(""" """) # 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:dramitkumargarg1@gmail.com)""") gr.HTML("

To do

") gr.HTML(""" """) demo.launch()