Spaces:
Sleeping
Sleeping
virtualmartire
commited on
Commit
•
4984355
1
Parent(s):
21fd416
requests are now stored in a private ds repo
Browse files- constants.py +1 -1
- requested_models.txt +0 -1
- utils/eval_requests.py +27 -30
constants.py
CHANGED
@@ -7,7 +7,7 @@ import os
|
|
7 |
#
|
8 |
|
9 |
TOKEN_HUB = os.environ.get("TOKEN_HUB", None)
|
10 |
-
|
11 |
COLUMN_DTYPES_LIST = ["markdown", "number", "number", "number"] # in accordance with ./leaderboard.csv
|
12 |
|
13 |
#
|
|
|
7 |
#
|
8 |
|
9 |
TOKEN_HUB = os.environ.get("TOKEN_HUB", None)
|
10 |
+
DATASET_REPO = "brescia-ai/open-ita-asr-requests"
|
11 |
COLUMN_DTYPES_LIST = ["markdown", "number", "number", "number"] # in accordance with ./leaderboard.csv
|
12 |
|
13 |
#
|
requested_models.txt
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
stabilityai/stable-audio-open-1.0
|
|
|
|
utils/eval_requests.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
import huggingface_hub as hf_hub
|
2 |
-
|
|
|
|
|
3 |
|
4 |
hf_api = hf_hub.HfApi(
|
5 |
endpoint="https://huggingface.co",
|
6 |
-
token=TOKEN_HUB,
|
7 |
)
|
8 |
|
9 |
|
@@ -36,17 +38,6 @@ def is_model_on_hub(model_id):
|
|
36 |
return "was not found on hub!"
|
37 |
|
38 |
|
39 |
-
def upload_file(local_filepath, repo_filepath, commit_message):
|
40 |
-
hf_api.upload_file(
|
41 |
-
path_or_fileobj=local_filepath,
|
42 |
-
path_in_repo=repo_filepath,
|
43 |
-
repo_id=REPO_ID,
|
44 |
-
token=TOKEN_HUB,
|
45 |
-
repo_type="space",
|
46 |
-
commit_message=commit_message
|
47 |
-
)
|
48 |
-
|
49 |
-
|
50 |
def request_model(model_id):
|
51 |
|
52 |
def styled_error(error):
|
@@ -55,26 +46,32 @@ def request_model(model_id):
|
|
55 |
def styled_message(message):
|
56 |
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
|
57 |
|
58 |
-
# Check if the model is on the hub
|
59 |
-
error_msg = is_model_on_hub(model_id)
|
60 |
-
if error_msg != None:
|
61 |
-
|
62 |
|
63 |
-
# Check if the model was already requested
|
64 |
-
with open("requested_models.txt", "r") as f:
|
65 |
-
|
66 |
-
if model_id in requested_models_list:
|
67 |
-
|
68 |
|
69 |
-
# Add the model to the local evaluation queue
|
70 |
-
with open("requested_models.txt", "a") as f:
|
71 |
-
|
72 |
|
73 |
-
# Push the request file to the
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
)
|
79 |
|
80 |
return styled_message("🤗 Your request has been submitted and will be evaluated as soon as possible!")
|
|
|
1 |
import huggingface_hub as hf_hub
|
2 |
+
import uuid
|
3 |
+
|
4 |
+
import constants
|
5 |
|
6 |
hf_api = hf_hub.HfApi(
|
7 |
endpoint="https://huggingface.co",
|
8 |
+
token=constants.TOKEN_HUB,
|
9 |
)
|
10 |
|
11 |
|
|
|
38 |
return "was not found on hub!"
|
39 |
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
def request_model(model_id):
|
42 |
|
43 |
def styled_error(error):
|
|
|
46 |
def styled_message(message):
|
47 |
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
|
48 |
|
49 |
+
# # Check if the model is on the hub
|
50 |
+
# error_msg = is_model_on_hub(model_id)
|
51 |
+
# if error_msg != None:
|
52 |
+
# return styled_error(f"{model_id} {error_msg}")
|
53 |
|
54 |
+
# # Check if the model was already requested
|
55 |
+
# with open("requested_models.txt", "r") as f:
|
56 |
+
# requested_models_list = f.read().splitlines()
|
57 |
+
# if model_id in requested_models_list:
|
58 |
+
# return styled_error(f"A request for {model_id} was already made.")
|
59 |
|
60 |
+
# # Add the model to the local evaluation queue
|
61 |
+
# with open("requested_models.txt", "a") as f:
|
62 |
+
# f.write(model_id + "\n")
|
63 |
|
64 |
+
# Push the request file to the private dataset repo
|
65 |
+
unique_request_filename = str(uuid.uuid4())
|
66 |
+
with open("unique_request_filename.json", "w") as f:
|
67 |
+
f.write(model_id)
|
68 |
+
hf_api.upload_file(
|
69 |
+
path_or_fileobj=unique_request_filename, #local_filepath
|
70 |
+
path_in_repo=unique_request_filename,
|
71 |
+
repo_id=constants.DATASET_REPO,
|
72 |
+
token=constants.TOKEN_HUB,
|
73 |
+
repo_type="dataset",
|
74 |
+
commit_message=f"{model_id} added to the evaluation queue.",
|
75 |
)
|
76 |
|
77 |
return styled_message("🤗 Your request has been submitted and will be evaluated as soon as possible!")
|