Views
No views yet
best_model.pt1from hf_model_hub import download_model_from_hub
2from model import SARM
3import torch
4import json
5
6# Download model and config
7files = download_model_from_hub(
8 repo_id="YOUR_USERNAME/YOUR_REPO",
9 checkpoint_name="best_model.pt",
10 output_dir="./downloaded_model"
11)
12
13# Load config
14with open(files["config"], "r") as f:
15 config = json.load(f)
16
17# Create model
18model_config = config["model"]
19model = SARM(
20 d_model=model_config["d_model"],
21 n_heads=model_config["n_heads"],
22 n_layers=model_config["n_layers"],
23 d_mlp=model_config["d_mlp"],
24 num_stages=model_config["num_stages"],
25 d_state=model_config["d_state"],
26 num_tasks=model_config["num_tasks"],
27)
28
29# Load checkpoint
30checkpoint = torch.load(files["checkpoint"])
31model.load_state_dict(checkpoint["model_state_dict"])
32model.eval()1# Assuming you have images and states prepared
2with torch.no_grad():
3 stage_logits, progress = model(images, states, tasks, padding_mask)
4
5 # Get predictions for the last frame
6 predicted_stage = stage_logits[:, -1].argmax(dim=-1)
7 predicted_progress = progress[:, -1]1@misc{sarm-model,
2 author = {Your Name},
3 title = {SARM Progress Prediction},
4 year = {2025},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/YOUR_USERNAME/YOUR_REPO}
7}1{
2 "metadata": {
3 "model_name": "SARM Progress Prediction",
4 "description": "Stage-aware progress prediction model for robot manipulation tasks",
5 "task": "clearing_food_from_table_into_fridge",
6 "task_number": 25,
7 "dataset": "IliaLarchenko/behavior_224_rgb",
8 "version": "1.0",
9 "author": "Your Name",
10 "tags": [
11 "robotics",
12 "progress-estimation",
13 "behavior-cloning"
14 ]
15 },
16 "model": {
17 "d_model": 768,
18 "n_heads": 12,
19 "n_layers": 8,
20 "d_mlp": 512,
21 "num_stages": 100,
22 "d_state": 256,
23 "num_tasks": 50
24 },
25 "training": {
26 "max_steps": 10000,
27 "learning_rate": 0.0001,
28 "weight_decay": 0.0001,
29 "batch_size": 16,
30 "gradient_accumulation_steps": 4,
31 "max_grad_norm": 1.0,
32 "scheduler": "cosine",
33 "stage_loss_weight": 1.0,
34 "progress_loss_weight": 1.0,
35 "validation_steps": 100,
36 "save_steps": 200
37 },
38 "data": {
39 "max_sequence_length": 13,
40 "image_size": 224,
41 "num_workers": 10,
42 "val_workers": 10,
43 "val_samples": 500,
44 "train_episodes": [
45 1,
46 2,
47 3,
48 4,
49 5,
50 6,
51 7,
52 8,
53 9,
54 10,
55 11,
56 12,
57 13,
58 14,
59 15,
60 16,
61 17,
62 18,
63 19,
64 20,
65 21,
66 22,
67 23,
68 24,
69 25,
70 26,
71 27,
72 28,
73 29,
74 30,
75 31,
76 32,
77 33,
78 34,
79 35,
80 36,
81 37,
82 38,
83 39,
84 40,
85 41,
86 42,
87 43,
88 44,
89 45,
90 46,
91 47,
92 48,
93 49,
94 50,
95 51,
96 52,
97 53,
98 54,
99 55,
100 56,
101 57,
102 58,
103 59,
104 60,
105 61,
106 62,
107 63,
108 64,
109 65,
110 66,
111 67,
112 68,
113 69,
114 70,
115 71,
116 72,
117 73,
118 74,
119 75,
120 76,
121 77,
122 78,
123 79,
124 80,
125 81,
126 82,
127 83,
128 84,
129 85,
130 86,
131 87,
132 88,
133 89,
134 90
135 ],
136 "val_episodes": [
137 91,
138 92,
139 93,
140 94,
141 95,
142 96,
143 97,
144 98,
145 99,
146 100,
147 101,
148 102,
149 103,
150 104,
151 105
152 ],
153 "seed": 42
154 },
155 "logging": {
156 "project_name": "sarm-training",
157 "run_name": null,
158 "log_freq": 10,
159 "checkpoint_dir": "checkpoints_sarm_25_2"
160 }
161}