dgs.utils.image.CustomToAspect.forward¶
- CustomToAspect.forward(*args, **kwargs) dict[str, any] [source]¶
Modify the image, bboxes and coordinates to have a given aspect ratio (shape)
Use module in Compose and pass structured dict as argument. This function will then obtain a dictionary as first and most likely only argument.
- Keyword Arguments:
image – One single image as tv_tensor.Image of shape
[B x C x H x W]
box – Zero, one, or multiple bounding boxes per image. With N detections and a batch size of B, the bounding boxes have a shape of
[B*N x 4]
. Also, keep in mind that bboxes has to be a two-dimensional tensor, because every image in this batch can have a different number of detections. The ordering of the bounding boxes will stay the same.keypoints – Joint-coordinates as key-points with coordinates in relation to the original image. With N detections per image and a batch size of B, the coordinates have a max shape of
[B*N x J x 2|3]
. Either batch and detections are stacked in one dimension, because every image in this batch can have a different number of detections, or there is not batched dimension at all. The ordering of the coordinates will stay the same.output_size – (h, w) as target height and width of the image
mode – See class description.
aspect_round_decimals – (int, optional) Before comparing them, round the aspect ratios to the number of decimals. Default
DEF_VAL.images.aspect_round_decimals
.fill – (Union[int, float, List[float]], optional) See parameter fill of
torchvision.transforms.v2.Pad()
. Only applicable ifmode
is ‘fill-pad’. In that instance, fill has to be set and is no longer optional / ignored.
- Returns:
Structured dict with updated and overwritten image(s), bboxes and coordinates. All additional input values are passed down as well.