d4rt 0.0.1__tar.gz
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.
- d4rt-0.0.1/.gitignore +220 -0
- d4rt-0.0.1/LICENSE +21 -0
- d4rt-0.0.1/PKG-INFO +72 -0
- d4rt-0.0.1/README.md +26 -0
- d4rt-0.0.1/d4rt/__init__.py +1 -0
- d4rt-0.0.1/d4rt/d4rt.py +167 -0
- d4rt-0.0.1/pyproject.toml +68 -0
d4rt-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
*.sh
|
|
2
|
+
|
|
3
|
+
# Byte-compiled / optimized / DLL files
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[codz]
|
|
6
|
+
*$py.class
|
|
7
|
+
|
|
8
|
+
# C extensions
|
|
9
|
+
*.so
|
|
10
|
+
|
|
11
|
+
# Distribution / packaging
|
|
12
|
+
.Python
|
|
13
|
+
build/
|
|
14
|
+
develop-eggs/
|
|
15
|
+
dist/
|
|
16
|
+
downloads/
|
|
17
|
+
eggs/
|
|
18
|
+
.eggs/
|
|
19
|
+
lib/
|
|
20
|
+
lib64/
|
|
21
|
+
parts/
|
|
22
|
+
sdist/
|
|
23
|
+
var/
|
|
24
|
+
wheels/
|
|
25
|
+
share/python-wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
MANIFEST
|
|
30
|
+
|
|
31
|
+
# PyInstaller
|
|
32
|
+
# Usually these files are written by a python script from a template
|
|
33
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
34
|
+
*.manifest
|
|
35
|
+
*.spec
|
|
36
|
+
|
|
37
|
+
# Installer logs
|
|
38
|
+
pip-log.txt
|
|
39
|
+
pip-delete-this-directory.txt
|
|
40
|
+
|
|
41
|
+
# Unit test / coverage reports
|
|
42
|
+
htmlcov/
|
|
43
|
+
.tox/
|
|
44
|
+
.nox/
|
|
45
|
+
.coverage
|
|
46
|
+
.coverage.*
|
|
47
|
+
.cache
|
|
48
|
+
nosetests.xml
|
|
49
|
+
coverage.xml
|
|
50
|
+
*.cover
|
|
51
|
+
*.py.cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
cover/
|
|
55
|
+
|
|
56
|
+
# Translations
|
|
57
|
+
*.mo
|
|
58
|
+
*.pot
|
|
59
|
+
|
|
60
|
+
# Django stuff:
|
|
61
|
+
*.log
|
|
62
|
+
local_settings.py
|
|
63
|
+
db.sqlite3
|
|
64
|
+
db.sqlite3-journal
|
|
65
|
+
|
|
66
|
+
# Flask stuff:
|
|
67
|
+
instance/
|
|
68
|
+
.webassets-cache
|
|
69
|
+
|
|
70
|
+
# Scrapy stuff:
|
|
71
|
+
.scrapy
|
|
72
|
+
|
|
73
|
+
# Sphinx documentation
|
|
74
|
+
docs/_build/
|
|
75
|
+
|
|
76
|
+
# PyBuilder
|
|
77
|
+
.pybuilder/
|
|
78
|
+
target/
|
|
79
|
+
|
|
80
|
+
# Jupyter Notebook
|
|
81
|
+
.ipynb_checkpoints
|
|
82
|
+
|
|
83
|
+
# IPython
|
|
84
|
+
profile_default/
|
|
85
|
+
ipython_config.py
|
|
86
|
+
|
|
87
|
+
# pyenv
|
|
88
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
89
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
90
|
+
# .python-version
|
|
91
|
+
|
|
92
|
+
# pipenv
|
|
93
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
94
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
95
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
96
|
+
# install all needed dependencies.
|
|
97
|
+
# Pipfile.lock
|
|
98
|
+
|
|
99
|
+
# UV
|
|
100
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
101
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
102
|
+
# commonly ignored for libraries.
|
|
103
|
+
# uv.lock
|
|
104
|
+
|
|
105
|
+
# poetry
|
|
106
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
107
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
108
|
+
# commonly ignored for libraries.
|
|
109
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
110
|
+
# poetry.lock
|
|
111
|
+
# poetry.toml
|
|
112
|
+
|
|
113
|
+
# pdm
|
|
114
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
115
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
116
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
117
|
+
# pdm.lock
|
|
118
|
+
# pdm.toml
|
|
119
|
+
.pdm-python
|
|
120
|
+
.pdm-build/
|
|
121
|
+
|
|
122
|
+
# pixi
|
|
123
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
124
|
+
# pixi.lock
|
|
125
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
126
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
127
|
+
.pixi
|
|
128
|
+
|
|
129
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
130
|
+
__pypackages__/
|
|
131
|
+
|
|
132
|
+
# Celery stuff
|
|
133
|
+
celerybeat-schedule
|
|
134
|
+
celerybeat.pid
|
|
135
|
+
|
|
136
|
+
# Redis
|
|
137
|
+
*.rdb
|
|
138
|
+
*.aof
|
|
139
|
+
*.pid
|
|
140
|
+
|
|
141
|
+
# RabbitMQ
|
|
142
|
+
mnesia/
|
|
143
|
+
rabbitmq/
|
|
144
|
+
rabbitmq-data/
|
|
145
|
+
|
|
146
|
+
# ActiveMQ
|
|
147
|
+
activemq-data/
|
|
148
|
+
|
|
149
|
+
# SageMath parsed files
|
|
150
|
+
*.sage.py
|
|
151
|
+
|
|
152
|
+
# Environments
|
|
153
|
+
.env
|
|
154
|
+
.envrc
|
|
155
|
+
.venv
|
|
156
|
+
env/
|
|
157
|
+
venv/
|
|
158
|
+
ENV/
|
|
159
|
+
env.bak/
|
|
160
|
+
venv.bak/
|
|
161
|
+
|
|
162
|
+
# Spyder project settings
|
|
163
|
+
.spyderproject
|
|
164
|
+
.spyproject
|
|
165
|
+
|
|
166
|
+
# Rope project settings
|
|
167
|
+
.ropeproject
|
|
168
|
+
|
|
169
|
+
# mkdocs documentation
|
|
170
|
+
/site
|
|
171
|
+
|
|
172
|
+
# mypy
|
|
173
|
+
.mypy_cache/
|
|
174
|
+
.dmypy.json
|
|
175
|
+
dmypy.json
|
|
176
|
+
|
|
177
|
+
# Pyre type checker
|
|
178
|
+
.pyre/
|
|
179
|
+
|
|
180
|
+
# pytype static type analyzer
|
|
181
|
+
.pytype/
|
|
182
|
+
|
|
183
|
+
# Cython debug symbols
|
|
184
|
+
cython_debug/
|
|
185
|
+
|
|
186
|
+
# PyCharm
|
|
187
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
188
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
189
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
190
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
191
|
+
# .idea/
|
|
192
|
+
|
|
193
|
+
# Abstra
|
|
194
|
+
# Abstra is an AI-powered process automation framework.
|
|
195
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
196
|
+
# Learn more at https://abstra.io/docs
|
|
197
|
+
.abstra/
|
|
198
|
+
|
|
199
|
+
# Visual Studio Code
|
|
200
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
201
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
202
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
203
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
204
|
+
# .vscode/
|
|
205
|
+
# Temporary file for partial code execution
|
|
206
|
+
tempCodeRunnerFile.py
|
|
207
|
+
|
|
208
|
+
# Ruff stuff:
|
|
209
|
+
.ruff_cache/
|
|
210
|
+
|
|
211
|
+
# PyPI configuration file
|
|
212
|
+
.pypirc
|
|
213
|
+
|
|
214
|
+
# Marimo
|
|
215
|
+
marimo/_static/
|
|
216
|
+
marimo/_lsp/
|
|
217
|
+
__marimo__/
|
|
218
|
+
|
|
219
|
+
# Streamlit
|
|
220
|
+
.streamlit/secrets.toml
|
d4rt-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 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.
|
d4rt-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: d4rt
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Implementation of D4RT, Efficiently Reconstructing Dynamic Scenes
|
|
5
|
+
Project-URL: Homepage, https://pypi.org/project/d4rt/
|
|
6
|
+
Project-URL: Repository, https://codeberg.org/lucidrains/d4rt
|
|
7
|
+
Author-email: Phil Wang <lucidrains@gmail.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 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: 4d,artificial intelligence,deep learning
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
35
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
36
|
+
Requires-Python: >=3.10
|
|
37
|
+
Requires-Dist: einops>=0.8.1
|
|
38
|
+
Requires-Dist: einx>=0.4.3
|
|
39
|
+
Requires-Dist: torch-einops-utils>=0.0.32
|
|
40
|
+
Requires-Dist: torch>=2.5
|
|
41
|
+
Requires-Dist: x-transformers>=2.18.10
|
|
42
|
+
Provides-Extra: examples
|
|
43
|
+
Provides-Extra: test
|
|
44
|
+
Requires-Dist: pytest; extra == 'test'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
<img src="./d4rt.png" width="400px"></img>
|
|
48
|
+
|
|
49
|
+
## d4rt (wip)
|
|
50
|
+
|
|
51
|
+
Implementation of [D4RT](https://d4rt-paper.github.io/), Efficiently Reconstructing Dynamic Scenes, Deepmind
|
|
52
|
+
|
|
53
|
+
## citations
|
|
54
|
+
|
|
55
|
+
```bibtex
|
|
56
|
+
@article{zhang2025d4rt,
|
|
57
|
+
title = {Efficiently Reconstructing Dynamic Scenes One D4RT at a Time},
|
|
58
|
+
author = {Zhang, Chuhan and Le Moing, Guillaume and Koppula, Skanda and Rocco, Ignacio and Momeni, Liliane and Xie, Junyu and Sun, Shuyang and Sukthankar, Rahul and Barral, Jo{\"e}lle K. and Hadsell, Raia and Ghahramani, Zoubin and Zisserman, Andrew and Zhang, Junlin and Sajjadi, Mehdi S. M.},
|
|
59
|
+
journal = {arXiv preprint},
|
|
60
|
+
year = {2025}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```bibtex
|
|
65
|
+
@inproceedings{liu2026geometryaware,
|
|
66
|
+
title = {Geometry-aware 4D Video Generation for Robot Manipulation},
|
|
67
|
+
author = {Zeyi Liu and Shuang Li and Eric Cousineau and Siyuan Feng and Benjamin Burchfiel and Shuran Song},
|
|
68
|
+
booktitle = {The Fourteenth International Conference on Learning Representations},
|
|
69
|
+
year = {2026},
|
|
70
|
+
url = {https://openreview.net/forum?id=18gC6pZVVc}
|
|
71
|
+
}
|
|
72
|
+
```
|
d4rt-0.0.1/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<img src="./d4rt.png" width="400px"></img>
|
|
2
|
+
|
|
3
|
+
## d4rt (wip)
|
|
4
|
+
|
|
5
|
+
Implementation of [D4RT](https://d4rt-paper.github.io/), Efficiently Reconstructing Dynamic Scenes, Deepmind
|
|
6
|
+
|
|
7
|
+
## citations
|
|
8
|
+
|
|
9
|
+
```bibtex
|
|
10
|
+
@article{zhang2025d4rt,
|
|
11
|
+
title = {Efficiently Reconstructing Dynamic Scenes One D4RT at a Time},
|
|
12
|
+
author = {Zhang, Chuhan and Le Moing, Guillaume and Koppula, Skanda and Rocco, Ignacio and Momeni, Liliane and Xie, Junyu and Sun, Shuyang and Sukthankar, Rahul and Barral, Jo{\"e}lle K. and Hadsell, Raia and Ghahramani, Zoubin and Zisserman, Andrew and Zhang, Junlin and Sajjadi, Mehdi S. M.},
|
|
13
|
+
journal = {arXiv preprint},
|
|
14
|
+
year = {2025}
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```bibtex
|
|
19
|
+
@inproceedings{liu2026geometryaware,
|
|
20
|
+
title = {Geometry-aware 4D Video Generation for Robot Manipulation},
|
|
21
|
+
author = {Zeyi Liu and Shuang Li and Eric Cousineau and Siyuan Feng and Benjamin Burchfiel and Shuran Song},
|
|
22
|
+
booktitle = {The Fourteenth International Conference on Learning Representations},
|
|
23
|
+
year = {2026},
|
|
24
|
+
url = {https://openreview.net/forum?id=18gC6pZVVc}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from d4rt.d4rt import D4RT
|
d4rt-0.0.1/d4rt/d4rt.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import torch
|
|
4
|
+
from torch import nn
|
|
5
|
+
import torch.nn.functional as F
|
|
6
|
+
from torch.nn import Module, ModuleList, Sequential
|
|
7
|
+
|
|
8
|
+
from x_transformers import Encoder, CrossAttender, Attention, FeedForward
|
|
9
|
+
|
|
10
|
+
# ein notation
|
|
11
|
+
|
|
12
|
+
import einx
|
|
13
|
+
from einops import rearrange
|
|
14
|
+
from einops.layers.torch import Rearrange
|
|
15
|
+
from torch_einops_utils import pack_with_inverse
|
|
16
|
+
|
|
17
|
+
# helpers
|
|
18
|
+
|
|
19
|
+
def exists(v):
|
|
20
|
+
return v is not None
|
|
21
|
+
|
|
22
|
+
# video self attention encoder
|
|
23
|
+
|
|
24
|
+
class VideoEncoder(Module):
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
*,
|
|
28
|
+
dim,
|
|
29
|
+
depth,
|
|
30
|
+
image_size,
|
|
31
|
+
patch_size,
|
|
32
|
+
max_time_len,
|
|
33
|
+
channels = 3,
|
|
34
|
+
dim_head = 64,
|
|
35
|
+
heads = 8,
|
|
36
|
+
ff_glu = True,
|
|
37
|
+
attn_kwargs: dict = dict(),
|
|
38
|
+
ff_kwargs: dict = dict()
|
|
39
|
+
):
|
|
40
|
+
super().__init__()
|
|
41
|
+
|
|
42
|
+
dim_patch = channels * patch_size * patch_size
|
|
43
|
+
|
|
44
|
+
self.patch_to_tokens = Sequential(
|
|
45
|
+
Rearrange('b t c (h p1) (w p2) -> b t (h w) (p1 p2 c)', p1 = patch_size, p2 = patch_size),
|
|
46
|
+
nn.Linear(dim_patch, dim),
|
|
47
|
+
nn.LayerNorm(dim, bias = False)
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
self.layers = ModuleList([])
|
|
51
|
+
|
|
52
|
+
for _ in range(depth):
|
|
53
|
+
|
|
54
|
+
spatial_attn = Attention(dim = dim, dim_head = dim_head, heads = heads, **attn_kwargs)
|
|
55
|
+
|
|
56
|
+
time_attn = Attention(dim = dim, dim_head = dim_head, heads = heads, **attn_kwargs)
|
|
57
|
+
|
|
58
|
+
ff = FeedForward(dim = dim, glu = ff_glu, **ff_kwargs)
|
|
59
|
+
|
|
60
|
+
self.layers.append(ModuleList([spatial_attn, time_attn, ff]))
|
|
61
|
+
|
|
62
|
+
self.norm = nn.LayerNorm(dim, bias = False)
|
|
63
|
+
|
|
64
|
+
def forward(
|
|
65
|
+
self,
|
|
66
|
+
video # float[b t c h w]
|
|
67
|
+
): # float[b n d]
|
|
68
|
+
|
|
69
|
+
tokens = self.patch_to_tokens(video) # float[b t s d]
|
|
70
|
+
|
|
71
|
+
for spatial_attn, time_attn, ff in self.layers:
|
|
72
|
+
|
|
73
|
+
# space attn
|
|
74
|
+
|
|
75
|
+
tokens, inverse_pack = pack_with_inverse(tokens, '* s d')
|
|
76
|
+
|
|
77
|
+
tokens = spatial_attn(tokens) + tokens
|
|
78
|
+
|
|
79
|
+
tokens = inverse_pack(tokens)
|
|
80
|
+
|
|
81
|
+
# time attn
|
|
82
|
+
|
|
83
|
+
tokens = rearrange(tokens, 'b t s d -> b s t d')
|
|
84
|
+
|
|
85
|
+
tokens, inverse_pack = pack_with_inverse(tokens, '* t d')
|
|
86
|
+
|
|
87
|
+
tokens = time_attn(tokens) + tokens
|
|
88
|
+
|
|
89
|
+
tokens = inverse_pack(tokens)
|
|
90
|
+
|
|
91
|
+
tokens = rearrange(tokens, 'b s t d -> b t s d')
|
|
92
|
+
|
|
93
|
+
# feedforward
|
|
94
|
+
|
|
95
|
+
tokens = ff(tokens) + tokens
|
|
96
|
+
|
|
97
|
+
return self.norm(tokens)
|
|
98
|
+
|
|
99
|
+
# main class
|
|
100
|
+
|
|
101
|
+
class D4RT(Module):
|
|
102
|
+
def __init__(
|
|
103
|
+
self,
|
|
104
|
+
*,
|
|
105
|
+
dim,
|
|
106
|
+
video_image_size,
|
|
107
|
+
video_patch_size,
|
|
108
|
+
video_max_time_len,
|
|
109
|
+
enc_depth,
|
|
110
|
+
dec_depth,
|
|
111
|
+
enc_dim_head = 64,
|
|
112
|
+
enc_heads = 8,
|
|
113
|
+
dec_dim_head = 64,
|
|
114
|
+
dec_heads = 8,
|
|
115
|
+
video_enc_attn_kwargs: dict = dict(),
|
|
116
|
+
video_enc_ff_kwargs: dict = dict(),
|
|
117
|
+
cross_attender_kwargs: dict = dict()
|
|
118
|
+
):
|
|
119
|
+
super().__init__()
|
|
120
|
+
|
|
121
|
+
self.to_global_spatial_repr = VideoEncoder(
|
|
122
|
+
dim = dim,
|
|
123
|
+
depth = enc_depth,
|
|
124
|
+
dim_head = enc_dim_head,
|
|
125
|
+
heads = enc_heads,
|
|
126
|
+
image_size = video_image_size,
|
|
127
|
+
patch_size = video_patch_size,
|
|
128
|
+
max_time_len = video_max_time_len,
|
|
129
|
+
attn_kwargs = video_enc_attn_kwargs,
|
|
130
|
+
ff_kwargs = video_enc_ff_kwargs
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
self.cross_attender = CrossAttender(
|
|
134
|
+
dim = dim,
|
|
135
|
+
depth = dec_depth,
|
|
136
|
+
heads = dec_heads,
|
|
137
|
+
attn_dim_head = dec_dim_head,
|
|
138
|
+
**cross_attender_kwargs
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
self.to_pred = nn.Linear(dim, 3, bias = False)
|
|
142
|
+
|
|
143
|
+
def forward(
|
|
144
|
+
self,
|
|
145
|
+
video, # float[b t c h w]
|
|
146
|
+
queries, # float[b q d]
|
|
147
|
+
points = None, # float[b q 3]
|
|
148
|
+
return_pred = False
|
|
149
|
+
):
|
|
150
|
+
|
|
151
|
+
global_spatial_repr = self.to_global_spatial_repr(video)
|
|
152
|
+
|
|
153
|
+
global_spatial_repr, inverse_pack_spacetime = pack_with_inverse(global_spatial_repr, 'b * d')
|
|
154
|
+
|
|
155
|
+
queried = self.cross_attender(queries, context = global_spatial_repr)
|
|
156
|
+
|
|
157
|
+
pred = self.to_pred(queried)
|
|
158
|
+
|
|
159
|
+
if not exists(points):
|
|
160
|
+
return pred
|
|
161
|
+
|
|
162
|
+
loss = F.mse_loss(pred, points)
|
|
163
|
+
|
|
164
|
+
if not return_pred:
|
|
165
|
+
return loss
|
|
166
|
+
|
|
167
|
+
return loss, pred
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "d4rt"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Implementation of D4RT, Efficiently Reconstructing Dynamic Scenes"
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Phil Wang", email = "lucidrains@gmail.com" }
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">= 3.10"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
keywords = [
|
|
12
|
+
'artificial intelligence',
|
|
13
|
+
'deep learning',
|
|
14
|
+
'4d'
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
classifiers=[
|
|
18
|
+
'Development Status :: 4 - Beta',
|
|
19
|
+
'Intended Audience :: Developers',
|
|
20
|
+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
|
21
|
+
'License :: OSI Approved :: MIT License',
|
|
22
|
+
'Programming Language :: Python :: 3.10',
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
dependencies = [
|
|
26
|
+
"einx>=0.4.3",
|
|
27
|
+
"einops>=0.8.1",
|
|
28
|
+
"torch>=2.5",
|
|
29
|
+
"torch-einops-utils>=0.0.32",
|
|
30
|
+
"x-transformers>=2.18.10"
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://pypi.org/project/d4rt/"
|
|
35
|
+
Repository = "https://codeberg.org/lucidrains/d4rt"
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
examples = []
|
|
39
|
+
test = [
|
|
40
|
+
"pytest"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
pythonpath = [
|
|
45
|
+
"."
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[build-system]
|
|
49
|
+
requires = ["hatchling"]
|
|
50
|
+
build-backend = "hatchling.build"
|
|
51
|
+
|
|
52
|
+
[tool.rye]
|
|
53
|
+
managed = true
|
|
54
|
+
dev-dependencies = []
|
|
55
|
+
|
|
56
|
+
[tool.hatch.metadata]
|
|
57
|
+
allow-direct-references = true
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build]
|
|
60
|
+
include = [
|
|
61
|
+
"d4rt",
|
|
62
|
+
"pyproject.toml",
|
|
63
|
+
"README.md",
|
|
64
|
+
"LICENSE"
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
[tool.hatch.build.targets.wheel]
|
|
68
|
+
packages = ["d4rt"]
|