imgaug.augmenters.debug

Augmenters that help with debugging.

List of augmenters:

Added in 0.4.0.

class imgaug.augmenters.debug.SaveDebugImageEveryNBatches(destination, interval, seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]

Bases: imgaug.augmenters.debug._SaveDebugImage

Visualize data in batches and save corresponding plots to a folder.

Added in 0.4.0.

Supported dtypes:

See draw_debug_image().

Parameters:
  • destination (str or _IImageDestination) – Path to a folder. The saved images will follow a filename pattern of batch_<batch_id>.png. The latest image will additionally be saved to latest.png.
  • interval (int) – Interval in batches. If set to N, every N th batch an image will be generated and saved, starting with the first observed batch. Note that the augmenter only counts batches that it sees. If it is executed conditionally or re-instantiated, it may not see all batches or the counter may be wrong in other ways.
  • seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See __init__().
  • name (None or str, optional) – See __init__().
  • random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.
  • deterministic (bool, optional) – Deprecated since 0.4.0. See method to_deterministic() for an alternative and for details about what the “deterministic mode” actually does.

Examples

>>> import imgaug.augmenters as iaa
>>> import tempfile
>>> folder_path = tempfile.mkdtemp()
>>> seq = iaa.Sequential([
>>>     iaa.Sequential([
>>>         iaa.Fliplr(0.5),
>>>         iaa.Crop(px=(0, 16))
>>>     ], random_order=True),
>>>     iaa.SaveDebugImageEveryNBatches(folder_path, 100)
>>> ])

Methods

__call__(self, *args, **kwargs) Alias for augment().
augment(self[, return_batch, hooks]) Augment a batch.
augment_batch(self, batch[, hooks]) Deprecated.
augment_batch_(self, batch[, parents, hooks]) Augment a single batch in-place.
augment_batches(self, batches[, hooks, …]) Augment multiple batches.
augment_bounding_boxes(self, …[, parents, …]) Augment a batch of bounding boxes.
augment_heatmaps(self, heatmaps[, parents, …]) Augment a batch of heatmaps.
augment_image(self, image[, hooks]) Augment a single image.
augment_images(self, images[, parents, hooks]) Augment a batch of images.
augment_keypoints(self, keypoints_on_images) Augment a batch of keypoints/landmarks.
augment_line_strings(self, …[, parents, hooks]) Augment a batch of line strings.
augment_polygons(self, polygons_on_images[, …]) Augment a batch of polygons.
augment_segmentation_maps(self, segmaps[, …]) Augment a batch of segmentation maps.
copy(self) Create a shallow copy of this Augmenter instance.
copy_random_state(self, source[, recursive, …]) Copy the RNGs from a source augmenter sequence.
copy_random_state_(self, source[, …]) Copy the RNGs from a source augmenter sequence (in-place).
deepcopy(self) Create a deep copy of this Augmenter instance.
draw_grid(self, images, rows, cols) Augment images and draw the results as a single grid-like image.
find_augmenters(self, func[, parents, flat]) Find augmenters that match a condition.
find_augmenters_by_name(self, name[, regex, …]) Find augmenter(s) by name.
find_augmenters_by_names(self, names[, …]) Find augmenter(s) by names.
get_all_children(self[, flat]) Get all children of this augmenter as a list.
get_children_lists(self) Get a list of lists of children of this augmenter.
get_parameters(self) Get the parameters of this augmenter.
localize_random_state(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
localize_random_state_(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
pool(self[, processes, maxtasksperchild, seed]) Create a pool used for multicore augmentation.
remove_augmenters(self, func[, copy, …]) Remove this augmenter or children that match a condition.
remove_augmenters_(self, func[, parents]) Remove in-place children of this augmenter that match a condition.
remove_augmenters_inplace(self, func[, parents]) Deprecated.
reseed(self[, random_state, deterministic_too]) Deprecated.
seed_(self[, entropy, deterministic_too]) Seed this augmenter and all of its children.
show_grid(self, images, rows, cols) Augment images and plot the results as a single grid-like image.
to_deterministic(self[, n]) Convert this augmenter from a stochastic to a deterministic one.
get_parameters(self)[source]

Get the parameters of this augmenter.

Returns:List of parameters of arbitrary types (usually child class of StochasticParameter, but not guaranteed to be).
Return type:list
imgaug.augmenters.debug.draw_debug_image(images, heatmaps=None, segmentation_maps=None, keypoints=None, bounding_boxes=None, polygons=None, line_strings=None)[source]

Generate a debug image grid of a single batch and various datatypes.

Added in 0.4.0.

Supported dtypes:

  • uint8: yes; tested
  • uint16: ?
  • uint32: ?
  • uint64: ?
  • int8: ?
  • int16: ?
  • int32: ?
  • int64: ?
  • float16: ?
  • float32: ?
  • float64: ?
  • float128: ?
  • bool: ?
Parameters:
  • images (ndarray or list of ndarray) – Images in the batch. Must always be provided. Batches without images cannot be visualized.
  • heatmaps (None or list of imgaug.augmentables.heatmaps.HeatmapsOnImage, optional) – Heatmaps on the provided images.
  • segmentation_maps (None or list of imgaug.augmentables.segmaps.SegmentationMapsOnImage, optional) – Segmentation maps on the provided images.
  • keypoints (None or list of imgaug.augmentables.kps.KeypointsOnImage, optional) – Keypoints on the provided images.
  • bounding_boxes (None or list of imgaug.augmentables.bbs.BoundingBoxesOnImage, optional) – Bounding boxes on the provided images.
  • polygons (None or list of imgaug.augmentables.polys.PolygonsOnImage, optional) – Polygons on the provided images.
  • line_strings (None or list of imgaug.augmentables.lines.LineStringsOnImage, optional) – Line strings on the provided images.
Returns:

Visualized batch as RGB image.

Return type:

ndarray

Examples

>>> import numpy as np
>>> import imgaug.augmenters as iaa
>>> image = np.zeros((64, 64, 3), dtype=np.uint8)
>>> debug_image = iaa.draw_debug_image(images=[image, image])

Generate a debug image for two empty images.

>>> from imgaug.augmentables.kps import KeypointsOnImage
>>> kpsoi = KeypointsOnImage.from_xy_array([(10.5, 20.5), (30.5, 30.5)],
>>>                                        shape=image.shape)
>>> debug_image = iaa.draw_debug_image(images=[image, image],
>>>                                    keypoints=[kpsoi, kpsoi])

Generate a debug image for two empty images, each having two keypoints drawn on them.

>>> from imgaug.augmentables.batches import UnnormalizedBatch
>>> segmap_arr = np.zeros((32, 32, 1), dtype=np.int32)
>>> kp_tuples = [(10.5, 20.5), (30.5, 30.5)]
>>> batch = UnnormalizedBatch(images=[image, image],
>>>                           segmentation_maps=[segmap_arr, segmap_arr],
>>>                           keypoints=[kp_tuples, kp_tuples])
>>> batch = batch.to_normalized_batch()
>>> debug_image = iaa.draw_debug_image(
>>>     images=batch.images_unaug,
>>>     segmentation_maps=batch.segmentation_maps_unaug,
>>>     keypoints=batch.keypoints_unaug)

Generate a debug image for two empty images, each having an empty segmentation map and two keypoints drawn on them. This example uses UnnormalizedBatch to show how to mostly evade going through imgaug classes.