Skip to content

Commit b332313

Browse files
Merge pull request #55 from OlafenwaMoses/moses/vizion3d-playground
auto cache of reconstruction bundle
2 parents f98ee99 + 11cb591 commit b332313

8 files changed

Lines changed: 114 additions & 97 deletions

File tree

.github/workflows/apisec-scan.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.
353 KB
Loading
107 KB
Loading

docs/reconstruction/object_3d_reconstruction.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,16 @@ The task resolves the reconstruction runtime asset bundle from:
158158

159159
1. the explicit `model_bundle` command field;
160160
2. `VIZION3D_RECONSTRUCTION_MODEL_BUNDLE`;
161-
3. the repository root;
162-
4. `~/.cache/vizion3d/models`.
161+
3. `~/.cache/vizion3d/models`;
162+
4. the repository root;
163+
5. the default `essentials-v1` GitHub release asset URL.
163164

164-
The bundle is extracted into the cache directory before reconstruction. It
165-
contains the runtime assets needed for foreground isolation, mesh generation,
166-
and optional accelerated execution.
165+
If no local bundle exists, the default release asset is downloaded and cached
166+
before extraction. The bundle contains the runtime assets needed for foreground
167+
isolation, mesh generation, and optional accelerated execution.
168+
169+
Direct download:
170+
[scene-components-3d-models.zip](https://github.com/OlafenwaMoses/vizion3D/releases/download/essentials-v1/scene-components-3d-models.zip)
167171

168172
## Python Usage
169173

docs/reconstruction/scene_components_3d_reconstruction.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,11 @@ The task applies these processing stages to the input image:
177177

178178
The reconstruction runtime asset bundle is resolved the same way as
179179
`Object3DReconstruction`: explicit `model_bundle`,
180-
`VIZION3D_RECONSTRUCTION_MODEL_BUNDLE`, repository root, then
181-
`~/.cache/vizion3d/models`.
180+
`VIZION3D_RECONSTRUCTION_MODEL_BUNDLE`, `~/.cache/vizion3d/models`,
181+
repository root, then the default `essentials-v1` GitHub release asset URL.
182+
183+
Direct download:
184+
[scene-components-3d-models.zip](https://github.com/OlafenwaMoses/vizion3D/releases/download/essentials-v1/scene-components-3d-models.zip)
182185

183186
## Python Usage
184187

tests/unit/test_reconstruction.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
SceneComponents3DReconstructionCommand,
2727
SceneComponents3DReconstructionConfig,
2828
)
29-
from vizion3d.reconstruction.defaults import extract_model_bundle
29+
from vizion3d.reconstruction.defaults import extract_model_bundle, resolve_model_bundle
3030
from vizion3d.reconstruction.handlers import (
3131
Object3DReconstructionHandler,
3232
SceneComponents3DReconstructionHandler,
@@ -69,6 +69,28 @@ def _result(point_count=12):
6969
)
7070

7171

72+
def test_reconstruction_model_bundle_auto_downloads_default_when_missing(tmp_path, monkeypatch):
73+
monkeypatch.delenv("VIZION3D_RECONSTRUCTION_MODEL_BUNDLE", raising=False)
74+
monkeypatch.setenv("VIZION3D_MODEL_CACHE", str(tmp_path / "cache"))
75+
monkeypatch.setattr(
76+
"vizion3d.reconstruction.defaults.Path.is_file",
77+
lambda path: False,
78+
)
79+
seen = {}
80+
81+
def download(url, destination):
82+
seen["url"] = url
83+
destination.parent.mkdir(parents=True, exist_ok=True)
84+
destination.write_bytes(b"zip")
85+
86+
monkeypatch.setattr("vizion3d.reconstruction.defaults._download", download)
87+
88+
bundle = resolve_model_bundle()
89+
90+
assert seen["url"].endswith("/scene-components-3d-models.zip")
91+
assert bundle == tmp_path / "cache" / "scene-components-3d-models.zip"
92+
93+
7294
def test_extract_model_bundle_validates_and_caches_tiny_zip(tmp_path, monkeypatch):
7395
bundle = tmp_path / "models.zip"
7496
with zipfile.ZipFile(bundle, "w") as archive:

uv.lock

Lines changed: 69 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vizion3d/reconstruction/defaults.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
from pathlib import Path
1313

1414
MODEL_BUNDLE_FILENAME = "scene-components-3d-models.zip"
15+
DEFAULT_MODEL_BUNDLE_URL = (
16+
"https://github.com/OlafenwaMoses/vizion3D/releases/download/"
17+
f"essentials-v1/{MODEL_BUNDLE_FILENAME}"
18+
)
1519
_BUNDLE_LOCK = threading.Lock()
1620

1721

@@ -22,15 +26,17 @@ def model_cache_dir() -> Path:
2226
return Path.home() / ".cache" / "vizion3d" / "models"
2327

2428

25-
def default_model_bundle() -> Path:
29+
def default_model_bundle() -> str | Path:
2630
configured = os.environ.get("VIZION3D_RECONSTRUCTION_MODEL_BUNDLE")
2731
if configured:
2832
return Path(configured).expanduser()
2933
cached = model_cache_dir() / MODEL_BUNDLE_FILENAME
3034
if cached.is_file():
3135
return cached
3236
checkout = Path(__file__).resolve().parents[2] / MODEL_BUNDLE_FILENAME
33-
return checkout
37+
if checkout.is_file():
38+
return checkout
39+
return DEFAULT_MODEL_BUNDLE_URL
3440

3541

3642
def _download(url: str, destination: Path) -> None:

0 commit comments

Comments
 (0)