Upload folder using huggingface_hub
Browse files- KeyVID/interpolation/epoch=1119-step=17920.ckpt +3 -0
- KeyVID/interpolation/epoch=3669-step=58720.ckpt +3 -0
- KeyVID/keyframe_generation/generator_checkpoint.ckpt +3 -0
- KeyVID/wav2motion/best_model_version1_with_skip.pth +3 -0
- RAFT_models/raft-chairs.pth +3 -0
- RAFT_models/raft-kitti.pth +3 -0
- RAFT_models/raft-sintel.pth +3 -0
- RAFT_models/raft-small.pth +3 -0
- RAFT_models/raft-things.pth +3 -0
- README.md +63 -0
- avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/audio_encoder/config.json +5 -0
- avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/audio_encoder/diffusion_pytorch_model.bin +3 -0
- avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/head/config.json +7 -0
- avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/head/diffusion_pytorch_model.bin +3 -0
- avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/video_encoder/config.json +5 -0
- avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/video_encoder/diffusion_pytorch_model.bin +3 -0
- upload.py +215 -0
KeyVID/interpolation/epoch=1119-step=17920.ckpt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c917b0a74d656829e8f1eb8f5a1010ecaded9a4c7932f63a2728307584a623da
|
| 3 |
+
size 15542982125
|
KeyVID/interpolation/epoch=3669-step=58720.ckpt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a586313228defcf5a13fea14fa7e80f28a2885181a44d258c7f5b5c85a99f64b
|
| 3 |
+
size 15542982125
|
KeyVID/keyframe_generation/generator_checkpoint.ckpt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:346bd6229a34c8f558318c86267853631820d91231f11b9b516477a3abf7423d
|
| 3 |
+
size 15551185467
|
KeyVID/wav2motion/best_model_version1_with_skip.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35dc48e9d5694142f7647441e239d63580e6d95106618c4fd152dc45b213b6ff
|
| 3 |
+
size 4807557626
|
RAFT_models/raft-chairs.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c6c75465cf995d137f89ca2e2d08594ed390befbb8859f7f65c48bcc8feb0fd7
|
| 3 |
+
size 21108000
|
RAFT_models/raft-kitti.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b9d170362415e1a27bd8402ee966a3ddf0d60df9b2df2c0b4949f5ced490a9e6
|
| 3 |
+
size 21108000
|
RAFT_models/raft-sintel.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:90630d2e7d488a0d3ccb5e8194524850c4c05c732ea4ff99799822c7fa5c5cbf
|
| 3 |
+
size 21108000
|
RAFT_models/raft-small.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c7d41b9cc88442bb8aa911dbb33086dac55a226394b142937ff22d5578717332
|
| 3 |
+
size 3984814
|
RAFT_models/raft-things.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fcfa4125d6418f4de95d84aec20a3c5f4e205101715a79f193243c186ac9a7e1
|
| 3 |
+
size 21108000
|
README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# KeyVID (Hugging Face Hub)
|
| 2 |
+
|
| 3 |
+
This folder contains the **KeyVID** Hugging Face upload utilities and the model checkpoint files tracked via **Git LFS**.
|
| 4 |
+
|
| 5 |
+
## Links
|
| 6 |
+
|
| 7 |
+
- **Model repo**: `https://huggingface.co/RyanWW/KeyVID`
|
| 8 |
+
- **Dataset repo**: `https://huggingface.co/datasets/RyanWW/KeyVID_data`
|
| 9 |
+
|
| 10 |
+
## Usage
|
| 11 |
+
|
| 12 |
+
### Download the model (checkpoints) from Hugging Face
|
| 13 |
+
|
| 14 |
+
Option A — **Git LFS clone** (recommended for large files):
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
git lfs install
|
| 18 |
+
git clone git@hf.co:RyanWW/KeyVID
|
| 19 |
+
# or:
|
| 20 |
+
# git clone https://huggingface.co/RyanWW/KeyVID
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
Option B — **Python** download a single file:
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
pip install -U huggingface_hub
|
| 27 |
+
python -c "from huggingface_hub import hf_hub_download; print(hf_hub_download(repo_id='RyanWW/KeyVID', filename='keyframe_generation/generator_checkpoint.ckpt'))"
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
### Use the dataset from Hugging Face
|
| 31 |
+
|
| 32 |
+
Option A — **Python** (recommended):
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
pip install -U datasets
|
| 36 |
+
python -c "from datasets import load_dataset; ds = load_dataset('RyanWW/KeyVID_data'); print(ds)"
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
Option B — **Git LFS clone**:
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
git lfs install
|
| 43 |
+
git clone git@hf.co:datasets/RyanWW/KeyVID_data
|
| 44 |
+
# or:
|
| 45 |
+
# git clone https://huggingface.co/datasets/RyanWW/KeyVID_data
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
### Upload (from this repo)
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
pip install -U huggingface_hub
|
| 52 |
+
python upload_fast.py
|
| 53 |
+
# or:
|
| 54 |
+
python upload.py
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
To upload a different local folder, set:
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
export KEYVID_PATH=/path/to/KeyVID_folder
|
| 61 |
+
python upload.py
|
| 62 |
+
```
|
| 63 |
+
|
avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/audio_encoder/config.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "AudioConv2DNet",
|
| 3 |
+
"_diffusers_version": "0.16.0",
|
| 4 |
+
"pretrained": true
|
| 5 |
+
}
|
avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/audio_encoder/diffusion_pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aa606209cce56b21cd20a38ee3afbde10a930880adff620119c278b9dba70270
|
| 3 |
+
size 18936899
|
avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/head/config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "FCHead",
|
| 3 |
+
"_diffusers_version": "0.16.0",
|
| 4 |
+
"dim": 512,
|
| 5 |
+
"dropout": 0.0,
|
| 6 |
+
"out_dim": 1
|
| 7 |
+
}
|
avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/head/diffusion_pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dd10b9cdf73ceb3580e70bae282b7f45a994df47298173bd1ab485ae25586387
|
| 3 |
+
size 2628055
|
avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/video_encoder/config.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "VideoR2Plus1DNet",
|
| 3 |
+
"_diffusers_version": "0.16.0",
|
| 4 |
+
"pretrained": true
|
| 5 |
+
}
|
avsync/vggss_sync_contrast_12/ckpts/checkpoint-40000/modules/video_encoder/diffusion_pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a709ec7670640ed48df0854a45e7ae0b5f30f5c219d5f0f47ab5602babb1191b
|
| 3 |
+
size 61648287
|
upload.py
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Upload KeyVID model to Hugging Face Hub (Optimized for Speed)
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from huggingface_hub import HfApi, login, upload_folder
|
| 8 |
+
import os
|
| 9 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 10 |
+
from tqdm import tqdm
|
| 11 |
+
import time
|
| 12 |
+
|
| 13 |
+
# Model repository name on Hugging Face
|
| 14 |
+
MODEL_ID = "RyanWW/KeyVID"
|
| 15 |
+
|
| 16 |
+
# Path to the KeyVID directory
|
| 17 |
+
KEYVID_PATH = "/dockerx/groups/KeyVID_hf_model"
|
| 18 |
+
|
| 19 |
+
# Upload configuration
|
| 20 |
+
MAX_WORKERS = 8 # 并发上传线程数
|
| 21 |
+
CHUNK_SIZE = 100 * 1024 * 1024 # 100MB chunks for large files
|
| 22 |
+
|
| 23 |
+
def should_exclude_file(file_path, exclude_patterns):
|
| 24 |
+
"""检查文件是否应该被排除"""
|
| 25 |
+
file_str = str(file_path)
|
| 26 |
+
for pattern in exclude_patterns:
|
| 27 |
+
# 支持通配符匹配
|
| 28 |
+
if '*' in pattern:
|
| 29 |
+
pattern_parts = pattern.split('*')
|
| 30 |
+
if all(part in file_str for part in pattern_parts if part):
|
| 31 |
+
return True
|
| 32 |
+
elif pattern in file_str:
|
| 33 |
+
return True
|
| 34 |
+
return False
|
| 35 |
+
|
| 36 |
+
def get_files_to_upload(keyvid_dir, exclude_patterns):
|
| 37 |
+
"""获取需要上传的文件列表"""
|
| 38 |
+
files = []
|
| 39 |
+
total_size = 0
|
| 40 |
+
|
| 41 |
+
print("🔍 Scanning files...")
|
| 42 |
+
for file_path in tqdm(keyvid_dir.rglob("*"), desc="Scanning"):
|
| 43 |
+
if file_path.is_file():
|
| 44 |
+
relative_path = file_path.relative_to(keyvid_dir)
|
| 45 |
+
|
| 46 |
+
if not should_exclude_file(relative_path, exclude_patterns):
|
| 47 |
+
file_size = file_path.stat().st_size
|
| 48 |
+
files.append((relative_path, file_size))
|
| 49 |
+
total_size += file_size
|
| 50 |
+
|
| 51 |
+
return files, total_size
|
| 52 |
+
|
| 53 |
+
def format_size(size_bytes):
|
| 54 |
+
"""格式化文件大小"""
|
| 55 |
+
for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
|
| 56 |
+
if size_bytes < 1024.0:
|
| 57 |
+
return f"{size_bytes:.2f} {unit}"
|
| 58 |
+
size_bytes /= 1024.0
|
| 59 |
+
return f"{size_bytes:.2f} PB"
|
| 60 |
+
|
| 61 |
+
def upload_file_wrapper(args):
|
| 62 |
+
"""包装文件上传函数用于并发"""
|
| 63 |
+
api, keyvid_dir, file_path, repo_id = args
|
| 64 |
+
try:
|
| 65 |
+
full_path = keyvid_dir / file_path
|
| 66 |
+
api.upload_file(
|
| 67 |
+
path_or_fileobj=str(full_path),
|
| 68 |
+
path_in_repo=str(file_path),
|
| 69 |
+
repo_id=repo_id,
|
| 70 |
+
repo_type="model",
|
| 71 |
+
commit_message="Upload KeyVID model files",
|
| 72 |
+
# multi_commits=True, # 允许分批提交
|
| 73 |
+
)
|
| 74 |
+
return (file_path, True, None)
|
| 75 |
+
except Exception as e:
|
| 76 |
+
return (file_path, False, str(e))
|
| 77 |
+
|
| 78 |
+
def main():
|
| 79 |
+
print("🚀 Starting KeyVID upload to Hugging Face (Optimized)...")
|
| 80 |
+
print(f"Repository: {MODEL_ID}")
|
| 81 |
+
|
| 82 |
+
# Check authentication
|
| 83 |
+
try:
|
| 84 |
+
api = HfApi()
|
| 85 |
+
print("✅ Hugging Face authentication found")
|
| 86 |
+
except Exception as e:
|
| 87 |
+
print("⚠️ Need to authenticate with Hugging Face")
|
| 88 |
+
print("Please run: huggingface-cli login")
|
| 89 |
+
print("Or set HF_TOKEN environment variable")
|
| 90 |
+
return
|
| 91 |
+
|
| 92 |
+
# Paths to upload
|
| 93 |
+
keyvid_dir = Path(KEYVID_PATH)
|
| 94 |
+
|
| 95 |
+
if not keyvid_dir.exists():
|
| 96 |
+
print(f"❌ Error: KeyVID directory not found at {KEYVID_PATH}")
|
| 97 |
+
return
|
| 98 |
+
|
| 99 |
+
print(f"\n📁 Directory: {keyvid_dir}")
|
| 100 |
+
|
| 101 |
+
# 优化后的排除模式
|
| 102 |
+
exclude_patterns = [
|
| 103 |
+
"__pycache__",
|
| 104 |
+
".git",
|
| 105 |
+
"*.pyc",
|
| 106 |
+
".DS_Store",
|
| 107 |
+
"save_results/", # 排除结果目录
|
| 108 |
+
"*.log",
|
| 109 |
+
"*.tmp",
|
| 110 |
+
"error.txt",
|
| 111 |
+
".bash_history",
|
| 112 |
+
".gitignore",
|
| 113 |
+
"upload.py", # 排除上传脚本本身
|
| 114 |
+
]
|
| 115 |
+
|
| 116 |
+
# 获取文件列表
|
| 117 |
+
files_to_upload, total_size = get_files_to_upload(keyvid_dir, exclude_patterns)
|
| 118 |
+
|
| 119 |
+
print(f"\n📊 Statistics:")
|
| 120 |
+
print(f" Files to upload: {len(files_to_upload)}")
|
| 121 |
+
print(f" Total size: {format_size(total_size)}")
|
| 122 |
+
|
| 123 |
+
if len(files_to_upload) == 0:
|
| 124 |
+
print("⚠️ No files to upload!")
|
| 125 |
+
return
|
| 126 |
+
|
| 127 |
+
# 询问用户确认
|
| 128 |
+
response = input(f"\n❓ Proceed with upload? (y/n): ").strip().lower()
|
| 129 |
+
if response != 'y':
|
| 130 |
+
print("❌ Upload cancelled")
|
| 131 |
+
return
|
| 132 |
+
|
| 133 |
+
# 策略选择:根据文件数量和大小选择上传方式
|
| 134 |
+
large_files = [f for f, s in files_to_upload if s > 100 * 1024 * 1024] # > 100MB
|
| 135 |
+
small_files = [f for f, s in files_to_upload if s <= 100 * 1024 * 1024]
|
| 136 |
+
|
| 137 |
+
print(f"\n📦 Upload strategy:")
|
| 138 |
+
print(f" Large files (>100MB): {len(large_files)}")
|
| 139 |
+
print(f" Small files: {len(small_files)}")
|
| 140 |
+
print(f" Concurrent workers: {MAX_WORKERS}")
|
| 141 |
+
|
| 142 |
+
# 方法1: 使用 upload_folder(最快,Hugging Face推荐)
|
| 143 |
+
print(f"\n⬆️ Uploading using optimized upload_folder...")
|
| 144 |
+
try:
|
| 145 |
+
start_time = time.time()
|
| 146 |
+
|
| 147 |
+
# 使用更精确的ignore_patterns
|
| 148 |
+
ignore_patterns = [
|
| 149 |
+
"**/__pycache__/**",
|
| 150 |
+
"**/.git/**",
|
| 151 |
+
"**/*.pyc",
|
| 152 |
+
"**/.DS_Store",
|
| 153 |
+
"**/save_results/**",
|
| 154 |
+
"**/*.log",
|
| 155 |
+
"**/*.tmp",
|
| 156 |
+
"**/upload.py",
|
| 157 |
+
]
|
| 158 |
+
|
| 159 |
+
upload_folder(
|
| 160 |
+
folder_path=str(keyvid_dir),
|
| 161 |
+
repo_id=MODEL_ID,
|
| 162 |
+
repo_type="model",
|
| 163 |
+
ignore_patterns=ignore_patterns,
|
| 164 |
+
commit_message="Upload KeyVID model files",
|
| 165 |
+
multi_commits=True, # 允许分批提交,加快大文件上传
|
| 166 |
+
multi_commits_verbose=True, # 显示详细进度
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
elapsed_time = time.time() - start_time
|
| 170 |
+
print(f"\n✅ Upload complete!")
|
| 171 |
+
print(f"⏱️ Time taken: {elapsed_time/60:.2f} minutes")
|
| 172 |
+
print(f"🔗 View model at: https://huggingface.co/{MODEL_ID}")
|
| 173 |
+
|
| 174 |
+
except Exception as e:
|
| 175 |
+
print(f"❌ Error with upload_folder: {e}")
|
| 176 |
+
print("\n📝 Falling back to concurrent file upload...")
|
| 177 |
+
|
| 178 |
+
# 方法2: 并发上传单个文件(备选方案)
|
| 179 |
+
start_time = time.time()
|
| 180 |
+
failed_files = []
|
| 181 |
+
|
| 182 |
+
with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
|
| 183 |
+
# 准备上传任务
|
| 184 |
+
tasks = [
|
| 185 |
+
(api, keyvid_dir, file_path, MODEL_ID)
|
| 186 |
+
for file_path, _ in files_to_upload
|
| 187 |
+
]
|
| 188 |
+
|
| 189 |
+
# 提交任务并显示进度
|
| 190 |
+
futures = {executor.submit(upload_file_wrapper, task): task[2]
|
| 191 |
+
for task in tasks}
|
| 192 |
+
|
| 193 |
+
with tqdm(total=len(files_to_upload), desc="Uploading") as pbar:
|
| 194 |
+
for future in as_completed(futures):
|
| 195 |
+
file_path, success, error = future.result()
|
| 196 |
+
if success:
|
| 197 |
+
pbar.update(1)
|
| 198 |
+
else:
|
| 199 |
+
failed_files.append((file_path, error))
|
| 200 |
+
pbar.update(1)
|
| 201 |
+
|
| 202 |
+
elapsed_time = time.time() - start_time
|
| 203 |
+
|
| 204 |
+
if failed_files:
|
| 205 |
+
print(f"\n⚠️ {len(failed_files)} files failed to upload:")
|
| 206 |
+
for file_path, error in failed_files[:10]:
|
| 207 |
+
print(f" - {file_path}: {error}")
|
| 208 |
+
else:
|
| 209 |
+
print(f"\n✅ All files uploaded successfully!")
|
| 210 |
+
print(f"⏱️ Time taken: {elapsed_time/60:.2f} minutes")
|
| 211 |
+
print(f"🔗 View model at: https://huggingface.co/{MODEL_ID}")
|
| 212 |
+
|
| 213 |
+
if __name__ == "__main__":
|
| 214 |
+
main()
|
| 215 |
+
|