mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 06:49:13 +08:00
Add Metadata Handling to Cameras Collation Function (#2001)
* Add metadata collate for cameras * checks passed --------- Co-authored-by: Matthew Tancik <tancik@berkeley.edu>
This commit is contained in:
1 parent
4d71cd2e95
commit
ba08a8f530
1 file changed
+8
@@ -162,6 +162,13 @@ def nerfstudio_collate(batch: Any, extra_mappings: Union[Dict[type, Callable], N
|
|||||||
else:
|
else:
|
||||||
op = torch.cat
|
op = torch.cat
|
||||||
|
|
||||||
|
# Create metadata dictionary
|
||||||
|
metadata_keys = batch[0].metadata.keys()
|
||||||
|
assert all(
|
||||||
|
(cam.metadata.keys() == metadata_keys for cam in batch)
|
||||||
|
), "All cameras must have the same metadata keys."
|
||||||
|
metadata = {key: op([cam.metadata[key] for cam in batch], dim=0) for key in metadata_keys}
|
||||||
|
|
||||||
return Cameras(
|
return Cameras(
|
||||||
op([cameras.camera_to_worlds for cameras in batch], dim=0),
|
op([cameras.camera_to_worlds for cameras in batch], dim=0),
|
||||||
op([cameras.fx for cameras in batch], dim=0),
|
op([cameras.fx for cameras in batch], dim=0),
|
||||||
@@ -184,6 +191,7 @@ def nerfstudio_collate(batch: Any, extra_mappings: Union[Dict[type, Callable], N
|
|||||||
[cameras.times if cameras.times is not None else -torch.ones_like(cameras.times) for cameras in batch],
|
[cameras.times if cameras.times is not None else -torch.ones_like(cameras.times) for cameras in batch],
|
||||||
dim=0,
|
dim=0,
|
||||||
),
|
),
|
||||||
|
metadata=metadata,
|
||||||
)
|
)
|
||||||
|
|
||||||
for type_key in extra_mappings:
|
for type_key in extra_mappings:
|
||||||
|
|||||||
Reference in new issue
Block a user