euler-inference 2.4.0__tar.gz → 2.5.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.
Files changed (24) hide show
  1. {euler_inference-2.4.0 → euler_inference-2.5.0}/PKG-INFO +1 -1
  2. {euler_inference-2.4.0 → euler_inference-2.5.0}/README.md +8 -3
  3. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/_outputs.py +117 -6
  4. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/config.py +2 -2
  5. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference.egg-info/PKG-INFO +1 -1
  6. {euler_inference-2.4.0 → euler_inference-2.5.0}/pyproject.toml +1 -1
  7. {euler_inference-2.4.0 → euler_inference-2.5.0}/tests/test_writer_integration.py +154 -0
  8. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/__init__.py +0 -0
  9. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/__main__.py +0 -0
  10. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/api.py +0 -0
  11. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/inference.py +0 -0
  12. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/model_card.py +0 -0
  13. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/models/__init__.py +0 -0
  14. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference/models/external_model.py +0 -0
  15. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference.egg-info/SOURCES.txt +0 -0
  16. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference.egg-info/dependency_links.txt +0 -0
  17. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference.egg-info/entry_points.txt +0 -0
  18. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference.egg-info/requires.txt +0 -0
  19. {euler_inference-2.4.0 → euler_inference-2.5.0}/euler_inference.egg-info/top_level.txt +0 -0
  20. {euler_inference-2.4.0 → euler_inference-2.5.0}/setup.cfg +0 -0
  21. {euler_inference-2.4.0 → euler_inference-2.5.0}/tests/test_intrinsics_resolution.py +0 -0
  22. {euler_inference-2.4.0 → euler_inference-2.5.0}/tests/test_model_card.py +0 -0
  23. {euler_inference-2.4.0 → euler_inference-2.5.0}/tests/test_model_metadata.py +0 -0
  24. {euler_inference-2.4.0 → euler_inference-2.5.0}/tests/test_save_path.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: euler-inference
3
- Version: 2.4.0
3
+ Version: 2.5.0
4
4
  Summary: Modality-agnostic inference pipeline using euler-loading
5
5
  Author-email: Daniel Rothenpieler <rothenpielerdaniel@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -104,6 +104,8 @@ Models can declare class-level attributes so pipelines don't need to know model
104
104
  class Model:
105
105
  OUTPUTS = [
106
106
  {"key": "depth", "type": "npy"},
107
+ # Dense 3D point map in (3, H, W) layout:
108
+ # {"key": "points_3d", "type": "npy"},
107
109
  {"key": "confidence", "type": "png"},
108
110
  ]
109
111
 
@@ -281,7 +283,7 @@ For simpler setups without placeholders, use a monolithic JSON config:
281
283
  | `dataset.hierarchical_modalities` | object | No | Map of hierarchical modality names to paths or structured entries |
282
284
  | `outputs` | list | No | What to save from the model's output dict. Defaults to the model's `OUTPUTS`, else `[{"key": "depth", "type": "npy"}]` with the default `_depth` suffix. |
283
285
  | `outputs[].key` | string | Yes | Key in the dict returned by `Model.predict()` |
284
- | `outputs[].type` | string | Yes | Legacy file format: `npy`, `png`, `jpg`, `jpeg`, `exr`. Used when no source-backed writer is available. |
286
+ | `outputs[].type` | string | Yes | Legacy file format: `npy`, `npz`, `png`, `jpg`, `jpeg`, `exr`. Used when no source-backed writer is available. |
285
287
  | `outputs[].suffix` | string | No | Legacy filename suffix before extension. Defaults to `_<key>`. Ignored for source-backed outputs. |
286
288
  | `outputs[].source_modality` | string | No | Regular input modality whose `euler-loading` writer/path should be mirrored under `output_base_path/<key>/`. Defaults to `key` when it matches a regular input modality. |
287
289
  | `outputs[].writer` | object | No | Override ds-crawler writer metadata for legacy outputs (see [Writer metadata](#writer-metadata)) |
@@ -445,6 +447,8 @@ output_base_path/
445
447
 
446
448
  If `outputs[].source_modality` is set explicitly but the named modality is missing, or no `euler-loading` writer is available for it, inference fails instead of silently falling back.
447
449
 
450
+ `points_3d` is a built-in legacy output modality. Configure it as `{"key": "points_3d", "type": "npy"}` or `{"key": "points_3d", "type": "npz"}` and return a float-compatible array with shape `(3, H, W)`. The output dataset is indexed with `euler_loading.loader = "generic"` and `euler_loading.function = "points_3d"`, so recent `euler-loading` versions can read it without an explicit loader.
451
+
448
452
  ### Pipeline Manifest
449
453
 
450
454
  When `pipeline.outputs_manifest_path` is set and at least one configured output has a matching pipeline target, finalization writes a manifest like this:
@@ -477,7 +481,7 @@ Legacy outputs are written via ds-crawler's `DatasetWriter`/`ZipDatasetWriter`,
477
481
  | `name` | Input dataset's name (from its `output.json`), or the output key if unavailable | `outputs[].writer.name` |
478
482
  | `type` | Output key (e.g. `"depth"`) | `outputs[].writer.type` |
479
483
  | `euler_train` | `{"used_as": "target", "modality_type": "<key>"}` | `outputs[].writer.euler_train` |
480
- | `euler_loading` | *(omitted)* | `outputs[].writer.euler_loading` |
484
+ | `euler_loading` | *(omitted; `points_3d` defaults to `{"loader": "generic", "function": "points_3d"}`)* | `outputs[].writer.euler_loading` |
481
485
  | `separator` | `null` | — |
482
486
  | `meta` | *(omitted)* | `outputs[].writer.meta` |
483
487
 
@@ -485,7 +489,7 @@ In `--no-strict` mode, `modality_type` defaults to `"other"` instead of the outp
485
489
 
486
490
  #### `euler_loading`
487
491
 
488
- When the output dataset should be loadable by [euler-loading](https://github.com/d-rothen/euler-loading) without an explicit loader, set `euler_loading` with the `loader` (module name) and `function` (callable name) that euler-loading should use to auto-resolve a loader from the output's `output.json`. Available loaders: `vkitti2`, `real_drive_sim`, `generic_dense_depth`.
492
+ When the output dataset should be loadable by [euler-loading](https://github.com/d-rothen/euler-loading) without an explicit loader, set `euler_loading` with the `loader` (module name) and `function` (callable name) that euler-loading should use to auto-resolve a loader from the output's `output.json`. Available loaders include `vkitti2`, `real_drive_sim`, `generic`, and `generic_dense_depth`.
489
493
 
490
494
  You can also include `used_as`, `modality_type`, `slot`, and `task` — these are consulted by euler-loading's `describe_for_runlog()` for experiment metadata.
491
495
 
@@ -513,6 +517,7 @@ Example with explicit writer overrides:
513
517
  | Format | Extension | Notes |
514
518
  |--------|-----------|-------|
515
519
  | NumPy | `npy` | Preserves full float precision |
520
+ | NumPy archive | `npz` | Compressed NumPy archive with array key `data` |
516
521
  | PNG | `png` | Float arrays clipped to [0,1] and scaled to uint8. Supports grayscale, RGB, RGBA. |
517
522
  | JPEG | `jpg`/`jpeg` | Same as PNG but lossy. |
518
523
  | OpenEXR | `exr` | Full float precision. Requires `pip install OpenEXR`. Not supported in zip mode. |
@@ -18,6 +18,14 @@ from euler_inference.config import (
18
18
 
19
19
  PIPELINE_OUTPUTS_MANIFEST_VERSION = 1
20
20
 
21
+ _NUMPY_OUTPUT_TYPES = {"npy", "npz"}
22
+ _LOADABLE_LEGACY_OUTPUTS = {
23
+ "points_3d": {
24
+ "euler_loading": {"loader": "generic", "function": "points_3d"},
25
+ "output_types": _NUMPY_OUTPUT_TYPES,
26
+ },
27
+ }
28
+
21
29
 
22
30
  def get_save_path(output_base: Path, full_id: str, suffix: str, extension: str) -> Path:
23
31
  """
@@ -100,7 +108,7 @@ def save_output(data: np.ndarray, target: Path | IO[bytes], output_type: str) ->
100
108
  Args:
101
109
  data: numpy array to save
102
110
  target: Path to save to, or a writable file-like object (for zip streaming)
103
- output_type: File format ("npy", "png", "jpg", "jpeg", "exr")
111
+ output_type: File format ("npy", "npz", "png", "jpg", "jpeg", "exr")
104
112
 
105
113
  Raises:
106
114
  ValueError: If output_type is not supported
@@ -112,6 +120,10 @@ def save_output(data: np.ndarray, target: Path | IO[bytes], output_type: str) ->
112
120
  np.save(target, data)
113
121
  return
114
122
 
123
+ if output_type == "npz":
124
+ np.savez_compressed(target, data=data)
125
+ return
126
+
115
127
  if output_type in ("png", "jpg", "jpeg"):
116
128
  _save_image_output(data, target, output_type)
117
129
  return
@@ -125,6 +137,88 @@ def save_output(data: np.ndarray, target: Path | IO[bytes], output_type: str) ->
125
137
  raise ValueError(f"Unsupported output type: {output_type}")
126
138
 
127
139
 
140
+ def _get_writer_modality_type(
141
+ output_config: OutputConfig,
142
+ writer_meta: dict[str, Any],
143
+ *,
144
+ strict: bool,
145
+ ) -> str:
146
+ euler_train = writer_meta.get("euler_train")
147
+ if isinstance(euler_train, dict):
148
+ modality_type = euler_train.get("modality_type")
149
+ if modality_type:
150
+ return modality_type
151
+
152
+ if output_config.key in _LOADABLE_LEGACY_OUTPUTS:
153
+ return output_config.key
154
+
155
+ if strict:
156
+ return output_config.key
157
+ return "other"
158
+
159
+
160
+ def _get_loadable_legacy_output(modality_type: str) -> dict[str, Any] | None:
161
+ return _LOADABLE_LEGACY_OUTPUTS.get(modality_type)
162
+
163
+
164
+ def _get_writer_type_default(
165
+ output_config: OutputConfig,
166
+ writer_meta: dict[str, Any],
167
+ ) -> str:
168
+ euler_train = writer_meta.get("euler_train")
169
+ if isinstance(euler_train, dict):
170
+ modality_type = euler_train.get("modality_type")
171
+ if modality_type:
172
+ return modality_type
173
+ return output_config.key
174
+
175
+
176
+ def _validate_loadable_legacy_output(
177
+ output_config: OutputConfig,
178
+ modality_type: str,
179
+ ) -> None:
180
+ loadable = _get_loadable_legacy_output(modality_type)
181
+ if loadable is None:
182
+ return
183
+
184
+ output_types = loadable.get("output_types")
185
+ if output_types and output_config.type not in output_types:
186
+ supported = ", ".join(sorted(output_types))
187
+ raise ValueError(
188
+ f"{modality_type} outputs must use one of: {supported}. "
189
+ f"Got: {output_config.type}"
190
+ )
191
+
192
+
193
+ def _to_numpy(data: Any) -> np.ndarray:
194
+ if hasattr(data, "detach"):
195
+ data = data.detach()
196
+ if hasattr(data, "cpu"):
197
+ data = data.cpu()
198
+ if hasattr(data, "numpy"):
199
+ data = data.numpy()
200
+ return np.asarray(data)
201
+
202
+
203
+ def _prepare_legacy_output_data(data: Any, output_config: OutputConfig) -> Any:
204
+ writer_meta = output_config.writer or {}
205
+ modality_type = _get_writer_modality_type(
206
+ output_config,
207
+ writer_meta,
208
+ strict=True,
209
+ )
210
+ if modality_type != "points_3d":
211
+ return data
212
+
213
+ arr = _to_numpy(data)
214
+ if arr.ndim != 3 or arr.shape[0] != 3:
215
+ raise ValueError(
216
+ "points_3d output must have shape (3, H, W), "
217
+ f"got {arr.shape}"
218
+ )
219
+ return arr.astype(np.float32, copy=False)
220
+
221
+
128
222
  def _get_writer_kwargs(
129
223
  output_config: OutputConfig,
130
224
  *,
@@ -134,14 +228,20 @@ def _get_writer_kwargs(
134
228
  """Derive DatasetWriter/ZipDatasetWriter kwargs from an OutputConfig."""
135
229
  writer_meta = output_config.writer or {}
136
230
  name = writer_meta.get("name", dataset_name or output_config.key)
231
+ modality_type = _get_writer_modality_type(
232
+ output_config,
233
+ writer_meta,
234
+ strict=strict,
235
+ )
236
+ _validate_loadable_legacy_output(output_config, modality_type)
237
+
137
238
  type_ = writer_meta.get(
138
239
  "type",
139
- writer_meta.get("euler_train", {}).get("modality_type", output_config.key),
240
+ _get_writer_type_default(output_config, writer_meta),
140
241
  )
141
- default_modality_type = output_config.key if strict else "other"
142
242
  euler_train = writer_meta.get("euler_train", {
143
243
  "used_as": "target",
144
- "modality_type": default_modality_type,
244
+ "modality_type": modality_type,
145
245
  })
146
246
  kwargs = dict(name=name, type=type_, euler_train=euler_train, separator=None)
147
247
 
@@ -149,7 +249,15 @@ def _get_writer_kwargs(
149
249
  if meta is not None:
150
250
  kwargs["meta"] = meta
151
251
 
152
- euler_loading = writer_meta.get("euler_loading")
252
+ if "euler_loading" in writer_meta:
253
+ euler_loading = writer_meta.get("euler_loading")
254
+ else:
255
+ loadable = _get_loadable_legacy_output(modality_type)
256
+ euler_loading = (
257
+ loadable.get("euler_loading")
258
+ if loadable is not None
259
+ else None
260
+ )
153
261
  if euler_loading is not None:
154
262
  merged = {
155
263
  key: value for key, value in euler_train.items()
@@ -472,7 +580,10 @@ class PreparedOutputs:
472
580
 
473
581
  file_id = _full_id_leaf(full_id)
474
582
  for output_config in self.legacy_outputs:
475
- output_data = outputs[output_config.key]
583
+ output_data = _prepare_legacy_output_data(
584
+ outputs[output_config.key],
585
+ output_config,
586
+ )
476
587
  basename = (
477
588
  f"{file_id}{output_config.effective_suffix}.{output_config.type}"
478
589
  )
@@ -13,7 +13,7 @@ class OutputConfig:
13
13
 
14
14
  Attributes:
15
15
  key: Key in the model's output dictionary (e.g., "depth", "dehazed")
16
- type: File format to save as ("npy", "png", "jpg", "exr")
16
+ type: File format to save as ("npy", "npz", "png", "jpg", "exr")
17
17
  suffix: Filename suffix before extension. Defaults to "_{key}".
18
18
  Use empty string "" for no suffix (filename will be {id}.{type}).
19
19
  source_modality: Optional regular input modality whose euler-loading
@@ -35,7 +35,7 @@ class OutputConfig:
35
35
  if not self.type:
36
36
  raise ValueError("output.type is required")
37
37
 
38
- supported_types = {"npy", "png", "jpg", "jpeg", "exr"}
38
+ supported_types = {"npy", "npz", "png", "jpg", "jpeg", "exr"}
39
39
  if self.type not in supported_types:
40
40
  raise ValueError(
41
41
  f"Unsupported output type '{self.type}'. Supported: {supported_types}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: euler-inference
3
- Version: 2.4.0
3
+ Version: 2.5.0
4
4
  Summary: Modality-agnostic inference pipeline using euler-loading
5
5
  Author-email: Daniel Rothenpieler <rothenpielerdaniel@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "euler-inference"
3
- version = "2.4.0"
3
+ version = "2.5.0"
4
4
  description = "Modality-agnostic inference pipeline using euler-loading"
5
5
  requires-python = ">=3.10"
6
6
  dependencies = [
@@ -92,6 +92,31 @@ def _make_indexed_rgb_dataset(tmp_path: Path) -> tuple[Path, dict[Path, np.ndarr
92
92
  return root, written
93
93
 
94
94
 
95
+ def _read_output_metadata(root: Path) -> dict:
96
+ """Read legacy output.json or newer dataset-head metadata."""
97
+ output_json = root / ".ds_crawler" / "output.json"
98
+ if output_json.exists():
99
+ with open(output_json) as f:
100
+ return json.load(f)
101
+
102
+ dataset_head = root / ".ds_crawler" / "dataset-head.json"
103
+ with open(dataset_head) as f:
104
+ head = json.load(f)
105
+
106
+ modality_key = head["modality"]["key"]
107
+ addons = head.get("addons", {})
108
+ euler_train = dict(addons.get("euler_train", {}))
109
+ euler_train.setdefault("modality_type", modality_key)
110
+ euler_loading = dict(addons.get("euler_loading", {}))
111
+ euler_loading.setdefault("modality_type", modality_key)
112
+ return {
113
+ "name": head["dataset"]["name"],
114
+ "type": modality_key,
115
+ "euler_train": euler_train,
116
+ "euler_loading": euler_loading,
117
+ }
118
+
119
+
95
120
  # ---------------------------------------------------------------------------
96
121
  # _get_writer_kwargs
97
122
  # ---------------------------------------------------------------------------
@@ -232,6 +257,32 @@ class TestGetWriterKwargs:
232
257
  kw = _get_writer_kwargs(oc, dataset_name=None)
233
258
  assert kw["name"] == "depth"
234
259
 
260
+ def test_points_3d_defaults_to_generic_loader_metadata(self):
261
+ oc = OutputConfig(key="points_3d", type="npy")
262
+ kw = _get_writer_kwargs(oc, strict=True)
263
+ assert kw["type"] == "points_3d"
264
+ assert kw["euler_train"] == {
265
+ "used_as": "target",
266
+ "modality_type": "points_3d",
267
+ }
268
+ assert kw["euler_loading"] == {
269
+ "used_as": "target",
270
+ "modality_type": "points_3d",
271
+ "loader": "generic",
272
+ "function": "points_3d",
273
+ }
274
+
275
+ def test_points_3d_keeps_modality_metadata_in_non_strict_mode(self):
276
+ oc = OutputConfig(key="points_3d", type="npy")
277
+ kw = _get_writer_kwargs(oc, strict=False)
278
+ assert kw["euler_train"]["modality_type"] == "points_3d"
279
+ assert kw["euler_loading"]["function"] == "points_3d"
280
+
281
+ def test_points_3d_rejects_non_numpy_output_format(self):
282
+ oc = OutputConfig(key="points_3d", type="png")
283
+ with pytest.raises(ValueError, match="points_3d outputs must use"):
284
+ _get_writer_kwargs(oc, strict=True)
285
+
235
286
 
236
287
  # ---------------------------------------------------------------------------
237
288
  # create_writers
@@ -415,6 +466,14 @@ class TestSaveOutputFileLike:
415
466
  loaded = np.load(buf)
416
467
  np.testing.assert_array_equal(loaded, data)
417
468
 
469
+ def test_npz_to_bytesio(self):
470
+ data = np.random.randn(10, 10).astype(np.float32)
471
+ buf = io.BytesIO()
472
+ save_output(data, buf, "npz")
473
+ buf.seek(0)
474
+ loaded = np.load(buf)["data"]
475
+ np.testing.assert_array_equal(loaded, data)
476
+
418
477
  def test_png_to_bytesio(self):
419
478
  from PIL import Image
420
479
 
@@ -459,6 +518,13 @@ class TestSaveOutputFileLike:
459
518
  loaded = np.load(path)
460
519
  np.testing.assert_array_equal(loaded, data)
461
520
 
521
+ def test_npz_path_still_works(self, tmp_path: Path):
522
+ data = np.random.randn(10, 10).astype(np.float32)
523
+ path = tmp_path / "test.npz"
524
+ save_output(data, path, "npz")
525
+ loaded = np.load(path)["data"]
526
+ np.testing.assert_array_equal(loaded, data)
527
+
462
528
 
463
529
  # ---------------------------------------------------------------------------
464
530
  # Filesystem writer end-to-end
@@ -529,6 +595,26 @@ class TestFilesystemWriterEndToEnd:
529
595
  index_path = Path(config.output_base_path) / key / ".ds_crawler" / "output.json"
530
596
  assert index_path.exists(), f"Missing index for {key}"
531
597
 
598
+ def test_points_3d_metadata_is_loadable_by_euler_loading(self, tmp_path: Path):
599
+ config = _make_config(
600
+ tmp_path,
601
+ outputs=[OutputConfig(key="points_3d", type="npy")],
602
+ strict=True,
603
+ )
604
+ writers = create_writers(config)
605
+ writer = writers["points_3d"]
606
+
607
+ full_id = "Scene01/Camera_0/00001"
608
+ path = writer.get_path(full_id, "00001_points_3d.npy")
609
+ save_output(np.zeros((3, 4, 5), dtype=np.float32), path, "npy")
610
+ writer.save_index()
611
+
612
+ index = _read_output_metadata(Path(config.output_base_path) / "points_3d")
613
+ assert index["type"] == "points_3d"
614
+ assert index["euler_train"]["modality_type"] == "points_3d"
615
+ assert index["euler_loading"]["loader"] == "generic"
616
+ assert index["euler_loading"]["function"] == "points_3d"
617
+
532
618
 
533
619
  # ---------------------------------------------------------------------------
534
620
  # Zip writer end-to-end
@@ -1083,3 +1169,71 @@ class TestRunInferenceWriterBackedOutputs:
1083
1169
  np.full((6, 8), 2.5, dtype=np.float32),
1084
1170
  )
1085
1171
  assert (output_root / ".ds_crawler" / "output.json").exists()
1172
+
1173
+ def test_unmapped_points_3d_output_uses_generic_loader_metadata(
1174
+ self,
1175
+ tmp_path: Path,
1176
+ ):
1177
+ dataset_root, _expected_images = _make_indexed_rgb_dataset(tmp_path)
1178
+ model_py = tmp_path / "points_model.py"
1179
+ model_py.write_text(
1180
+ "import numpy as np\n\n"
1181
+ "class Model:\n"
1182
+ " def __init__(self, config, device=None):\n"
1183
+ " pass\n\n"
1184
+ " def predict(self, inputs):\n"
1185
+ " height, width = inputs['rgb'].shape[-2:]\n"
1186
+ " points = np.stack([\n"
1187
+ " np.full((height, width), 1.0),\n"
1188
+ " np.full((height, width), 2.0),\n"
1189
+ " np.full((height, width), 3.0),\n"
1190
+ " ])\n"
1191
+ " return {'points_3d': points}\n"
1192
+ )
1193
+
1194
+ config = InferenceConfig(
1195
+ external_model=ExternalModelConfig(model_path=str(model_py)),
1196
+ dataset=DatasetConfig(modalities={"rgb": str(dataset_root)}),
1197
+ output_base_path=str(tmp_path / "predictions"),
1198
+ outputs=[OutputConfig(key="points_3d", type="npy")],
1199
+ strict=True,
1200
+ )
1201
+
1202
+ run_inference(config)
1203
+
1204
+ output_root = Path(config.output_base_path) / "points_3d"
1205
+ legacy_path = output_root / "Scene01" / "Camera_0" / "00001_points_3d.npy"
1206
+ assert legacy_path.exists()
1207
+ loaded = np.load(legacy_path)
1208
+ assert loaded.dtype == np.float32
1209
+ assert loaded.shape == (3, 6, 8)
1210
+ np.testing.assert_array_equal(loaded[:, 0, 0], np.array([1.0, 2.0, 3.0]))
1211
+
1212
+ output_index = _read_output_metadata(output_root)
1213
+ assert output_index["euler_train"]["modality_type"] == "points_3d"
1214
+ assert output_index["euler_loading"]["loader"] == "generic"
1215
+ assert output_index["euler_loading"]["function"] == "points_3d"
1216
+
1217
+ def test_points_3d_output_rejects_hwc_layout(self, tmp_path: Path):
1218
+ dataset_root, _expected_images = _make_indexed_rgb_dataset(tmp_path)
1219
+ model_py = tmp_path / "bad_points_model.py"
1220
+ model_py.write_text(
1221
+ "import numpy as np\n\n"
1222
+ "class Model:\n"
1223
+ " def __init__(self, config, device=None):\n"
1224
+ " pass\n\n"
1225
+ " def predict(self, inputs):\n"
1226
+ " height, width = inputs['rgb'].shape[-2:]\n"
1227
+ " return {'points_3d': np.zeros((height, width, 3), dtype=np.float32)}\n"
1228
+ )
1229
+
1230
+ config = InferenceConfig(
1231
+ external_model=ExternalModelConfig(model_path=str(model_py)),
1232
+ dataset=DatasetConfig(modalities={"rgb": str(dataset_root)}),
1233
+ output_base_path=str(tmp_path / "predictions"),
1234
+ outputs=[OutputConfig(key="points_3d", type="npy")],
1235
+ strict=True,
1236
+ )
1237
+
1238
+ with pytest.raises(ValueError, match="points_3d output must have shape"):
1239
+ run_inference(config)