Adam Jirkovsky
commited on
Commit
Β·
7dead3c
1
Parent(s):
6344c55
Reaply GUI changes
Browse files- app.py +62 -64
- src/submission/submit.py +1 -1
app.py
CHANGED
|
@@ -30,6 +30,9 @@ from src.display.utils import (
|
|
| 30 |
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, TOKEN, QUEUE_REPO, REPO_ID, RESULTS_REPO
|
| 31 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
| 32 |
from src.submission.submit import add_new_eval
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
original_df = None
|
|
@@ -41,7 +44,7 @@ def restart_space():
|
|
| 41 |
|
| 42 |
def download_data():
|
| 43 |
global original_df
|
| 44 |
-
global leaderboard_df
|
| 45 |
try:
|
| 46 |
print(EVAL_REQUESTS_PATH,QUEUE_REPO)
|
| 47 |
snapshot_download(
|
|
@@ -60,7 +63,7 @@ def download_data():
|
|
| 60 |
|
| 61 |
_, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
| 62 |
leaderboard_df = original_df.copy()
|
| 63 |
-
|
| 64 |
|
| 65 |
download_data()
|
| 66 |
|
|
@@ -78,7 +81,7 @@ def update_table(
|
|
| 78 |
hidden_df: pd.DataFrame,
|
| 79 |
columns: list,
|
| 80 |
query: str,
|
| 81 |
-
):
|
| 82 |
#filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
|
| 83 |
filtered_df = filter_queries(query, hidden_df)
|
| 84 |
df = select_columns(filtered_df, columns)
|
|
@@ -151,7 +154,15 @@ def validate_upload(input):
|
|
| 151 |
#raise gr.Error("Cannot divide by zero!")
|
| 152 |
except:
|
| 153 |
raise gr.Error("Cannot parse file")
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
|
| 157 |
demo = gr.Blocks(css=custom_css)
|
|
@@ -185,7 +196,7 @@ with demo:
|
|
| 185 |
elem_id="column-select",
|
| 186 |
interactive=True,
|
| 187 |
)
|
| 188 |
-
"""
|
| 189 |
with gr.Column(min_width=320):
|
| 190 |
# with gr.Box(elem_id="box-filter"):
|
| 191 |
filter_columns_type = gr.CheckboxGroup(
|
|
@@ -215,7 +226,7 @@ with demo:
|
|
| 215 |
value=leaderboard_df[
|
| 216 |
[c.name for c in fields(AutoEvalColumn) if c.never_hidden]
|
| 217 |
+ shown_columns.value
|
| 218 |
-
|
| 219 |
],
|
| 220 |
headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
| 221 |
datatype=TYPES,
|
|
@@ -264,7 +275,7 @@ with demo:
|
|
| 264 |
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
| 265 |
"""
|
| 266 |
with gr.Column():
|
| 267 |
-
|
| 268 |
with gr.Accordion(
|
| 269 |
f"β
Finished Evaluations ({len(finished_eval_queue_df)})",
|
| 270 |
open=False,
|
|
@@ -287,6 +298,7 @@ with demo:
|
|
| 287 |
datatype=EVAL_TYPES,
|
| 288 |
row_count=5,
|
| 289 |
)
|
|
|
|
| 290 |
with gr.Accordion(
|
| 291 |
f"β³ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
|
| 292 |
open=False,
|
|
@@ -304,62 +316,47 @@ with demo:
|
|
| 304 |
|
| 305 |
with gr.Row():
|
| 306 |
with gr.Column():
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
| 349 |
-
"""
|
| 350 |
-
submit_button = gr.Button("Submit Eval", interactive=True)
|
| 351 |
-
submission_result = gr.Markdown()
|
| 352 |
-
submit_button.click(
|
| 353 |
-
fn = add_new_eval,
|
| 354 |
-
inputs = [
|
| 355 |
-
model_name_textbox,
|
| 356 |
-
upload_button,
|
| 357 |
-
precision,
|
| 358 |
-
hf_model_id,
|
| 359 |
-
contact_email
|
| 360 |
-
],
|
| 361 |
-
outputs = [submission_result, model_name_textbox, precision, hf_model_id, contact_email],
|
| 362 |
-
)
|
| 363 |
|
| 364 |
with gr.Row():
|
| 365 |
with gr.Accordion("π Citation", open=False):
|
|
@@ -374,4 +371,5 @@ with demo:
|
|
| 374 |
#scheduler = BackgroundScheduler()
|
| 375 |
#scheduler.add_job(restart_space, "interval", seconds=3600)
|
| 376 |
#scheduler.start()
|
| 377 |
-
demo.queue(default_concurrency_limit=40).launch(server_name="0.0.0.0")
|
|
|
|
|
|
| 30 |
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, TOKEN, QUEUE_REPO, REPO_ID, RESULTS_REPO
|
| 31 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
| 32 |
from src.submission.submit import add_new_eval
|
| 33 |
+
from captcha.image import ImageCaptcha
|
| 34 |
+
from PIL import Image
|
| 35 |
+
import random, string
|
| 36 |
|
| 37 |
|
| 38 |
original_df = None
|
|
|
|
| 44 |
|
| 45 |
def download_data():
|
| 46 |
global original_df
|
| 47 |
+
global leaderboard_df
|
| 48 |
try:
|
| 49 |
print(EVAL_REQUESTS_PATH,QUEUE_REPO)
|
| 50 |
snapshot_download(
|
|
|
|
| 63 |
|
| 64 |
_, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
| 65 |
leaderboard_df = original_df.copy()
|
| 66 |
+
|
| 67 |
|
| 68 |
download_data()
|
| 69 |
|
|
|
|
| 81 |
hidden_df: pd.DataFrame,
|
| 82 |
columns: list,
|
| 83 |
query: str,
|
| 84 |
+
):
|
| 85 |
#filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
|
| 86 |
filtered_df = filter_queries(query, hidden_df)
|
| 87 |
df = select_columns(filtered_df, columns)
|
|
|
|
| 154 |
#raise gr.Error("Cannot divide by zero!")
|
| 155 |
except:
|
| 156 |
raise gr.Error("Cannot parse file")
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def generate_captcha(width=200, height=150, length=4):
|
| 160 |
+
text = ''.join(random.choices(string.ascii_uppercase + string.digits, k=length))
|
| 161 |
+
captcha_obj = ImageCaptcha(width, height)
|
| 162 |
+
data = captcha_obj.generate(text)
|
| 163 |
+
image = Image.open(data)
|
| 164 |
+
return image, text
|
| 165 |
+
|
| 166 |
|
| 167 |
|
| 168 |
demo = gr.Blocks(css=custom_css)
|
|
|
|
| 196 |
elem_id="column-select",
|
| 197 |
interactive=True,
|
| 198 |
)
|
| 199 |
+
"""
|
| 200 |
with gr.Column(min_width=320):
|
| 201 |
# with gr.Box(elem_id="box-filter"):
|
| 202 |
filter_columns_type = gr.CheckboxGroup(
|
|
|
|
| 226 |
value=leaderboard_df[
|
| 227 |
[c.name for c in fields(AutoEvalColumn) if c.never_hidden]
|
| 228 |
+ shown_columns.value
|
| 229 |
+
|
| 230 |
],
|
| 231 |
headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
| 232 |
datatype=TYPES,
|
|
|
|
| 275 |
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
| 276 |
"""
|
| 277 |
with gr.Column():
|
| 278 |
+
|
| 279 |
with gr.Accordion(
|
| 280 |
f"β
Finished Evaluations ({len(finished_eval_queue_df)})",
|
| 281 |
open=False,
|
|
|
|
| 298 |
datatype=EVAL_TYPES,
|
| 299 |
row_count=5,
|
| 300 |
)
|
| 301 |
+
|
| 302 |
with gr.Accordion(
|
| 303 |
f"β³ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
|
| 304 |
open=False,
|
|
|
|
| 316 |
|
| 317 |
with gr.Row():
|
| 318 |
with gr.Column():
|
| 319 |
+
with gr.Group():
|
| 320 |
+
model_name_textbox = gr.Textbox(label="Model name")
|
| 321 |
+
#precision = gr.Radio(["bfloat16", "float16", "4bit"], label="Precision", info="What precision are you using for inference?")
|
| 322 |
+
precision = gr.Dropdown(
|
| 323 |
+
choices=[i.value.name for i in Precision if i != Precision.Unknown],
|
| 324 |
+
label="Precision",
|
| 325 |
+
multiselect=False,
|
| 326 |
+
value="other",
|
| 327 |
+
interactive=True,
|
| 328 |
+
info="What weight precision were you using during the evaluation?"
|
| 329 |
+
)
|
| 330 |
+
hf_model_id = gr.Textbox(label="Model link (Optional)", info="URL to the model's Hugging Face repository, or it's official website")
|
| 331 |
+
contact_email = gr.Textbox(label="Your E-Mail")
|
| 332 |
+
file_input = gr.File(file_count="single", interactive=True)
|
| 333 |
+
#file_input.upload(validate_upload, file_input)
|
| 334 |
+
upload_button = gr.UploadButton("Upload json", file_types=['.json'])
|
| 335 |
+
upload_button.upload(validate_upload, upload_button, file_input)
|
| 336 |
+
|
| 337 |
+
with gr.Group():
|
| 338 |
+
image, text = generate_captcha()
|
| 339 |
+
captcha_img = gr.Image(
|
| 340 |
+
image,
|
| 341 |
+
#container=False,
|
| 342 |
+
show_download_button=False,
|
| 343 |
+
show_fullscreen_button=False,
|
| 344 |
+
show_share_button=False,
|
| 345 |
+
)
|
| 346 |
+
captcha_input = gr.Textbox(placeholder="Enter the text in the image above", show_label=False, container=False)
|
| 347 |
+
submit_button = gr.Button("Submit Eval", interactive=True)
|
| 348 |
+
submission_result = gr.Markdown()
|
| 349 |
+
submit_button.click(
|
| 350 |
+
fn = add_new_eval,
|
| 351 |
+
inputs = [
|
| 352 |
+
model_name_textbox,
|
| 353 |
+
file_input,
|
| 354 |
+
precision,
|
| 355 |
+
hf_model_id,
|
| 356 |
+
contact_email
|
| 357 |
+
],
|
| 358 |
+
outputs = [submission_result, model_name_textbox, precision, hf_model_id, contact_email],
|
| 359 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
|
| 361 |
with gr.Row():
|
| 362 |
with gr.Accordion("π Citation", open=False):
|
|
|
|
| 371 |
#scheduler = BackgroundScheduler()
|
| 372 |
#scheduler.add_job(restart_space, "interval", seconds=3600)
|
| 373 |
#scheduler.start()
|
| 374 |
+
demo.queue(default_concurrency_limit=40).launch(server_name="0.0.0.0")
|
| 375 |
+
|
src/submission/submit.py
CHANGED
|
@@ -83,7 +83,7 @@ def add_new_eval(
|
|
| 83 |
|
| 84 |
if ret['eval_name'] in existing_eval_names:
|
| 85 |
print(f"Model name {ret['eval_name']} is used!")
|
| 86 |
-
return styled_error(f"Model name {ret['eval_name']} is used!")
|
| 87 |
|
| 88 |
out_path = f"{OUT_DIR}/{eval_name}_eval_request.json"
|
| 89 |
|
|
|
|
| 83 |
|
| 84 |
if ret['eval_name'] in existing_eval_names:
|
| 85 |
print(f"Model name {ret['eval_name']} is used!")
|
| 86 |
+
return styled_error(f"Model name {ret['eval_name']} is used!"), "", "", "", ""
|
| 87 |
|
| 88 |
out_path = f"{OUT_DIR}/{eval_name}_eval_request.json"
|
| 89 |
|