Datasets¶
Dataset loading utilities for training and evaluation.
Image Datasets¶
ImageFolder¶
Custom ImageFolder dataset for training compression models.
ImageFolder
¶
Bases: Dataset[Image | T]
Load an image folder database. Training and testing image samples are respectively stored in separate directories:
.. code-block::
- rootdir/
- train/
- img000.png
- img001.png
- test/
- img000.png
- img001.png
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
string
|
root directory of the dataset |
required |
transform
|
callable
|
a function or transform that takes in a PIL image and returns a transformed version |
None
|
split
|
string
|
split mode ('train' or 'val') |
'train'
|
__getitem__
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index |
required |
Returns:
| Name | Type | Description |
|---|---|---|
img |
Image | T
|
|
Video Datasets¶
VideoFolder
¶
Bases: Dataset[tuple[Tensor, ...]]
Load a video folder database. Training and testing video clips are stored in a directorie containing mnay sub-directorie like Vimeo90K Dataset:
.. code-block::
- rootdir/
train.list
test.list
- sequences/
- 00010/
...
-0932/
-0933/
...
- 00011/
...
- 00012/
...
training and testing (valid) clips are withdrew from sub-directory navigated by corresponding input files listing relevant folders.
This class returns a set of three video frames in a tuple. Random interval can be applied to if subfolders includes more than 6 frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
string
|
root directory of the dataset |
required |
rnd_interval
|
bool
|
enable random interval [1,2,3] when drawing sample frames |
False
|
transform
|
callable
|
a function or transform that takes in a PIL image and returns a transformed version |
None
|
split
|
string
|
split mode ('train' or 'test') |
'train'
|
__getitem__
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index |
required |
Returns:
| Name | Type | Description |
|---|---|---|
img |
tuple[Tensor, ...]
|
|
Dataset Structure¶
Tinify datasets follow this structure:
dataset/
├── train/
│ ├── image001.png
│ ├── image002.png
│ └── ...
└── test/
├── image001.png
├── image002.png
└── ...
Images should be in PNG or JPEG format with RGB channels.