Ë
    \;jÞ«  ã                   óê   — d Z ddlmZmZmZ ddlZddlZddlm	Z
 ddlmZ ddlmZ d	Zg d
¢Z ej                   dg d¢«      Zd„ Zd„ Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)z@Classes representing batches of normalized or unnormalized data.é    )Úprint_functionÚdivisionÚabsolute_importNé   )Úimgaugé   )Únormalization)ÚutilsÚDEFAULT©ÚimagesÚheatmapsÚsegmentation_mapsÚ	keypointsÚbounding_boxesÚpolygonsÚline_stringsÚ_AugmentableColumn)ÚnameÚvalueÚ	attr_namec                 óT   — t        | |«      D �cg c]  }|j                  ‘Œ c}S c c}w ©N)Ú_get_columnsr   )ÚbatchÚpostfixÚcolumns      údG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\imgaug/augmentables/batches.pyÚ_get_column_namesr      s7   € ô ˜E 7Ô+ó-á+ð ð �K‹Kà+ñ-ð -ùò -s   �%c                 ó¤   — g }t         D ]D  }||z   }t        | ||z   «      }|€Œt        |«      dkD  sŒ)|j                  t	        |||«      «       ŒF |S )Nr   )Ú_AUGMENTABLE_NAMESÚgetattrÚlenÚappendr   )r   r   Úresultr   r   r   s         r   r   r      sY   € Ø€Fß"ˆØ˜7‘Nˆ	Ü˜˜t g™~Ó.ˆð
 Ñ¤ U£¨a£Ø�M‰MÔ,¨T°5¸)ÓDÕEð #ð €Mó    c                   ó6   — e Zd ZdZ	 	 	 dd„Zd„ Zd„ Zd„ Zd„ Zy)	ÚUnnormalizedBatcha  
    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 in ``N`` 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 in ``N`` 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, then ``N`` denotes the number of images and ``K`` the
        number of keypoints on each image.
        If anything else than ``KeypointsOnImage`` is provided, then the
        number of keypoint groups must match the number of images provided
        via parameter `images`. The number is contained e.g. in ``N`` 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`` and ``y2``.

    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.

    Nc	                 óÖ   — || _         d| _        || _        d| _        || _        d| _        || _        d| _        || _        d| _	        || _
        d| _        || _        d| _        || _        y)z4Construct a new :class:`UnnormalizedBatch` instance.N©Úimages_unaugÚ
images_augÚheatmaps_unaugÚheatmaps_augÚsegmentation_maps_unaugÚsegmentation_maps_augÚkeypoints_unaugÚkeypoints_augÚbounding_boxes_unaugÚbounding_boxes_augÚpolygons_unaugÚpolygons_augÚline_strings_unaugÚline_strings_augÚdata©	Úselfr   r   r   r   r   r   r   r9   s	            r   Ú__init__zUnnormalizedBatch.__init__…   óz   € ð #ˆÔØˆŒØ&ˆÔØ ˆÔØ'8ˆÔ$Ø%)ˆÔ"Ø(ˆÔØ!ˆÔØ$2ˆÔ!Ø"&ˆÔØ&ˆÔØ ˆÔØ".ˆÔØ $ˆÔØˆ�	r&   c                 ó   — t        | d«      S ©á–  Get the names of types of augmentables that contain data.

        This method is intended for situations where one wants to know which
        data is contained in the batch that has to be augmented, visualized
        or something similar.

        Added in 0.4.0.

        Returns
        -------
        list of str
            Names of types of augmentables. E.g. ``["images", "polygons"]``.

        Ú_unaug©r   ©r;   s    r   Úget_column_namesz"UnnormalizedBatch.get_column_names™   ó   € ô !  xÓ0Ð0r&   c                 óÖ  — t        | j                  j                  «       D ��cg c]  \  }}|j                  d«      r|du ‘Œ c}}«      }|sJ d«       ‚t	        j
                  | j                  «      }d}|�|D �cg c]  }|j                  ‘Œ }}t        |t	        j                  | j                  |«      t	        j                  | j                  |«      t	        j                  | j                  |«      t	        j                  | j                   |«      t	        j"                  | j$                  |«      t	        j&                  | j(                  |«      | j*                  ¬«      S c c}}w c c}w )a  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
        -------
        imgaug.augmentables.batches.Batch
            The batch, with ``*_unaug`` attributes being normalized.

        Ú_augNz†Expected UnnormalizedBatch to not contain any augmented data before normalization, but at least one '*_aug' attribute was already set.©r   r   r   r   r   r   r   r9   )ÚallÚ__dict__ÚitemsÚendswithÚnlibÚnormalize_imagesr+   ÚshapeÚBatchÚnormalize_heatmapsr-   Únormalize_segmentation_mapsr/   Únormalize_keypointsr1   Únormalize_bounding_boxesr3   Únormalize_polygonsr5   Únormalize_line_stringsr7   r9   )r;   r   ÚattrÚcontains_no_augmented_data_yetr+   ÚshapesÚimages          r   Úto_normalized_batchz%UnnormalizedBatch.to_normalized_batchª   s]  € ô  *-ð �}‰}×"Ñ"Ô$ô.+ñ %ñ  �	˜4à×!Ñ! &Ô)ð �DŠLà$ò.+ó *,Ð&ñ
 .ð 	ðó	Ð-ô
 ×,Ñ,¨T×->Ñ->Ó?ˆØˆØÐ#Ù/;Ó<©| e�e—k“k¨|ˆFÐ<äØÜ×,Ñ,Ø×#Ñ# Vó-ä"×>Ñ>Ø×,Ñ,¨fó6ä×.Ñ.Ø×$Ñ$ fó.ä×8Ñ8Ø×)Ñ)¨6ó3ä×,Ñ,Ø×#Ñ# Vó-ä×4Ñ4Ø×'Ñ'¨ó1à—‘ô
ð 	
ùó.+ùò =s   £E 
Á:E&c                 ó˜  — t        j                  |j                  | j                  «      | _        t        j                  |j
                  | j                  «      | _        t        j                  |j                  | j                  «      | _        t        j                  |j                  | j                  «      | _        t        j                  |j                  | j                  «      | _        t        j                   |j"                  | j$                  «      | _        t        j&                  |j(                  | j*                  «      | _        | S )aF  
        Fill this batch with (normalized) augmentation results in-place.

        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.

        Added in 0.4.0.

        Parameters
        ----------
        batch_aug_norm: imgaug.augmentables.batches.Batch
            Batch after normalization and augmentation.

        Returns
        -------
        imgaug.augmentables.batches.UnnormalizedBatch
            This instance itself.
            All ``*_unaug`` attributes are unchanged.
            All ``*_aug`` attributes are taken from `batch_normalized`,
            converted to unnormalized form.

        )rM   Úinvert_normalize_imagesr,   r+   Úinvert_normalize_heatmapsr.   r-   Ú"invert_normalize_segmentation_mapsr0   r/   Úinvert_normalize_keypointsr2   r1   Úinvert_normalize_bounding_boxesr4   r3   Úinvert_normalize_polygonsr6   r5   Úinvert_normalize_line_stringsr8   r7   )r;   Úbatch_aug_norms     r   Ú%fill_from_augmented_normalized_batch_z7UnnormalizedBatch.fill_from_augmented_normalized_batch_Ú   s  € ô2 ×6Ñ6Ø×%Ñ% t×'8Ñ'8ó:ˆŒä ×:Ñ:Ø×'Ñ'¨×)<Ñ)<ó>ˆÔä%)×%LÑ%LØ×0Ñ0°$×2NÑ2Nó&PˆÔ"ä!×<Ñ<Ø×(Ñ(¨$×*>Ñ*>ó@ˆÔä"&×"FÑ"FØ×-Ñ-¨t×/HÑ/Hó#JˆÔä ×:Ñ:Ø×'Ñ'¨×)<Ñ)<ó>ˆÔä $× BÑ BØ×+Ñ+¨T×-DÑ-Dó!FˆÔàˆr&   c           
      ó^  — t        | j                  | j                  | j                  | j                  | j
                  | j                  | j                  |j                  ¬«      }t        j                  |j                  | j                  «      |_        t        j                  |j                  | j                  «      |_        t        j                  |j                  | j                  «      |_        t        j                   |j"                  | j                  «      |_        t        j$                  |j&                  | j
                  «      |_        t        j(                  |j*                  | j                  «      |_        t        j,                  |j.                  | j                  «      |_        |S )ag  
        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
        -------
        imgaug.augmentables.batches.UnnormalizedBatch
            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.

        rH   )r(   r+   r-   r/   r1   r3   r5   r7   r9   rM   r]   r,   r^   r.   r_   r0   r`   r2   ra   r4   rb   r6   rc   r8   )r;   rd   r   s      r   Ú$fill_from_augmented_normalized_batchz6UnnormalizedBatch.fill_from_augmented_normalized_batch  s_  € ô4 "Ø×$Ñ$Ø×(Ñ(Ø"×:Ñ:Ø×*Ñ*Ø×4Ñ4Ø×(Ñ(Ø×0Ñ0Ø×$Ñ$ô	
ˆô  ×7Ñ7Ø×%Ñ% t×'8Ñ'8ó:ˆÔä!×;Ñ;Ø×'Ñ'¨×)<Ñ)<ó>ˆÔä&*×&MÑ&MØ×0Ñ0°$×2NÑ2Nó'PˆÔ#ä"×=Ñ=Ø×(Ñ(¨$×*>Ñ*>ó@ˆÔä#'×#GÑ#GØ×-Ñ-¨t×/HÑ/Hó$JˆÔ ä!×;Ñ;Ø×'Ñ'¨×)<Ñ)<ó>ˆÔä!%×!CÑ!CØ×+Ñ+¨T×-DÑ-Dó"FˆÔð ˆr&   ©NNNNNNNN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r<   rD   r[   re   rg   © r&   r   r(   r(   -   s1   „ ñUðn FJØ?CØ)-óò(1ò".
ò`'óR4r&   r(   c                   ó|  — e Zd ZdZ	 	 	 dd„Ze ej                  d«      d„ «       «       Ze ej                  d«      d„ «       «       Z	e ej                  d«      d	„ «       «       Z
e ej                  d
«      d„ «       «       Ze ej                  d«      d„ «       «       Zd„ Zd„ Zd„ Zd„ Zeeeeeeeeeeeeeefd„Zy)rP   aÿ  
    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.

    Nc	                 óÖ   — || _         d| _        || _        d| _        || _        d| _        || _        d| _        || _        d| _	        || _
        d| _        || _        d| _        || _        y)z(Construct a new :class:`Batch` instance.Nr*   r:   s	            r   r<   zBatch.__init__^  r=   r&   zBatch.images_unaugc                 ó   — | j                   S )zGet unaugmented images.)r+   rC   s    r   r   zBatch.imagesr  s   € ð × Ñ Ð r&   zBatch.heatmaps_unaugc                 ó   — | j                   S )zGet unaugmented heatmaps.)r-   rC   s    r   r   zBatch.heatmapsx  s   € ð ×"Ñ"Ð"r&   zBatch.segmentation_maps_unaugc                 ó   — | j                   S )z"Get unaugmented segmentation maps.)r/   rC   s    r   r   zBatch.segmentation_maps~  s   € ð ×+Ñ+Ð+r&   zBatch.keypoints_unaugc                 ó   — | j                   S )zGet unaugmented keypoints.)r1   rC   s    r   r   zBatch.keypoints„  s   € ð ×#Ñ#Ð#r&   zBatch.bounding_boxes_unaugc                 ó   — | j                   S )zGet unaugmented bounding boxes.)r3   rC   s    r   r   zBatch.bounding_boxesŠ  s   € ð ×(Ñ(Ð(r&   c                 ó   — t        | d«      S r?   rB   rC   s    r   rD   zBatch.get_column_names�  rE   r&   c                 ó   — | S )a6  Return this batch.

        This method does nothing and only exists to simplify interfaces
        that accept both :class:`UnnormalizedBatch` and :class:`Batch`.

        Added in 0.4.0.

        Returns
        -------
        imgaug.augmentables.batches.Batch
            This batch (not copied).

        rm   rC   s    r   r[   zBatch.to_normalized_batch¡  ó	   € ð ˆr&   c                 ó  — d„ }t         || j                  «       || j                  «       || j                  «       || j                  «       || j
                  «       || j                  «       || j                  «      ¬«      S )zÝConvert this batch to a :class:`_BatchInAugmentation` instance.

        Added in 0.4.0.

        Returns
        -------
        imgaug.augmentables.batches._BatchInAugmentation
            The converted batch.

        c                 ó4   — | �t        j                  | «      S | S r   )r
   Úcopy_augmentables)Úvars    r   Ú_copyz-Batch.to_batch_in_augmentation.<locals>._copy¼  s   € àˆÜ×.Ñ.¨sÓ3Ð3ØˆJr&   r   )Ú_BatchInAugmentationr+   r-   r/   r1   r3   r5   r7   )r;   r|   s     r   Úto_batch_in_augmentationzBatch.to_batch_in_augmentation±  sx   € ò	ô $Ù˜×*Ñ*Ó+Ù˜4×.Ñ.Ó/Ù# D×$@Ñ$@ÓAÙ˜D×0Ñ0Ó1Ù  ×!:Ñ!:Ó;Ù˜4×.Ñ.Ó/Ù˜t×6Ñ6Ó7ô
ð 	
r&   c                 óô   — |j                   | _        |j                  | _        |j                  | _        |j                  | _        |j                  | _	        |j                  | _        |j                  | _        | S )aÉ  Set the columns in this batch to the column values of another batch.

        This method works in-place.

        Added in 0.4.0.

        Parameters
        ----------
        batch_in_augmentation : _BatchInAugmentation
            Batch of which to use the column values.
            The values are *not* copied. Only their references are used.

        Returns
        -------
        Batch
            The updated batch. (Modified in-place.)

        )r   r,   r   r.   r   r0   r   r2   r   r4   r   r6   r   r8   ©r;   Úbatch_in_augmentations     r   Ú fill_from_batch_in_augmentation_z&Batch.fill_from_batch_in_augmentation_Ì  sj   € ð& 0×6Ñ6ˆŒØ1×:Ñ:ˆÔØ%:×%LÑ%LˆÔ"Ø2×<Ñ<ˆÔØ"7×"FÑ"FˆÔØ1×:Ñ:ˆÔØ 5× BÑ BˆÔØˆr&   c                 óª  — d„ }t         || j                  |«       || j                  |«       || j                  |«       || j                  |«       || j
                  |	«       || j                  |«       || j                  |«      t        j                  | j                  «      ¬«      } || j                  |«      |_         || j                  |«      |_         || j                  |«      |_         || j                  |«      |_         || j                  |
«      |_         || j                   |«      |_         || j"                  |«      |_        |S )aº  Copy this batch and all of its column values.

        Parameters
        ----------
        images_unaug : imgaug.augmentables.batches.DEFAULT or None or (N,H,W,C) ndarray or list of (H,W,C) ndarray
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        images_aug : imgaug.augmentables.batches.DEFAULT or None or (N,H,W,C) ndarray or list of (H,W,C) ndarray
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        heatmaps_unaug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.heatmaps.HeatmapsOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        heatmaps_aug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.heatmaps.HeatmapsOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        segmentation_maps_unaug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.segmaps.SegmentationMapsOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        segmentation_maps_aug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.segmaps.SegmentationMapsOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        keypoints_unaug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.kps.KeypointOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        keypoints_aug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.kps.KeypointOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        bounding_boxes_unaug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.bbs.BoundingBoxesOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        bounding_boxes_aug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.bbs.BoundingBoxesOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        polygons_unaug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.polys.PolygonsOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        polygons_aug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.polys.PolygonsOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        line_strings_unaug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.lines.LineStringsOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        line_strings_aug : imgaug.augmentables.batches.DEFAULT or None or list of imgaug.augmentables.lines.LineStringsOnImage
            Copies the current attribute value without changes if set to
            ``imgaug.augmentables.batches.DEFAULT``.
            Otherwise same as in :func:`Batch.__init__`.

        Returns
        -------
        Batch
            Deep copy of the batch, optionally with new attributes.

        c                 óH   — t        j                  |t        ur|«      S | «      S r   )r
   Údeepcopy_fastr   )Ú	self_attrÚargs     r   Ú_copy_optionalz&Batch.deepcopy.<locals>._copy_optionalG  s"   € Ü×&Ñ&¨c¼Ñ.@ sÓPÐPÀiÓPÐPr&   rH   )rP   r+   r-   r/   r1   r3   r5   r7   r
   r…   r9   r,   r.   r0   r2   r4   r6   r8   )r;   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   rˆ   r   s                    r   ÚdeepcopyzBatch.deepcopyè  sH  € ò~	Qô Ù! $×"3Ñ"3°\ÓBÙ# D×$7Ñ$7¸ÓHÙ,¨T×-IÑ-IØ-DóFá$ T×%9Ñ%9¸?ÓKÙ)¨$×*CÑ*CØ*>ó@á# D×$7Ñ$7¸ÓHÙ'¨×(?Ñ(?Ø(:ó<ä×$Ñ$ T§Y¡YÓ/ô
ˆñ *¨$¯/©/¸:ÓFˆÔÙ+¨D×,=Ñ,=¸|ÓLˆÔÙ&4°T×5OÑ5OØ5Jó'LˆÔ#á,¨T×-?Ñ-?ÀÓOˆÔÙ#1°$×2IÑ2IØ2Dó$FˆÔ á+¨D×,=Ñ,=¸|ÓLˆÔÙ!/°×0EÑ0EØ0@ó"BˆÔð ˆr&   rh   )ri   rj   rk   rl   r<   ÚpropertyÚiaÚ
deprecatedr   r   r   r   r   rD   r[   r~   r‚   r   r‰   rm   r&   r   rP   rP   :  s(  „ ñ!ðF FJØ?CØ)-óð( Ø€R‡]�]Ð'Ó(ñ!ó )ó ð!ð Ø€R‡]�]Ð)Ó*ñ#ó +ó ð#ð Ø€R‡]�]Ð2Ó3ñ,ó 4ó ð,ð Ø€R‡]�]Ð*Ó+ñ$ó ,ó ð$ð Ø€R‡]�]Ð/Ó0ñ)ó 1ó ð)ò1ò"ò 
ò6ð: &Ø#Ø 'Ø%Ø)0Ø'.Ø!(Ø&Ø&-Ø$+Ø 'Ø%Ø$+Ø")ôzr&   rP   c                   ó   — e Zd Zd„ Zd„ Zd„ Zy)Ú&_BatchInAugmentationPropagationContextc                 óJ   — || _         || _        || _        || _        d | _        y r   )r   Ú	augmenterÚhooksÚparentsÚ
noned_info)r;   r   r�   r‘   r’   s        r   r<   z/_BatchInAugmentationPropagationContext.__init__g  s%   € ØˆŒ
Ø"ˆŒØˆŒ
ØˆŒØˆ�r&   c                 ó²   — | j                   �@| j                  j                  | j                  | j                   | j                  «      | _        | j                  S r   )r‘   r   Úapply_propagation_hooks_r�   r’   r“   rC   s    r   Ú	__enter__z0_BatchInAugmentationPropagationContext.__enter__n  s?   € Ø�:‰:Ð!Ø"Ÿj™j×AÑAØ—‘ §
¡
¨D¯L©Ló:ˆDŒOà�z‰zÐr&   c                 ór   — | j                   �+| j                  j                  | j                   «      | _        y y r   )r“   r   Úinvert_apply_propagation_hooks_)r;   Úexc_typeÚexc_valÚexc_tbs       r   Ú__exit__z/_BatchInAugmentationPropagationContext.__exit__t  s.   € Ø�?‰?Ð&à—
‘
×:Ñ:¸4¿?¹?ÓKð �Jð 'r&   N)ri   rj   rk   r<   r–   rœ   rm   r&   r   rŽ   rŽ   f  s   „ òòóLr&   rŽ   c                   ó�   — e Zd ZdZ	 	 	 dd„Zed„ «       Zed„ «       Zed„ «       Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)r}   aC  
    Class encapsulating a batch during the augmentation process.

    Data within the batch is already verified and normalized, similar to
    :class:`Batch`. Data within the batch may be changed in-place. No initial
    copy is needed.

    Added in 0.4.0.

    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.

    Nc	                 ót   — || _         || _        || _        || _        || _        || _        || _        || _        y)z4Create a new :class:`_BatchInAugmentation` instance.NrH   r:   s	            r   r<   z_BatchInAugmentation.__init__ž  s?   € ð ˆŒØ ˆŒØ!2ˆÔØ"ˆŒØ,ˆÔØ ˆŒØ(ˆÔØˆ�	r&   c                 ó    — | j                   dk(  S )zíEstimate whether this batch is empty, i.e. contains no data.

        Added in 0.4.0.

        Returns
        -------
        bool
            ``True`` if the batch contains no data to augment.
            ``False`` otherwise.

        r   )Únb_rowsrC   s    r   Úemptyz_BatchInAugmentation.empty«  s   € ð �|‰|˜qÑ Ð r&   c                 óP   — t         D ]  }t        | |«      }|€Œt        |«      c S  y)a)  Get the number of rows (i.e. examples) in this batch.

        Note that this method assumes that all columns have the same number
        of rows.

        Added in 0.4.0.

        Returns
        -------
        int
            Number of rows or ``0`` if there is no data in the batch.

        r   )r!   r"   r#   )r;   Ú	augm_namer   s      r   r    z_BatchInAugmentation.nb_rowsº  s/   € ÷ ,ˆIÜ˜D )Ó,ˆEØÑ Ü˜5“zÒ!ð ,ð r&   c                 ó   — t        | d«      S )a*  Get the columns of data to augment.

        Each column represents one datatype and its corresponding data,
        e.g. images or polygons.

        Added in 0.4.0.

        Returns
        -------
        list of _AugmentableColumn
            The columns to augment within this batch.

        Ú )r   rC   s    r   Úcolumnsz_BatchInAugmentation.columnsÏ  s   € ô ˜D "Ó%Ð%r&   c                 ó   — t        | d«      S )r@   r¥   rB   rC   s    r   rD   z%_BatchInAugmentation.get_column_namesà  s   € ô !  rÓ*Ð*r&   c                 óº  — | j                   }| j                  }dg|z  }t        j                  |ft        ¬«      }|D ]›  }|j
                  dk(  r=t        j                  |j                  «      r|j                  j                  dd g|z  }n4t        |j                  «      D ]  \  }}|€Œ	|j                  ||<   d||<   Œ t        j                  |«      sŒ™|c S  |S )a  Get the shape of each row within this batch.

        Each row denotes the data of different types (e.g. image array,
        polygons) corresponding to a single example in the batch.

        This method assumes that all ``.shape`` attributes contain the same
        shape and that it is identical to the image's shape.
        It also assumes that there are no columns containing only ``None`` s.

        Added in 0.4.0.

        Returns
        -------
        list of tuple of int
            The shapes of each row.

        N)Údtyper   r   T)r    r¦   ÚnpÚzerosÚboolr   r‹   Úis_np_arrayr   rO   Ú	enumeraterI   )r;   r    r¦   rY   Úfoundr   ÚiÚitems           r   Úget_rowwise_shapesz'_BatchInAugmentation.get_rowwise_shapesñ  sÃ   € ð$ —,‘,ˆØ—,‘,ˆØ�˜'Ñ!ˆÜ—‘˜'˜¬4Ô0ˆÛˆFØ�{‰{˜hÒ&¬2¯>©>¸&¿,¹,Ô+GØ Ÿ,™,×,Ñ,¨Q¨RÐ0Ð1°GÑ;‘ä(¨¯©Ö6‘G�A�tØÑ'Ø$(§J¡J˜˜q™	Ø#'˜˜ašð  7ô �v‰v�e�}Ø’ð ð ˆr&   c                 óþ   — d| j                   i}t        D ]W  }t        | |«      }|�B|dk(  rt        j                  |«      r||   }n|D �cg c]  }||   ‘Œ	 }}t        |«      dk(  rd}|||<   ŒY t        di |¤ŽS c c}w )aH  Reduce this batch to a subset of rows based on their row indices.

        Added in 0.4.0.

        Parameters
        ----------
        indices : iterable of int
            Row indices to select.

        Returns
        -------
        _BatchInAugmentation
            Batch containing only a subselection of rows.

        r9   Nr   r   rm   )r9   r!   r"   r‹   r­   r#   r}   )r;   ÚindicesÚkwargsr£   ÚrowsÚindexs         r   Úsubselect_rows_by_indicesz._BatchInAugmentation.subselect_rows_by_indices  s‘   € ð  ˜$Ÿ)™)Ð$ˆß+ˆIÜ˜4 Ó+ˆDØÐØ Ò(¬R¯^©^¸DÔ-AØ ™=‘Dá5<Ó=±W¨E˜D ›K°W�DÐ=ä�t“9 ’>Ø�DØ $ˆF�9Òð ,ô $Ñ- fÑ-Ð-ùò >s   Á
A:c                 óD  — t         D �]‹  }t        | |«      }|€Œt        ||«      }|€Œ"|dk(  �rIt        j                  |«      �r3t        j                  |«      rK|j                  dd |j                  dd h}|j
                  j                  |j
                  j                  h}nyt        |j                  dd g|D �cg c]  }|j                  ‘Œ c}z   «      }t        |j
                  j                  g|D �cg c]  }|j
                  j                  ‘Œ c}z   «      }t        |«      dk(  rt        |«      dk(  r|||<   �Œ:t        |«      | _
        t        |«      D ]  \  }	}
||	   | j                  |
<   Œ �Œqt        |«      D ]  \  }	}
||	   ||
<   Œ �ŒŽ | S c c}w c c}w )a?  Reverse the subselection of rows in-place.

        This is the inverse of
        :func:`_BatchInAugmentation.subselect_rows_by_indices`.

        This method has to be executed on the batch *before* subselection.

        Added in 0.4.0.

        Parameters
        ----------
        indices : iterable of int
            Row indices that were selected. (This is the input to

        batch_subselected : _BatchInAugmentation
            The batch after
            :func:`_BatchInAugmentation.subselect_rows_by_indices` was called.

        Returns
        -------
        _BatchInAugmentation
            The updated batch. (Modified in-place.)

        Examples
        --------
        >>> import numpy as np
        >>> from imgaug.augmentables.batches import _BatchInAugmentation
        >>> images = np.zeros((2, 10, 20, 3), dtype=np.uint8)
        >>> batch = _BatchInAugmentation(images=images)
        >>> batch_sub = batch.subselect_rows_by_indices([0])
        >>> batch_sub.images += 1
        >>> batch = batch.invert_subselect_rows_by_indices_([0], batch_sub)

        Nr   r   )r!   r"   r‹   r­   rO   r©   r   Úsetr#   Úlistr   r®   )r;   r´   Úbatch_subselectedr£   r   Ú
column_subrY   ÚdtypesrZ   Ú	ith_indexr·   s              r   Ú!invert_subselect_rows_by_indices_z6_BatchInAugmentation.invert_subselect_rows_by_indices_2  s¤  € ÷F ,Ð+ˆIÜ˜T 9Ó-ˆFØÑ!Ü$Ð%6¸	ÓB�
ØÐ%ð
 Ø (Ó*¬r¯~©~¸fÕ/Eô —~‘~ jÔ1Ø"(§,¡,¨q¨rÐ"2°J×4DÑ4DÀQÀRÐ4HÐ!I˜Ø"(§,¡,×"3Ñ"3°Z×5EÑ5E×5JÑ5JÐ!K™ä!$Ø#Ÿ\™\¨!¨"Ð-Ð.Ù8BÓC¹
¨u˜uŸ{›{¸
ÑCñDó"E˜ô "%Ø#Ÿ\™\×.Ñ.Ð/Ù=GÓH¹Z°E˜uŸ{™{×/Ó/¸ZÑHñIó"J˜ô ˜6“{ aÒ'¬C°«K¸1Ò,<Ø*4˜˜w›ä&*¨6£l˜œÜ09¸'Ö0BÑ,˜I uØ1;¸IÑ1F˜DŸK™K¨Ò.ò 1Cô -6°gÖ,>Ñ(˜	 5Ø(2°9Ñ(=˜˜ušò -?ðA ,ðF ˆùò Dùò Is   Â=FÃ8Fc                 ó    — t        | |||¬«      S )a�  Start a context in which propagation hooks are applied.

        Added in 0.4.0.

        Parameters
        ----------
        augmenter : imgaug.augmenters.meta.Augmenter
            Augmenter to provide to the propagation hook function.

        hooks : imgaug.imgaug.HooksImages or imgaug.imgaug.HooksKeypoints
            The hooks that might contain a propagation hook function.

        parents : list of imgaug.augmenters.meta.Augmenter
            The list of parents to provide to the propagation hook function.

        Returns
        -------
        _BatchInAugmentationPropagationContext
            The progagation hook context.

        )r�   r‘   r’   )rŽ   )r;   r�   r‘   r’   s       r   Úpropagation_hooks_ctxz*_BatchInAugmentation.propagation_hooks_ctxz  s   € ô, 6Ø˜I¨U¸GôEð 	Er&   c                 óò   — |€yg }| j                   D ]b  }|j                  |j                  ||d¬«      }|rŒ%t        | |j                  d«       |j                  |j                  |j                  f«       Œd |S )a´  Set columns in this batch to ``None`` based on a propagation hook.

        This method works in-place.

        Added in 0.4.0.

        Parameters
        ----------
        augmenter : imgaug.augmenters.meta.Augmenter
            Augmenter to provide to the propagation hook function.

        hooks : imgaug.imgaug.HooksImages or imgaug.imgaug.HooksKeypoints
            The hooks that might contain a propagation hook function.

        parents : list of imgaug.augmenters.meta.Augmenter
            The list of parents to provide to the propagation hook function.

        Returns
        -------
        list of tuple of str
            Information about which columns were set to ``None``.
            Each tuple contains
            ``(column attribute name, column value before setting it to None)``.
            This information is required when calling
            :func:`_BatchInAugmentation.invert_apply_propagation_hooks_`.

        NT)r�   r’   Údefault)r¦   Úis_propagatingr   Úsetattrr   r$   )r;   r�   r‘   r’   r“   r   Úis_props          r   r•   z-_BatchInAugmentation.apply_propagation_hooks_“  s~   € ð8 ˆ=Øàˆ
Ø—l”lˆFØ×*Ñ*Ø—‘¨	¸7Øð +ó ˆGò Ü˜˜f×.Ñ.°Ô5Ø×!Ñ! 6×#3Ñ#3°V·\±\Ð"BÕCð #ð Ðr&   c                 ó4   — |D ]  \  }}t        | ||«       Œ | S )ac  Set columns from ``None`` back to their original values.

        This is the inverse of
        :func:`_BatchInAugmentation.apply_propagation_hooks_`.

        This method works in-place.

        Added in 0.4.0.

        Parameters
        ----------
        noned_info : list of tuple of str
            Information about which columns were set to ``None`` and their
            original values. This is the output of
            :func:`_BatchInAugmentation.apply_propagation_hooks_`.

        Returns
        -------
        _BatchInAugmentation
            The updated batch. (Modified in-place.)

        )rÆ   )r;   r“   r   r   s       r   r˜   z4_BatchInAugmentation.invert_apply_propagation_hooks_¼  s$   € ó. !+ÑˆI�uÜ�D˜) UÕ+ð !+àˆr&   c                 ó   — | S )a^  Convert this batch to a :class:`_BatchInAugmentation` instance.

        This method simply returns the batch itself. It exists for consistency
        with the other batch classes.

        Added in 0.4.0.

        Returns
        -------
        imgaug.augmentables.batches._BatchInAugmentation
            The batch itself. (Not copied.)

        rm   rC   s    r   r~   z-_BatchInAugmentation.to_batch_in_augmentation×  rw   r&   c                 ó   — || u r| S |j                   | _         |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        | S )aØ  Set the columns in this batch to the column values of another batch.

        This method works in-place.

        Added in 0.4.0.

        Parameters
        ----------
        batch_in_augmentation : _BatchInAugmentation
            Batch of which to use the column values.
            The values are *not* copied. Only their references are used.

        Returns
        -------
        _BatchInAugmentation
            The updated batch. (Modified in-place.)

        r   r€   s     r   r‚   z5_BatchInAugmentation.fill_from_batch_in_augmentation_ç  st   € ð& ! DÑ(ØˆKà+×2Ñ2ˆŒØ-×6Ñ6ˆŒØ!6×!HÑ!HˆÔØ.×8Ñ8ˆŒØ3×BÑBˆÔØ-×6Ñ6ˆŒØ1×>Ñ>ˆÔàˆr&   c           
      óº  — t        |j                  |j                  |j                  |j                  |j
                  |j                  |j                  |j                  ¬«      }| j                  |_
        | j                  |_        | j                  |_        | j                  |_        | j"                  |_        | j&                  |_        | j*                  |_        |S )a[  Convert this batch into a :class:`Batch` instance.

        Added in 0.4.0.

        Parameters
        ----------
        batch_before_aug : imgaug.augmentables.batches.Batch
            The batch before augmentation. It is required to set the input
            data of the :class:`Batch` instance, e.g. ``images_unaug``
            or ``data``.

        Returns
        -------
        imgaug.augmentables.batches.Batch
            Batch, with original unaugmented inputs from `batch_before_aug`
            and augmented outputs from this :class:`_BatchInAugmentation`
            instance.

        rH   )rP   r+   r-   r/   r1   r3   r5   r7   r9   r   r,   r   r.   r   r0   r   r2   r   r4   r   r6   r   r8   )r;   Úbatch_before_augr   s      r   Úto_batchz_BatchInAugmentation.to_batch  s·   € ô( Ø#×0Ñ0Ø%×4Ñ4Ø.×FÑFØ&×6Ñ6Ø+×@Ñ@Ø%×4Ñ4Ø)×<Ñ<Ø!×&Ñ&ô	
ˆð  Ÿ;™;ˆÔØ!Ÿ]™]ˆÔØ&*×&<Ñ&<ˆÔ#Ø"Ÿn™nˆÔØ#'×#6Ñ#6ˆÔ Ø!Ÿ]™]ˆÔØ!%×!2Ñ!2ˆÔØˆr&   c                 óÌ   — t        t        j                  | j                  «      ¬«      }t        D ]1  }t        | |«      }|€Œt        ||t        j                  |«      «       Œ3 |S )z³Copy this batch and all of its column values.

        Added in 0.4.0.

        Returns
        -------
        _BatchInAugmentation
            Deep copy of this batch.

        )r9   )r}   r
   r…   r9   r!   r"   rÆ   rz   )r;   r   r£   r   s       r   r‰   z_BatchInAugmentation.deepcopy.  sW   € ô %¬%×*=Ñ*=¸d¿i¹iÓ*HÔIˆç+ˆIÜ˜D )Ó,ˆEØÑ Ü˜˜y¬%×*AÑ*AÀ%Ó*HÕIð ,ð
 ˆr&   rh   )ri   rj   rk   rl   r<   rŠ   r¡   r    r¦   rD   r²   r¸   rÀ   rÂ   r•   r˜   r~   r‚   rÍ   r‰   rm   r&   r   r}   r}   z  s”   „ ñ ðF FJØ?CØ)-óð ñ!ó ð!ð ñó ðð( ñ&ó ð&ò +ò" òD.ò>FòPEò2'òRò6ò ò@%óNr&   r}   )rl   Ú
__future__r   r   r   ÚcollectionsÚnumpyrª   r¥   r   r‹   r	   rM   r
   r   r!   Ú
namedtupler   r   r   Úobjectr(   rP   rŽ   r}   rm   r&   r   Ú<module>rÔ      s‰   ðÙ Fß @Ñ @ã ã å Ý #Ý à
€ò2Ð ð ,�[×+Ñ+ØÚ"ó$Ð ò
-òô J˜ô JôZhˆFô hôX	L¨Vô Lô(F˜6õ Fr&   