Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,205 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
import pandas as pd
|
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 |
-
def restart_space():
|
34 |
-
API.restart_space(repo_id=REPO_ID)
|
35 |
-
|
36 |
-
### Space initialisation
|
37 |
-
try:
|
38 |
-
print(EVAL_REQUESTS_PATH)
|
39 |
-
snapshot_download(
|
40 |
-
repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
|
41 |
-
)
|
42 |
-
except Exception:
|
43 |
-
restart_space()
|
44 |
-
try:
|
45 |
-
print(EVAL_RESULTS_PATH)
|
46 |
-
snapshot_download(
|
47 |
-
repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
|
48 |
)
|
49 |
-
except Exception:
|
50 |
-
restart_space()
|
51 |
-
|
52 |
-
|
53 |
-
LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
54 |
-
|
55 |
-
(
|
56 |
-
finished_eval_queue_df,
|
57 |
-
running_eval_queue_df,
|
58 |
-
pending_eval_queue_df,
|
59 |
-
) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
60 |
-
|
61 |
-
def init_leaderboard(dataframe):
|
62 |
-
if dataframe is None or dataframe.empty:
|
63 |
-
raise ValueError("Leaderboard DataFrame is empty or None.")
|
64 |
-
return Leaderboard(
|
65 |
-
value=dataframe,
|
66 |
-
datatype=[c.type for c in fields(AutoEvalColumn)],
|
67 |
-
select_columns=SelectColumns(
|
68 |
-
default_selection=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
|
69 |
-
cant_deselect=[c.name for c in fields(AutoEvalColumn) if c.never_hidden],
|
70 |
-
label="Select Columns to Display:",
|
71 |
-
),
|
72 |
-
search_columns=[AutoEvalColumn.model.name, AutoEvalColumn.license.name],
|
73 |
-
hide_columns=[c.name for c in fields(AutoEvalColumn) if c.hidden],
|
74 |
-
filter_columns=[
|
75 |
-
ColumnFilter(AutoEvalColumn.model_type.name, type="checkboxgroup", label="Model types"),
|
76 |
-
ColumnFilter(AutoEvalColumn.precision.name, type="checkboxgroup", label="Precision"),
|
77 |
-
ColumnFilter(
|
78 |
-
AutoEvalColumn.params.name,
|
79 |
-
type="slider",
|
80 |
-
min=0.01,
|
81 |
-
max=150,
|
82 |
-
label="Select the number of parameters (B)",
|
83 |
-
),
|
84 |
-
ColumnFilter(
|
85 |
-
AutoEvalColumn.still_on_hub.name, type="boolean", label="Deleted/incomplete", default=True
|
86 |
-
),
|
87 |
-
],
|
88 |
-
bool_checkboxgroup_label="Hide models",
|
89 |
-
interactive=False,
|
90 |
-
)
|
91 |
-
|
92 |
-
|
93 |
-
demo = gr.Blocks(css=custom_css)
|
94 |
-
with demo:
|
95 |
-
gr.HTML(TITLE)
|
96 |
-
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
97 |
-
|
98 |
-
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
99 |
-
with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
100 |
-
leaderboard = init_leaderboard(LEADERBOARD_DF)
|
101 |
-
|
102 |
-
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
103 |
-
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
104 |
-
|
105 |
-
with gr.TabItem("🚀 Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
|
106 |
-
with gr.Column():
|
107 |
-
with gr.Row():
|
108 |
-
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
109 |
-
|
110 |
-
with gr.Column():
|
111 |
-
with gr.Accordion(
|
112 |
-
f"✅ finished Evaluations ({len(finished_eval_queue_df)})",
|
113 |
-
open=False,
|
114 |
-
):
|
115 |
-
with gr.Row():
|
116 |
-
finished_eval_table = gr.components.Dataframe(
|
117 |
-
value=finished_eval_queue_df,
|
118 |
-
headers=EVAL_COLS,
|
119 |
-
datatype=EVAL_TYPES,
|
120 |
-
row_count=5,
|
121 |
-
)
|
122 |
-
with gr.Accordion(
|
123 |
-
f"🔄 running Evaluation Queue ({len(running_eval_queue_df)})",
|
124 |
-
open=False,
|
125 |
-
):
|
126 |
-
with gr.Row():
|
127 |
-
running_eval_table = gr.components.Dataframe(
|
128 |
-
value=running_eval_queue_df,
|
129 |
-
headers=EVAL_COLS,
|
130 |
-
datatype=EVAL_TYPES,
|
131 |
-
row_count=5,
|
132 |
-
)
|
133 |
-
|
134 |
-
with gr.Accordion(
|
135 |
-
f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
|
136 |
-
open=False,
|
137 |
-
):
|
138 |
-
with gr.Row():
|
139 |
-
pending_eval_table = gr.components.Dataframe(
|
140 |
-
value=pending_eval_queue_df,
|
141 |
-
headers=EVAL_COLS,
|
142 |
-
datatype=EVAL_TYPES,
|
143 |
-
row_count=5,
|
144 |
-
)
|
145 |
-
with gr.Row():
|
146 |
-
gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
|
147 |
-
|
148 |
-
with gr.Row():
|
149 |
-
with gr.Column():
|
150 |
-
model_name_textbox = gr.Textbox(label="Model name")
|
151 |
-
revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
|
152 |
-
model_type = gr.Dropdown(
|
153 |
-
choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
|
154 |
-
label="Model type",
|
155 |
-
multiselect=False,
|
156 |
-
value=None,
|
157 |
-
interactive=True,
|
158 |
-
)
|
159 |
-
|
160 |
-
with gr.Column():
|
161 |
-
precision = gr.Dropdown(
|
162 |
-
choices=[i.value.name for i in Precision if i != Precision.Unknown],
|
163 |
-
label="Precision",
|
164 |
-
multiselect=False,
|
165 |
-
value="float16",
|
166 |
-
interactive=True,
|
167 |
-
)
|
168 |
-
weight_type = gr.Dropdown(
|
169 |
-
choices=[i.value.name for i in WeightType],
|
170 |
-
label="Weights type",
|
171 |
-
multiselect=False,
|
172 |
-
value="Original",
|
173 |
-
interactive=True,
|
174 |
-
)
|
175 |
-
base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
176 |
-
|
177 |
-
submit_button = gr.Button("Submit Eval")
|
178 |
-
submission_result = gr.Markdown()
|
179 |
-
submit_button.click(
|
180 |
-
add_new_eval,
|
181 |
-
[
|
182 |
-
model_name_textbox,
|
183 |
-
base_model_name_textbox,
|
184 |
-
revision_name_textbox,
|
185 |
-
precision,
|
186 |
-
weight_type,
|
187 |
-
model_type,
|
188 |
-
],
|
189 |
-
submission_result,
|
190 |
-
)
|
191 |
-
|
192 |
-
with gr.Row():
|
193 |
-
with gr.Accordion("📙 Citation", open=False):
|
194 |
-
citation_button = gr.Textbox(
|
195 |
-
value=CITATION_BUTTON_TEXT,
|
196 |
-
label=CITATION_BUTTON_LABEL,
|
197 |
-
lines=20,
|
198 |
-
elem_id="citation-button",
|
199 |
-
show_copy_button=True,
|
200 |
-
)
|
201 |
|
202 |
-
|
203 |
-
scheduler.add_job(restart_space, "interval", seconds=1800)
|
204 |
-
scheduler.start()
|
205 |
-
demo.queue(default_concurrency_limit=40).launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from evaluate import run_evaluation
|
3 |
import pandas as pd
|
4 |
+
import os
|
5 |
+
|
6 |
+
LEADERBOARD_CSV = "leaderboard.csv"
|
7 |
+
|
8 |
+
def evaluate_and_update(pred_file, username):
|
9 |
+
score = run_evaluation(pred_file.name)
|
10 |
+
if os.path.exists(LEADERBOARD_CSV):
|
11 |
+
df = pd.read_csv(LEADERBOARD_CSV)
|
12 |
+
else:
|
13 |
+
df = pd.DataFrame(columns=["name", "score"])
|
14 |
+
df.loc[len(df)] = {"name": username, "score": score}
|
15 |
+
df = df.sort_values(by="score", ascending=False).reset_index(drop=True)
|
16 |
+
df.to_csv(LEADERBOARD_CSV, index=False)
|
17 |
+
return f"Your score: {score:.4f}", df
|
18 |
+
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
gr.Markdown("# 🧊 3D IoU Challenge")
|
21 |
+
name = gr.Textbox(label="Username")
|
22 |
+
upload = gr.File(label="Upload your prediction (.npy)")
|
23 |
+
score_text = gr.Textbox(label="Evaluation score")
|
24 |
+
leaderboard = gr.Dataframe(headers=["Name", "Score"], interactive=False)
|
25 |
+
|
26 |
+
submit_btn = gr.Button("Submit")
|
27 |
+
submit_btn.click(
|
28 |
+
fn=evaluate_and_update,
|
29 |
+
inputs=[upload, name],
|
30 |
+
outputs=[score_text, leaderboard]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
demo.launch()
|
|
|
|
|
|