Spaces:
Running
Running
Pratyush Maini
commited on
Commit
•
06e7a40
1
Parent(s):
a967188
upload option
Browse files- app.py +1 -0
- uploads.py +27 -23
app.py
CHANGED
@@ -174,6 +174,7 @@ with demo:
|
|
174 |
organisation = gr.Textbox(label="Organisation")
|
175 |
mail = gr.Textbox(label="Contact email")
|
176 |
file_output = gr.File()
|
|
|
177 |
|
178 |
|
179 |
submit_button = gr.Button("Submit Eval")
|
|
|
174 |
organisation = gr.Textbox(label="Organisation")
|
175 |
mail = gr.Textbox(label="Contact email")
|
176 |
file_output = gr.File()
|
177 |
+
|
178 |
|
179 |
|
180 |
submit_button = gr.Button("Submit Eval")
|
uploads.py
CHANGED
@@ -2,6 +2,7 @@ from email.utils import parseaddr
|
|
2 |
from huggingface_hub import HfApi
|
3 |
import os
|
4 |
import datetime
|
|
|
5 |
|
6 |
|
7 |
OWNER="locuslab"
|
@@ -38,33 +39,36 @@ def add_new_eval(
|
|
38 |
if not "@" in parsed_mail:
|
39 |
return format_warning("Please provide a valid email adress.")
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
#
|
44 |
-
|
45 |
-
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
# Save submitted file
|
51 |
api.upload_file(
|
52 |
-
repo_id=
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
)
|
58 |
-
|
59 |
-
|
60 |
-
# Actual submission
|
61 |
-
eval_entry = {
|
62 |
-
"model": model,
|
63 |
-
"model_family": model_family,
|
64 |
-
"url": url,
|
65 |
-
"organisation": organisation,
|
66 |
-
"mail": mail,
|
67 |
-
"forget_rate": forget_rate,
|
68 |
-
}
|
69 |
|
70 |
return format_log(f"Model {model} submitted by {organisation} successfully. \nPlease refresh the leaderboard, and wait a bit to see the score displayed")
|
|
|
2 |
from huggingface_hub import HfApi
|
3 |
import os
|
4 |
import datetime
|
5 |
+
import pandas as pd
|
6 |
|
7 |
|
8 |
OWNER="locuslab"
|
|
|
39 |
if not "@" in parsed_mail:
|
40 |
return format_warning("Please provide a valid email adress.")
|
41 |
|
42 |
+
file_value = path_to_file.value
|
43 |
+
if file_value is None:
|
44 |
+
return format_warning("Please attach a file.")
|
45 |
+
|
46 |
+
# load the file
|
47 |
+
df = pd.read_csv(file_value)
|
48 |
+
|
49 |
+
# modify the df to include metadata
|
50 |
+
df["model"] = model
|
51 |
+
df["model_family"] = model_family
|
52 |
+
df["forget_rate"] = forget_rate
|
53 |
+
df["url"] = url
|
54 |
+
df["organisation"] = organisation
|
55 |
+
df["mail"] = mail
|
56 |
+
df["timestamp"] = datetime.datetime.now()
|
57 |
|
58 |
+
#upload to spaces using the hf api at
|
59 |
+
RESULTS_PATH = "locuslab/tofu_leaderboard"
|
60 |
+
path_in_repo = f"versions/{model_family}-{forget_rate.replace('%', 'p')}"
|
61 |
+
file_name = f"{model}-{organisation}-{datetime.datetime.now().strftime('%Y-%m-%d')}.csv"
|
62 |
|
63 |
+
# upload the df to spaces
|
64 |
+
new_file = df.to_csv(index=False)
|
65 |
|
|
|
66 |
api.upload_file(
|
67 |
+
repo_id = RESULTS_PATH,
|
68 |
+
path_in_repo = f"{path_in_repo}/{file_name}",
|
69 |
+
file_name = file_value,
|
70 |
+
token=TOKEN,
|
71 |
+
repo_type="space",
|
72 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
return format_log(f"Model {model} submitted by {organisation} successfully. \nPlease refresh the leaderboard, and wait a bit to see the score displayed")
|