mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 21:39:06 +08:00
1 parent
2be4625b4f
commit
c7c4ac5a4d
2 files changed
+12
-6
No files matched your search
@@ -88,6 +88,8 @@ class DataManager(nn.Module):
|
|||||||
|
|
||||||
train_input_dataset: Optional[InputDataset] = None
|
train_input_dataset: Optional[InputDataset] = None
|
||||||
eval_input_dataset: Optional[InputDataset] = None
|
eval_input_dataset: Optional[InputDataset] = None
|
||||||
|
train_sampler: Optional[DistributedSampler] = None
|
||||||
|
eval_sampler: Optional[DistributedSampler] = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Constructor for the DataManager class.
|
"""Constructor for the DataManager class.
|
||||||
@@ -326,5 +328,7 @@ class VanillaDataManager(DataManager): # pylint: disable=abstract-method
|
|||||||
|
|
||||||
def next_eval_image(self, step: int) -> Tuple[int, RayBundle, Dict]:
|
def next_eval_image(self, step: int) -> Tuple[int, RayBundle, Dict]:
|
||||||
for camera_ray_bundle, batch in self.eval_dataloader:
|
for camera_ray_bundle, batch in self.eval_dataloader:
|
||||||
|
assert camera_ray_bundle.camera_indices is not None
|
||||||
image_idx = int(camera_ray_bundle.camera_indices[0, 0])
|
image_idx = int(camera_ray_bundle.camera_indices[0, 0])
|
||||||
return image_idx, camera_ray_bundle, batch
|
return image_idx, camera_ray_bundle, batch
|
||||||
|
raise ValueError("No more eval images")
|
||||||
@@ -117,7 +117,7 @@ class Pipeline(nn.Module):
|
|||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@profiler.time_function
|
@profiler.time_function
|
||||||
def get_train_loss_dict(self, step: Optional[int] = None):
|
def get_train_loss_dict(self, step: int):
|
||||||
"""This function gets your training loss dict. This will be responsible for
|
"""This function gets your training loss dict. This will be responsible for
|
||||||
getting the next batch of data from the DataManager and interfacing with the
|
getting the next batch of data from the DataManager and interfacing with the
|
||||||
Model class, feeding the data to the model's forward function.
|
Model class, feeding the data to the model's forward function.
|
||||||
@@ -125,15 +125,16 @@ class Pipeline(nn.Module):
|
|||||||
Args:
|
Args:
|
||||||
step: current iteration step to update sampler if using DDP (distributed)
|
step: current iteration step to update sampler if using DDP (distributed)
|
||||||
"""
|
"""
|
||||||
if self.world_size > 1:
|
if self.world_size > 1 and step:
|
||||||
self.datamanager.train_image_dataloader.sampler.set_epoch(step)
|
assert self.datamanager.train_sampler is not None
|
||||||
|
self.datamanager.train_sampler.set_epoch(step)
|
||||||
ray_bundle, batch = self.datamanager.next_train(step)
|
ray_bundle, batch = self.datamanager.next_train(step)
|
||||||
model_outputs, loss_dict, metrics_dict = self.model(ray_bundle, batch)
|
model_outputs, loss_dict, metrics_dict = self.model(ray_bundle, batch)
|
||||||
return model_outputs, loss_dict, metrics_dict
|
return model_outputs, loss_dict, metrics_dict
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@profiler.time_function
|
@profiler.time_function
|
||||||
def get_eval_loss_dict(self, step: Optional[int] = None):
|
def get_eval_loss_dict(self, step: int):
|
||||||
"""This function gets your evaluation loss dict. It needs to get the data
|
"""This function gets your evaluation loss dict. It needs to get the data
|
||||||
from the DataManager and feed it to the model's forward function
|
from the DataManager and feed it to the model's forward function
|
||||||
|
|
||||||
@@ -142,7 +143,8 @@ class Pipeline(nn.Module):
|
|||||||
"""
|
"""
|
||||||
self.eval()
|
self.eval()
|
||||||
if self.world_size > 1:
|
if self.world_size > 1:
|
||||||
self.datamanager.eval_image_dataloader.sampler.set_epoch(step)
|
assert self.datamanager.eval_sampler is not None
|
||||||
|
self.datamanager.eval_sampler.set_epoch(step)
|
||||||
ray_bundle, batch = self.datamanager.next_eval(step)
|
ray_bundle, batch = self.datamanager.next_eval(step)
|
||||||
model_outputs, loss_dict, metrics_dict = self.model(ray_bundle, batch)
|
model_outputs, loss_dict, metrics_dict = self.model(ray_bundle, batch)
|
||||||
self.train()
|
self.train()
|
||||||
@@ -150,7 +152,7 @@ class Pipeline(nn.Module):
|
|||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@profiler.time_function
|
@profiler.time_function
|
||||||
def get_eval_image_metrics_and_images(self, step: Optional[int] = None):
|
def get_eval_image_metrics_and_images(self, step: int):
|
||||||
"""This function gets your evaluation loss dict. It needs to get the data
|
"""This function gets your evaluation loss dict. It needs to get the data
|
||||||
from the DataManager and feed it to the model's forward function
|
from the DataManager and feed it to the model's forward function
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user