Maria Castellanos
commited on
Commit
·
6fc2c2d
1
Parent(s):
960994d
add latest submission
Browse files- app.py +37 -29
- evaluate.py +5 -2
app.py
CHANGED
|
@@ -7,18 +7,30 @@ from evaluate import submit_data, evaluate_data
|
|
| 7 |
|
| 8 |
from datasets import load_dataset
|
| 9 |
from datetime import datetime
|
| 10 |
-
from about import ENDPOINTS
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def get_leaderboard(endpoint):
|
| 14 |
dset = load_dataset(results_repo, split='train', download_mode="force_redownload")
|
| 15 |
full_df = dset.to_pandas()
|
| 16 |
to_show = full_df.copy(deep=True)
|
| 17 |
to_show = to_show[to_show['endpoint'] == endpoint]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# The columns to display publicly
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
return to_show
|
| 22 |
|
| 23 |
def gradio_interface():
|
| 24 |
with gr.Blocks(title="OpenADMET ADMET Challenge") as demo:
|
|
@@ -91,38 +103,23 @@ def gradio_interface():
|
|
| 91 |
|
| 92 |
# --- Gradio Interface ---
|
| 93 |
with gr.Tabs(elem_classes="tab-buttons"):
|
|
|
|
| 94 |
|
| 95 |
with gr.TabItem("📝About"):
|
| 96 |
gr.Markdown(welcome_md)
|
| 97 |
|
| 98 |
with gr.TabItem("🚀Leaderboard"):
|
| 99 |
gr.Markdown("View the leaderboard for each ADMET endpoint by selecting the appropiate tab.")
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
"MAE": [0.1, 0.2, 0.15],
|
| 103 |
-
"R2": [0.94, 0.92, 0.89],
|
| 104 |
-
"Spearman R": [0.93, 0.91, 0.88],
|
| 105 |
-
"Kendall's Tau": [0.90, 0.89, 0.85],
|
| 106 |
-
})
|
| 107 |
-
df2 = pd.DataFrame({
|
| 108 |
-
"user": ["User1", "User2", "User3"],
|
| 109 |
-
"MAE": [0.2, 0.3, 0.15],
|
| 110 |
-
"R2": [0.2, 0.72, 0.89],
|
| 111 |
-
"Spearman R": [0.91, 0.71, 0.68],
|
| 112 |
-
"Kendall's Tau": [0.90, 0.4, 0.7],
|
| 113 |
-
})
|
| 114 |
-
# Make separate leaderboards in separate tabs
|
| 115 |
-
mock_data = [df1, df1, df2, df1, df2, df1, df1, df2, df1, df2]
|
| 116 |
-
for i, endpoint in enumerate(ENDPOINTS):
|
| 117 |
-
df = mock_data[i]
|
| 118 |
with gr.TabItem(endpoint):
|
| 119 |
-
Leaderboard(
|
| 120 |
value=get_leaderboard(endpoint),
|
| 121 |
-
datatype=['
|
| 122 |
-
select_columns=["user", "MAE", "R2", "Spearman R", "Kendall's Tau"],
|
| 123 |
search_columns=["user"],
|
| 124 |
-
every=60,
|
| 125 |
)
|
|
|
|
| 126 |
|
| 127 |
with gr.TabItem("Submit Predictions"):
|
| 128 |
gr.Markdown(
|
|
@@ -141,10 +138,14 @@ def gradio_interface():
|
|
| 141 |
gr.Markdown(
|
| 142 |
"""
|
| 143 |
## Participant Information
|
| 144 |
-
To participate,
|
| 145 |
-
Other information is optional but helps us track participation.
|
| 146 |
If you wish to be included in Challenge discussions, please provide your Discord username and email.
|
| 147 |
If you wish to be included in a future publication with the Challenge results, please provide your name and affiliation.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
"""
|
| 149 |
)
|
| 150 |
# endpoint_type = gr.CheckboxGroup(
|
|
@@ -177,13 +178,19 @@ def gradio_interface():
|
|
| 177 |
label="Affiliation",
|
| 178 |
placeholder="Enter your school/company affiliation (optional)",
|
| 179 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
with gr.Row():
|
| 182 |
with gr.Column():
|
| 183 |
gr.Markdown(
|
| 184 |
"""
|
| 185 |
## Submission Instructions
|
| 186 |
-
Upload a single CSV file containing your predictions for all ligands in the test set.
|
|
|
|
|
|
|
| 187 |
You can download the ligand test set here (lik/to/download/smiles/csv).
|
| 188 |
"""
|
| 189 |
)
|
|
@@ -201,9 +208,10 @@ def gradio_interface():
|
|
| 201 |
submit_btn = gr.Button("Submit Predictions")
|
| 202 |
message = gr.Textbox(label="Status", lines=1, visible=False)
|
| 203 |
|
|
|
|
| 204 |
submit_btn.click(
|
| 205 |
submit_data,
|
| 206 |
-
inputs=[predictions_file, user_state, participant_name, discord_username, email, affiliation],
|
| 207 |
outputs=[message, filename],
|
| 208 |
).success(
|
| 209 |
fn=lambda m: gr.update(value=m, visible=True),
|
|
|
|
| 7 |
|
| 8 |
from datasets import load_dataset
|
| 9 |
from datetime import datetime
|
| 10 |
+
from about import ENDPOINTS, API
|
| 11 |
|
| 12 |
+
def make_user_clickable(name):
|
| 13 |
+
link =f'https://huggingface.co/{name}'
|
| 14 |
+
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{name}</a>'
|
| 15 |
+
def make_tag_clickable(tag):
|
| 16 |
+
return f'<a target="_blank" href="{tag}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">Report</a>'
|
| 17 |
|
| 18 |
def get_leaderboard(endpoint):
|
| 19 |
dset = load_dataset(results_repo, split='train', download_mode="force_redownload")
|
| 20 |
full_df = dset.to_pandas()
|
| 21 |
to_show = full_df.copy(deep=True)
|
| 22 |
to_show = to_show[to_show['endpoint'] == endpoint]
|
| 23 |
+
to_show['user'] = to_show['user'].apply(lambda x: make_user_clickable(x)).astype(str)
|
| 24 |
+
# Get the most recent submission
|
| 25 |
+
to_show["submission_time"] = pd.to_datetime(to_show["submission_time"])
|
| 26 |
+
latest_per_user = to_show.loc[to_show.groupby("user")["submission_time"].idxmax()].reset_index(drop=True)
|
| 27 |
+
latest_per_user.rename(columns={"submission_time": "submission time"}, inplace=True)
|
| 28 |
# The columns to display publicly
|
| 29 |
+
df = latest_per_user[["user", "MAE", "R2", "Spearman R", "Kendall's Tau", "submission time"]]
|
| 30 |
+
# TODO: Also display the column with report link and make it clickable with make_tag_clickable
|
| 31 |
+
|
| 32 |
+
return df
|
| 33 |
|
|
|
|
| 34 |
|
| 35 |
def gradio_interface():
|
| 36 |
with gr.Blocks(title="OpenADMET ADMET Challenge") as demo:
|
|
|
|
| 103 |
|
| 104 |
# --- Gradio Interface ---
|
| 105 |
with gr.Tabs(elem_classes="tab-buttons"):
|
| 106 |
+
lboard_dict = {}
|
| 107 |
|
| 108 |
with gr.TabItem("📝About"):
|
| 109 |
gr.Markdown(welcome_md)
|
| 110 |
|
| 111 |
with gr.TabItem("🚀Leaderboard"):
|
| 112 |
gr.Markdown("View the leaderboard for each ADMET endpoint by selecting the appropiate tab.")
|
| 113 |
+
# Make separate leaderboards in separate tabs
|
| 114 |
+
for endpoint in ENDPOINTS:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
with gr.TabItem(endpoint):
|
| 116 |
+
lboard_dict[endpoint] = Leaderboard(
|
| 117 |
value=get_leaderboard(endpoint),
|
| 118 |
+
datatype=['markdown', 'number', 'number', 'number', 'number'],
|
| 119 |
+
select_columns=["user", "MAE", "R2", "Spearman R", "Kendall's Tau", "submission time"],
|
| 120 |
search_columns=["user"],
|
|
|
|
| 121 |
)
|
| 122 |
+
# TODO: Make aggregated leaderboard and display on first tab
|
| 123 |
|
| 124 |
with gr.TabItem("Submit Predictions"):
|
| 125 |
gr.Markdown(
|
|
|
|
| 138 |
gr.Markdown(
|
| 139 |
"""
|
| 140 |
## Participant Information
|
| 141 |
+
To participate, we **only** require a Hugging Face username, which will be displayed on the leaderboard.
|
| 142 |
+
Other information is optional but helps us track participation.
|
| 143 |
If you wish to be included in Challenge discussions, please provide your Discord username and email.
|
| 144 |
If you wish to be included in a future publication with the Challenge results, please provide your name and affiliation.
|
| 145 |
+
|
| 146 |
+
We also ask you to provide a link to a report decribing your method. While not mandatory at the time of participation,
|
| 147 |
+
you need to submit the link before the challenge deadline in order to be considered for the final leaderboard.
|
| 148 |
+
|
| 149 |
"""
|
| 150 |
)
|
| 151 |
# endpoint_type = gr.CheckboxGroup(
|
|
|
|
| 178 |
label="Affiliation",
|
| 179 |
placeholder="Enter your school/company affiliation (optional)",
|
| 180 |
)
|
| 181 |
+
model_tag = gr.Textbox(
|
| 182 |
+
label="Model Report",
|
| 183 |
+
placeholder="Link to a report describing your method (optional)",
|
| 184 |
+
)
|
| 185 |
|
| 186 |
with gr.Row():
|
| 187 |
with gr.Column():
|
| 188 |
gr.Markdown(
|
| 189 |
"""
|
| 190 |
## Submission Instructions
|
| 191 |
+
Upload a single CSV file containing your predictions for all ligands in the test set.
|
| 192 |
+
Only your latest submission will be considered.
|
| 193 |
+
|
| 194 |
You can download the ligand test set here (lik/to/download/smiles/csv).
|
| 195 |
"""
|
| 196 |
)
|
|
|
|
| 208 |
submit_btn = gr.Button("Submit Predictions")
|
| 209 |
message = gr.Textbox(label="Status", lines=1, visible=False)
|
| 210 |
|
| 211 |
+
# TODO: Refresh leaderboard every time a submission is received
|
| 212 |
submit_btn.click(
|
| 213 |
submit_data,
|
| 214 |
+
inputs=[predictions_file, user_state, participant_name, discord_username, email, affiliation, model_tag],
|
| 215 |
outputs=[message, filename],
|
| 216 |
).success(
|
| 217 |
fn=lambda m: gr.update(value=m, visible=True),
|
evaluate.py
CHANGED
|
@@ -18,7 +18,7 @@ class ParticipantRecord(pydantic.BaseModel):
|
|
| 18 |
discord_username: Optional[str] = pydantic.Field(default=None, description="Discord username")
|
| 19 |
email: Optional[str] = pydantic.Field(default=None, description="Email address")
|
| 20 |
affiliation: Optional[str] = pydantic.Field(default=None, description="Affiliation")
|
| 21 |
-
|
| 22 |
|
| 23 |
|
| 24 |
class SubmissionMetadata(pydantic.BaseModel):
|
|
@@ -40,7 +40,8 @@ def submit_data(predictions_file: str,
|
|
| 40 |
participant_name: str = "",
|
| 41 |
discord_username: str = "",
|
| 42 |
email: str = "",
|
| 43 |
-
affiliation: str = ""
|
|
|
|
| 44 |
):
|
| 45 |
|
| 46 |
if user_state is None:
|
|
@@ -88,6 +89,7 @@ def submit_data(predictions_file: str,
|
|
| 88 |
discord_username=discord_username,
|
| 89 |
email=email,
|
| 90 |
affiliation=affiliation,
|
|
|
|
| 91 |
)
|
| 92 |
except pydantic.ValidationError as e:
|
| 93 |
return f"❌ Error in participant information: {str(e)}"
|
|
@@ -165,6 +167,7 @@ def evaluate_data(filename: str) -> None:
|
|
| 165 |
|
| 166 |
# Write results to results dataset
|
| 167 |
results_df['user'] = username
|
|
|
|
| 168 |
safe_user = _unsafify_username(username)
|
| 169 |
destination_path = f"results/{safe_user}_{timestamp}_results.csv"
|
| 170 |
tmp_name = None
|
|
|
|
| 18 |
discord_username: Optional[str] = pydantic.Field(default=None, description="Discord username")
|
| 19 |
email: Optional[str] = pydantic.Field(default=None, description="Email address")
|
| 20 |
affiliation: Optional[str] = pydantic.Field(default=None, description="Affiliation")
|
| 21 |
+
model_tag: Optional[str] = pydantic.Field(default=None, description="Model tag")
|
| 22 |
|
| 23 |
|
| 24 |
class SubmissionMetadata(pydantic.BaseModel):
|
|
|
|
| 40 |
participant_name: str = "",
|
| 41 |
discord_username: str = "",
|
| 42 |
email: str = "",
|
| 43 |
+
affiliation: str = "",
|
| 44 |
+
model_tag: str = "",
|
| 45 |
):
|
| 46 |
|
| 47 |
if user_state is None:
|
|
|
|
| 89 |
discord_username=discord_username,
|
| 90 |
email=email,
|
| 91 |
affiliation=affiliation,
|
| 92 |
+
model_tag=model_tag,
|
| 93 |
)
|
| 94 |
except pydantic.ValidationError as e:
|
| 95 |
return f"❌ Error in participant information: {str(e)}"
|
|
|
|
| 167 |
|
| 168 |
# Write results to results dataset
|
| 169 |
results_df['user'] = username
|
| 170 |
+
results_df['submission_time'] = timestamp
|
| 171 |
safe_user = _unsafify_username(username)
|
| 172 |
destination_path = f"results/{safe_user}_{timestamp}_results.csv"
|
| 173 |
tmp_name = None
|