deeplabcut.pose_estimation_pytorch.data.collate
Custom collate functions.
Classes:
| Name | Description |
|---|---|
CollateFunction |
A class that can be called as a collate function. |
ResizeCollate |
A collate function which resizes all images in a batch to the same size. |
ResizeFromDataSizeCollate |
A collate function which resizes all images in a batch to the same size. |
ResizeFromListCollate |
A collate function which resizes all images in a batch to the same size. |
CollateFunction
ResizeCollate
Bases: CollateFunction, ABC
A collate function which resizes all images in a batch to the same size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
The maximum shift, in pixels, to add to the random crop (this means there can be a slight border around the image) |
10
|
|
int
|
The maximum size of the long edge of the image when resized. If the longest side will be greater than this value, resizes such that the longest side is this size, and the shortest side is smaller than the desired size. This is useful to keep some information from images with extreme aspect ratios. |
2048
|
|
int
|
The random seed to use to sample scales/sizes. |
0
|
Methods:
| Name | Description |
|---|---|
__call__ |
Returns: the collated batch |
Source code in deeplabcut/pose_estimation_pytorch/data/collate.py
__call__
Returns: the collated batch
Source code in deeplabcut/pose_estimation_pytorch/data/collate.py
ResizeFromDataSizeCollate
Bases: ResizeCollate
A collate function which resizes all images in a batch to the same size.
The target size is obtained by taking the size of the first image in the batch, and multiplying it by a scale taken uniformly at random from (min_scale, max_scale).
The aspect ratio of all images in the batch is preserved, with cropping/padding used to generate images of the correct shapes.
If to_square
The images will be resized to squares, where the side is the short side of the original image.
else: The images will be resized to a scaled version of the shape of the first image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float
|
The minimum scale factor to apply to the image size |
required |
|
float
|
The maximum scale factor to apply to the image size |
required |
|
int
|
The smallest size for the target short side. |
128
|
|
int
|
The largest size for the target short side. |
1152
|
|
float
|
The largest aspect ratio allowed for a target (longSide / shortSide). If the aspect ratio is larger, it will be clamped to max_ratio. Must be >=1. |
2.0
|
|
int | None
|
If defined, the height and width of all target sizes will be a multiple of this value. |
None
|
|
bool
|
Whether images should be resized to squares. |
False
|
Source code in deeplabcut/pose_estimation_pytorch/data/collate.py
ResizeFromListCollate
Bases: ResizeCollate
A collate function which resizes all images in a batch to the same size.
The target size image size is sampled from a list. If it's a list of integers, all images will be resized into squares. If it's a list of tuples, that will be the target (h, w) for images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[int] | list[tuple[int, int]]
|
The target sizes to resize the images to. |
required |