| import os |
| from huggingface_hub import HfApi |
|
|
| |
| REPO_ID = "LancetRobotics/DeCo-MAE" |
|
|
| |
| |
| MODEL_SOTA_PATH = "/root/autodl-tmp/checkpoints_final/final_sota_best.pth" |
| |
| MODEL_ZS_PATH = "/root/autodl-tmp/checkpoints_zeroshot/zeroshot_model.pth" |
| |
| MODEL_COOL_PATH = "/root/autodl-tmp/checkpoints_cooldown/cooldown_best.pth" |
|
|
| |
| CODE_DIR = "/root/hri30" |
|
|
| print(f"🚀 开始上传到 Hugging Face: {REPO_ID}") |
| api = HfApi() |
|
|
| |
| |
| |
| print("\n📦 正在上传模型权重 (可能需要几分钟)...") |
|
|
| |
| if os.path.exists(MODEL_SOTA_PATH): |
| print(f" -> Uploading: {os.path.basename(MODEL_SOTA_PATH)}") |
| api.upload_file( |
| path_or_fileobj=MODEL_SOTA_PATH, |
| path_in_repo="final_sota_best.pth", |
| repo_id=REPO_ID, |
| repo_type="model" |
| ) |
|
|
| |
| if os.path.exists(MODEL_ZS_PATH): |
| print(f" -> Uploading: {os.path.basename(MODEL_ZS_PATH)}") |
| api.upload_file( |
| path_or_fileobj=MODEL_ZS_PATH, |
| path_in_repo="zeroshot_model.pth", |
| repo_id=REPO_ID, |
| repo_type="model" |
| ) |
|
|
| |
| if os.path.exists(MODEL_COOL_PATH): |
| print(f" -> Uploading: {os.path.basename(MODEL_COOL_PATH)}") |
| api.upload_file( |
| path_or_fileobj=MODEL_COOL_PATH, |
| path_in_repo="cooldown_best.pth", |
| repo_id=REPO_ID, |
| repo_type="model" |
| ) |
|
|
| |
| |
| |
| print("\n📂 正在上传代码和图片...") |
|
|
| |
| api.upload_folder( |
| folder_path=CODE_DIR, |
| repo_id=REPO_ID, |
| repo_type="model", |
| allow_patterns=["*.py", "*.md", "*.txt", "fig/*", "LICENSE"], |
| ignore_patterns=[".git/*", "__pycache__/*", "*.pth", "wandb/*"] |
| ) |
|
|
| print("\n✅ 所有文件上传成功!") |
| print(f"👉 查看地址: https://huggingface.co/{REPO_ID}") |
|
|