Spaces:
Running
Running
Update app.py
#25
by
reach-vb
HF staff
- opened
app.py
CHANGED
@@ -27,6 +27,15 @@ QUANT_PARAMS = {
|
|
27 |
"Q8": 8,
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
def clear_hf_cache_space():
|
31 |
scan = scan_cache_dir()
|
32 |
to_delete = []
|
@@ -75,14 +84,25 @@ def upload_to_hub(path, upload_repo, hf_path, oauth_token):
|
|
75 |
|
76 |
api = HfApi(token=oauth_token.token)
|
77 |
api.create_repo(repo_id=upload_repo, exist_ok=True)
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
print(f"Upload successful, go to https://huggingface.co/{upload_repo} for details.")
|
87 |
|
88 |
def process_model(model_id, q_method, oauth_token: gr.OAuthToken | None):
|
|
|
27 |
"Q8": 8,
|
28 |
}
|
29 |
|
30 |
+
def list_files_in_folder(folder_path):
|
31 |
+
# List all files and directories in the specified folder
|
32 |
+
all_items = os.listdir(folder_path)
|
33 |
+
|
34 |
+
# Filter out only files
|
35 |
+
files = [item for item in all_items if os.path.isfile(os.path.join(folder_path, item))]
|
36 |
+
|
37 |
+
return files
|
38 |
+
|
39 |
def clear_hf_cache_space():
|
40 |
scan = scan_cache_dir()
|
41 |
to_delete = []
|
|
|
84 |
|
85 |
api = HfApi(token=oauth_token.token)
|
86 |
api.create_repo(repo_id=upload_repo, exist_ok=True)
|
87 |
+
|
88 |
+
files = list_files_in_folder(path)
|
89 |
+
print(files)
|
90 |
+
for file in files:
|
91 |
+
file_path = os.path.join('.', file)
|
92 |
+
print(f"Uploading file: {file_path}")
|
93 |
+
api.upload_file(
|
94 |
+
path_or_fileobj=file_path,
|
95 |
+
path_in_repo=file,
|
96 |
+
repo_id=repo_id,
|
97 |
+
)
|
98 |
+
# api.upload_folder(
|
99 |
+
# folder_path=path,
|
100 |
+
# repo_id=upload_repo,
|
101 |
+
# repo_type="model",
|
102 |
+
# multi_commits=True,
|
103 |
+
# multi_commits_verbose=True,
|
104 |
+
# token=oauth_token.token
|
105 |
+
# )
|
106 |
print(f"Upload successful, go to https://huggingface.co/{upload_repo} for details.")
|
107 |
|
108 |
def process_model(model_id, q_method, oauth_token: gr.OAuthToken | None):
|