trying to write results
Browse files- app.py +44 -31
- requirements.txt +2 -1
app.py
CHANGED
@@ -7,6 +7,7 @@ import pandas as pd
|
|
7 |
import gradio as gr
|
8 |
from datasets import load_dataset, Dataset
|
9 |
from huggingface_hub import upload_file, hf_hub_download
|
|
|
10 |
from evaluation import evaluate_problem
|
11 |
from datetime import datetime
|
12 |
import os
|
@@ -118,43 +119,55 @@ def get_leaderboard(problem_type: str):
|
|
118 |
score_field = "score" if "score" in df.columns else "objective" # fallback
|
119 |
|
120 |
df = df.sort_values(by=score_field, ascending=True)
|
121 |
-
leaderboard = df[["submission_time", "problem_type", score_field]].reset_index(drop=True)
|
122 |
-
return
|
123 |
|
124 |
def gradio_interface() -> gr.Blocks:
|
125 |
with gr.Blocks() as demo:
|
126 |
-
gr.
|
127 |
-
""
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
)
|
136 |
-
boundary_file = gr.File(label="Boundary JSON File (.json)")
|
137 |
-
|
138 |
-
boundary_file
|
139 |
-
output = gr.Textbox(label="Evaluation Result", lines=10)
|
140 |
-
submit_btn = gr.Button("Evaluate")
|
141 |
-
submit_btn.click(
|
142 |
-
submit_boundary,
|
143 |
-
inputs=[problem_type, boundary_file],
|
144 |
-
outputs=output,
|
145 |
-
)
|
146 |
-
|
147 |
-
with gr.Row():
|
148 |
-
leaderboard_type = gr.Dropdown(PROBLEM_TYPES, label="Leaderboard Problem Type", value="geometrical")
|
149 |
-
leaderboard_btn = gr.Button("Load Leaderboard")
|
150 |
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
-
|
154 |
-
lambda pt: get_leaderboard(pt).to_dict(orient="records"),
|
155 |
-
inputs=[leaderboard_type],
|
156 |
-
outputs=[leaderboard_df]
|
157 |
-
)
|
158 |
return demo
|
159 |
|
160 |
|
|
|
7 |
import gradio as gr
|
8 |
from datasets import load_dataset, Dataset
|
9 |
from huggingface_hub import upload_file, hf_hub_download
|
10 |
+
from gradio_leaderboard import ColumnFilter, Leaderboard, SelectColumns
|
11 |
from evaluation import evaluate_problem
|
12 |
from datetime import datetime
|
13 |
import os
|
|
|
119 |
score_field = "score" if "score" in df.columns else "objective" # fallback
|
120 |
|
121 |
df = df.sort_values(by=score_field, ascending=True)
|
122 |
+
# leaderboard = df[["submission_time", "problem_type", score_field]].reset_index(drop=True)
|
123 |
+
return df
|
124 |
|
125 |
def gradio_interface() -> gr.Blocks:
|
126 |
with gr.Blocks() as demo:
|
127 |
+
with gr.Tabs():
|
128 |
+
with gr.Tab("Submit"):
|
129 |
+
gr.Markdown(
|
130 |
+
"""
|
131 |
+
# Plasma Boundary Evaluation App
|
132 |
+
Upload your plasma boundary JSON and select the problem type to get your score.
|
133 |
+
"""
|
134 |
+
)
|
135 |
+
with gr.Row():
|
136 |
+
problem_type = gr.Dropdown(
|
137 |
+
PROBLEM_TYPES, label="Problem Type", value="geometrical"
|
138 |
+
)
|
139 |
+
boundary_file = gr.File(label="Boundary JSON File (.json)")
|
140 |
+
|
141 |
+
boundary_file
|
142 |
+
output = gr.Textbox(label="Evaluation Result", lines=10)
|
143 |
+
submit_btn = gr.Button("Evaluate")
|
144 |
+
submit_btn.click(
|
145 |
+
submit_boundary,
|
146 |
+
inputs=[problem_type, boundary_file],
|
147 |
+
outputs=output,
|
148 |
+
)
|
149 |
+
with gr.Tab("Leaderboards"):
|
150 |
+
gr.Markdown("# Leaderboard")
|
151 |
+
leaderboard_type = gr.Dropdown(PROBLEM_TYPES, value="geometrical", label="Problem Type")
|
152 |
+
refresh_btn = gr.Button("Refresh Leaderboard")
|
153 |
+
leaderboard_df = gr.Dataframe(label="Leaderboard")
|
154 |
+
|
155 |
+
# Trigger refresh when button is clicked
|
156 |
+
refresh_btn.click(
|
157 |
+
lambda pt: get_leaderboard(pt).to_dict(orient="records"),
|
158 |
+
inputs=[leaderboard_type],
|
159 |
+
outputs=[leaderboard_df],
|
160 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
+
Leaderboard(
|
163 |
+
value=leaderboard_df,
|
164 |
+
select_columns=["submission_time", "feasability", "score ⬆️", "objective"],
|
165 |
+
# search_columns=["model_name_for_query", "Type"],
|
166 |
+
# hide_columns=["model_name_for_query", "Model Size"],
|
167 |
+
# filter_columns=["T", "Precision", "Model Size"],
|
168 |
+
)
|
169 |
|
170 |
+
|
|
|
|
|
|
|
|
|
171 |
return demo
|
172 |
|
173 |
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
constellaration==0.2.1
|
2 |
gradio
|
3 |
datasets
|
4 |
-
huggingface_hub
|
|
|
|
1 |
constellaration==0.2.1
|
2 |
gradio
|
3 |
datasets
|
4 |
+
huggingface_hub
|
5 |
+
gradio-leaderboard
|