passing linting tests and fixed documentation

This commit is contained in:
Jake Austin committed 2022-07-20 16:42:47 -07:00
1 parent 482f7c9eea
commit 3a78a9cb2e
3 files changed
+37 -15

No files matched your search

+28 -9
View File
@@ -88,17 +88,19 @@ def setup_dataset_eval(config: DataConfig, test_mode: bool, device: str) -> Tupl
class AbstractDataloaderV2(nn.Module): class AbstractDataloaderV2(nn.Module):
"""Second version of the dataloader class """Second version of the dataloader class
This version of the dataloader is designed to subsume both the train and eval dataloaders, especially since This version of the dataloader is designed to subsume both the train and eval dataloaders,
this may contain learnable parameters which need to be shared across the train and test dataloaders. The idea especially since this may contain learnable parameters which need to be shared across the train
is that we have setup methods for train and eval separatley and this can be a combined train/eval if you want. 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 The default should be for the train and eval dataloaders to be the same, but this can be
needed when there are learned parameters either in your data itself or in the way some of the data (that we will overridden. This is needed when there are learned parameters either in your data itself or in
pass to the renderer / Field) was generated. In these cases, we want these parameters to be accessible by the way some of the data (that we will pass to the renderer / Field) was generated. In these
both the train and eval dataloaders, hence why you would want them to be in the same dataloader. 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 An instance where you may want to have only the eval dataloader is if you are doing evaluation
don't have the dataset used to train the model. and don't have the dataset used to train the model.
Train Methods: Train Methods:
@@ -190,6 +192,23 @@ class AbstractCachedDataloaderV2(AbstractDataloaderV2):
camera_to_world: torch.Tensor camera_to_world: torch.Tensor
intrinsics: 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: class TrainDataloader:
"""Training dataloader base class.""" """Training dataloader base class."""
+2 -1
View File
@@ -20,9 +20,10 @@ from dataclasses import dataclass
from typing import List, Optional from typing import List, Optional
import torch import torch
from pyrad.cameras.rays import RayBundle
from torchtyping import TensorType from torchtyping import TensorType
from pyrad.cameras.rays import RayBundle
@dataclass @dataclass
class PointCloud: class PointCloud:
+7 -5
View File
@@ -92,12 +92,14 @@ def get_hash_str_from_dict(dictionary: Dict[str, Any]) -> str:
return dhash.hexdigest() return dhash.hexdigest()
class IterableWrapper: 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. """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 To use this, pass in the instance of the class you want to have multiple kinds of iterables for,
method belonging to that class that you want to be the __next__() method of the iterable. The resulting instantiated object will and pass in a method belonging to that class that you want to be the __next__() method of the
be an iterable that will use the passed in class method as the __next__() method. iterable. The resulting instantiated object will be an iterable that will use the passed in
class method as the __next__() method.
Args: Args:
instance (object): instance class we are wrapping instance (object): instance class we are wrapping