LancetRobotics commited on
Commit
b2ac48c
·
verified ·
1 Parent(s): 030f2e0

Delete upload_hf.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. upload_hf.py +0 -71
upload_hf.py DELETED
@@ -1,71 +0,0 @@
1
- import os
2
- from huggingface_hub import HfApi
3
-
4
- # 🔥 1. 设置你的仓库 ID
5
- REPO_ID = "LancetRobotics/DeCo-MAE"
6
-
7
- # 🔥 2. 设置文件路径 (根据你之前的训练记录)
8
- # SOTA 最佳模型
9
- MODEL_SOTA_PATH = "/root/autodl-tmp/checkpoints_final/final_sota_best.pth"
10
- # Zero-Shot 最佳模型
11
- MODEL_ZS_PATH = "/root/autodl-tmp/checkpoints_zeroshot/zeroshot_model.pth"
12
- # 冷却模型 (如果你有的话)
13
- MODEL_COOL_PATH = "/root/autodl-tmp/checkpoints_cooldown/cooldown_best.pth"
14
-
15
- # 项目代码目录
16
- CODE_DIR = "/root/hri30"
17
-
18
- print(f"🚀 开始上传到 Hugging Face: {REPO_ID}")
19
- api = HfApi()
20
-
21
- # ==========================================
22
- # 任务 A: 上传模型权重 (大文件)
23
- # ==========================================
24
- print("\n📦 正在上传模型权重 (可能需要几分钟)...")
25
-
26
- # 1. 上传 Final SOTA 模型
27
- if os.path.exists(MODEL_SOTA_PATH):
28
- print(f" -> Uploading: {os.path.basename(MODEL_SOTA_PATH)}")
29
- api.upload_file(
30
- path_or_fileobj=MODEL_SOTA_PATH,
31
- path_in_repo="final_sota_best.pth",
32
- repo_id=REPO_ID,
33
- repo_type="model"
34
- )
35
-
36
- # 2. 上传 Zero-Shot 模型
37
- if os.path.exists(MODEL_ZS_PATH):
38
- print(f" -> Uploading: {os.path.basename(MODEL_ZS_PATH)}")
39
- api.upload_file(
40
- path_or_fileobj=MODEL_ZS_PATH,
41
- path_in_repo="zeroshot_model.pth",
42
- repo_id=REPO_ID,
43
- repo_type="model"
44
- )
45
-
46
- # 3. 上传 Cooldown 模型 (如果有)
47
- if os.path.exists(MODEL_COOL_PATH):
48
- print(f" -> Uploading: {os.path.basename(MODEL_COOL_PATH)}")
49
- api.upload_file(
50
- path_or_fileobj=MODEL_COOL_PATH,
51
- path_in_repo="cooldown_best.pth",
52
- repo_id=REPO_ID,
53
- repo_type="model"
54
- )
55
-
56
- # ==========================================
57
- # 任务 B: 上传代码和图片
58
- # ==========================================
59
- print("\n📂 正在上传代码和图片...")
60
-
61
- # 我们只上传 .py, .md, .txt 和 fig 文件夹,忽略 .git, __pycache__ 等垃圾文件
62
- api.upload_folder(
63
- folder_path=CODE_DIR,
64
- repo_id=REPO_ID,
65
- repo_type="model",
66
- allow_patterns=["*.py", "*.md", "*.txt", "fig/*", "LICENSE"],
67
- ignore_patterns=[".git/*", "__pycache__/*", "*.pth", "wandb/*"] # 忽略本地的pth防止重复
68
- )
69
-
70
- print("\n✅ 所有文件上传成功!")
71
- print(f"👉 查看地址: https://huggingface.co/{REPO_ID}")