Spaces:
Sleeping
Sleeping
fix: hub push.
Browse files
main.py
CHANGED
@@ -2,7 +2,7 @@ from typing import List
|
|
2 |
|
3 |
import gradio as gr
|
4 |
import tensorflow as tf
|
5 |
-
from huggingface_hub import Repository
|
6 |
|
7 |
from utils import benchmark, convert_to_trt
|
8 |
|
@@ -36,11 +36,14 @@ def push_to_hub(hf_token: str, push_dir: str) -> str:
|
|
36 |
if hf_token == "":
|
37 |
return "### No HF token provided. Model won't be pushed."
|
38 |
else:
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
44 |
|
45 |
|
46 |
def post_optimization(list_of_strs: List[str]) -> str:
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
import tensorflow as tf
|
5 |
+
from huggingface_hub import HfApi, Repository, create_repo
|
6 |
|
7 |
from utils import benchmark, convert_to_trt
|
8 |
|
|
|
36 |
if hf_token == "":
|
37 |
return "### No HF token provided. Model won't be pushed."
|
38 |
else:
|
39 |
+
hf_api = HfApi(token=hf_token)
|
40 |
+
user = hf_api.whoami()["name"]
|
41 |
+
repo_id = f"{user}/{push_dir}"
|
42 |
+
_ = create_repo(repo_id=repo_id, token=hf_token)
|
43 |
+
url = hf_api.upload_folder(folder_path=push_dir, repo_id=repo_id)
|
44 |
+
return f"### Model successfully pushed: [{url}]({url})"
|
45 |
+
except Exception as e:
|
46 |
+
return f"### {e}"
|
47 |
|
48 |
|
49 |
def post_optimization(list_of_strs: List[str]) -> str:
|