mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 23:08:44 +08:00
Fix dynamic batch logic during inference (#1160)
This commit is contained in:
1 parent
8d4a82ef0b
commit
335c5c3661
2 files changed
+8
-2
No files matched your search
@@ -298,6 +298,8 @@ class VanillaDataManager(DataManager): # pylint: disable=abstract-method
|
|||||||
train_dataset: InputDataset
|
train_dataset: InputDataset
|
||||||
eval_dataset: InputDataset
|
eval_dataset: InputDataset
|
||||||
train_dataparser_outputs: DataparserOutputs
|
train_dataparser_outputs: DataparserOutputs
|
||||||
|
train_pixel_sampler: Optional[PixelSampler] = None
|
||||||
|
eval_pixel_sampler: Optional[PixelSampler] = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -408,6 +410,7 @@ class VanillaDataManager(DataManager): # pylint: disable=abstract-method
|
|||||||
"""Returns the next batch of data from the train dataloader."""
|
"""Returns the next batch of data from the train dataloader."""
|
||||||
self.train_count += 1
|
self.train_count += 1
|
||||||
image_batch = next(self.iter_train_image_dataloader)
|
image_batch = next(self.iter_train_image_dataloader)
|
||||||
|
assert self.train_pixel_sampler is not None
|
||||||
batch = self.train_pixel_sampler.sample(image_batch)
|
batch = self.train_pixel_sampler.sample(image_batch)
|
||||||
ray_indices = batch["indices"]
|
ray_indices = batch["indices"]
|
||||||
ray_bundle = self.train_ray_generator(ray_indices)
|
ray_bundle = self.train_ray_generator(ray_indices)
|
||||||
@@ -417,6 +420,7 @@ class VanillaDataManager(DataManager): # pylint: disable=abstract-method
|
|||||||
"""Returns the next batch of data from the eval dataloader."""
|
"""Returns the next batch of data from the eval dataloader."""
|
||||||
self.eval_count += 1
|
self.eval_count += 1
|
||||||
image_batch = next(self.iter_eval_image_dataloader)
|
image_batch = next(self.iter_eval_image_dataloader)
|
||||||
|
assert self.eval_pixel_sampler is not None
|
||||||
batch = self.eval_pixel_sampler.sample(image_batch)
|
batch = self.eval_pixel_sampler.sample(image_batch)
|
||||||
ray_indices = batch["indices"]
|
ray_indices = batch["indices"]
|
||||||
ray_bundle = self.eval_ray_generator(ray_indices)
|
ray_bundle = self.eval_ray_generator(ray_indices)
|
||||||
|
|||||||
@@ -64,8 +64,10 @@ class DynamicBatchPipeline(VanillaPipeline):
|
|||||||
|
|
||||||
def _update_pixel_samplers(self):
|
def _update_pixel_samplers(self):
|
||||||
"""Update the pixel samplers for train and eval with the dynamic number of rays per batch."""
|
"""Update the pixel samplers for train and eval with the dynamic number of rays per batch."""
|
||||||
self.datamanager.train_pixel_sampler.set_num_rays_per_batch(self.dynamic_num_rays_per_batch)
|
if self.datamanager.train_pixel_sampler is not None:
|
||||||
self.datamanager.eval_pixel_sampler.set_num_rays_per_batch(self.dynamic_num_rays_per_batch)
|
self.datamanager.train_pixel_sampler.set_num_rays_per_batch(self.dynamic_num_rays_per_batch)
|
||||||
|
if self.datamanager.eval_pixel_sampler is not None:
|
||||||
|
self.datamanager.eval_pixel_sampler.set_num_rays_per_batch(self.dynamic_num_rays_per_batch)
|
||||||
|
|
||||||
def _update_dynamic_num_rays_per_batch(self, num_samples_per_batch: int):
|
def _update_dynamic_num_rays_per_batch(self, num_samples_per_batch: int):
|
||||||
"""Updates the dynamic number of rays per batch variable,
|
"""Updates the dynamic number of rays per batch variable,
|
||||||
|
|||||||
Reference in new issue
Block a user