vizion3d 1.0.0__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.
- vizion3d-1.0.0/.gitignore +239 -0
- vizion3d-1.0.0/LICENSE +21 -0
- vizion3d-1.0.0/PKG-INFO +38 -0
- vizion3d-1.0.0/README.md +2 -0
- vizion3d-1.0.0/docs/api/lifting.md +27 -0
- vizion3d-1.0.0/docs/features/depth_estimation.md +290 -0
- vizion3d-1.0.0/docs/index.md +83 -0
- vizion3d-1.0.0/mkdocs.yml +29 -0
- vizion3d-1.0.0/pyproject.toml +100 -0
- vizion3d-1.0.0/tests/conftest.py +12 -0
- vizion3d-1.0.0/tests/test_depth_values.py +45 -0
- vizion3d-1.0.0/tests/test_facade.py +116 -0
- vizion3d-1.0.0/tests/test_hf.py +50 -0
- vizion3d-1.0.0/tests/test_lifting_defaults.py +44 -0
- vizion3d-1.0.0/tests/test_ply.py +55 -0
- vizion3d-1.0.0/vizion3d/__init__.py +1 -0
- vizion3d-1.0.0/vizion3d/core/__init__.py +0 -0
- vizion3d-1.0.0/vizion3d/core/container.py +27 -0
- vizion3d-1.0.0/vizion3d/core/cqrs.py +60 -0
- vizion3d-1.0.0/vizion3d/lifting/__init__.py +41 -0
- vizion3d-1.0.0/vizion3d/lifting/commands.py +44 -0
- vizion3d-1.0.0/vizion3d/lifting/defaults.py +65 -0
- vizion3d-1.0.0/vizion3d/lifting/depth_anything.py +194 -0
- vizion3d-1.0.0/vizion3d/lifting/handlers.py +247 -0
- vizion3d-1.0.0/vizion3d/lifting/models.py +44 -0
- vizion3d-1.0.0/vizion3d/lifting/utils.py +76 -0
- vizion3d-1.0.0/vizion3d/proto/__init__.py +0 -0
- vizion3d-1.0.0/vizion3d/proto/lifting.proto +30 -0
- vizion3d-1.0.0/vizion3d/proto/lifting_pb2.py +42 -0
- vizion3d-1.0.0/vizion3d/proto/lifting_pb2_grpc.py +97 -0
- vizion3d-1.0.0/vizion3d/py.typed +0 -0
- vizion3d-1.0.0/vizion3d/server/__init__.py +0 -0
- vizion3d-1.0.0/vizion3d/server/grpc/__init__.py +0 -0
- vizion3d-1.0.0/vizion3d/server/grpc/server.py +78 -0
- vizion3d-1.0.0/vizion3d/server/rest/__init__.py +0 -0
- vizion3d-1.0.0/vizion3d/server/rest/app.py +85 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
|
|
220
|
+
# ── vision3d project-specific ─────────────────────────────────────────────
|
|
221
|
+
|
|
222
|
+
# Claude Code
|
|
223
|
+
.claude/
|
|
224
|
+
|
|
225
|
+
# macOS
|
|
226
|
+
.DS_Store
|
|
227
|
+
|
|
228
|
+
# Model weight files (downloaded at runtime — not committed)
|
|
229
|
+
*.pth
|
|
230
|
+
*.pt
|
|
231
|
+
|
|
232
|
+
# Local scratch / output files
|
|
233
|
+
*.ply
|
|
234
|
+
image.png
|
|
235
|
+
image2.png
|
|
236
|
+
sample.py
|
|
237
|
+
|
|
238
|
+
# uv python pin (library — consumers choose their own Python)
|
|
239
|
+
.python-version
|
vizion3d-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MOSES OLAFENWA
|
|
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.
|
vizion3d-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vizion3d
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: U3D Capability and Intelligence for the real world.
|
|
5
|
+
Project-URL: Homepage, https://github.com/OlafenwaMoses/vizion3D
|
|
6
|
+
Project-URL: Documentation, https://olafenwamoses.github.io/vizion3D
|
|
7
|
+
Project-URL: Repository, https://github.com/OlafenwaMoses/vizion3D
|
|
8
|
+
Project-URL: Issues, https://github.com/OlafenwaMoses/vizion3D/issues
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: 3d,ai,artificial intelligence,computer-vision,depth-estimation,lidar,llm,mesh,nerf,point-cloud,reconstruction,slam
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Multimedia :: Graphics :: 3D Rendering
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Requires-Dist: clean-ioc>=1.3.0
|
|
24
|
+
Requires-Dist: fastapi>=0.115.0
|
|
25
|
+
Requires-Dist: grpcio-tools>=1.60.0
|
|
26
|
+
Requires-Dist: grpcio>=1.60.0
|
|
27
|
+
Requires-Dist: open3d>=0.18.0
|
|
28
|
+
Requires-Dist: pillow>=12.2.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Requires-Dist: python-multipart>=0.0.6
|
|
31
|
+
Requires-Dist: torch>=2.11.0
|
|
32
|
+
Requires-Dist: torchvision>=0.26.0
|
|
33
|
+
Requires-Dist: transformers>=5.6.2
|
|
34
|
+
Requires-Dist: uvicorn>=0.23.0
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# vizion3D
|
|
38
|
+
3D Capability and Intelligence for the real world.
|
vizion3d-1.0.0/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Lifting API Reference
|
|
2
|
+
|
|
3
|
+
The `lifting` module exposes tasks that convert 2D image data into 3D representations — depth maps, point clouds, and meshes.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## DepthEstimation
|
|
8
|
+
|
|
9
|
+
The primary entry point for the depth estimation task. Instantiate once and call `.run()` with a `DepthEstimationCommand`.
|
|
10
|
+
|
|
11
|
+
::: vizion3d.lifting.DepthEstimation
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## DepthEstimationCommand
|
|
16
|
+
|
|
17
|
+
Input contract for the depth estimation task. All inference parameters are declared here.
|
|
18
|
+
|
|
19
|
+
::: vizion3d.lifting.commands.DepthEstimationCommand
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## DepthEstimationResult
|
|
24
|
+
|
|
25
|
+
Output contract returned by `DepthEstimation.run()`. All fields are always present; optional geometry fields are `None` when the corresponding `return_*` flag was not set.
|
|
26
|
+
|
|
27
|
+
::: vizion3d.lifting.models.DepthEstimationResult
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# Depth Estimation
|
|
2
|
+
|
|
3
|
+
**Category:** Lifting (2D → 3D)
|
|
4
|
+
**Experimental:** No
|
|
5
|
+
|
|
6
|
+
Depth estimation predicts the per-pixel distance from the camera for every pixel in a 2D RGB image, producing a depth map and optionally unprojecting it into a 3D point cloud or surface mesh. vizion3d uses [Depth Anything V2](https://github.com/DepthAnything/Depth-Anything-V2) as its default backend.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Model backends
|
|
11
|
+
|
|
12
|
+
| Value | What happens |
|
|
13
|
+
|---|---|
|
|
14
|
+
| `"depth-anything/Depth-Anything-V2-Base-hf"` *(default)* | Downloads the vizion3D release checkpoint (`depth_anything_v2_vitb.pth`) to `~/.cache/vizion3d/models/` on first use, then loads it directly |
|
|
15
|
+
| Any other string | Passed through to Hugging Face `transformers.pipeline(task="depth-estimation", model=...)` |
|
|
16
|
+
| A local `.pth` or `.pt` file path | Loaded directly as a Depth Anything V2 checkpoint — never downloaded |
|
|
17
|
+
|
|
18
|
+
Models are kept in memory after the first inference in the current process. Subsequent calls to any `DepthEstimation` instance reuse the loaded weights.
|
|
19
|
+
|
|
20
|
+
Set `VISION3D_MODEL_CACHE` in your environment to change the default cache directory.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Command parameters
|
|
25
|
+
|
|
26
|
+
`DepthEstimationCommand` is the input contract for this task.
|
|
27
|
+
|
|
28
|
+
| Parameter | Type | Required | Default | Description |
|
|
29
|
+
|---|---|---|---|---|
|
|
30
|
+
| `image_input` | `str \| bytes` | **Yes** | — | Image to process. Pass a file path string or raw image bytes. |
|
|
31
|
+
| `model_backend` | `str` | No | `"depth-anything/Depth-Anything-V2-Base-hf"` | Model backend identifier. See [Model backends](#model-backends) above. |
|
|
32
|
+
| `return_depth_image` | `bool` | No | `False` | If `True`, the result includes a 16-bit grayscale Open3D Image of the depth map. |
|
|
33
|
+
| `return_point_cloud` | `bool` | No | `False` | If `True`, the result includes an Open3D PointCloud unprojected from the RGB-D image. |
|
|
34
|
+
| `return_mesh` | `bool` | No | `False` | If `True`, the result includes an Open3D TriangleMesh reconstructed from the point cloud via ball-pivoting. |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Result fields
|
|
39
|
+
|
|
40
|
+
`DepthEstimationResult` is the output contract for this task.
|
|
41
|
+
|
|
42
|
+
| Field | Type | Always present | Description |
|
|
43
|
+
|---|---|---|---|
|
|
44
|
+
| `depth_map` | `list[list[float]]` | Yes | Raw floating-point depth array, shape `[H][W]`. Values are relative (not metric) — closer objects have higher values for inverse-depth models. |
|
|
45
|
+
| `min_depth` | `float` | Yes | Minimum value in `depth_map`. |
|
|
46
|
+
| `max_depth` | `float` | Yes | Maximum value in `depth_map`. Guaranteed `max_depth >= min_depth`. |
|
|
47
|
+
| `backend_used` | `str` | Yes | Resolved model identifier that processed the request (local file path or HuggingFace model ID). |
|
|
48
|
+
| `depth_image` | `open3d.geometry.Image \| None` | When `return_depth_image=True` | 16-bit grayscale image, dtype `uint16`, shape `(H, W)`. The full 0–65535 range maps to `[min_depth, max_depth]`. |
|
|
49
|
+
| `point_cloud` | `open3d.geometry.PointCloud \| None` | When `return_point_cloud=True` | Coloured 3D point cloud unprojected from the RGB-D image using PrimeSense default intrinsics. Coordinates are in metres. |
|
|
50
|
+
| `mesh` | `open3d.geometry.TriangleMesh \| None` | When `return_mesh=True` | Triangle mesh surface reconstructed from the point cloud via ball-pivoting. Includes vertex colours. |
|
|
51
|
+
| `point_cloud_scale` | `float` | Yes | Scale factor: multiply any distance measured between two points in the point cloud by this value to get the equivalent distance in metres. Always `1.0` — Open3D produces point cloud coordinates directly in metres. |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 1. Direct Python import — image bytes
|
|
56
|
+
|
|
57
|
+
The most common usage: read an image file into bytes and dispatch the command.
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from vizion3d.lifting import DepthEstimation, DepthEstimationCommand
|
|
61
|
+
|
|
62
|
+
with open("scene.png", "rb") as f:
|
|
63
|
+
img_bytes = f.read()
|
|
64
|
+
|
|
65
|
+
cmd = DepthEstimationCommand(image_input=img_bytes)
|
|
66
|
+
result = DepthEstimation().run(cmd)
|
|
67
|
+
|
|
68
|
+
print(f"Depth map shape : {len(result.depth_map)} rows × {len(result.depth_map[0])} cols")
|
|
69
|
+
print(f"Depth range : {result.min_depth:.4f} → {result.max_depth:.4f}")
|
|
70
|
+
print(f"Backend used : {result.backend_used}")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 2. Direct Python import — file path
|
|
76
|
+
|
|
77
|
+
Pass a file path string instead of bytes; the handler opens it automatically.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from vizion3d.lifting import DepthEstimation, DepthEstimationCommand
|
|
81
|
+
|
|
82
|
+
cmd = DepthEstimationCommand(image_input="scene.png")
|
|
83
|
+
result = DepthEstimation().run(cmd)
|
|
84
|
+
|
|
85
|
+
print(f"Depth range: {result.min_depth:.4f} → {result.max_depth:.4f}")
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 3. Depth image (16-bit PNG)
|
|
91
|
+
|
|
92
|
+
Request a 16-bit grayscale Open3D Image of the depth map for visualization or downstream processing.
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import numpy as np
|
|
96
|
+
from PIL import Image as PILImage
|
|
97
|
+
from vizion3d.lifting import DepthEstimation, DepthEstimationCommand
|
|
98
|
+
|
|
99
|
+
cmd = DepthEstimationCommand(
|
|
100
|
+
image_input="scene.png",
|
|
101
|
+
return_depth_image=True,
|
|
102
|
+
)
|
|
103
|
+
result = DepthEstimation().run(cmd)
|
|
104
|
+
|
|
105
|
+
# result.depth_image is an open3d.geometry.Image (uint16)
|
|
106
|
+
depth_array = np.asarray(result.depth_image) # shape (H, W), dtype uint16
|
|
107
|
+
print(f"Depth image shape: {depth_array.shape}, dtype: {depth_array.dtype}")
|
|
108
|
+
|
|
109
|
+
# Save as 16-bit PNG via PIL
|
|
110
|
+
PILImage.fromarray(depth_array).save("depth.png")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 4. Point cloud
|
|
116
|
+
|
|
117
|
+
Request a coloured 3D point cloud unprojected from the RGB-D image. Distances between points are in metres (`point_cloud_scale == 1.0`).
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
import numpy as np
|
|
121
|
+
import open3d as o3d
|
|
122
|
+
from vizion3d.lifting import DepthEstimation, DepthEstimationCommand
|
|
123
|
+
|
|
124
|
+
cmd = DepthEstimationCommand(
|
|
125
|
+
image_input="scene.png",
|
|
126
|
+
return_point_cloud=True,
|
|
127
|
+
)
|
|
128
|
+
result = DepthEstimation().run(cmd)
|
|
129
|
+
|
|
130
|
+
pcd = result.point_cloud # open3d.geometry.PointCloud
|
|
131
|
+
points = np.asarray(pcd.points) # shape (N, 3), float64, in metres
|
|
132
|
+
colors = np.asarray(pcd.colors) # shape (N, 3), float64, range [0, 1]
|
|
133
|
+
|
|
134
|
+
print(f"Points : {len(points)}")
|
|
135
|
+
print(f"Scale : {result.point_cloud_scale} metre per unit")
|
|
136
|
+
|
|
137
|
+
# Measure real-world distance between two points
|
|
138
|
+
dist_metres = np.linalg.norm(points[0] - points[1]) * result.point_cloud_scale
|
|
139
|
+
print(f"Distance p0→p1: {dist_metres:.4f} m")
|
|
140
|
+
|
|
141
|
+
# Save as PLY
|
|
142
|
+
o3d.io.write_point_cloud("scene.ply", pcd)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 5. Surface mesh
|
|
148
|
+
|
|
149
|
+
Request a triangulated mesh reconstructed from the point cloud via ball-pivoting. Includes vertex colours.
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
import open3d as o3d
|
|
153
|
+
from vizion3d.lifting import DepthEstimation, DepthEstimationCommand
|
|
154
|
+
|
|
155
|
+
cmd = DepthEstimationCommand(
|
|
156
|
+
image_input="scene.png",
|
|
157
|
+
return_mesh=True,
|
|
158
|
+
)
|
|
159
|
+
result = DepthEstimation().run(cmd)
|
|
160
|
+
|
|
161
|
+
mesh = result.mesh # open3d.geometry.TriangleMesh
|
|
162
|
+
print(f"Vertices : {len(mesh.vertices)}")
|
|
163
|
+
print(f"Triangles : {len(mesh.triangles)}")
|
|
164
|
+
|
|
165
|
+
# Save as PLY
|
|
166
|
+
o3d.io.write_triangle_mesh("scene_mesh.ply", mesh)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 6. All outputs at once
|
|
172
|
+
|
|
173
|
+
All three optional outputs can be requested in a single inference pass.
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
import numpy as np
|
|
177
|
+
import open3d as o3d
|
|
178
|
+
from vizion3d.lifting import DepthEstimation, DepthEstimationCommand
|
|
179
|
+
|
|
180
|
+
cmd = DepthEstimationCommand(
|
|
181
|
+
image_input="scene.png",
|
|
182
|
+
return_depth_image=True,
|
|
183
|
+
return_point_cloud=True,
|
|
184
|
+
return_mesh=True,
|
|
185
|
+
)
|
|
186
|
+
result = DepthEstimation().run(cmd)
|
|
187
|
+
|
|
188
|
+
# Depth map
|
|
189
|
+
print(f"Depth range : {result.min_depth:.4f} → {result.max_depth:.4f}")
|
|
190
|
+
|
|
191
|
+
# 16-bit depth image
|
|
192
|
+
depth_arr = np.asarray(result.depth_image) # uint16 (H, W)
|
|
193
|
+
|
|
194
|
+
# Point cloud
|
|
195
|
+
pcd = result.point_cloud
|
|
196
|
+
o3d.io.write_point_cloud("scene.ply", pcd)
|
|
197
|
+
|
|
198
|
+
# Mesh
|
|
199
|
+
o3d.io.write_triangle_mesh("scene_mesh.ply", result.mesh)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 7. Custom model backend
|
|
205
|
+
|
|
206
|
+
Use any Hugging Face depth estimation model or a local `.pth` checkpoint.
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from vizion3d.lifting import DepthEstimation, DepthEstimationCommand
|
|
210
|
+
|
|
211
|
+
# Hugging Face model
|
|
212
|
+
cmd = DepthEstimationCommand(
|
|
213
|
+
image_input="scene.png",
|
|
214
|
+
model_backend="Intel/dpt-large",
|
|
215
|
+
)
|
|
216
|
+
result = DepthEstimation().run(cmd)
|
|
217
|
+
print(f"Backend: {result.backend_used}")
|
|
218
|
+
|
|
219
|
+
# Local checkpoint
|
|
220
|
+
cmd = DepthEstimationCommand(
|
|
221
|
+
image_input="scene.png",
|
|
222
|
+
model_backend="/models/depth_anything_v2_vitl.pth",
|
|
223
|
+
)
|
|
224
|
+
result = DepthEstimation().run(cmd)
|
|
225
|
+
print(f"Backend: {result.backend_used}")
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 8. REST API
|
|
231
|
+
|
|
232
|
+
Start the server:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
uv run task serve-rest
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Send a request with `multipart/form-data`:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
curl -X POST "http://localhost:8000/lifting/depth-estimation" \
|
|
242
|
+
-F "image=@scene.png" \
|
|
243
|
+
-F "return_point_cloud=true" \
|
|
244
|
+
-F "return_mesh=true"
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The response is a JSON-serialised `DepthEstimationResult`. Binary fields (`depth_image`, `point_cloud`, `mesh`) are base64-encoded in the JSON response.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 9. gRPC API
|
|
252
|
+
|
|
253
|
+
Start the server:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
uv run task serve-grpc
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Call from any gRPC client using the generated stubs:
|
|
260
|
+
|
|
261
|
+
```python
|
|
262
|
+
import grpc
|
|
263
|
+
from vizion3d.proto import lifting_pb2, lifting_pb2_grpc
|
|
264
|
+
|
|
265
|
+
channel = grpc.insecure_channel("localhost:50051")
|
|
266
|
+
stub = lifting_pb2_grpc.LiftingServiceStub(channel)
|
|
267
|
+
|
|
268
|
+
with open("scene.png", "rb") as f:
|
|
269
|
+
img_bytes = f.read()
|
|
270
|
+
|
|
271
|
+
request = lifting_pb2.DepthEstimationRequest(
|
|
272
|
+
image_bytes=img_bytes,
|
|
273
|
+
return_point_cloud=True,
|
|
274
|
+
return_mesh=True,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
response = stub.RunDepthEstimation(request)
|
|
278
|
+
print(f"Min depth : {response.min_depth}")
|
|
279
|
+
print(f"Max depth : {response.max_depth}")
|
|
280
|
+
print(f"Backend : {response.backend_used}")
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Known limitations
|
|
286
|
+
|
|
287
|
+
- **Relative depth only** — the default monocular backend produces relative (inverse) depth, not metric depth. Point cloud distances are internally consistent but not calibrated to real-world scale without a known reference distance.
|
|
288
|
+
- **Fixed camera intrinsics** — point cloud unprojection uses `PrimeSenseDefault` (640×480) intrinsics regardless of input image resolution. For accurate metric geometry, supply real camera intrinsics.
|
|
289
|
+
- **Ball-pivoting mesh quality** — the mesh reconstructor works best on dense, evenly sampled point clouds. Sparse or noisy clouds may produce gaps or missing faces.
|
|
290
|
+
- **Python 3.12 required for Open3D** — `return_depth_image`, `return_point_cloud`, and `return_mesh` require Open3D, which currently only supports Python 3.12 in this project.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# vizion3d
|
|
2
|
+
|
|
3
|
+
**vizion3d** is an open-source Python library for 3D computer vision that gives ML/CV researchers a single, unified interface for running inference across the full spectrum of 3D vision tasks — from depth estimation and point cloud generation to NeRF reconstruction and pose estimation.
|
|
4
|
+
|
|
5
|
+
Every task is accessible through three consumption modes driven by one shared CQRS architecture:
|
|
6
|
+
|
|
7
|
+
| Mode | When to use |
|
|
8
|
+
|---|---|
|
|
9
|
+
| **Direct Python import** | Notebooks, research scripts, local prototyping |
|
|
10
|
+
| **REST API** | Web integrations, any-language clients |
|
|
11
|
+
| **gRPC API** | High-throughput, low-latency microservice pipelines |
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Requires **Python 3.12** (Open3D constraint).
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv python pin 3.12
|
|
21
|
+
uv sync
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Quick start — depth estimation
|
|
27
|
+
|
|
28
|
+
Get a depth map, point cloud, and mesh from a single image in under 10 lines.
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import open3d as o3d
|
|
32
|
+
from vizion3d.lifting import DepthEstimation, DepthEstimationCommand
|
|
33
|
+
|
|
34
|
+
result = DepthEstimation().run(
|
|
35
|
+
DepthEstimationCommand(
|
|
36
|
+
image_input="scene.png",
|
|
37
|
+
return_point_cloud=True,
|
|
38
|
+
return_mesh=True,
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
print(f"Depth range : {result.min_depth:.4f} → {result.max_depth:.4f}")
|
|
43
|
+
print(f"Points : {len(result.point_cloud.points)}")
|
|
44
|
+
print(f"Scale : {result.point_cloud_scale} metre per unit")
|
|
45
|
+
|
|
46
|
+
o3d.io.write_point_cloud("scene.ply", result.point_cloud)
|
|
47
|
+
o3d.io.write_triangle_mesh("scene_mesh.ply", result.mesh)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Starting the servers
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# REST API (FastAPI, default port 8000)
|
|
56
|
+
uv run task serve-rest
|
|
57
|
+
|
|
58
|
+
# gRPC API (default port 50051)
|
|
59
|
+
uv run task serve-grpc
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Architecture
|
|
65
|
+
|
|
66
|
+
vizion3d uses a [CQRS](https://martinfowler.com/bliki/CQRS.html) pattern throughout:
|
|
67
|
+
|
|
68
|
+
- **Commands** carry inference parameters and trigger side-effecting handlers.
|
|
69
|
+
- **Queries** retrieve results or metadata without side effects.
|
|
70
|
+
- All handlers are registered through a [`clean_ioc`](https://github.com/peter-daly/clean-ioc) container — no direct handler instantiation anywhere in the public API.
|
|
71
|
+
|
|
72
|
+
Each task lives in its own module under `vizion3d/<category>/` and exposes exactly `commands.py`, `handlers.py`, and `models.py`. Adding a new task means adding one module and one container registration — nothing else changes.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Tasks
|
|
77
|
+
|
|
78
|
+
### Lifting (2D → 3D)
|
|
79
|
+
|
|
80
|
+
| Task | Status | Docs |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| Monocular depth estimation | Stable | [Depth Estimation](features/depth_estimation.md) |
|
|
83
|
+
|