Upload upload.py with huggingface_hub
Browse files
upload.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from tqdm import tqdm
|
| 3 |
+
from huggingface_hub import upload_file
|
| 4 |
+
|
| 5 |
+
# --- 설정 ---
|
| 6 |
+
repo_id = "Syzseisus/24W_GLM_pretrained"
|
| 7 |
+
base_folder = "." # 업로드할 로컬 폴더
|
| 8 |
+
repo_type = "model" # 모델 레포지토리
|
| 9 |
+
|
| 10 |
+
# --- 폴더 재귀 탐색 ---
|
| 11 |
+
for root, dirs, files in tqdm(os.walk(base_folder), desc="mother"):
|
| 12 |
+
for file in tqdm(files, desc="children", leave=False):
|
| 13 |
+
local_path = os.path.join(root, file)
|
| 14 |
+
# repo 내 경로: base_folder 이후 경로만 사용
|
| 15 |
+
repo_path = os.path.relpath(local_path, base_folder)
|
| 16 |
+
|
| 17 |
+
print(f"Uploading {local_path} -> {repo_path} ...")
|
| 18 |
+
|
| 19 |
+
try:
|
| 20 |
+
upload_file(
|
| 21 |
+
path_or_fileobj=local_path,
|
| 22 |
+
path_in_repo=repo_path,
|
| 23 |
+
repo_id=repo_id,
|
| 24 |
+
repo_type=repo_type
|
| 25 |
+
)
|
| 26 |
+
print("✅ Done")
|
| 27 |
+
except Exception as e:
|
| 28 |
+
print(f"❌ Failed: {e}")
|