Vision
VisionDataModule #
Bases: LightningDataModule
, DataModule[BatchType_co]
A LightningDataModule for image datasets.
(Taken from pl_bolts which is not very well maintained.)
__init__ #
__init__(
data_dir: str | Path = DATA_DIR,
val_split: int | float = 0.2,
num_workers: int = NUM_WORKERS,
normalize: bool = False,
batch_size: int = 32,
seed: int = 42,
shuffle: bool = True,
pin_memory: bool = True,
drop_last: bool = False,
train_transforms: Callable | None = None,
val_transforms: Callable | None = None,
test_transforms: Callable | None = None,
**kwargs
) -> None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dir
|
str | Path
|
Where to save/load the data |
DATA_DIR
|
val_split
|
int | float
|
Percent (float) or number (int) of samples to use for the validation split |
0.2
|
num_workers
|
int
|
How many workers to use for loading data |
NUM_WORKERS
|
normalize
|
bool
|
If true applies image normalize |
False
|
batch_size
|
int
|
How many samples per batch to load |
32
|
seed
|
int
|
Random seed to be used for train/val/test splits |
42
|
shuffle
|
bool
|
If true shuffles the train data every epoch |
True
|
pin_memory
|
bool
|
If true, the data loader will copy Tensors into CUDA pinned memory before returning them |
True
|
drop_last
|
bool
|
If true drops the last incomplete batch |
False
|
train_transforms
|
Callable | None
|
transformations you can apply to train dataset |
None
|
val_transforms
|
Callable | None
|
transformations you can apply to validation dataset |
None
|
test_transforms
|
Callable | None
|
transformations you can apply to test dataset |
None
|
default_transforms
abstractmethod
#
default_transforms() -> Callable
Default transform for the dataset.
train_dataloader #
train_dataloader(
_dataloader_fn: Callable[
Concatenate[Dataset, P], DataLoader
] = DataLoader,
*args: args,
**kwargs: kwargs
) -> DataLoader
The train dataloader.
val_dataloader #
val_dataloader(
_dataloader_fn: Callable[
Concatenate[Dataset, P], DataLoader
] = DataLoader,
*args: args,
**kwargs: kwargs
) -> DataLoader
The val dataloader.
test_dataloader #
test_dataloader(
_dataloader_fn: Callable[
Concatenate[Dataset, P], DataLoader
] = DataLoader,
*args: args,
**kwargs: kwargs
) -> DataLoader
The test dataloader.