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, # 覆盖已有文件 )