|
import pandas as pd |
|
|
|
import gradio as gr |
|
from gradio_leaderboard import Leaderboard |
|
|
|
from utils import fetch_hf_results, show_output_box |
|
from about import ASSAY_LIST, ASSAY_RENAME, ASSAY_EMOJIS, ASSAY_DESCRIPTION, ABOUT_TEXT, FAQS |
|
from submit import make_submission |
|
|
|
def format_leaderboard_table(df_results: pd.DataFrame, assay: str | None = None): |
|
|
|
|
|
|
|
|
|
column_order = ["model", "property", "spearman", "spearman_cross_val"] |
|
df = df_results.query("assay.isin(@ASSAY_RENAME.keys())").copy() |
|
if assay is not None: |
|
df = df[df['assay'] == assay] |
|
df = df[column_order] |
|
return df.sort_values(by="spearman", ascending=False) |
|
|
|
def get_leaderboard_object(df_results: pd.DataFrame, assay: str | None = None): |
|
df = format_leaderboard_table(df_results=df_results, assay=assay) |
|
filter_columns = ["model"] |
|
if assay is None: |
|
filter_columns.append("property") |
|
|
|
Leaderboard( |
|
value=df, |
|
datatype=["str", "str", "str", "number"], |
|
select_columns=["model", "property", "spearman", "spearman_cross_val"], |
|
search_columns=["model"], |
|
filter_columns=filter_columns, |
|
every=60, |
|
render=True |
|
) |
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown(""" |
|
## Welcome to the Ginkgo Antibody Developability Benchmark! |
|
|
|
Participants can submit their model to the leaderboard by uploading a CSV file (see the "✉️ Submit" tab). |
|
See more details in the "❔About" tab. |
|
""") |
|
df = fetch_hf_results() |
|
with gr.Tabs(elem_classes="tab-buttons"): |
|
|
|
for assay in ASSAY_LIST: |
|
with gr.TabItem(f"{ASSAY_EMOJIS[assay]} {ASSAY_RENAME[assay]}", elem_id=f"abdev-benchmark-tab-table"): |
|
gr.Markdown(f"# {ASSAY_DESCRIPTION[assay]}") |
|
get_leaderboard_object(df_results=df, assay=assay) |
|
|
|
with gr.TabItem("🚀 Overall", elem_id="abdev-benchmark-tab-table"): |
|
gr.Markdown("# Antibody Developability Benchmark Leaderboard over all properties") |
|
get_leaderboard_object(df_results=df) |
|
|
|
|
|
with gr.TabItem("❔About", elem_id="abdev-benchmark-tab-table"): |
|
gr.Markdown( |
|
""" |
|
<style> |
|
.resized-image img { |
|
width: 80%; |
|
height: auto; |
|
display: block; |
|
margin-left: auto; |
|
margin-right: auto; |
|
} |
|
|
|
@media (max-width: 768px) { |
|
.resized-image img { |
|
width: 100%; |
|
} |
|
} |
|
</style> |
|
""", |
|
elem_id="style-inject" |
|
) |
|
gr.Image( |
|
value="./assets/competition_logo.jpg", |
|
show_label=False, |
|
elem_classes=["resized-image"], |
|
show_download_button=False, |
|
) |
|
gr.Markdown(ABOUT_TEXT) |
|
for question, answer in FAQS.items(): |
|
with gr.Accordion(question): |
|
gr.Markdown(answer) |
|
|
|
with gr.TabItem("✉️ Submit", elem_id="boundary-benchmark-tab-table"): |
|
gr.Markdown( |
|
""" |
|
# Antibody Developability Submission |
|
Upload a CSV to get a score! |
|
""" |
|
) |
|
filename = gr.State(value=None) |
|
eval_state = gr.State(value=None) |
|
user_state = gr.State(value=None) |
|
anonymous_state = gr.State(value=False) |
|
|
|
gr.LoginButton() |
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
username_input = gr.Textbox( |
|
label="Username", |
|
placeholder="Enter your Hugging Face username", |
|
info="This will be displayed on the leaderboard." |
|
) |
|
|
|
anonymous_checkbox = gr.Checkbox(label="Would you like to keep your submission anonymous?") |
|
with gr.Column(): |
|
boundary_file = gr.File(label="Submission CSV") |
|
|
|
username_input.change( |
|
fn=lambda x: x if x.strip() else None, |
|
inputs=username_input, |
|
outputs=user_state |
|
) |
|
|
|
submit_btn = gr.Button("Evaluate") |
|
message = gr.Textbox(label="Status", lines=1, visible=False) |
|
|
|
gr.Markdown("If you have issues with submission or using the leaderboard, please start a discussion in the Community tab of this Space.") |
|
|
|
submit_btn.click( |
|
make_submission, |
|
inputs=[boundary_file, user_state, anonymous_state], |
|
outputs=[message], |
|
).then( |
|
fn=show_output_box, |
|
inputs=[message], |
|
outputs=[message], |
|
) |
|
|
|
gr.Markdown( |
|
""" |
|
<div style="text-align: center; font-size: 14px; color: gray; margin-top: 2em;"> |
|
📬 For questions or feedback, contact <a href="mailto:[email protected]">[email protected]</a> or visit the Community tab at the top of this page. |
|
</div> |
|
""", |
|
elem_id="contact-footer" |
|
) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|