Skip to content

Commit 3fafbc2

Browse files
Merge branch 'dataloading-revamp' of https://github.com/AntonioMacaronio/nerfstudio into dataloading-revamp
2 parents b8da37d + c316a7b commit 3fafbc2

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

nerfstudio/data/datamanagers/base_datamanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def __post_init__(self):
357357
try:
358358
torch.multiprocessing.set_start_method("spawn")
359359
except RuntimeError:
360-
pass
360+
assert torch.multiprocessing.get_start_method() == "spawn", 'start method must be "spawn"'
361361
self.dataloader_num_workers = 4 if self.dataloader_num_workers == 0 else self.dataloader_num_workers
362362

363363

nerfstudio/data/datamanagers/full_images_datamanager.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __post_init__(self):
9797
try:
9898
torch.multiprocessing.set_start_method("spawn")
9999
except RuntimeError:
100-
pass
100+
assert torch.multiprocessing.get_start_method() == "spawn", 'start method must be "spawn"'
101101
if self.prefetch_factor == 0:
102102
CONSOLE.log('cache_images set to "disk" with no prefetch factor, defaulting to 4')
103103
self.prefetch_factor = 4
@@ -352,7 +352,7 @@ def setup_eval(self):
352352
self.eval_image_dataloader = DataLoader(
353353
self.eval_imagebatch_stream,
354354
batch_size=1,
355-
num_workers=0,
355+
num_workers=0, # This must be 0 otherwise there is a crash when trying to pickle custom_view_processor
356356
collate_fn=identity_collate,
357357
)
358358
self.iter_eval_image_dataloader = iter(self.eval_image_dataloader)
@@ -434,6 +434,9 @@ def next_eval_image(self, step: int) -> Tuple[Cameras, Dict]:
434434
"""Returns the next evaluation batch
435435
Returns a Camera instead of raybundle
436436
TODO: Make sure this logic is consistent with the vanilladatamanager"""
437+
if self.config.cache_images == "disk":
438+
camera, data = next(self.iter_eval_image_dataloader)[0]
439+
return camera, data
437440
image_idx = self.eval_unseen_cameras.pop(random.randint(0, len(self.eval_unseen_cameras) - 1))
438441
# Make sure to re-populate the unseen cameras list if we have exhausted it
439442
if len(self.eval_unseen_cameras) == 0:

nerfstudio/data/datamanagers/parallel_datamanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def setup_eval(self):
174174
self.eval_ray_dataloader = DataLoader(
175175
self.eval_raybatchstream,
176176
batch_size=1,
177-
num_workers=0,
177+
num_workers=0, # This must be 0 otherwise there is a crash when trying to pickle custom_view_processor
178178
shuffle=False,
179179
collate_fn=identity_collate, # Our dataset handles batching / collation of rays
180180
)

nerfstudio/viewer/render_panel.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import viser.transforms as tf
3131
from scipy import interpolate
3232

33+
from nerfstudio.utils.rich_utils import CONSOLE
3334
from nerfstudio.viewer.control_panel import ControlPanel
3435

3536

@@ -1130,8 +1131,15 @@ def _(event: viser.GuiEvent) -> None:
11301131
}
11311132

11321133
# now write the json file
1133-
json_outfile = datapath / "camera_paths" / f"{render_name_text.value}.json"
1134-
json_outfile.parent.mkdir(parents=True, exist_ok=True)
1134+
try:
1135+
json_outfile = datapath / "camera_paths" / f"{render_name_text.value}.json"
1136+
json_outfile.parent.mkdir(parents=True, exist_ok=True)
1137+
except Exception:
1138+
CONSOLE.print(
1139+
"[bold yellow]Warning: Failed to write the camera path to the data directory. Saving to the output directory instead."
1140+
)
1141+
json_outfile = config_path.parent / "camera_paths" / f"{render_name_text.value}.json"
1142+
json_outfile.parent.mkdir(parents=True, exist_ok=True)
11351143
with open(json_outfile.absolute(), "w") as outfile:
11361144
json.dump(json_data, outfile)
11371145
# now show the command

0 commit comments

Comments
 (0)