Ë
    \;jÎ˜  ã                   óÖ  — d Z ddlmZmZmZ ddlmZmZmZ ddl	Z	ddl
Z
ddlZddl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d
lmZ dZeZd„ Z ej8                  e«       G d„ de«      «       Z G d„ de«      Z G d„ de«      Z  G d„ de«      Z! G d„ de«      Z" G d„ de«      Z# G d„ de«      Z$	 	 	 d9d„Z%d„ Z&d„ Z'd„ Z(d„ Z)d „ Z*d!„ Z+d"„ Z,d#„ Z-d$„ Z.d%„ Z/d&„ Z0d'„ Z1d(„ Z2 G d)„ d*e«      Z3 ej8                  e«       G d+„ d,e«      «       Z4 G d-„ d.e4«      Z5 G d/„ d0e4«      Z6 ej8                  e«       G d1„ d2e«      «       Z7 G d3„ d4e7«      Z8 G d5„ d6ejr                  «      Z: G d7„ d8e:«      Z;y):zxAugmenters that help with debugging.

List of augmenters:

    * :class:`SaveDebugImageEveryNBatches`

Added in 0.4.0.

é    )Úprint_functionÚdivisionÚabsolute_import)ÚABCMetaÚabstractmethodÚabstractpropertyNé   )Údtypesé   )Úmeta)Úsize)Úblend)éÿ   éÀ   éË   c                 óÔ  — |d   }|d   }| j                   d   }| j                   d   }||z  }||z
  }||z
  }	||	k  r|}
||z  }n||z  }
|}t        t        t        j                  |
«      «      d«      }
t        t        t        j                  |«      «      d«      }t        j                  | |
|f«      }||
z
  }||z
  }t        t        j                  |dz  «      «      }t        t        j                  |dz  «      «      }t        t        j                  |dz  «      «      }t        t        j                  |dz  «      «      }t        j                  ||||||¬«      }||||f}||
|f|fS )zñResize and pad and image to given size.

    This first resizes until one image size matches one size in `size` (while
    retaining the aspect ratio).
    Then it pads the other side until both sides match `size`.

    Added in 0.4.0.

    r   r   r	   ©ÚtopÚrightÚbottomÚleftÚcval)ÚshapeÚmaxÚintÚnpÚroundÚiaÚimresize_single_imageÚfloorÚceilÚsizelibÚpad)Úimager   r   ÚheightÚwidthÚ	height_imÚwidth_imÚaspect_ratio_imÚheight_diffÚ
width_diffÚheight_im_rsÚwidth_im_rsÚimage_rsÚpad_yÚpad_xÚpad_topÚ	pad_rightÚ
pad_bottomÚpad_leftÚimage_rs_padÚpaddingss                        ú`G:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\imgaug/augmenters/debug.pyÚ_resizepad_to_sizer8      sr  € ð �!‰W€FØ�‰G€EØ—‘˜A‘€IØ�{‰{˜1‰~€HØ Ñ*€Oð ˜9Ñ$€KØ˜Ñ!€JØ�ZÒØˆØ˜Ñ.‰à˜Ñ.ˆØˆä”sœ2Ÿ8™8 LÓ1Ó2°AÓ6€LÜ”cœ"Ÿ(™( ;Ó/Ó0°!Ó4€Kä×'Ñ'¨°¸kÐ/JÓK€Hð �\Ñ!€EØ�KÑ€EÜ”"—(‘(˜5 1™9Ó%Ó&€GÜ”B—G‘G˜E A™IÓ&Ó'€IÜ”R—W‘W˜U Q™YÓ'Ó(€JÜ”2—8‘8˜E A™IÓ&Ó'€Hä—;‘;˜xØ#*°)Ø&0°xØ$(ô*€Lð
 ˜ J°Ð9€HØ˜,¨Ð4°hÐ>Ð>ó    c                   ó@   — e Zd ZdZed„ «       Zed„ «       Zed„ «       Zy)Ú_IDebugGridCellz–A single cell within a debug image's grid.

    Usually corresponds to one image, but can also be e.g. a title/description.

    Added in 0.4.0.

    c                  ó   — y)zRMinimum width in pixels that the cell requires.

        Added in 0.4.0.

        N© ©Úselfs    r7   Ú	min_widthz_IDebugGridCell.min_width[   ó   � r9   c                  ó   — y)zSMinimum height in pixels that the cell requires.

        Added in 0.4.0.

        Nr=   r>   s    r7   Ú
min_heightz_IDebugGridCell.min_heightc   rA   r9   c                  ó   — y)ab  Draw the debug image grid cell's content.

        Added in 0.4.0.

        Parameters
        ----------
        height : int
            Expected height of the drawn cell image/array.

        width : int
            Expected width of the drawn cell image/array.

        Returns
        -------
        ndarray
            ``(H,W,3)`` Image.

        Nr=   )r?   r%   r&   s      r7   Údrawz_IDebugGridCell.drawk   rA   r9   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r@   rC   r   rE   r=   r9   r7   r;   r;   Q   sC   „ ñð ñó ðð ñó ðð ñó ñr9   r;   c                   ó<   — e Zd ZdZd„ Zed„ «       Zed„ «       Zd„ Zy)Ú_DebugGridBorderCellz\Helper to add a border around a cell within the debug image grid.

    Added in 0.4.0.

    c                 ó.   — || _         || _        || _        y ©N)r   ÚcolorÚchild)r?   r   rN   rO   s       r7   Ú__init__z_DebugGridBorderCell.__init__‰   s   € ØˆŒ	ØˆŒ
Øˆ�
r9   c                 ó.   — | j                   j                  S rM   )rO   rC   r>   s    r7   rC   z_DebugGridBorderCell.min_height�   s   € à�z‰z×$Ñ$Ð$r9   c                 ó.   — | j                   j                  S rM   )rO   r@   r>   s    r7   r@   z_DebugGridBorderCell.min_width”   s   € à�z‰z×#Ñ#Ð#r9   c           	      óÚ   — | j                   j                  ||«      }t        j                  || j                  | j                  | j                  | j                  d| j
                  ¬«      }|S )NÚconstant©r   r   r   r   Úmoder   )rO   rE   r"   r#   r   rN   )r?   r%   r&   Úcontents       r7   rE   z_DebugGridBorderCell.draw™   sQ   € Ø—*‘*—/‘/ &¨%Ó0ˆÜ—+‘+˜gØ"&§)¡)°4·9±9Ø%)§Y¡Y°T·Y±YØ#-°D·J±Jô@ˆð ˆr9   N©	rF   rG   rH   rI   rP   ÚpropertyrC   r@   rE   r=   r9   r7   rK   rK   �   s9   „ ñòð ñ%ó ð%ð ñ$ó ð$ór9   rK   c                   ó<   — e Zd ZdZd„ Zed„ «       Zed„ «       Zd„ Zy)Ú_DebugGridTextCellz0Cell containing text.

    Added in 0.4.0.

    c                 ó   — || _         y rM   )Útext)r?   r]   s     r7   rP   z_DebugGridTextCell.__init__ª   s	   € Øˆ�	r9   c                 ód   — t        dt        | j                  j                  d«      «      dz  «      S )Né   Ú
é   )r   Úlenr]   Úsplitr>   s    r7   rC   z_DebugGridTextCell.min_height®   s&   € ä�2”s˜4Ÿ9™9Ÿ?™?¨4Ó0Ó1°BÑ6Ó7Ð7r9   c                 óÐ   — | j                   j                  d«      }t        |«      dk(  ryt        dt	        dt        |D �cg c]  }t        |«      ‘Œ c}«      z  «      «      S c c}w )Nr`   r   r_   é   )r]   rc   rb   r   r   )r?   ÚlinesÚlines      r7   r@   z_DebugGridTextCell.min_width³   sT   € à—	‘	—‘ Ó%ˆÜˆu‹:˜Š?ØÜ�2”s˜1œs¹%Ó#@¹%°$¤C¨¥I¸%Ñ#@ÓAÑAÓBÓCÐCùÒ#@s   Á A#c                 ó¢   — t        j                  ||dfdt         j                  ¬«      }t        j                  |dd| j
                  dd¬«      }|S )Né   r   ©Údtyper   )r   r   r   é   )rN   r   )r   ÚfullÚuint8r   Ú	draw_textr]   )r?   r%   r&   r$   s       r7   rE   z_DebugGridTextCell.draw»   sC   € Ü—‘˜ ¨Ð*¨C´r·x±xÔ@ˆÜ—‘˜U A q¨$¯)©)¸9Ø"$ô&ˆàˆr9   NrX   r=   r9   r7   r[   r[   ¢   s;   „ ñòð ñ8ó ð8ð ñDó ðDór9   r[   c                   óN   — e Zd ZdZdd„Zed„ «       Zed„ «       Zd„ Ze	d„ «       Z
y)	Ú_DebugGridImageCellz_Cell containing an image, possibly with an different-shaped overlay.

    Added in 0.4.0.

    Nc                 ó.   — || _         || _        || _        y rM   )r$   ÚoverlayÚoverlay_alpha)r?   r$   rs   rt   s       r7   rP   z_DebugGridImageCell.__init__Ê   s   € ØˆŒ
ØˆŒØ*ˆÕr9   c                 ó4   — | j                   j                  d   S ©Nr   ©r$   r   r>   s    r7   rC   z_DebugGridImageCell.min_heightÐ   ó   € à�z‰z×Ñ Ñ"Ð"r9   c                 ó4   — | j                   j                  d   S ©Nr   rw   r>   s    r7   r@   z_DebugGridImageCell.min_widthÕ   rx   r9   c                 óÐ  — | j                   }|j                  j                  }|dk(  r#|j                  t        j
                  «      dz  }n�|dk(  rFt        j                  |j                  «      \  }}}|j                  t        j                  «      |z  }nR|dk(  rMt        j                  |j                  «      \  }}}||z
  }||j                  t        j                  «      z   |z  }|j                  j                  dk(  r7t	        j                  |dd«      dz  j                  t        j
                  «      }t        |||ft        ¬«      \  }	}
}|	}| j                  �ˆ| j                  | j                  |j                  dd	 «      }| j                  ||
«      }t        j                   ||d   |d
   |d	   |d   t        ¬«      }t#        j$                  ||	| j&                  ¬«      }|S )NÚbr   ÚuÚiÚfr   g      ð?©r   r	   r   ri   r   )Úalpha)r$   rk   ÚkindÚastyper   rn   ÚiadtÚget_value_range_of_dtypeÚfloat64Úclipr8   Ú_COLOR_GRID_BACKGROUNDrs   Ú_resize_overlayr   r"   r#   ÚblendlibÚblend_alphart   )r?   r%   r&   r$   r‚   Ú	min_valueÚ_Ú	max_valueÚdynamic_rangeÚ	image_rspÚsize_rsr6   r   Ú
overlay_rsÚoverlay_rsps                  r7   rE   z_DebugGridImageCell.drawÚ   s¬  € Ø—
‘
ˆØ�{‰{×ÑˆØ�3Š;Ø—L‘L¤§¡Ó*¨SÑ0‰EØ�SŠ[Ü&*×&CÑ&CÀEÇKÁKÓ&PÑ#ˆI�q˜)Ø—L‘L¤§¡Ó,¨yÑ8‰EØ�SŠ[Ü&*×&CÑ&CÀEÇKÁKÓ&PÑ#ˆI�q˜)Ø&¨Ñ2ˆMØ §¡¬b¯j©jÓ!9Ñ9¸]ÑJˆEà�;‰;×Ñ˜sÒ"Ü—W‘W˜U A sÓ+¨cÑ1×9Ñ9¼"¿(¹(ÓCˆEä'9Ø�F˜E�?Ô)?ô(AÑ$ˆ	�7˜Hð ˆØ�<‰<Ð#Ø×-Ñ-¨d¯l©lØ.3¯k©k¸!¸AÐ.>ó@ˆJà×.Ñ.¨z¸7ÓCˆKÜ!Ÿ+™+ kØ*2°1©+¸XÀa¹[Ø-5°a©[¸xÈ¹{Ü+AôCˆKô
 ×(Ñ(¨°iØ/3×/AÑ/AôCˆEð ˆr9   c                 ó6   — t        j                  ||d¬«      }|S )NÚnearest)Úinterpolation)r   r   )ÚclsÚarrr   Úarr_rss       r7   r‰   z#_DebugGridImageCell._resize_overlayý   s   € ä×)Ñ)¨#¨tÀ9ÔMˆØˆr9   )Ng      è?)rF   rG   rH   rI   rP   rY   rC   r@   rE   Úclassmethodr‰   r=   r9   r7   rq   rq   Â   sN   „ ñó+ð ñ#ó ð#ð ñ#ó ð#ò ðF ñó ñr9   rq   c                   ó<   — e Zd ZdZd„ Zed„ «       Zed„ «       Zd„ Zy)Ú_DebugGridCBAsOICellz¡Cell visualizing a coordinate-based augmentable.

    CBAsOI = coordinate-based augmentables on images,
    e.g. ``KeypointsOnImage``.

    Added in 0.4.0.

    c                 ó    — || _         || _        y rM   )Úcbasoir$   )r?   rž   r$   s      r7   rP   z_DebugGridCBAsOICell.__init__  s   € ØˆŒØˆ�
r9   c                 ó4   — | j                   j                  d   S rv   rw   r>   s    r7   rC   z_DebugGridCBAsOICell.min_height  rx   r9   c                 ó4   — | j                   j                  d   S rz   rw   r>   s    r7   r@   z_DebugGridCBAsOICell.min_width  rx   r9   c                 ó  — t        | j                  ||ft        ¬«      \  }}}| j                  j	                  «       }|j                  |«      }|j                  |d   |d   ¬«      }|j                  |_        |j                  |«      S )Nr€   r   ri   )ÚyÚx)	r8   r$   rˆ   rž   ÚdeepcopyÚon_Úshift_r   Údraw_on_image)r?   r%   r&   r�   r‘   r6   rž   s          r7   rE   z_DebugGridCBAsOICell.draw  s|   € Ü'9Ø�J‰J˜ ˜Ô.Dô(FÑ$ˆ	�7˜Hð —‘×%Ñ%Ó'ˆØ—‘˜GÓ$ˆØ—‘ ¨!¡°¸±�Ó<ˆØ —‘ˆŒà×#Ñ# IÓ.Ð.r9   NrX   r=   r9   r7   rœ   rœ     s9   „ ñòð
 ñ#ó ð#ð ñ#ó ð#ó	/r9   rœ   c                   óL   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zd„ Z	y)Ú_DebugGridColumnzGA single column within the debug image grid.

    Added in 0.4.0.

    c                 ó   — || _         y rM   )Úcells)r?   r«   s     r7   rP   z_DebugGridColumn.__init__0  s	   € Øˆ�
r9   c                 ó,   — t        | j                  «      S )zXNumber of rows in the column, i.e. examples in batch.

        Added in 0.4.0.

        )rb   r«   r>   s    r7   Únb_rowsz_DebugGridColumn.nb_rows3  s   € ô �4—:‘:‹Ðr9   c                 óf   — t        | j                  D �cg c]  }|j                  ‘Œ c}«      S c c}w )zTWidth in pixels of the widest cell in the column.

        Added in 0.4.0.

        )r   r«   r@   ©r?   Úcells     r7   Úmax_cell_widthz_DebugGridColumn.max_cell_width<  s)   € ô ¨t¯zªzÓ:©z t�D—N“N¨zÑ:Ó;Ð;ùÒ:ó   ”.c                 óf   — t        | j                  D �cg c]  }|j                  ‘Œ c}«      S c c}w )zVHeight in pixels of the tallest cell in the column.

        Added in 0.4.0.

        )r   r«   rC   r¯   s     r7   Úmax_cell_heightz _DebugGridColumn.max_cell_heightE  s)   € ô °·
²
Ó;±
¨�D—O“O°
Ñ;Ó<Ð<ùÒ;r²   c           
      óÀ   — | j                   }t        j                  t        | j                  |«      D ��cg c]  \  }}|j                  ||¬«      ‘Œ c}}«      S c c}}w )zIConvert this column to an image array.

        Added in 0.4.0.

        )r%   r&   )r±   r   ÚvstackÚzipr«   rE   )r?   Úheightsr&   r°   r%   s        r7   rE   z_DebugGridColumn.drawN  s_   € ð ×#Ñ#ˆÜ�y‰yä  §¡¨WÔ5ô7á5ñ +˜d Fð Ÿ)™)¨6¸˜)Õ?à5ò7ó 8ð 	8ùó 7s   µA
N)
rF   rG   rH   rI   rP   rY   r­   r±   r´   rE   r=   r9   r7   r©   r©   )  sM   „ ñòð ñó ðð ñ<ó ð<ð ñ=ó ð=ó	8r9   r©   c                   ó   — e Zd ZdZd„ Zd„ Zy)Ú
_DebugGridz°A debug image grid.

    Columns correspond to the input datatypes (e.g. images, bounding boxes).
    Rows correspond to the examples within a batch.

    Added in 0.4.0.

    c                 ó2   — t        |«      dkD  sJ ‚|| _        y rv   )rb   Úcolumns)r?   r¼   s     r7   rP   z_DebugGrid.__init__e  s   € Ü�7‹|˜aÒÐÐØˆ�r9   c                 ó   — | j                   D �cg c]  }|j                  ‘Œ }}t        t        |«      «      dk(  sJ ‚t	        j
                  | j                   d   j                  ft        j                  ¬«      }| j                   D ];  }|j                  D �cg c]  }|j                  ‘Œ }}t	        j                  ||«      }Œ= t	        j                  | j                   D �cg c]  }|j                  |¬«      ‘Œ c}«      S c c}w c c}w c c}w )zGConvert this grid to an image array.

        Added in 0.4.0.

        r   r   rj   )r¸   )r¼   r­   rb   Úsetr   ÚzerosÚint32r«   rC   ÚmaximumÚhstackrE   )r?   ÚcolumnÚnb_rows_by_colÚrowwise_heightsr°   r¸   s         r7   rE   z_DebugGrid.drawi  så   € ð 8<·|²|ÓD±|¨V˜&Ÿ.›.°|ˆÐDÜ”3�~Ó&Ó'¨1Ò,Ð,Ð,ÜŸ(™( D§L¡L°¡O×$;Ñ$;Ð#=ÄRÇXÁXÔNˆØ—l”lˆFØ39·<²<Ó@±<¨4�t—“°<ˆGÐ@Ü Ÿj™j¨¸'ÓB‰Oð #ô �y‰yØ(,¯ªó6Ù(4˜fð !Ÿ+™+¨o˜+Õ>Ø(4ñ6ó 7ð 	7ùò Eùò Aùò6s   �DÂDÃ!DN)rF   rG   rH   rI   rP   rE   r=   r9   r7   rº   rº   Z  s   „ ñòó7r9   rº   c           	      óø  — t        | «      g}|�|j                  t        || «      «       |�|j                  t        || «      «       |�|j	                  t        || d«      «       |�|j	                  t        || d«      «       |�|j	                  t        || d«      «       |�|j	                  t        || d«      «       t        |«      }|j                  «       }t        j                  |dddddt        ¬«      }|S )aå  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
    -------
    ndarray
        Visualized batch as RGB image.

    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.

    Ú	KeypointszBounding BoxesÚPolygonszLine Stringsr   rT   rU   )Ú_create_images_columnÚextendÚ_create_heatmaps_columnsÚ_create_segmap_columnsÚappendÚ_create_cbasois_columnrº   rE   r"   r#   rˆ   )	ÚimagesÚheatmapsÚsegmentation_mapsÚ	keypointsÚbounding_boxesÚpolygonsÚline_stringsr¼   Úresults	            r7   Údraw_debug_imager×   ~  s   € ôp % VÓ,Ð-€GàÐØ�‰Ô/°¸&ÓAÔBàÐ$Ø�‰Ô-Ð.?ÀÓHÔIàÐØ�‰Ô-¨i¸ÀÓMÔNàÐ!Ø�‰Ô-¨n¸fØ.>ó@ô 	Að ÐØ�‰Ô-¨h¸À
ÓKÔLàÐØ�‰Ô-¨l¸FØ.<ó>ô 	?ô ˜Ó €FØ�[‰[‹]€FÜ�[‰[˜ Q¨a¸ÀØ(Ô/EôG€Fà€Mr9   c                 óJ   — | D �cg c]  }t        dt        |«      ‘Œ c}S c c}w )z"Add a border (cell) around a cell.r   )rK   rˆ   )r«   r°   s     r7   Ú_add_bordersrÙ   ô  s3   € ñ óÙ�ô ! Ô$:¸DÕAØñð ùò s   … c                 ó    — t        | «      g|z   S )z#Add a text cell before other cells.)r[   )Útitler«   s     r7   Ú_add_text_cellrÜ   û  s   € ä˜uÓ%Ð&¨Ñ.Ð.r9   c                 ó¦   — | D �cg c]  }t        |«      ‘Œ }}t        | «      }t        t        t	        dt	        ||«      «      «      «      }|S c c}w )zCreate columns for image data.ÚImages)rq   Ú_generate_images_descriptionr©   rÙ   rÜ   )rÏ   r$   r«   Úimages_descrrÃ   s        r7   rÉ   rÉ     s]   € á5;Ó<±V¨EÔ  Õ'°V€EÐ<Ü/°Ó7€LÜÜÜØÜØ Øóóó	
ó	€Fð €Mùò =s   …Ac                 ó  — t        | D �cg c]  }|j                  j                  d   ‘Œ c}«      }t        j                  |«      D �cg c]  }g ‘Œ }}t        || «      D ]G  \  }}|j                  «       }t        |«      D ]$  \  }}	||   j                  t        ||	¬«      «       Œ& ŒI t        |«      D ��
cg c]<  \  }}
t        t        t        dt        t        | ||dk(  ¬«      |
«      «      «      «      ‘Œ> }}}
|S c c}w c c}w c c}
}w )z Create columns for heatmap data.r	   ©rs   ÚHeatmapsr   ©Úchannel_idxÚshow_details)r   Úarr_0to1r   r   Úaranger·   rE   Ú	enumeraterÍ   rq   r©   rÙ   rÜ   Ú_generate_heatmaps_description)rÐ   rÏ   ÚheatmapÚnb_map_channelsr�   r¼   r$   Úheatmap_drawnÚcÚheatmap_drawn_cr«   s              r7   rË   rË     s%  € äÙ*2ó4Ù*2˜wð #×+Ñ+×1Ñ1°!Ó4Ø*2ñ4ó 5€OäŸ9™9 _Ô5Ó6Ñ5�aŠrÐ5€GÐ6Ü˜f hÖ/‰ˆˆwØŸ™›ˆÜ"+¨MÖ":ÑˆAˆØ�A‰J×ÑÜ# E°?ÔCõEñ #;ð 0ô( " 'Ô*ôñ +‰HˆAˆuô 	ÜÜØÜ"Ü6Ø$Ø()Ø*+¨q©&ô3ð óóó
õ	
ð +ð ñ ð  €Nùò34ùâ6ùóó   Š C=Á	DÂ7ADc                 ó  — t        | D �cg c]  }|j                  j                  d   ‘Œ c}«      }t        j                  |«      D �cg c]  }g ‘Œ }}t        || «      D ]G  \  }}|j                  «       }t        |«      D ]$  \  }}	||   j                  t        ||	¬«      «       Œ& ŒI t        |«      D ��
cg c]<  \  }}
t        t        t        dt        t        | ||dk(  ¬«      |
«      «      «      «      ‘Œ> }}}
|S c c}w c c}w c c}
}w )z)Create columns for segmentation map data.r	   râ   ÚSegMapsr   rä   )r   r˜   r   r   rè   r·   rE   ré   rÍ   rq   r©   rÙ   rÜ   Ú_generate_segmaps_description)rÑ   rÏ   Úsegmaprì   r�   r¼   r$   Úsegmap_drawnrî   Úsegmap_drawn_cr«   s              r7   rÌ   rÌ   2  s&  € äÙ):ó<Ù):˜vð "Ÿ:™:×+Ñ+¨AÓ.Ø):ñ<ó =€OäŸ9™9 _Ô5Ó6Ñ5�aŠrÐ5€GÐ6Ü˜VÐ%6Ö7‰ˆˆvð —{‘{“}ˆÜ!*¨<Ö!8ÑˆAˆ~Ø�A‰J×ÑÜ# E°>ÔBõDñ "9ð	 8ô. " 'Ô*ôñ +‰HˆAˆuô 	ÜÜØÜ"Ü5Ø-Ø()Ø*+¨q©&ô3ð óó	óõ	
ð +ð ñ ð$ €Nùò;<ùâ6ùórð   c                 óÊ   — t        | |«      D ��cg c]  \  }}t        ||«      ‘Œ }}}t        | |«      }t        t	        t        |t        ||«      «      «      «      }|S c c}}w )z2Create a column for coordinate-based augmentables.)r·   rœ   Ú_generate_cbasois_descriptionr©   rÙ   rÜ   )ÚcbasoisrÏ   Úcolumn_namerž   r$   r«   ÚdescrrÃ   s           r7   rÎ   rÎ   U  sz   € ô �G˜VÔ$ô&á$ñ �˜ô " &¨%Õ0à$ð 
ñ &ô *¨'°6Ó:€EÜÜÜØÜ˜u eÓ,óó	
ó€Fð €Mùó&s   �Ac                 ó:  — t        j                  | «      r»dt        | j                  «      d›�}d| j                  j
                  d›�}t        | «      dk(  rd}�n²| j                  j                  dv r/dt        j                  | «      t        j                  | «      fz  }�nkd	t        j                  | «      t        j                  | «      fz  }�n<t        | «      }|j                  rd}n›|j                  rd
t        | «      |j                  d   fz  }nqdt        | «      |j                  |j                   |j"                  |j$                  |j&                  |j(                  |j+                  d«      |j-                  d«      f	z  }|j                  rd}n>|j.                  rd|j0                  d   d›�}nddj3                  |j4                  «      ›�}|j                  rd}n+d}|j6                  sd}||j8                  |j:                  fz  }|||g}t=        |«      S )z'Generate description for image columns.zarray, shape ú>11zdtype z>8r   Ú ©r}   r~   r|   zvalue range: %3d to %3dzvalue range: %7.4f to %7.4fz!list of %3d arrays
all shape %11sz„list of %3d arrays
varying shapes
smallest image: %11s
largest image: %11s
height: %3d to %3d
width: %3d to %3d
channels: %1s to %1sÚNonez
all dtype zdtypes: z, zvalue range: %6.4f to %6.4f)r   Úis_np_arrayÚstrr   rk   Únamerb   r‚   r   Úminr   Ú_ListOfArraysStatsÚemptyÚall_same_shapeÚshapesÚsmallest_shapeÚlargest_shapeÚ
height_minÚ
height_maxÚ	width_minÚ	width_maxÚget_channels_minÚget_channels_maxÚall_same_dtyper
   ÚjoinÚunique_dtype_namesÚall_dtypes_intlikeÚ	value_minÚ	value_maxÚ_join_description_strs)rÏ   Ú
shapes_strÚ
dtypes_strÚvalue_range_strÚstatsÚstrss         r7   rß   rß   g  sß  € ä	‡~�~�fÕÜ,/°·±Õ,=Ð?‰
Ø$*§L¡L×$5Ó$5Ð7ˆ
Üˆv‹;˜!ÒØ ŠOØ�\‰\×Ñ /Ñ1Ø7Ü—‘�v“¤§¡ v£ð;0ñ 0ŠOð <Ü—‘�v“¤§¡ v£ð?0ñ 0ŠOô # 6Ó*ˆà�;Š;Ø‰JØ×!Ò!ð!ä�V“˜eŸl™l¨1™oÐ/ñ0‰Jð'ô �V“Ø×%Ñ% u×':Ñ':Ø×!Ñ! 5×#3Ñ#3Ø—‘ %§/¡/Ø×'Ñ'¨Ó/Ø×'Ñ'¨Ó/ð1ñ1ˆJð �;Š;Ø‰JØ×!Ó!Ø,1¯L©L¸«OÐ=‰Jð "ð *.¯©°5×3KÑ3KÔ)LÐNˆJà�;Š;Ø ‰Oà7ˆOØ×+Ò+Ø"?�Ø-°·±Ø16·±ð1Bñ BˆOð ˜
 OÐ4€DÜ! $Ó'Ð'r9   c                 ó
  — t        | «      dk(  ryt        | ||«      }| D �cg c]  }|j                  dd…dd…|f   ‘Œ }}t        |«      }d|j                  |j
                  |j                  fz  }t        ||gz   «      S c c}w )z(Generate description for segmap columns.r   ú
empty listNz5value range: %3d to %3d
number of unique classes: %2d)rb   Ú_generate_sm_hm_descriptionr˜   r  r  r  Únb_unique_valuesr  )Úsegmapsrå   ræ   r  rô   Úarrs_channelÚstats_channelr  s           r7   ró   ró   £  s“   € ä
ˆ7ƒ|�qÒØä& w°¸\ÓJ€Dá@GÓHÁ°f�F—J‘Jšq¢! [Ð0Ó1À€LÐHÜ& |Ó4€Mð	(à	×	 Ñ	  -×"9Ñ"9Ø	×	'Ñ	'ð	)ñ)€Oô " $¨/Ð):Ñ":Ó;Ð;ùò Is   ¡B c                 óô   — t        | «      dk(  ryt        | ||«      }| D �cg c]  }|j                  dd…dd…|f   ‘Œ }}t        |«      }d|j                  |j
                  fz  }t        ||gz   «      S c c}w )z)Generate description for heatmap columns.r   r  Nz=value range: %6.4f to %6.4f
    (internal, max is [0.0, 1.0]))rb   r  rç   r  r  r  r  )rÐ   rå   ræ   r  rë   r"  r#  r  s           r7   rê   rê   ¶  sŠ   € ä
ˆ8ƒ}˜ÒØä& x°¸lÓK€DáGOÓPÁx¸G�G×$Ñ$¢Qª¨;Ð%6Ó7Àx€LÐPÜ& |Ó4€Mð	,à	×	 Ñ	  -×"9Ñ"9Ð:ñ;€Oô
 " $¨/Ð):Ñ":Ó;Ð;ùò Qs   ¡A5c                 óJ  — | €yt        | «      dk(  ry| D �cg c]  }|j                  «       ‘Œ }}t        |«      }|j                  d«      dkD  rd|dz   |j                  d«      fz  }nd}|sd}n›|j                  rdt        | «      |j
                  d   fz  }nqdt        | «      |j                  |j                  |j                  |j                  |j                  |j                  |j                  d	«      |j                  d	«      f	z  }|sd}nt        | «      }|||gS c c}w )
z0Generate description for SegMap/Heatmap columns.rþ   r   r  éÿÿÿÿzChannel %1d of %1dr   z-items for %3d images
all arrays of shape %11sz€items for %3d images
varying array shapes
smallest: %11s
largest: %11s
height: %3d to %3d
width: %3d to %3d
channels: %1s to %1sr   )rb   Úget_arrr  r  r  r  r	  r
  r  r  r  r  r  Ú_generate_on_image_shapes_descr)	Úaugmentablesrå   ræ   ÚaugmentableÚarrsr  Úchannel_strr  Úon_shapes_strs	            r7   r  r  È  sA  € àÐØÜ
ˆ<Ó˜AÒØá5AÓB±\ kˆK×ÑÕ!°\€DÐBÜ˜tÓ$€Eà×Ñ˜bÓ! BÒ&Ø*¨k¸!©mØ.3×.DÑ.DÀRÓ.Hð.Jñ J‰ð ˆáØ‰
Ø	×	Ò	ð'ä�Ó §¡¨Q¡Ð1ñ2‰
ð#ô �ÓØ×!Ñ! 5×#6Ñ#6Ø×Ñ˜u×/Ñ/Ø�_‰_˜eŸo™oØ×#Ñ# FÓ+Ø×#Ñ# FÓ+ð-ñ-ˆ
ñ Ø‰ä7¸ÓEˆà˜ ]Ð3Ð3ùòK Cs   —D c                 ó¸  — dt        | «      fz  }| D �cg c]  }t        |j                  «      ‘Œ }}t        | «      dkD  r|ndg}t        |«      }dt        |«      t	        |«      |fz  }| D ��cg c]-  }|j                  D ]  }t        |d«      r|j                  nd‘Œ Œ/ }}}t        | «      dkD  r|ndg}dt        |«      t	        |«      fz  }	t        t        j                  | D ��
cg c]-  }|j                  D ]  }
t        |
d«      r|
j                  nd‘Œ Œ/ c}
}«      «      }t        j                  |«      }g }|j                  d	«      D ]"  \  }}|j                  d
||||z  dz  fz  «       Œ$ dt        |j                  «       «      dj!                  |«      fz  }g }g }t#        | |«      D ]ž  \  }}|j$                  dd \  }}|j                  D ]x  }|j&                  }|D ]e  }|\  }}||dz  z
  dz  ||dz  z
  dz  z   }|j                  d|cxk  xr |k  nc xr d|cxk  xr |k  nc  «       |j                  ||f|f«       Œg Œz Œ  t)        |d„ ¬«      D ���cg c]  \  \  }}}||f‘Œ }}}}t        |«      }d||t        |«      z  dz  |d   d   |d   d   fz  } t+        | «      }!t-        |||	|| |!g«      S c c}w c c}}w c c}
}w c c}}}w )z>Generate description for coordinate-based augmentable columns.zitems for %d imagesr   r&  zDfewest items on image: %3d
most items on image: %3d
total items: %6dÚareaz(smallest area: %7.4f
largest area: %7.4fÚlabelNé
   z
    - %s (%3d, %6.2f%%)éd   z(unique labels: %2d
most common labels:%srþ   r	   c                 ó   — | d   S rz   r=   ©Úts    r7   Ú<lambda>z/_generate_cbasois_description.<locals>.<lambda>,  s   € °Q°q²Tr9   ©ÚkeyzDcoords out of image: %d (%6.2f%%)
most extreme coord: (%5.1f, %5.1f)r   )rb   ÚitemsÚsumr  r   Úhasattrr/  Úlistr   Úflattenr0  ÚcollectionsÚCounterÚmost_commonrÍ   Úkeysr  r·   r   ÚcoordsÚsortedr(  r  )"rù   rÏ   Ú
images_strrž   Únb_items_lstÚnb_itemsÚ	items_strÚcbaÚareasÚ	areas_strÚitemÚlabelsÚ
labels_ctrÚlabels_most_commonr0  ÚcountÚ
labels_strÚ
coords_ooiÚdistsr$   ÚhÚwrB  Úcoordr£   r¢   ÚdistÚx_Úy_r�   Úcoords_extremeÚnb_ooiÚooi_strr-  s"                                     r7   rø   rø   ø  sE  € à&¬#¨g«,¨Ñ8€Já4;Ó<±G¨&”C˜Ÿ™Õ%°G€LÐ<Ü#& w£<°!Ò#3‘<¸"¸€LÜ�<Ó €Hð	ô 
ˆ\Ó	œC Ó-¨xÐ8ñ	9€Iñ ô!áˆFØ—<”<ˆCô ˜C Ô(ˆ�Š¨bÑ0àð 	1Øð 
ñ !ô ˜“\ AÒ%‰E¨B¨4€Eð	ä	ˆU‹”S˜“ZÐ ñ!€Iô
 ”"—*‘*Ù,3ô8Ù,3 &Ø*0¯,¬, $ô -4°D¸'Ô,B˜dŸjšjÈÑLà*6ð MØ,3ò8ó 9ó :€Fô ×$Ñ$ VÓ,€JØÐØ"×.Ñ.¨rÖ2‰ˆˆuØ×!Ñ!Ð"=Ø�5˜% ™.¨3Ñ.ðA0ñ #0õ 	1ð 3ð	ô 
ˆZ�_‰_ÓÓ	 §¡Ð);Ó!<Ð=ñ	>€Jð €JØ€EÜ˜W fÖ-‰ˆ�Ø�{‰{˜1˜QÐ‰ˆˆ1Ø—<”<ˆCØ—Z‘ZˆFÛ�Ø‘��1Ø˜A˜a™C™ !‘| q¨1¨Q©3¡w°1¡nÑ4�Ø×!Ñ! q¨A¦z°¤zÒ'@°a¸1¶j¸q´jÐ"AÔBØ—‘˜q !˜f d˜^Õ,ñ	  ñ  ð .ô   ©>Õ:õ<á:ñ &™(˜2˜r Að ˜2’hà:ð ò <ô �‹_€Fð	-ð 
�œ#˜j›/Ñ)¨CÑ/Ø	˜Ñ	˜AÑ	 ¨rÑ 2°1Ñ 5ð	7ñ7€Gô 4°GÓ<€Mä! :¨y¸)Ø#-¨w¸ð#Gó Hð Hùò{ =ùó!ùó8ùô6<s   ”KÁ/2K	Ã)2KÉ$Kc                 ó"  — | D �cg c]  }|j                   ‘Œ }}t        |D �cg c]  }t        j                  |«      ‘Œ c}«      }|j                  rd|j
                  d   d›�}|S d|j                  d›d|j                  d›�}|S c c}w c c}w )zEGenerate text block for non-image data describing their image shapes.zall on image shape r   rý   z(on varying image shapes
smallest image: z
largest image: )r   r  r   r  r  r  r	  r
  )r)  r*  Ú	on_shapesÚon_shapeÚ
stats_imgsr-  s         r7   r(  r(  >  s¥   € á6BÓC±l {�×"Ó"°l€IÐCÜ#Ù5>ó%@Ù5>¨ô &(§X¡X¨hÕ%7Ø5>ñ%@ó A€Jà× Ó Ø5?×5FÑ5FÀqÓ5IÐKˆð Ðð !ð ×&Ô&¨
×(@Ó(@ð	Bˆð
 Ðùò Dùò%@s
   …B£Bc                 ój   — | D �cg c]  }t        |«      dkD  sŒ|‘Œ } }dj                  | «      S c c}w )z9Join lines to a single string while removing empty lines.r   r`   )rb   r  )r  Ústr_is     r7   r  r  O  s3   € á#Ó6™t�e¤s¨5£z°A£~ŠE˜t€DÐ6Ø�9‰9�T‹?Ðùò 7s   …0™0c                   ó‚  — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
ed„ «       Zed	„ «       Zed
„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zd„ Zd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zy)r  z–Class to derive aggregated values from a list of arrays.

    E.g. shape of the largest array, number of unique dtypes etc.

    Added in 0.4.0.

    c                 ó   — || _         y rM   )Úarrays)r?   rd  s     r7   rP   z_ListOfArraysStats.__init__^  s	   € Øˆ�r9   c                 ó2   — t        | j                  «      dk(  S rv   )rb   rd  r>   s    r7   r  z_ListOfArraysStats.emptyb  s   € ä�4—;‘;Ó 1Ñ$Ð$r9   c                 ó€   — | j                   D �cg c]$  }t        j                  |j                  dd «      ‘Œ& c}S c c}w )Nr   r	   )rd  r   Úprodr   ©r?   r˜   s     r7   rI  z_ListOfArraysStats.areasg  s1   € à37·;²;Ó?±;¨C”—‘˜Ÿ	™	 ! A˜Õ'°;Ñ?Ð?ùÒ?s   �);c                 óŽ   — t        t        | j                  | j                  «      d„ ¬«      D ��cg c]  \  }}|‘Œ	 }}}|S c c}}w )Nc                 ó   — | d   S rz   r=   r4  s    r7   r6  z3_ListOfArraysStats.arrays_by_area.<locals>.<lambda>p  s   € À!ÀAÂ$r9   r7  )rC  r·   rd  rI  )r?   r˜   r�   Úarrays_by_areas       r7   rk  z!_ListOfArraysStats.arrays_by_areal  sK   € ô ”c˜$Ÿ+™+ t§z¡zÓ2¹ÕGô
áGñ �C˜ŠCØGð 	ñ 
ð Ðùó	
s   °Ac                 óT   — | j                   D �cg c]  }|j                  ‘Œ c}S c c}w rM   ©rd  r   rh  s     r7   r  z_ListOfArraysStats.shapesu  ó"   € à%)§[¢[Ó1¡[˜c�—	“	 [Ñ1Ð1ùÒ1ó   �%c                 ó^   — | j                   ryt        t        | j                  «      «      dk(  S )NTr   )r  rb   r¾   r  r>   s    r7   r  z!_ListOfArraysStats.all_same_shapez  s%   € à�:Š:ØÜ”3�t—{‘{Ó#Ó$¨Ñ)Ð)r9   c                 ó`   — | j                   r
t        «       S | j                  d   j                  S rv   ©r  Útuplerk  r   r>   s    r7   r	  z!_ListOfArraysStats.smallest_shape�  s'   € à�:Š:Ü“7ˆNØ×"Ñ" 1Ñ%×+Ñ+Ð+r9   c                 ó`   — | j                   r
t        «       S | j                  d   j                  S ©Nr&  rr  r>   s    r7   r
  z _ListOfArraysStats.largest_shapeˆ  s'   € à�:Š:Ü“7ˆNØ×"Ñ" 2Ñ&×,Ñ,Ð,r9   c                 óx   — | j                   r
t        «       S t        j                  | j                  d   dd «      S )Nr&  r   r	   )r  rs  r   rg  rk  r>   s    r7   Úarea_maxz_ListOfArraysStats.area_max�  s1   € à�:Š:Ü“7ˆNÜ�w‰w�t×*Ñ*¨2Ñ.¨q°Ð3Ó4Ð4r9   c                 óZ   — | j                   D �cg c]  }|j                  d   ‘Œ c}S c c}w rv   rm  rh  s     r7   r¸   z_ListOfArraysStats.heights–  ó&   € à(,¯ªÓ4© �—	‘	˜!“¨Ñ4Ð4ùÒ4ó   �(c                 óP   — | j                   }t        |«      dkD  rt        |«      S dS rv   )r¸   rb   r  ©r?   r¸   s     r7   r  z_ListOfArraysStats.height_min›  ó%   € à—,‘,ˆÜ" 7›|¨aÒ/Œs�7‹|Ð6°QÐ6r9   c                 óP   — | j                   }t        |«      dkD  rt        |«      S dS rv   )r¸   rb   r   r|  s     r7   r  z_ListOfArraysStats.height_max¡  r}  r9   c                 óZ   — | j                   D �cg c]  }|j                  d   ‘Œ c}S c c}w rz   rm  rh  s     r7   Úwidthsz_ListOfArraysStats.widths§  ry  rz  c                 óP   — | j                   }t        |«      dkD  rt        |«      S dS rv   )r€  rb   r  ©r?   r€  s     r7   r  z_ListOfArraysStats.width_min¬  ó$   € à—‘ˆÜ! &›k¨AšoŒs�6‹{Ð4°1Ð4r9   c                 óP   — | j                   }t        |«      dkD  rt        |«      S dS rv   )r€  rb   r   r‚  s     r7   r  z_ListOfArraysStats.width_max²  rƒ  r9   c                 ó  — | j                   ryt        | j                  D �cg c]  }|j                  dk(  ‘Œ c}«      r|S t	        | j                  D �cg c]!  }|j                  dkD  sŒ|j
                  d   ‘Œ# c}«      S c c}w c c}w ©Nr&  r	   )r  Úanyrd  Úndimr  r   ©r?   Údefaultr˜   s      r7   r  z#_ListOfArraysStats.get_channels_min¸  sl   € Ø�:Š:ØÜ¨¯ªÓ5© #�—‘˜A“¨Ñ5Ô6ØˆNÜ¨D¯KªKÓH©K S¸3¿8¹8Àa»<�C—I‘I˜a“L¨KÑHÓIÐIùò 6ùâHó   ¡B ÁBÁ(Bc                 ó  — | j                   ryt        | j                  D �cg c]  }|j                  dkD  ‘Œ c}«      s|S t	        | j                  D �cg c]!  }|j                  dkD  sŒ|j
                  d   ‘Œ# c}«      S c c}w c c}w r†  )r  r‡  rd  rˆ  r   r   r‰  s      r7   r  z#_ListOfArraysStats.get_channels_maxÀ  sl   € Ø�:Š:ØÜ¨D¯KªKÓ8©K S�C—H‘H˜q“L¨KÑ8Ô9ØˆNÜ¨D¯KªKÓH©K S¸3¿8¹8Àa»<�C—I‘I˜a“L¨KÑHÓIÐIùò 9ùâHr‹  c                 óT   — | j                   D �cg c]  }|j                  ‘Œ c}S c c}w rM   )rd  rk   rh  s     r7   r
   z_ListOfArraysStats.dtypesÈ  rn  ro  c                 óT   — | j                   D �cg c]  }|j                  ‘Œ c}S c c}w rM   )r
   r  )r?   rk   s     r7   Údtype_namesz_ListOfArraysStats.dtype_namesÍ  s"   € à(,¯ªÓ4©˜u�—
“
¨Ñ4Ð4ùÒ4ro  c                 óB   — t        t        | j                  «      «      dv S )N)r   r   )rb   r¾   r�  r>   s    r7   r  z!_ListOfArraysStats.all_same_dtypeÒ  s   € ä”3�t×'Ñ'Ó(Ó)¨VÐ3Ð3r9   c                 ó˜   — | j                   ryt        | j                  D �cg c]  }|j                  j                  dv ‘Œ c}«      S c c}w )NTrÿ   )r  Úallrd  rk   r‚   rh  s     r7   r  z%_ListOfArraysStats.all_dtypes_intlike×  s:   € à�:Š:ØÜÀÇÂÓMÁ¸#�C—I‘I—N‘N oÒ5ÀÑMÓNÐNùÒMs   ¡Ac                 óŒ   — t        t        | j                  D �ch c]  }|j                  j                  ’Œ c}«      «      S c c}w rM   )rC  r<  rd  rk   r  rh  s     r7   r  z%_ListOfArraysStats.unique_dtype_namesÞ  s0   € ä”d°d·k²kÓB±k¨s˜CŸI™IŸN›N°kÑBÓCÓDÐDùÒBs   ™Ac                 óx   — t        | j                  D �cg c]  }t        j                   |«      ‘Œ c}«      S c c}w rM   )r  rd  r   rh  s     r7   r  z_ListOfArraysStats.value_minã  ó+   € ä¨4¯;ª;Ó7©; C”B—F‘F˜3•K¨;Ñ7Ó8Ð8ùÒ7ó   ”7c                 óx   — t        | j                  D �cg c]  }t        j                   |«      ‘Œ c}«      S c c}w rM   )r   rd  r   rh  s     r7   r  z_ListOfArraysStats.value_maxè  r•  r–  c                 ó–   — t        «       }| j                  D ]&  }|j                  t        j                  |«      «       Œ( t        |«      S rM   )r¾   rd  Úupdater   Úuniquerb   )r?   Ú	values_uqr˜   s      r7   r   z#_ListOfArraysStats.nb_unique_valuesí  s7   € ä“Eˆ	Ø—;”;ˆCØ×ÑœRŸY™Y s›^Õ,ð ä�9‹~Ðr9   N)rF   rG   rH   rI   rP   rY   r  rI  rk  r  r  r	  r
  rw  r¸   r  r  r€  r  r  r  r  r
   r�  r  r  r  r  r  r   r=   r9   r7   r  r  U  sÖ  „ ñòð ñ%ó ð%ð ñ@ó ð@ð ñó ðð ñ2ó ð2ð ñ*ó ð*ð ñ,ó ð,ð ñ-ó ð-ð ñ5ó ð5ð ñ5ó ð5ð ñ7ó ð7ð
 ñ7ó ð7ð
 ñ5ó ð5ð ñ5ó ð5ð
 ñ5ó ð5ò
JòJð ñ2ó ð2ð ñ5ó ð5ð ñ4ó ð4ð ñOó ðOð ñEó ðEð ñ9ó ð9ð ñ9ó ð9ð ñó ñr9   r  c                   ó   — e Zd ZdZd„ Zd„ Zy)Ú_IImageDestinationz,A destination which receives images to save.c                  ó   — y)a[  Signal to the destination that a new batch is processed.

        This is intended to be used by the destination e.g. to count batches.

        Added in 0.4.0.

        Parameters
        ----------
        batch : imgaug.augmentables.batches._BatchInAugmentation
            A batch to which the next ``receive()`` call may correspond.

        Nr=   ©r?   Úbatchs     r7   Úon_batchz_IImageDestination.on_batchú  rA   r9   c                  ó   — y)z²Receive and handle an image.

        Added in 0.4.0.

        Parameters
        ----------
        image : ndarray
            Image to be handled by the destination.

        Nr=   ©r?   r$   s     r7   Úreceivez_IImageDestination.receive  rA   r9   N)rF   rG   rH   rI   r¡  r¤  r=   r9   r7   r�  r�  ö  s   „ á6òó
r9   r�  c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)Ú_MultiDestinationz;A list of multiple destinations behaving like a single one.c                 ó   — || _         y rM   )Údestinations)r?   r¨  s     r7   rP   z_MultiDestination.__init__  s
   € Ø(ˆÕr9   c                 óH   — | j                   D ]  }|j                  |«       Œ y rM   )r¨  r¡  )r?   r   Údestinations      r7   r¡  z_MultiDestination.on_batch  s    € Ø×,Ô,ˆKØ× Ñ  Õ'ñ -r9   c                 óH   — | j                   D ]  }|j                  |«       Œ y rM   )r¨  r¤  )r?   r$   rª  s      r7   r¤  z_MultiDestination.receive#  s    € Ø×,Ô,ˆKØ×Ñ Õ&ñ -r9   N)rF   rG   rH   rI   rP   r¡  r¤  r=   r9   r7   r¦  r¦    s   „ ÙEò)ò(ó
'r9   r¦  c                   ó2   ‡ — e Zd ZdZ	 dˆ fd„	Zd„ Zd„ Zˆ xZS )Ú_FolderImageDestinationz0A destination which saves images to a directory.c                 ób   •— t         t        | �  «        || _        || _        d| _        d | _        y ru  )Úsuperr­  rP   Úfolder_pathÚfilename_patternÚ	_batch_idÚ	_filepath)r?   r°  r±  Ú	__class__s      €r7   rP   z _FolderImageDestination.__init__-  s/   ø€ äÔ% tÑ5Ô7Ø&ˆÔØ 0ˆÔØˆŒØˆ�r9   c                 óÔ   — | xj                   dz  c_         t        j                  j                  | j                  | j
                  j                  | j                   ¬«      «      | _        y )Nr   )Úbatch_id)r²  ÚosÚpathr  r°  r±  Úformatr³  rŸ  s     r7   r¡  z _FolderImageDestination.on_batch6  sI   € Ø�Š˜!Ñ�ÜŸ™Ÿ™Ø×ÑØ×!Ñ!×(Ñ(°$·.±.Ð(ÓAóCˆ�r9   c                 óD   — t        j                  | j                  |«       y rM   )ÚimageioÚimwriter³  r£  s     r7   r¤  z_FolderImageDestination.receive=  s   € Ü�‰˜Ÿ™¨Õ.r9   )zbatch_{batch_id:06d}.png)rF   rG   rH   rI   rP   r¡  r¤  Ú__classcell__©r´  s   @r7   r­  r­  )  s   ø„ Ù:ð #=õòCö/r9   r­  c                   ó   — e Zd ZdZd„ Zy)Ú_IBatchwiseSchedulez<A schedule determining per batch whether a condition is met.c                  ó   — y)a@  Determine for the given batch whether the condition is met.

        Added in 0.4.0.

        Parameters
        ----------
        batch : _BatchInAugmentation
            Batch for which to evaluate the condition.

        Returns
        -------
        bool
            Signal whether the condition is met.

        Nr=   rŸ  s     r7   r¡  z_IBatchwiseSchedule.on_batchF  rA   r9   N)rF   rG   rH   rI   r¡  r=   r9   r7   rÀ  rÀ  B  s
   „ áFór9   rÀ  c                   ó   — e Zd ZdZd„ Zd„ Zy)Ú_EveryNBatchesSchedulez¢A schedule that generates a signal at every ``N`` th batch.

    This schedule must be called for *every* batch in order to count them.

    Added in 0.4.0.

    c                 ó    — || _         d| _        y ru  )Úintervalr²  )r?   rÅ  s     r7   rP   z_EveryNBatchesSchedule.__init__b  s   € Ø ˆŒØˆ�r9   c                 óh   — | xj                   dz  c_         | j                   | j                  z  dk(  }|S )Nr   r   )r²  rÅ  )r?   r   Úsignals      r7   r¡  z_EveryNBatchesSchedule.on_batchg  s,   € Ø�Š˜!Ñ�Ø—.‘. 4§=¡=Ñ0°AÑ5ˆØˆr9   N)rF   rG   rH   rI   rP   r¡  r=   r9   r7   rÃ  rÃ  Y  s   „ ñòó
r9   rÃ  c                   ó.   ‡ — e Zd ZdZ	 	 dˆ fd„	Zd„ Zˆ xZS )Ú_SaveDebugImageaß  Augmenter saving debug images to a destination according to a schedule.

    Added in 0.4.0.

    Parameters
    ----------
    destination : _IImageDestination
        The destination receiving debug images.

    schedule : _IBatchwiseSchedule
        The schedule to use to determine for which batches an image is
        supposed to be generated.

    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 :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__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.

    c                 óP   •— t         t        | �  ||||¬«       || _        || _        y )N)Úseedr  Úrandom_stateÚdeterministic)r¯  rÉ  rP   rª  Úschedule)r?   rª  rÎ  rË  r  rÌ  rÍ  r´  s          €r7   rP   z_SaveDebugImage.__init__�  s5   ø€ ô 	Œo˜tÑ-Ø˜DØ%°]ð 	.ô 	Dð 'ˆÔØ ˆ�r9   c           	      ó\  — | j                   j                  |«      }| j                  j                  |«       |rst        |j                  |j
                  |j                  |j                  |j                  |j                  |j                  ¬«      }| j                  j                  |«       |S )N)rÏ   rÐ   rÑ   rÒ   rÓ   rÔ   rÕ   )rÎ  r¡  rª  r×   rÏ   rÐ   rÑ   rÒ   rÓ   rÔ   rÕ   r¤  )r?   r   rÌ  ÚparentsÚhooksÚsaver$   s          r7   Ú_augment_batch_z_SaveDebugImage._augment_batch_™  s‰   € Ø�}‰}×%Ñ% eÓ,ˆØ×Ñ×!Ñ! %Ô(áÜ$Ø—|‘|ØŸ™Ø"'×"9Ñ"9ØŸ/™/Ø$×3Ñ3ØŸ™Ø"×/Ñ/ô1ˆEð ×Ñ×$Ñ$ UÔ+àˆr9   ©NNÚ
deprecatedrÕ  )rF   rG   rH   rI   rP   rÓ  r½  r¾  s   @r7   rÉ  rÉ  m  s   ø„ ñðD "&Ø:Fõ!ör9   rÉ  c                   ó.   ‡ — e Zd ZdZ	 	 dˆ fd„	Zd„ Zˆ xZS )ÚSaveDebugImageEveryNBatchesa%  Visualize data in batches and save corresponding plots to a folder.

    Added in 0.4.0.

    **Supported dtypes**:

    See :func:`~imgaug.augmenters.debug.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 :func:`~imgaug.augmenters.meta.Augmenter.__init__`.

    name : None or str, optional
        See :func:`~imgaug.augmenters.meta.Augmenter.__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)
    >>> ])

    c                 ó  •— t        |«      }t        |t        «      sKt        j                  j                  |«      sJ d|›d�«       ‚t        t        |«      t        |d¬«      g«      }t        t        | �+  ||||||¬«       y )NzOExpected 'destination' to be a string path to an existing directory. Got path 'z'.zbatch_latest.png)r±  )rª  rÎ  rË  r  rÌ  rÍ  )rÃ  Ú
isinstancer�  r·  r¸  Úisdirr¦  r­  r¯  r×  rP   )	r?   rª  rÅ  rË  r  rÌ  rÍ  rÎ  r´  s	           €r7   rP   z$SaveDebugImageEveryNBatches.__init__å  s�   ø€ ô *¨(Ó3ˆÜ˜+Ô'9Ô:Ü—7‘7—=‘= Ô-ñ >â/:ð=ó>Ð-ô ,Ü'¨Ó4Ü'¨Ø9KôMð-ó ˆKô
 	Ô)¨4Ñ9Ø#¨hØ˜DØ%°]ð 	:õ 	Dr9   c                 óÌ   — | j                   j                  }|d   j                  |d   j                  |d   j                  |d   j                  | j                  j
                  gS )Nr   r   )rª  r¨  r°  r±  rÎ  rÅ  )r?   Údestss     r7   Úget_parametersz*SaveDebugImageEveryNBatches.get_parametersø  s^   € Ø× Ñ ×-Ñ-ˆà�!‰H× Ñ Ø�!‰H×%Ñ%Ø�!‰H× Ñ Ø�!‰H×%Ñ%Ø�M‰M×"Ñ"ð
ð 	
r9   rÔ  )rF   rG   rH   rI   rP   rÝ  r½  r¾  s   @r7   r×  r×  ¬  s   ø„ ñ5ðr "&Ø:FõDö&
r9   r×  )NNNNNN)<rI   Ú
__future__r   r   r   Úabcr   r   r   r·  r>  ÚsixÚnumpyr   r»  Úimgaugr   rþ   r
   r„   r   r   r"   r   rŠ   Ú_COLOR_PINKrˆ   r8   Úadd_metaclassÚobjectr;   rK   r[   rq   rœ   r©   rº   r×   rÙ   rÜ   rÉ   rË   rÌ   rÎ   rß   ró   rê   r  rø   r(  r  r  r�  r¦  r­  rÀ  rÃ  Ú	AugmenterrÉ  r×  r=   r9   r7   Ú<module>rç     s¾  ðñ÷ AÑ @ç 9Ñ 9ã 	Û ã 
Û Û ã Ý Ý Ý Ý à€Ø$Ð ò.?ðd €×Ñ�7Óô,�fó ,ó ð,ô^˜?ô ôB˜ô ô@>˜/ô >ôB#/˜?ô #/ôL.8�vô .8ôb7�ô 7ðH ?CØCGØ"&óròlò/òò$ò>òFò$8(òx<ò&<ò$,4ò`BHòLò"ô]˜ô ]ðB €×Ñ�7Óô˜ó ó ðô>'Ð*ô 'ô&/Ð0ô /ð2 €×Ñ�7Óô˜&ó ó ðô,Ð0ô ô(<�d—n‘nô <ô~T
 /õ T
r9   