diff --git a/pyrad/data/dataloader.py b/pyrad/data/dataloader.py index 90404bf12..2c644d5b0 100644 --- a/pyrad/data/dataloader.py +++ b/pyrad/data/dataloader.py @@ -88,17 +88,19 @@ def setup_dataset_eval(config: DataConfig, test_mode: bool, device: str) -> Tupl class AbstractDataloaderV2(nn.Module): """Second version of the dataloader class - This version of the dataloader is designed to subsume both the train and eval dataloaders, especially since - this may contain learnable parameters which need to be shared across the train and test dataloaders. The idea - is that we have setup methods for train and eval separatley and this can be a combined train/eval if you want. + This version of the dataloader is designed to subsume both the train and eval dataloaders, + especially since this may contain learnable parameters which need to be shared across the train + and test dataloaders. The idea is that we have setup methods for train and eval separatley and + this can be a combined train/eval if you want. - The default should be for the train and eval dataloaders to be the same, but this can be overridden. This is - needed when there are learned parameters either in your data itself or in the way some of the data (that we will - pass to the renderer / Field) was generated. In these cases, we want these parameters to be accessible by - both the train and eval dataloaders, hence why you would want them to be in the same dataloader. + The default should be for the train and eval dataloaders to be the same, but this can be + overridden. This is needed when there are learned parameters either in your data itself or in + the way some of the data (that we will pass to the renderer / Field) was generated. In these + cases, we want these parameters to be accessible by both the train and eval dataloaders, hence + why you would want them to be in the same dataloader. - An instance where you may want to have only the eval dataloader is if you are doing evaluation and - don't have the dataset used to train the model. + An instance where you may want to have only the eval dataloader is if you are doing evaluation + and don't have the dataset used to train the model. Train Methods: @@ -190,6 +192,23 @@ class AbstractCachedDataloaderV2(AbstractDataloaderV2): camera_to_world: torch.Tensor intrinsics: torch.Tensor + # These abstract methods are only copied over to appease the linter + @abstractmethod + def setup_train(self): + """Sets up the dataloader for training""" + + @abstractmethod + def setup_eval(self): + """Sets up the dataloader for evaluation""" + + @abstractmethod + def next_train(self) -> GenericDataContainer: + """Returns the next batch of data from the train dataloader""" + + @abstractmethod + def next_eval(self) -> GenericDataContainer: + """Returns the next batch of data from the eval dataloader""" + class TrainDataloader: """Training dataloader base class.""" diff --git a/pyrad/data/structs.py b/pyrad/data/structs.py index 949c92248..7e2fdb755 100644 --- a/pyrad/data/structs.py +++ b/pyrad/data/structs.py @@ -20,9 +20,10 @@ from dataclasses import dataclass from typing import List, Optional import torch -from pyrad.cameras.rays import RayBundle from torchtyping import TensorType +from pyrad.cameras.rays import RayBundle + @dataclass class PointCloud: diff --git a/pyrad/utils/misc.py b/pyrad/utils/misc.py index 2600431e5..51539320e 100644 --- a/pyrad/utils/misc.py +++ b/pyrad/utils/misc.py @@ -92,12 +92,14 @@ def get_hash_str_from_dict(dictionary: Dict[str, Any]) -> str: return dhash.hexdigest() -class IterableWrapper: - """A helper that will allow an instance of a class to return multiple kinds of iterables bound to different functions of that class. +class IterableWrapper: # pylint: disable=too-few-public-methods + """A helper that will allow an instance of a class to return multiple kinds of iterables bound + to different functions of that class. - To use this, pass in the instance of the class you want to have multiple kinds of iterables for, and pass in a - method belonging to that class that you want to be the __next__() method of the iterable. The resulting instantiated object will - be an iterable that will use the passed in class method as the __next__() method. + To use this, pass in the instance of the class you want to have multiple kinds of iterables for, + and pass in a method belonging to that class that you want to be the __next__() method of the + iterable. The resulting instantiated object will be an iterable that will use the passed in + class method as the __next__() method. Args: instance (object): instance class we are wrapping