Dex1B 0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Dex1B/Dex1B.py ADDED
@@ -0,0 +1,116 @@
1
+ import torch
2
+ from torch import cdist
3
+ from torch.nn import Module, ModuleList
4
+
5
+ from x_transformers import Encoder
6
+
7
+ from x_mlps_pytorch import MLP
8
+
9
+ import einx
10
+ from einops import rearrange
11
+
12
+ # helpers
13
+
14
+ def exists(v):
15
+ return v is not None
16
+
17
+ def default(v, d):
18
+ return v if exists(v) else d
19
+
20
+ # losses
21
+
22
+ def simple_sdf_loss(
23
+ surface_points, # (b n 3)
24
+ hand_points, # (b m 3)
25
+ hand_point_radius, # (b m)
26
+ mask = None # (b n) | none
27
+ ):
28
+ """
29
+ add their simple penetration loss in section IV
30
+ """
31
+
32
+ dist = cdist(hand_points, surface_points)
33
+
34
+ hand_to_all_surface = einx.subtract('b m, b m n', hand_point_radius, dist).relu() # max(0, radius - dist)
35
+
36
+ if exists(mask):
37
+ mask_value = torch.finfo(hand_to_all_surface.dtype).max
38
+ hand_to_all_surface = einx.where('b n, b m n,', mask, hand_to_all_surface, mask_value)
39
+
40
+ hand_to_closest_dist = hand_to_all_surface.amin(dim = -1)
41
+
42
+ return hand_to_closest_dist.sum()
43
+
44
+ # classes
45
+
46
+ class PointTransformer(Module):
47
+ """ https://arxiv.org/abs/2312.10035v1 """
48
+
49
+ def __init__(self):
50
+ super().__init__()
51
+
52
+ class CVAE(Module):
53
+ def __init__(
54
+ self,
55
+ dim,
56
+ dim_hiddens = (256, 512, 256), # from Table 6. in paper
57
+ kl_loss_weight = 1e-4
58
+ ):
59
+ super().__init__()
60
+ assert len(dim_hiddens) > 0
61
+ dim_latent = default_layer_sizes[-1]
62
+
63
+ self.encode = MLP(dim, *default_layer_sizes)
64
+
65
+ self.to_mean_log_variance = nn.Linear(dim_latent, dim_latent * 2, bias = False)
66
+
67
+ self.decode = MLP(*default_layer_sizes, dim)
68
+
69
+ # loss weights
70
+
71
+ self.kl_loss_weight = kl_loss_weight
72
+
73
+ def forward(
74
+ self,
75
+ inp, # (b d)
76
+ return_loss = False
77
+ ):
78
+
79
+ encoded = self.encode(inp)
80
+
81
+ mean, log_variance = self.to_mean_log_variance(encoded).chunk(2, dim = -1)
82
+
83
+ std = (0.5 * log_variance).exp()
84
+
85
+ noise = torch.randn_like(mean)
86
+
87
+ reparamed = mean + std * noise
88
+
89
+ recon = self.decode(reparamed)
90
+
91
+ if not return_loss:
92
+ return recon
93
+
94
+ mse_loss = F.mse_loss(recon, inp)
95
+
96
+ kl_loss = 0.5 * (mean.square() + log_variance.exp() - log_variance - 1.).sum(dim = -1).mean()
97
+
98
+ total_loss = (
99
+ mse_loss +
100
+ kl_loss * self.kl_loss_weight
101
+ )
102
+
103
+ loss_breakdown = (mse_loss, kl_loss)
104
+
105
+ return total_loss, loss_breakdown
106
+
107
+ class DexSimple(Module):
108
+ def __init__(
109
+ self,
110
+ point_transformer: PointTransformer,
111
+ cvae: CVAE
112
+ ):
113
+ super().__init__()
114
+
115
+ self.pointnet = pointnet
116
+ self.cvae = cvae
Dex1B/__init__.py ADDED
File without changes
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: Dex1B
3
+ Version: 0.0.2
4
+ Summary: MMDiT
5
+ Project-URL: Homepage, https://pypi.org/project/Dex1B/
6
+ Project-URL: Repository, https://github.com/lucidrains/Dex1B
7
+ Author-email: Phil Wang <lucidrains@gmail.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 Phil Wang
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Keywords: artificial intelligence,deep learning,dexterity,scaling,synthetic data
31
+ Classifier: Development Status :: 4 - Beta
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3.9
35
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
36
+ Requires-Python: >=3.9
37
+ Requires-Dist: einops>=0.8.0
38
+ Requires-Dist: gotennet-pytorch>=0.3.1
39
+ Requires-Dist: torch>=2.0
40
+ Requires-Dist: x-mlps-pytorch
41
+ Requires-Dist: x-transformers>=2.5.3
42
+ Provides-Extra: examples
43
+ Provides-Extra: test
44
+ Requires-Dist: pytest; extra == 'test'
45
+ Description-Content-Type: text/markdown
46
+
47
+ <img src="./fig3.png" width="400px"></img>
48
+
49
+ ## Dex1B (wip)
50
+
51
+ ## Citations
52
+
53
+ ```bibtex
54
+ @inproceedings{ye2025dex1b,
55
+ title = {Dex1B: Learning with 1B Demonstrations for Dexterous Manipulation},
56
+ author = {Ye, Jianglong and Wang, Keyi and Yuan, Chengjing and Yang, Ruihan and Li, Yiquan and Zhu, Jiyue and Qin, Yuzhe and Zou, Xueyan and Wang, Xiaolong},
57
+ booktitle = {Robotics: Science and Systems (RSS)},
58
+ year = {2025}
59
+ }
60
+ ```
61
+
62
+ ```bibtex
63
+ @misc{wu2024pointtransformerv3simpler,
64
+ title = {Point Transformer V3: Simpler, Faster, Stronger},
65
+ author = {Xiaoyang Wu and Li Jiang and Peng-Shuai Wang and Zhijian Liu and Xihui Liu and Yu Qiao and Wanli Ouyang and Tong He and Hengshuang Zhao},
66
+ year = {2024},
67
+ eprint = {2312.10035},
68
+ archivePrefix = {arXiv},
69
+ primaryClass = {cs.CV},
70
+ url = {https://arxiv.org/abs/2312.10035},
71
+ }
72
+ ```
@@ -0,0 +1,6 @@
1
+ Dex1B/Dex1B.py,sha256=qpX5BNxLs5LUoWJZRZOW4oK_bxnkJxoYiqPKNOSWunI,2633
2
+ Dex1B/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ dex1b-0.0.2.dist-info/METADATA,sha256=QZ4MIlr2vflOZsHOAd7iLF7eou-NYNALDXF2qCZwR_8,3007
4
+ dex1b-0.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ dex1b-0.0.2.dist-info/licenses/LICENSE,sha256=1yCiA9b5nhslTavxPjsQAO-wpOnwJR9-l8LTVi7GJuk,1066
6
+ dex1b-0.0.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Phil Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.