File size: 747 Bytes
1f57542
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from huggingface_hub import HfApi

# 初始化 API
api = HfApi()

# 上传超大文件夹(自动分片+续传)
api.upload_large_folder(
    folder_path="./clean-model-files",  # 清理后的本地目录
    repo_id="你的用户名/你的仓库名",     # 如 zhangsan/my-llm-model
    repo_type="model",                  # 仓库类型
    allow_patterns=[                    # 仅上传以下文件(白名单)
        "*.safetensors",
        "*.bin",
        "config.json",
        "tokenizer*.json",
        "vocab.txt"
    ],
    ignore_patterns=[                   # 排除以下文件(黑名单)
        ".cache/**",
        "*.log",
        "__pycache__/**"
    ],
    overwrite=True,                     # 覆盖已有文件
)