Dimios45 commited on
Commit
09094bf
·
verified ·
1 Parent(s): 12934c0

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +146 -59
README.md CHANGED
@@ -10,63 +10,124 @@ tags:
10
  - cross-attention
11
  ---
12
 
13
- # Graspmax — GeoMatch & GeoMatch++
14
 
15
- **Graspmax** contains two geometry-aware contact prediction models for dexterous robotic grasping, trained on the CMapDataset across 5 robot end-effectors.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ---
18
 
19
- ## Models
 
 
20
 
21
- ### GeoMatch
22
- Dual GCN encoder (object + robot surface) → projection layers → 5 autoregressive MLP modules → BCE contact map prediction.
23
 
24
  > Based on: [*Geometry Matching for Multi-Embodiment Grasping*](https://openreview.net/forum?id=oyWkrG-LD5) (NeurIPS 2024)
25
 
26
  ### GeoMatch++
27
- Extends GeoMatch with a **morphology encoder** (third GCN over the robot's kinematic-tree graph) and a **DCP-style cross-attention transformer** that fuses object geometry with robot morphology before contact prediction. Pretrained GeoMatch encoders are frozen; only the morphology encoder, transformer, projection heads, and AR modules are trained.
28
 
29
- > Based on: [*GeoMatch++: Morphology-Aware Grasping via Correspondence Learning*](https://arxiv.org/abs/2412.18998)
 
 
30
 
31
- ---
32
 
33
- ## Architecture Comparison
34
 
35
- | Component | GeoMatch | GeoMatch++ |
36
  |---|---|---|
37
- | Object GCN encoder | 3 layers × 256 → 512 | Same, **frozen** |
38
- | Robot surface GCN | 3 layers × 256 → 512 | Same, **frozen** |
39
- | Morphology encoder | — | **NEW** GCN(9 → 256×3 → 512) |
40
  | Cross-attention | — | **NEW** DCP transformer (512-dim, 4 heads, 1 layer) |
41
  | Projection heads | Linear(512→64) × 2 | Same, re-initialised |
42
  | AR keypoint modules | 5× MLP | Same, re-initialised |
43
- | **Total params** | **~1.9M** | **~6.4M (5.8M trainable)** |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  ---
46
 
47
  ## Training Details
48
 
49
- ### GeoMatch
50
 
51
  | Setting | Value |
52
  |---|---|
53
- | Dataset | CMapDataset (ContactDB + YCB) |
54
- | Training samples | 41,871 |
55
  | End-effectors | EZGripper, Barrett, Robotiq 3-Finger, Allegro, ShadowHand |
56
  | Batch size | 256 |
57
  | Optimizer | Adam (β₁=0.9, β₂=0.99) |
58
  | Learning rate | 1e-4 |
59
  | Epochs | 200 |
60
  | Hardware | AMD Instinct MI300X (192 GB HBM3), ROCm 6.2.4 |
61
- | Training time | 22.18 hours |
62
  | Precision | FP32 |
63
- | **Final val loss** | **0.435** |
 
64
 
65
- ### GeoMatch++
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  | Setting | Value |
68
  |---|---|
69
- | Initialisation | Pretrained GeoMatch encoders (frozen) |
70
  | Trainable params | ~5.8M |
71
  | Batch size | 32 per GPU × 8 GPUs = 256 effective |
72
  | Optimizer | Adam (β₁=0.9, β₂=0.99) |
@@ -75,46 +136,72 @@ Extends GeoMatch with a **morphology encoder** (third GCN over the robot's kinem
75
  | Hardware | 8× AMD Instinct MI300X, ROCm 6.2.4 (DDP) |
76
  | Training time | ~2.8 hours |
77
  | Precision | FP32 |
78
- | **Final val loss** | **0.350** (↓19% vs GeoMatch) |
79
- | **Final val accuracy** | **0.940** |
80
 
81
- ### GeoMatch++ Training Curves
82
 
83
  | Epoch | Val Loss | Val Accuracy |
84
  |---|---|---|
85
  | 0 | 0.465 | 0.999 |
86
  | 25 | 0.370 | 0.880 |
87
- | 50 | — | — |
88
  | 89 | 0.362 | 0.902 |
89
- | 100 | — | — |
90
- | 140 | — | — |
91
  | 149 | 0.350 | 0.940 |
92
 
93
  ---
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  ## Checkpoints
96
 
97
- ### GeoMatch
98
- | File | Epoch | Notes |
99
- |---|---|---|
100
- | `checkpoint_epoch50.pth` | 50 | Early convergence |
101
- | `checkpoint_epoch100.pth` | 100 | Mid-training |
102
- | `checkpoint_epoch150.pth` | 150 | Near-converged |
103
- | `geomatch_final.pth` | 200 | **Final model (recommended)** |
 
 
 
104
 
105
- ### GeoMatch++
106
  | File | Epoch | Notes |
107
  |---|---|---|
108
  | `geomatch_pp_checkpoint_epoch50.pth` | 50 | Early convergence |
109
  | `geomatch_pp_checkpoint_epoch100.pth` | 100 | Mid-training |
110
  | `geomatch_pp_checkpoint_epoch140.pth` | 140 | Near-converged |
111
- | `geomatch_pp_final.pth` | 149 | **Final model (recommended)** |
 
 
 
 
 
 
 
 
 
112
 
113
  ---
114
 
115
  ## Usage
116
 
117
- ### GeoMatch
 
118
  ```python
119
  import torch, sys
120
  sys.path.append(".")
@@ -122,23 +209,24 @@ import config
122
  from models.geomatch import GeoMatch
123
 
124
  model = GeoMatch(config).cuda()
125
- model.load_state_dict(torch.load("geomatch_final.pth", map_location="cuda"))
126
  model.eval()
127
 
128
  with torch.no_grad():
129
  contact_map, keypoint_probs = model(
130
- obj_pc, # [B, 2048, 3]
131
- robot_pc, # [B, 6, 3]
132
- robot_key_point_idx, # [B, 6]
133
- obj_adj, # [B, 2048, 2048]
134
- robot_adj, # [B, 6, 6]
135
- xyz_prev, # [B, 6, 3]
136
  )
137
- # contact_map: [B, 2048, 6, 1]
138
- # keypoint_probs: [B, 2048, 5, 1]
139
  ```
140
 
141
- ### GeoMatch++
 
142
  ```python
143
  import torch, sys
144
  sys.path.append(".")
@@ -151,20 +239,18 @@ model.eval()
151
 
152
  with torch.no_grad():
153
  contact_map, keypoint_probs = model(
154
- obj_pc, # [B, 2048, 3] object point cloud
155
- robot_pc, # [B, 6, 3] robot surface points
156
- robot_key_point_idx, # [B, 6] keypoint indices
157
- obj_adj, # [B, 2048, 2048] object adjacency
158
- robot_adj, # [B, 6, 6] robot adjacency
159
- xyz_prev, # [B, 6, 3] previous keypoint positions
160
  morph_features, # [B, 32, 9] morphology node features
161
  morph_adj, # [B, 32, 32] morphology adjacency
162
  )
163
- # contact_map: [B, 2048, 6, 1]
164
- # keypoint_probs: [B, 2048, 5, 1]
165
  ```
166
 
167
- Morphology graphs (`morph_features`, `morph_adj`) are pre-built per robot using `preprocess_morphology.py` and stored in `gnn_morphology_new.pt`.
168
 
169
  ---
170
 
@@ -172,11 +258,12 @@ Morphology graphs (`morph_features`, `morph_adj`) are pre-built per robot using
172
 
173
  ```
174
  models/
175
- geomatch.py # GeoMatch model (dual GCN + AR modules)
176
  geomatch_pp.py # GeoMatch++ model (+ morphology encoder + DCP transformer)
177
  gnn.py # Graph Convolutional Network
178
  mlp.py # MLP building block
179
- config.py # Hyperparameters for both models
 
180
  ```
181
 
182
  ---
@@ -202,4 +289,4 @@ config.py # Hyperparameters for both models
202
  ## License
203
 
204
  Original GeoMatch code © 2023 DeepMind Technologies Limited, licensed under the Apache License 2.0.
205
- GeoMatch++ extension and checkpoints trained by [Dimios45](https://huggingface.co/Dimios45) as part of the Graspmax project.
 
10
  - cross-attention
11
  ---
12
 
13
+ # Graspmax — GeoMatch v2 · GeoMatch++ · GeoMatch v1
14
 
15
+ **Graspmax** contains geometry-aware contact prediction models for dexterous robotic grasping,
16
+ trained on the CMapDataset across 5 robot end-effectors (EZGripper, Barrett, Robotiq 3-Finger,
17
+ Allegro, ShadowHand).
18
+
19
+ > **⚠️ Version notice:** GeoMatch v1 and GeoMatch++ were trained with a corrupted
20
+ > `robot_keypoints.json` (2× scale factor and wrong shadowhand axis-swap stage).
21
+ > **Use GeoMatch v2 for any new work.** v1 and GeoMatch++ are kept for reproducibility only.
22
+
23
+ ---
24
+
25
+ ## Models at a Glance
26
+
27
+ | Model | Status | File prefix | Val loss | Val acc |
28
+ |---|---|---|---|---|
29
+ | **GeoMatch v2** | ✅ **Recommended** | `geomatch_v2_*` | **1.594** | **0.695** |
30
+ | GeoMatch++ | ⚠️ Deprecated (built on v1 encoders) | `geomatch_pp_*` | 0.350 | 0.940 |
31
+ | GeoMatch v1 | ⚠️ Deprecated (corrupted keypoints) | `geomatch_final / checkpoint_epoch*` | 0.435 | 0.959 |
32
+
33
+ > The lower loss/higher accuracy of v1 and GeoMatch++ are an artefact of training on corrupted
34
+ > keypoints — the 2× scale inflated keypoint distances making the contact maps geometrically
35
+ > trivial to predict. v2 trains on correct geometry and is the only model that produces valid
36
+ > IK targets during grasp generation.
37
 
38
  ---
39
 
40
+ ## Architecture
41
+
42
+ ### GeoMatch (v1 and v2 share the same architecture)
43
 
44
+ Dual GCN encoder (object + robot surface) → L2-normalised embeddings → linear projection heads
45
+ (512→64) × 2 → 5 autoregressive MLP modules → per-keypoint BCE contact map prediction.
46
 
47
  > Based on: [*Geometry Matching for Multi-Embodiment Grasping*](https://openreview.net/forum?id=oyWkrG-LD5) (NeurIPS 2024)
48
 
49
  ### GeoMatch++
 
50
 
51
+ Extends GeoMatch with a **morphology encoder** (GCN over the robot kinematic-tree graph, 9D node
52
+ features, 32 nodes) and a **DCP-style cross-attention transformer** that fuses object geometry with
53
+ robot morphology before contact prediction. Pretrained GeoMatch v1 encoders are frozen.
54
 
55
+ > Based on: [*GeoMatch++: Morphology-Aware Grasping via Correspondence Learning*](https://arxiv.org/abs/2412.18998)
56
 
57
+ ### Component Comparison
58
 
59
+ | Component | GeoMatch v1 / v2 | GeoMatch++ |
60
  |---|---|---|
61
+ | Object GCN encoder | 3 layers × 256 → 512, trainable | Same, **frozen** (from GeoMatch v1) |
62
+ | Robot surface GCN | 3 layers × 256 → 512, trainable | Same, **frozen** (from GeoMatch v1) |
63
+ | Morphology encoder | — | **NEW** GCN(9 → 256×3 → 512), trainable |
64
  | Cross-attention | — | **NEW** DCP transformer (512-dim, 4 heads, 1 layer) |
65
  | Projection heads | Linear(512→64) × 2 | Same, re-initialised |
66
  | AR keypoint modules | 5× MLP | Same, re-initialised |
67
+ | **Total params** | **~1.9M** | **~6.4M (~5.8M trainable)** |
68
+
69
+ ---
70
+
71
+ ## What Changed in v2 (Keypoint Bug Fix)
72
+
73
+ GeoMatch requires a `robot_keypoints.json` that defines canonical 3D keypoint positions for each
74
+ robot in rest-pose world space. The v1 keypoints had two bugs:
75
+
76
+ **Bug 1 — 2× scale factor:** The generation script applied `world_pos *= 2.0`, citing
77
+ `HandModel`'s `hand_scale=2.0` class default. However, every actual call site passes
78
+ `hand_scale=1.0`, overriding that default. Because the scale was applied before the inverse-FK
79
+ projection that `HandModel.get_canonical_keypoints()` uses (`T⁻¹[2p;1] ≠ 2·T⁻¹[p;1]`), the
80
+ distortion was not uniform — it grew with each link's distance from the kinematic root, corrupting
81
+ both training labels and inference IK targets.
82
+
83
+ **Bug 2 — ShadowHand axis-swap at wrong stage:** The `[x, -z, y]` axis permutation for ShadowHand
84
+ was applied to the final world-space `world_pos` (after FK). The reference implementation
85
+ (`gripper_utils.py`) applies it to raw mesh points in link-local space *before* the visual-origin
86
+ transform. Rotation and axis permutation do not commute, so the wrong stage produced scrambled
87
+ keypoint positions for any ShadowHand link with a non-zero visual-origin rotation.
88
+
89
+ Both bugs were confirmed by comparing `generate_keypoints_json.py` against `gripper_utils.py` and
90
+ verified by observing that v1 ShadowHand tip keypoints had y-values of ~−0.84 m (outside any
91
+ physical hand envelope) versus the corrected ~0.01 m.
92
 
93
  ---
94
 
95
  ## Training Details
96
 
97
+ ### GeoMatch v2 ✅ (Recommended)
98
 
99
  | Setting | Value |
100
  |---|---|
101
+ | Dataset | CMapDataset (ContactDB + YCB), fixed keypoints |
 
102
  | End-effectors | EZGripper, Barrett, Robotiq 3-Finger, Allegro, ShadowHand |
103
  | Batch size | 256 |
104
  | Optimizer | Adam (β₁=0.9, β₂=0.99) |
105
  | Learning rate | 1e-4 |
106
  | Epochs | 200 |
107
  | Hardware | AMD Instinct MI300X (192 GB HBM3), ROCm 6.2.4 |
108
+ | Training time | 8.58 hours |
109
  | Precision | FP32 |
110
+ | **Final val loss** | **1.594** |
111
+ | **Final val accuracy** | **0.695** |
112
 
113
+ #### GeoMatch v2 Training Curves
114
+
115
+ | Epoch | Val Loss | Val Accuracy |
116
+ |---|---|---|
117
+ | 0 | 1.935 | 0.205 |
118
+ | 25 | 1.731 | 0.563 |
119
+ | 50 | 1.675 | 0.580 |
120
+ | 100 | 1.649 | 0.632 |
121
+ | 150 | 1.603 | 0.656 |
122
+ | 199 | 1.594 | 0.695 |
123
+
124
+ ---
125
+
126
+ ### GeoMatch++ ⚠️ (Deprecated — built on GeoMatch v1 encoders)
127
 
128
  | Setting | Value |
129
  |---|---|
130
+ | Initialisation | Pretrained **GeoMatch v1** encoders (frozen) |
131
  | Trainable params | ~5.8M |
132
  | Batch size | 32 per GPU × 8 GPUs = 256 effective |
133
  | Optimizer | Adam (β₁=0.9, β₂=0.99) |
 
136
  | Hardware | 8× AMD Instinct MI300X, ROCm 6.2.4 (DDP) |
137
  | Training time | ~2.8 hours |
138
  | Precision | FP32 |
139
+ | **Final val loss** | **0.350** *(artefact of corrupted training data)* |
140
+ | **Final val accuracy** | **0.940** *(artefact of corrupted training data)* |
141
 
142
+ #### GeoMatch++ Training Curves
143
 
144
  | Epoch | Val Loss | Val Accuracy |
145
  |---|---|---|
146
  | 0 | 0.465 | 0.999 |
147
  | 25 | 0.370 | 0.880 |
 
148
  | 89 | 0.362 | 0.902 |
 
 
149
  | 149 | 0.350 | 0.940 |
150
 
151
  ---
152
 
153
+ ### GeoMatch v1 ⚠️ (Deprecated — corrupted keypoints)
154
+
155
+ | Setting | Value |
156
+ |---|---|
157
+ | Dataset | CMapDataset (ContactDB + YCB), **corrupted keypoints** |
158
+ | Batch size | 256 |
159
+ | Optimizer | Adam (β₁=0.9, β₂=0.99) |
160
+ | Learning rate | 1e-4 |
161
+ | Epochs | 200 |
162
+ | Hardware | AMD Instinct MI300X (192 GB HBM3), ROCm 6.2.4 |
163
+ | Training time | 22.18 hours |
164
+ | Precision | FP32 |
165
+ | **Final val loss** | **0.435** *(artefact of corrupted training data)* |
166
+ | **Final val accuracy** | **0.959** *(artefact of corrupted training data)* |
167
+
168
+ ---
169
+
170
  ## Checkpoints
171
 
172
+ ### GeoMatch v2 ✅ (Use these)
173
+
174
+ | File | Epoch | Val Loss | Notes |
175
+ |---|---|---|---|
176
+ | `geomatch_v2_epoch50.pth` | 50 | 1.675 | Early convergence |
177
+ | `geomatch_v2_epoch100.pth` | 100 | 1.649 | Mid-training |
178
+ | `geomatch_v2_epoch150.pth` | 150 | 1.603 | Near-converged |
179
+ | `geomatch_v2_final.pth` | 199 | 1.594 | **Final model (recommended)** |
180
+
181
+ ### GeoMatch++ ⚠️ (Deprecated)
182
 
 
183
  | File | Epoch | Notes |
184
  |---|---|---|
185
  | `geomatch_pp_checkpoint_epoch50.pth` | 50 | Early convergence |
186
  | `geomatch_pp_checkpoint_epoch100.pth` | 100 | Mid-training |
187
  | `geomatch_pp_checkpoint_epoch140.pth` | 140 | Near-converged |
188
+ | `geomatch_pp_final.pth` | 149 | Final (deprecated) |
189
+
190
+ ### GeoMatch v1 ⚠️ (Deprecated)
191
+
192
+ | File | Epoch | Notes |
193
+ |---|---|---|
194
+ | `checkpoint_epoch50.pth` | 50 | Early convergence |
195
+ | `checkpoint_epoch100.pth` | 100 | Mid-training |
196
+ | `checkpoint_epoch150.pth` | 150 | Near-converged |
197
+ | `geomatch_final.pth` | 200 | Final (deprecated) |
198
 
199
  ---
200
 
201
  ## Usage
202
 
203
+ ### GeoMatch v2 (Recommended)
204
+
205
  ```python
206
  import torch, sys
207
  sys.path.append(".")
 
209
  from models.geomatch import GeoMatch
210
 
211
  model = GeoMatch(config).cuda()
212
+ model.load_state_dict(torch.load("geomatch_v2_final.pth", map_location="cuda"))
213
  model.eval()
214
 
215
  with torch.no_grad():
216
  contact_map, keypoint_probs = model(
217
+ obj_pc, # [B, 2048, 3] object point cloud
218
+ robot_pc, # [B, 6, 3] robot surface points (6 keypoints)
219
+ robot_key_point_idx, # [B, 6] keypoint indices into robot_pc
220
+ obj_adj, # [B, 2048, 2048] object adjacency (sparse COO)
221
+ robot_adj, # [B, 6, 6] robot adjacency
222
+ xyz_prev, # [B, 6, 3] previous keypoint positions
223
  )
224
+ # contact_map: [B, 2048, 6, 1] — per-object-point × per-keypoint contact probability
225
+ # keypoint_probs: [B, 2048, 5, 1] — autoregressive keypoint contact probabilities
226
  ```
227
 
228
+ ### GeoMatch++ (Deprecated — kept for reproducibility)
229
+
230
  ```python
231
  import torch, sys
232
  sys.path.append(".")
 
239
 
240
  with torch.no_grad():
241
  contact_map, keypoint_probs = model(
242
+ obj_pc, # [B, 2048, 3]
243
+ robot_pc, # [B, 6, 3]
244
+ robot_key_point_idx, # [B, 6]
245
+ obj_adj, # [B, 2048, 2048]
246
+ robot_adj, # [B, 6, 6]
247
+ xyz_prev, # [B, 6, 3]
248
  morph_features, # [B, 32, 9] morphology node features
249
  morph_adj, # [B, 32, 32] morphology adjacency
250
  )
 
 
251
  ```
252
 
253
+ Morphology graphs are pre-built per robot using `preprocess_morphology.py` → `gnn_morphology_new.pt`.
254
 
255
  ---
256
 
 
258
 
259
  ```
260
  models/
261
+ geomatch.py # GeoMatch model (shared by v1 and v2)
262
  geomatch_pp.py # GeoMatch++ model (+ morphology encoder + DCP transformer)
263
  gnn.py # Graph Convolutional Network
264
  mlp.py # MLP building block
265
+ config.py # Hyperparameters for all models
266
+ generate_keypoints_json.py # Fixed keypoint generator (used for v2 training data)
267
  ```
268
 
269
  ---
 
289
  ## License
290
 
291
  Original GeoMatch code © 2023 DeepMind Technologies Limited, licensed under the Apache License 2.0.
292
+ GeoMatch++ extension, v2 training, and all checkpoints produced by [Dimios45](https://huggingface.co/Dimios45) as part of the Graspmax project.