imgaug.augmentables.batches¶
-
class
imgaug.augmentables.batches.
Batch
(images=None, heatmaps=None, segmentation_maps=None, keypoints=None, bounding_boxes=None, polygons=None, line_strings=None, data=None)[source]¶ Bases:
object
Class encapsulating a batch before and after augmentation.
Parameters: - images (None or (N,H,W,C) ndarray or list of (H,W,C) ndarray) – The images to augment.
- heatmaps (None or list of imgaug.augmentables.heatmaps.HeatmapsOnImage) – The heatmaps to augment.
- segmentation_maps (None or list of imgaug.augmentables.segmaps.SegmentationMapsOnImage) – The segmentation maps to augment.
- keypoints (None or list of imgaug.augmentables.kps.KeypointOnImage) – The keypoints to augment.
- bounding_boxes (None or list of imgaug.augmentables.bbs.BoundingBoxesOnImage) – The bounding boxes to augment.
- polygons (None or list of imgaug.augmentables.polys.PolygonsOnImage) – The polygons to augment.
- line_strings (None or list of imgaug.augmentables.lines.LineStringsOnImage) – The line strings to augment.
- data – Additional data that is saved in the batch and may be read out after augmentation. This could e.g. contain filepaths to each image in images. As this object is usually used for background augmentation with multiple processes, the augmented Batch objects might not be returned in the original order, making this information useful.
Attributes: bounding_boxes
Deprecated. Use
Batch.bounding_boxes_unaug
instead.heatmaps
Deprecated. Use
Batch.heatmaps_unaug
instead.images
Deprecated. Use
Batch.images_unaug
instead.keypoints
Deprecated. Use
Batch.keypoints_unaug
instead.segmentation_maps
Deprecated. Use
Batch.segmentation_maps_unaug
instead.
Methods
deepcopy -
bounding_boxes
¶ Deprecated. Use
Batch.bounding_boxes_unaug
instead.
-
deepcopy
(self, images_unaug='DEFAULT', images_aug='DEFAULT', heatmaps_unaug='DEFAULT', heatmaps_aug='DEFAULT', segmentation_maps_unaug='DEFAULT', segmentation_maps_aug='DEFAULT', keypoints_unaug='DEFAULT', keypoints_aug='DEFAULT', bounding_boxes_unaug='DEFAULT', bounding_boxes_aug='DEFAULT', polygons_unaug='DEFAULT', polygons_aug='DEFAULT', line_strings_unaug='DEFAULT', line_strings_aug='DEFAULT')[source]¶
-
heatmaps
¶ Deprecated. Use
Batch.heatmaps_unaug
instead.
-
images
¶ Deprecated. Use
Batch.images_unaug
instead.
-
keypoints
¶ Deprecated. Use
Batch.keypoints_unaug
instead.
-
segmentation_maps
¶ Deprecated. Use
Batch.segmentation_maps_unaug
instead.
-
class
imgaug.augmentables.batches.
UnnormalizedBatch
(images=None, heatmaps=None, segmentation_maps=None, keypoints=None, bounding_boxes=None, polygons=None, line_strings=None, data=None)[source]¶ Bases:
object
Class for batches of unnormalized data before and after augmentation.
Parameters: images (None or (N,H,W,C) ndarray or (N,H,W) ndarray or iterable of (H,W,C) ndarray or iterable of (H,W) ndarray) – The images to augment.
heatmaps (None or (N,H,W,C) ndarray or imgaug.augmentables.heatmaps.HeatmapsOnImage or iterable of (H,W,C) ndarray or iterable of imgaug.augmentables.heatmaps.HeatmapsOnImage) – The heatmaps to augment. If anything else than
HeatmapsOnImage
, then the number of heatmaps must match the number of images provided via parameter images. The number is contained either inN
or the first iterable’s size.segmentation_maps (None or (N,H,W) ndarray or imgaug.augmentables.segmaps.SegmentationMapsOnImage or iterable of (H,W) ndarray or iterable of imgaug.augmentables.segmaps.SegmentationMapsOnImage) – The segmentation maps to augment. If anything else than
SegmentationMapsOnImage
, then the number of segmaps must match the number of images provided via parameter images. The number is contained either inN
or the first iterable’s size.keypoints (None or list of (N,K,2) ndarray or tuple of number or imgaug.augmentables.kps.Keypoint or iterable of (K,2) ndarray or iterable of tuple of number or iterable of imgaug.augmentables.kps.Keypoint or iterable of imgaug.augmentables.kps.KeypointOnImage or iterable of iterable of tuple of number or iterable of iterable of imgaug.augmentables.kps.Keypoint) – The keypoints to augment. If a tuple (or iterable(s) of tuple), then iterpreted as (x,y) coordinates and must hence contain two numbers. A single tuple represents a single coordinate on one image, an iterable of tuples the coordinates on one image and an iterable of iterable of tuples the coordinates on several images. Analogous if
Keypoint
objects are used instead of tuples. If an ndarray, thenN
denotes the number of images andK
the number of keypoints on each image. If anything else thanKeypointsOnImage
is provided, then the number of keypoint groups must match the number of images provided via parameter images. The number is contained e.g. inN
or in case of “iterable of iterable of tuples” in the first iterable’s size.bounding_boxes (None or (N,B,4) ndarray or tuple of number or imgaug.augmentables.bbs.BoundingBox or imgaug.augmentables.bbs.BoundingBoxesOnImage or iterable of (B,4) ndarray or iterable of tuple of number or iterable of imgaug.augmentables.bbs.BoundingBox or iterable of imgaug.augmentables.bbs.BoundingBoxesOnImage or iterable of iterable of tuple of number or iterable of iterable imgaug.augmentables.bbs.BoundingBox) – The bounding boxes to augment. This is analogous to the keypoints parameter. However, each tuple – and also the last index in case of arrays – has size 4, denoting the bounding box coordinates
x1
,y1
,x2
andy2
.polygons (None or (N,#polys,#points,2) ndarray or imgaug.augmentables.polys.Polygon or imgaug.augmentables.polys.PolygonsOnImage or iterable of (#polys,#points,2) ndarray or iterable of tuple of number or iterable of imgaug.augmentables.kps.Keypoint or iterable of imgaug.augmentables.polys.Polygon or iterable of imgaug.augmentables.polys.PolygonsOnImage or iterable of iterable of (#points,2) ndarray or iterable of iterable of tuple of number or iterable of iterable of imgaug.augmentables.kps.Keypoint or iterable of iterable of imgaug.augmentables.polys.Polygon or iterable of iterable of iterable of tuple of number or iterable of iterable of iterable of tuple of imgaug.augmentables.kps.Keypoint) – The polygons to augment. This is similar to the keypoints parameter. However, each polygon may be made up of several
(x,y)
coordinates (three or more are required for valid polygons). The following datatypes will be interpreted as a single polygon on a single image:imgaug.augmentables.polys.Polygon
iterable of tuple of number
iterable of imgaug.augmentables.kps.Keypoint
The following datatypes will be interpreted as multiple polygons on a single image:
imgaug.augmentables.polys.PolygonsOnImage
iterable of imgaug.augmentables.polys.Polygon
iterable of iterable of tuple of number
iterable of iterable of imgaug.augmentables.kps.Keypoint
iterable of iterable of imgaug.augmentables.polys.Polygon
The following datatypes will be interpreted as multiple polygons on multiple images:
(N,#polys,#points,2) ndarray
iterable of (#polys,#points,2) ndarray
iterable of iterable of (#points,2) ndarray
iterable of iterable of iterable of tuple of number
iterable of iterable of iterable of tuple of imgaug.augmentables.kps.Keypoint
line_strings (None or (N,#lines,#points,2) ndarray or imgaug.augmentables.lines.LineString or imgaug.augmentables.lines.LineStringOnImage or iterable of (#lines,#points,2) ndarray or iterable of tuple of number or iterable of imgaug.augmentables.kps.Keypoint or iterable of imgaug.augmentables.lines.LineString or iterable of imgaug.augmentables.lines.LineStringOnImage or iterable of iterable of (#points,2) ndarray or iterable of iterable of tuple of number or iterable of iterable of imgaug.augmentables.kps.Keypoint or iterable of iterable of imgaug.augmentables.polys.LineString or iterable of iterable of iterable of tuple of number or iterable of iterable of iterable of tuple of imgaug.augmentables.kps.Keypoint) – The line strings to augment. See polygons for more details as polygons follow a similar structure to line strings.
data – Additional data that is saved in the batch and may be read out after augmentation. This could e.g. contain filepaths to each image in images. As this object is usually used for background augmentation with multiple processes, the augmented Batch objects might not be returned in the original order, making this information useful.
Methods
fill_from_augmented_normalized_batch
(self, …)Fill this batch with (normalized) augmentation results. to_normalized_batch
(self)Convert this unnormalized batch to an instance of Batch. -
fill_from_augmented_normalized_batch
(self, batch_aug_norm)[source]¶ Fill this batch with (normalized) augmentation results.
This method receives a (normalized) Batch instance, takes all
*_aug
attributes out if it and assigns them to this batch in unnormalized form. Hence, the datatypes of all*_aug
attributes will match the datatypes of the*_unaug
attributes.Parameters: batch_aug_norm (imgaug.augmentables.batches.Batch) – Batch after normalization and augmentation. Returns: New UnnormalizedBatch instance. All *_unaug
attributes are taken from the old UnnormalizedBatch (without deepcopying them) and all*_aug
attributes are taken from batch_normalized converted to unnormalized form.Return type: imgaug.augmentables.batches.UnnormalizedBatch
-
to_normalized_batch
(self)[source]¶ Convert this unnormalized batch to an instance of Batch.
As this method is intended to be called before augmentation, it assumes that none of the
*_aug
attributes is yet set. It will produce an AssertionError otherwise.The newly created Batch’s
*_unaug
attributes will match the ones in this batch, just in normalized form.Returns: The batch, with *_unaug
attributes being normalized.Return type: imgaug.augmentables.batches.Batch