mlx3d.datasets¶
mlx3d.datasets
¶
ColmapDataset
dataclass
¶
Source code in src/mlx3d/datasets/colmap.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
ImageCollection
¶
A list-like view over training images with configurable storage.
Always yields (H, W, 3) float32 MLX arrays in [0, 1], regardless of the underlying storage mode.
Source code in src/mlx3d/datasets/images.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
nbytes_resident
property
¶
Approximate resident memory of the stored images, in bytes.
append_file(path)
¶
Register an image file, decoding it now or later per the cache mode.
Source code in src/mlx3d/datasets/images.py
65 66 67 68 69 70 71 72 73 74 | |
shape_of(i)
¶
(height, width) of image i (decodes it in disk mode).
Source code in src/mlx3d/datasets/images.py
76 77 78 79 | |
MaskCollection
¶
List-like (H, W) float32 masks with the same cache modes as images.
"ram" keeps float32 MLX arrays, "uint8" keeps 8-bit NumPy arrays
(masks are 8-bit at the source, so this is lossless), "disk" keeps
paths and decodes on access.
Source code in src/mlx3d/datasets/masks.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
append_file(path, expected_hw=None)
¶
Register a mask, validating it now: it must be non-empty and, when
expected_hw is given, match the image's (height, width).
Source code in src/mlx3d/datasets/masks.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
coverage(i)
¶
Foreground fraction (mean mask value) of mask i.
Source code in src/mlx3d/datasets/masks.py
104 105 106 | |
load_blender(root, split='train', downscale=1, white_background=True, cache='ram')
¶
Load a Blender-synthetic scene (lego, chair, ...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str
|
scene directory containing |
required |
split
|
str
|
|
'train'
|
downscale
|
int
|
integer image downscaling factor. |
1
|
white_background
|
bool
|
composite the RGBA renders onto white (else black). |
True
|
cache
|
str
|
image storage policy ( |
'ram'
|
Source code in src/mlx3d/datasets/blender.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
load_colmap(root, images_dir='images', downscale=1, load_images=True, cache='ram', masks_dir=None, masks_from_alpha=False)
¶
Load a COLMAP scene laid out as root/sparse/0 + root/<images_dir>.
COLMAP already uses the OpenCV camera convention, so extrinsics map
directly onto :class:~mlx3d.cameras.Camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache
|
str
|
image storage policy — |
'ram'
|
masks_dir
|
str | None
|
optional foreground-mask directory (relative to |
None
|
masks_from_alpha
|
bool
|
use the source images' alpha channel as masks. |
False
|
Source code in src/mlx3d/datasets/colmap.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
save_colmap(root, cameras, image_names, points, point_colors, point_errors=None)
¶
Write a COLMAP binary sparse model to root/sparse/0.
The inverse of :func:load_colmap (2D observations/tracks are not stored).
Identical intrinsics are deduplicated into a shared COLMAP camera. Colors
are float in [0, 1]; points/colors accept MLX or NumPy arrays.
Returns the sparse model directory.
Source code in src/mlx3d/datasets/colmap.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
load_instant_ngp(root, transforms_file='transforms.json', downscale=1, white_background=False, cache='ram')
¶
Load an Instant-NGP / nerfstudio scene.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str
|
scene directory containing |
required |
transforms_file
|
str
|
name of the transforms JSON (default |
'transforms.json'
|
downscale
|
int
|
integer image downscaling factor (intrinsics are scaled to match). |
1
|
white_background
|
bool
|
composite RGBA images onto white (else black). |
False
|
cache
|
str
|
image storage policy; see :class: |
'ram'
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
BlenderDataset
|
class: |
Source code in src/mlx3d/datasets/instant_ngp.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
decode_mask_file(path, downscale=1, from_image_alpha=False)
¶
Decode a mask to (H, W) float32 in [0, 1].
With from_image_alpha the file is a source image and its alpha
channel is the mask (it must have one).
Source code in src/mlx3d/datasets/masks.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
find_mask_file(masks_dir, image_name)
¶
Mask path for image_name (relative to the images directory), or None.
Source code in src/mlx3d/datasets/masks.py
26 27 28 29 30 31 32 33 | |