Ë
    T^(h-	 ã                   óN  — d Z ddlZddlmZmZmZmZmZmZm	Z	m
Z
mZ ddlZddlmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZ ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- dd	l.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8  e5«       r
ddl9Z9dd
l9m:Z:  e7«       rddl;Z; e2«       rddl<Z=ddl>Z= e8j~                  e@«      ZAe j„                  e j†                  fZD	 dFdeejŠ                     deeeFe"f      deeG   fd„ZH	 dGde
eGeGf   deGdeeG   deGde
eGeGf   f
d„ZI	 dFdejŠ                  deGdeGdeeeFe"f      de
eGeGf   f
d„ZJ	 	 dHdejŠ                  deeGe
eGeGf   eeG   f   deeG   deeeFe"f      de
eGeGf   f
d„ZKdefd„ZLdFdejŠ                  deeG   dejŠ                  fd„ZMdede
eGeGf   defd„ZNdee   dee   fd „ZO	 dFd!ejŠ                  d"e
eGeGf   deeeFe"f      dejŠ                  fd#„ZPd$eGd%eGdejŠ                  fd&„ZQ	 	 dId'eRdeee"eFf      fd(„ZSd)ejŠ                  dejŠ                  fd*„ZT	 	 dJd!ejŠ                  d+ed,eeFejª                  f   d-eRdee"eFf   defd.„ZV	 dKd)ejŠ                  d/e
d0e
fd1„ZWd2ejŠ                  d0e
eGeGf   d3eGdejŠ                  fd4„ZXd5ejŠ                  de
ejŠ                  ejŠ                  f   fd6„ZYd7e$j´                  fdeeFef   d8e
eGeGf   d0e
eGeGf   d9e[d:e$f
d;„Z\d<„ Z]d=„ Z^d>„ Z_dLd?„Z`	 	 	 	 dMd@e[dAe[dBee	eG      d0e
eGeGf   fdC„Za G dD„ dEe«      ZbdEgZcy)Nz Image processor class for YOLOS.é    N)	ÚAnyÚCallableÚDictÚIterableÚListÚOptionalÚSetÚTupleÚUnioné   )ÚBatchFeature)ÚBaseImageProcessorÚget_size_dict)	ÚPaddingModeÚcenter_to_corners_formatÚcorners_to_center_formatÚ	id_to_rgbÚpadÚrescaleÚresizeÚ	rgb_to_idÚto_channel_dimension_format)ÚIMAGENET_DEFAULT_MEANÚIMAGENET_DEFAULT_STDÚAnnotationFormatÚAnnotationTypeÚChannelDimensionÚ
ImageInputÚPILImageResamplingÚget_image_sizeÚinfer_channel_dimension_formatÚis_scaled_imageÚmake_list_of_imagesÚto_numpy_arrayÚvalid_imagesÚvalidate_annotationsÚvalidate_kwargsÚvalidate_preprocess_arguments)
Ú
TensorTypeÚis_flax_availableÚis_jax_tensorÚis_scipy_availableÚis_tf_availableÚis_tf_tensorÚis_torch_availableÚis_torch_tensorÚis_vision_availableÚlogging)ÚnnÚimagesÚinput_data_formatÚreturnc                 óJ  — |€t        | d   «      }|t        j                  k(  r+t        | D �cg c]  }|j                  ‘Œ c}«      \  }}}||fS |t        j
                  k(  r+t        | D �cg c]  }|j                  ‘Œ c}«      \  }}}||fS t        d|› �«      ‚c c}w c c}w )zH
    Get the maximum height and width across all images in a batch.
    r   z"Invalid channel dimension format: )r!   r   ÚFIRSTÚmax_across_indicesÚshapeÚLASTÚ
ValueError)r4   r5   ÚimgÚ_Ú
max_heightÚ	max_widths         ún/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/yolos/image_processing_yolos.pyÚget_max_height_widthrB   V   s³   € ð Ð Ü:¸6À!¹9ÓEÐàÔ,×2Ñ2Ò2Ü#5ÈFÖ6SÀS°s·y³yÒ6SÓ#TÑ ˆˆ:�yð
 ˜	Ð"Ð"ð	 
Ô.×3Ñ3Ò	3Ü#5ÈFÖ6SÀS°s·y³yÒ6SÓ#TÑ ˆ
�I˜qð ˜	Ð"Ð"ô Ð=Ð>OÐ=PÐQÓRÐRùò	 7Tùâ6Ss   ­BÁ+B Ú
image_sizeÚsizeÚmax_sizeÚmod_sizec                 ó  — | \  }}d}|�St        t        ||f«      «      }t        t        ||f«      «      }||z  |z  |kD  r||z  |z  }t        t	        |«      «      }||k  r*|}	|�|�t        ||z  |z  «      }
nTt        ||z  |z  «      }
nB||k  r||k(  s
||k  r
||k(  r||}	}
n)|}
|�|�t        ||z  |z  «      }	nt        ||z  |z  «      }	|�6t        j                  |	|«      }t        j                  |
|«      }|	|z
  }	|
|z
  }
|
|	fS )a¼  
    Computes the output image size given the input image size and the desired output size with multiple of divisible_size.

    Args:
        image_size (`Tuple[int, int]`):
            The input image size.
        size (`int`):
            The desired output size.
        max_size (`int`, *optional*):
            The maximum allowed output size.
        mod_size (`int`, *optional*):
            The size to make multiple of mod_size.
    N)ÚfloatÚminÚmaxÚintÚroundÚnpÚmod)rC   rD   rE   rF   ÚheightÚwidthÚraw_sizeÚmin_original_sizeÚmax_original_sizeÚowÚohÚow_modÚoh_mods                rA   Úget_size_with_aspect_ratiorX   h   sJ  € ð  �M€FˆEØ€HØÐÜ!¤# v¨u oÓ"6Ó7ÐÜ!¤# v¨u oÓ"6Ó7ÐØÐ0Ñ0°4Ñ7¸(ÒBØÐ"3Ñ3Ð6GÑGˆHÜ”u˜X“Ó'ˆDàˆv‚~ØˆØÐ HÐ$8Ü�X Ñ&¨Ñ.Ó/‰Bä�T˜F‘] UÑ*Ó+‰BØ
�EŠ/˜f¨šn°%¸6²/ÀeÈtÂmØ˜ˆB‰àˆØÐ HÐ$8Ü�X Ñ%¨Ñ.Ó/‰Bä�T˜E‘\ FÑ*Ó+ˆBàÐÜ—‘˜˜HÓ%ˆÜ—‘˜˜HÓ%ˆØ�&‰[ˆØ�&‰[ˆà�ˆ8€Oó    Úinput_imager?   r@   c                 ó�   — t        | |«      }|\  }}||z  }||z  }t        ||«      }	t        ||	z  «      }
t        ||	z  «      }|
|fS )a„  
    Computes the output image size given the input image and the maximum allowed height and width. Keep aspect ratio.
    Important, even if image_height < max_height and image_width < max_width, the image will be resized
    to at least one of the edges be equal to max_height or max_width.

    For example:
        - input_size: (100, 200), max_height: 50, max_width: 50 -> output_size: (25, 50)
        - input_size: (100, 200), max_height: 200, max_width: 500 -> output_size: (200, 400)

    Args:
        input_image (`np.ndarray`):
            The image to resize.
        max_height (`int`):
            The maximum allowed height.
        max_width (`int`):
            The maximum allowed width.
        input_data_format (`ChannelDimension` or `str`, *optional*):
            The channel dimension format of the input image. If not provided, it will be inferred from the input image.
    )r    rI   rK   )rZ   r?   r@   r5   rC   rO   rP   Úheight_scaleÚwidth_scaleÚ	min_scaleÚ
new_heightÚ	new_widths               rA   Ú#get_image_size_for_max_height_widthra   š   sc   € ô2   Ð->Ó?€JØ�M€FˆEØ Ñ&€LØ˜eÑ#€KÜ�L +Ó.€IÜ�V˜iÑ'Ó(€JÜ�E˜IÑ%Ó&€IØ�yÐ Ð rY   c                 ód   — t        | |«      }t        |t        t        f«      r|S t	        |||«      S )a   
    Computes the output image size given the input image size and the desired output size. If the desired output size
    is a tuple or list, the output image size is returned as is. If the desired output size is an integer, the output
    image size is computed by keeping the aspect ratio of the input image size.

    Args:
        input_image (`np.ndarray`):
            The image to resize.
        size (`int` or `Tuple[int, int]` or `List[int]`):
            The desired output size.
        max_size (`int`, *optional*):
            The maximum allowed output size.
        input_data_format (`ChannelDimension` or `str`, *optional*):
            The channel dimension format of the input image. If not provided, it will be inferred from the input image.
    )r    Ú
isinstanceÚlistÚtuplerX   )rZ   rD   rE   r5   rC   s        rA   Úget_resize_output_image_sizerf   ¾   s3   € ô*   Ð->Ó?€JÜ�$œœu˜Ô&Øˆä% j°$¸ÓAÐArY   c                 óf  — t        | t        j                  «      rt        j                  S t	        «       rt        | «      rddl}|j                  S t        «       rt        | «      rddl
}|j                  S t        «       rt        | «      rddlm} |j                  S t!        dt#        | «      › �«      ‚)zš
    Returns a function that converts a numpy array to the framework of the input array.

    Args:
        arr (`np.ndarray`): The array to convert.
    r   NzCannot convert arrays of type )rc   rM   ÚndarrayÚarrayr-   r.   Ú
tensorflowÚconvert_to_tensorr/   r0   ÚtorchÚtensorr*   r+   Ú	jax.numpyÚnumpyr<   Útype)ÚarrÚtfrl   Újnps       rA   Úget_numpy_to_framework_fnrt   Û   s‚   € ô �#”r—z‘zÔ"Ü�x‰xˆÜÔœ\¨#Ô.Ûà×#Ñ#Ð#ÜÔ¤°Ô 4Ûà�|‰|ÐÜÔœ}¨SÔ1Ýà�y‰yÐÜ
Ð5´d¸3³i°[ÐAÓ
BÐBrY   rq   Úaxisc                 ón   — |€| j                  «       S 	 | j                  |¬«      S # t        $ r | cY S w xY w)zF
    Squeezes an array, but only if the axis specified has dim 1.
    ©ru   )Úsqueezer<   )rq   ru   s     rA   Úsafe_squeezery   ô   s?   € ð €|Ø�{‰{‹}ÐðØ�{‰{ ˆ{Ó%Ð%øÜò ØŠ
ðús   ”& ¦4³4Ú
annotationc                 óÖ   — |\  }}i }| j                  «       D ]N  \  }}|dk(  r?|}t        |«      }|t        j                  ||||gt        j                  ¬«      z  }|||<   ŒJ|||<   ŒP |S )NÚboxes©Údtype)Úitemsr   rM   ÚasarrayÚfloat32)rz   rC   Úimage_heightÚimage_widthÚnorm_annotationÚkeyÚvaluer|   s           rA   Únormalize_annotationr‡     s„   € Ø *Ñ€L�+Ø€OØ ×&Ñ&Ó(ò )‰
ˆˆUØ�'Š>ØˆEÜ,¨UÓ3ˆEØ”R—Z‘Z ¨l¸KÈÐ VÔ^`×^hÑ^hÔiÑiˆEØ#(ˆO˜CÒ à#(ˆO˜CÒ ð)ð ÐrY   Úvaluesc                 óJ   — t        | Ž D �cg c]  }t        |«      ‘Œ c}S c c}w )zO
    Return the maximum value across all indices of an iterable of values.
    )ÚziprJ   )rˆ   Úvalues_is     rA   r9   r9     s    € ô +.¨v¨,Ö7˜hŒC��MÒ7Ð7ùÒ7s   ‹ ÚimageÚoutput_sizec                 ó†   — t        | |¬«      \  }}t        j                  |t        j                  ¬«      }d|d|…d|…f<   |S )a  
    Make a pixel mask for the image, where 1 indicates a valid pixel and 0 indicates padding.

    Args:
        image (`np.ndarray`):
            Image to make the pixel mask for.
        output_size (`Tuple[int, int]`):
            Output size of the mask.
    ©Úchannel_dimr}   é   N)r    rM   ÚzerosÚint64)rŒ   r�   r5   Úinput_heightÚinput_widthÚmasks         rA   Úmake_pixel_maskr—     sF   € ô !/¨uÐBSÔ TÑ€L�+Ü�8‰8�K¤r§x¡xÔ0€DØ()€Dˆˆ,ˆ˜˜˜Ð	$Ñ%Ø€KrY   rO   rP   c                 óø  — 	 ddl m} g }| D ]�  }|j                  |||«      }|j	                  |«      }t        |j                  «      dk  r|d   }t        j                  |t        j                  ¬«      }t        j                  |d¬«      }|j                  |«       Œ’ |rt        j                  |d¬«      }|S t        j                  d||ft        j                  ¬«      }|S # t        $ r t        d«      ‚w xY w)	a1  
    Convert a COCO polygon annotation to a mask.

    Args:
        segmentations (`List[List[float]]`):
            List of polygons, each polygon represented by a list of x-y coordinates.
        height (`int`):
            Height of the mask.
        width (`int`):
            Width of the mask.
    r   ©r–   z1Pycocotools is not installed in your environment.r   ).Nr}   é   rw   )Úpycocotoolsr–   ÚImportErrorÚfrPyObjectsÚdecodeÚlenr:   rM   r€   Úuint8ÚanyÚappendÚstackr’   )ÚsegmentationsrO   rP   Ú	coco_maskÚmasksÚpolygonsÚrlesr–   s           rA   Úconvert_coco_poly_to_maskr©   ,  së   € ðOÝ1ð €EØ!ò ˆØ×$Ñ$ X¨v°uÓ=ˆØ×Ñ Ó%ˆÜˆt�z‰z‹?˜QÒØ˜	‘?ˆDÜ�z‰z˜$¤b§h¡hÔ/ˆÜ�v‰v�d Ô#ˆØ�‰�TÕðñ Ü—‘˜ QÔ'ˆð €Lô —‘˜!˜V UÐ+´2·8±8Ô<ˆà€Løô# ò OÜÐMÓNÐNðOús   ‚C$ Ã$C9Úreturn_segmentation_masksc                 óú  — t        | |¬«      \  }}|d   }t        j                  |gt        j                  ¬«      }|d   }|D �cg c]  }d|vs	|d   dk(  sŒ|‘Œ }}|D �cg c]  }|d   ‘Œ	 }	}t        j                  |	t        j                  ¬«      }	t        j                  |D �cg c]  }|d   ‘Œ	 c}t        j                  ¬«      }
t        j                  |D �cg c]  }d|v r|d   nd‘Œ c}t        j                  ¬«      }|D �cg c]  }|d	   ‘Œ	 }}t        j                  |t        j                  ¬«      j                  d
d«      }|dd…dd…fxx   |dd…dd…f   z  cc<   |dd…ddd…f   j                  d|¬«      |dd…ddd…f<   |dd…ddd…f   j                  d|¬«      |dd…ddd…f<   |dd…df   |dd…df   kD  |dd…df   |dd…df   kD  z  }i }||d<   |	|   |d<   ||   |d<   |
|   |d<   ||   |d<   t        j                  t        |«      t        |«      gt        j                  ¬«      |d<   |rld|d   v re|D �cg c]  }|d   ‘Œ	 }}t        j                  |t        j                  ¬«      }||   }|j                  d   }|r|j                  d«      n|}||d<   |r'|D �cg c]  }|d   ‘Œ	 }}t        |||«      }||   |d<   |S c c}w c c}w c c}w c c}w c c}w c c}w c c}w )zM
    Convert the target in COCO format into the format expected by DETR.
    r�   Úimage_idr}   ÚannotationsÚiscrowdr   Úcategory_idÚareaÚbboxéÿÿÿÿé   Nrš   )rI   rJ   r‘   r   Úclass_labelsr|   Ú	orig_sizeÚ	keypoints)r²   r   Úsegmentationr¦   )
r    rM   r€   r“   r�   ÚreshapeÚcliprK   r:   r©   )rŒ   Útargetrª   r5   r‚   rƒ   r¬   r­   ÚobjÚclassesr°   r®   r|   ÚkeepÚ
new_targetr¶   Únum_keypointsÚsegmentation_masksr¦   s                      rA   Ú!prepare_coco_detection_annotationrÁ   O  s  € ô !/¨uÐBSÔ TÑ€L�+à�jÑ!€HÜ�z‰z˜8˜*¬B¯H©HÔ5€Hð ˜Ñ'€KØ"-Ö]˜3°À#Ñ1EÈÈYÉÐ[\ÓI\’3Ð]€KÐ]à-8Ö9 cˆs�=Ó!Ð9€GÐ9Ü�j‰j˜¬¯©Ô1€Gô �:‰:¨kÖ: s�s˜6“{Ò:Ä"Ç*Á*ÔM€DÜ�j‰jÈ{Ö[È¨I¸Ñ,<˜#˜iš.À!ÑCÒ[Ôce×ckÑckÔl€Gà$/Ö0˜SˆS�‹[Ð0€EÐ0ä�J‰J�u¤B§J¡JÔ/×7Ñ7¸¸AÓ>€EØ	Š!ˆQ‰Rˆ%ƒL�Eš!˜R˜a˜R˜%‘LÑ ƒLØš1˜a˜d ˜d˜7‘^×(Ñ(¨Q°KÐ(Ó@€EŠ!ˆQˆT�ˆTˆ'�NØš1˜a˜d ˜d˜7‘^×(Ñ(¨Q°LÐ(ÓA€EŠ!ˆQˆT�ˆTˆ'�Nà’!�Q�$‰K˜%¢ 1 ™+Ñ%¨%²°1°©+¸ºaÀ¸d¹Ñ*CÑD€Dà€JØ%€JˆzÑØ!(¨¡€Jˆ~ÑØ ™+€JˆwÑØ˜d™€JˆvÑØ# D™M€JˆyÑÜ Ÿj™j¬#¨lÓ*;¼SÀÓ=MÐ)NÔVX×V^ÑV^Ô_€Jˆ{Ñá�{ k°!¡nÑ4Ø1<Ö=¨#�S˜Ó%Ð=ˆ	Ð=ä—J‘J˜y´·
±
Ô;ˆ	à˜d‘Oˆ	Ø!Ÿ™¨Ñ*ˆÙ2?�I×%Ñ% gÔ.ÀYˆ	Ø"+ˆ
�;Ñá Ø=HÖI°c˜c .Ó1ÐIÐÐIÜ)Ð*<¸lÈKÓXˆØ# D™kˆ
�7ÑàÐùòS ^ùâ9ùò ;ùÚ[ùâ0ùò$ >ùò Js0   ÁKÁKÁ!KÂ'K$ÃK)Ä
K.ÉK3Ê5K8r¦   c                 ó|  — | j                   dk(  rt        j                  d«      S | j                  dd \  }}t        j                  d|t        j
                  ¬«      }t        j                  d|t        j
                  ¬«      }t        j                  ||d¬«      \  }}| t        j                  |d¬«      z  }|j                  |j                  d   d	«      j                  d	«      }t        j                  j                  |t        j                  | t        ¬«       ¬
«      }|j                  d¬«      }|j                  |j                  d   d	«      j                  d	«      }| t        j                  |d¬«      z  }|j                  |j                  d   d	«      j                  d	«      }	t        j                  j                  |t        j                  | t        ¬«       ¬
«      }|j                  d¬«      }
|
j                  |
j                  d   d	«      j                  d	«      }
t        j                  ||
||	gd«      S )a  
    Compute the bounding boxes around the provided panoptic segmentation masks.

    Args:
        masks: masks in format `[number_masks, height, width]` where N is the number of masks

    Returns:
        boxes: bounding boxes in format `[number_masks, 4]` in xyxy format
    r   )r   r³   éþÿÿÿNr}   Úij)Úindexingrw   r²   r™   g    „×—A)Ú
fill_valuer‘   )rD   rM   r’   r:   Úaranger�   ÚmeshgridÚexpand_dimsr¸   rJ   Úmari   ÚboolÚfilledrI   r£   )r¦   ÚhÚwÚyÚxÚx_maskÚx_maxÚx_minÚy_maskÚy_maxÚy_mins              rA   Úmasks_to_boxesr×   Œ  s¬  € ð ‡z�z�Q‚Ü�x‰x˜ÓÐà�;‰;�r�sÐ�D€A€qÜ
�	‰	�!�QœbŸj™jÔ)€AÜ
�	‰	�!�QœbŸj™jÔ)€Aä�;‰;�q˜! dÔ+�D€A€qà”R—^‘^ A¨AÔ.Ñ.€FØ�N‰N˜6Ÿ<™<¨™?¨BÓ/×3Ñ3°BÓ7€EÜ
�‰�‰�F¤2§8¡8¨E¼Ô#>Ð!?ˆÓ@€AØ�H‰H ˆHÓ$€EØ�M‰M˜%Ÿ+™+ a™.¨"Ó-×1Ñ1°"Ó5€Eà”R—^‘^ A¨AÔ.Ñ.€FØ�N‰N˜6Ÿ<™<¨™?¨BÓ/×3Ñ3°BÓ7€EÜ
�‰�‰�F¤2§8¡8¨E¼Ô#>Ð!?ˆÓ@€AØ�H‰H ˆHÓ$€EØ�M‰M˜%Ÿ+™+ a™.¨"Ó-×1Ñ1°"Ó5€Eä�8‰8�U˜E 5¨%Ð0°!Ó4Ð4rY   rº   Ú
masks_pathÚreturn_masksc                 óz  — t        | |¬«      \  }}t        j                  |«      |d   z  }i }t        j                  d|v r|d   n|d   gt        j
                  ¬«      |d<   t        j                  ||gt        j
                  ¬«      |d<   t        j                  ||gt        j
                  ¬«      |d<   d|v �rkt        j                  t        j                  j                  |«      t        j                  ¬«      }	t        |	«      }	t        j                  |d   D �
cg c]  }
|
d   ‘Œ	 c}
«      }|	|d	d	…d	d	f   k(  }	|	j                  t        j                  «      }	|r|	|d
<   t        |	«      |d<   t        j                  |d   D �
cg c]  }
|
d   ‘Œ	 c}
t        j
                  ¬«      |d<   t        j                  |d   D �
cg c]  }
|
d   ‘Œ	 c}
t        j
                  ¬«      |d<   t        j                  |d   D �
cg c]  }
|
d   ‘Œ	 c}
t        j                  ¬«      |d<   |S c c}
w c c}
w c c}
w c c}
w )z7
    Prepare a coco panoptic annotation for YOLOS.
    r�   Ú	file_namer¬   Úidr}   rD   rµ   Úsegments_infoNr¦   r|   r¯   r´   r®   r°   )r    ÚpathlibÚPathrM   r€   r“   ÚPILÚImageÚopenÚuint32r   ri   Úastyper    r×   r�   )rŒ   rº   rØ   rÙ   r5   r‚   rƒ   Úannotation_pathr¾   r¦   Úsegment_infoÚidss               rA   Ú prepare_coco_panoptic_annotationrè   ¯  sü  € ô !/¨uÐBSÔ TÑ€L�+Ü—l‘l :Ó.°¸Ñ1DÑD€Oà€JÜŸZ™Z¸zÈVÑ?S¨°
Ò);ÐY_Ð`dÑYeÐ(fÔnp×nvÑnvÔw€JˆzÑÜŸ™ \°;Ð$?ÄrÇxÁxÔP€JˆvÑÜ Ÿj™j¨,¸Ð)DÌBÏHÉHÔU€Jˆ{Ñà˜&Ò Ü—
‘
œ3Ÿ9™9Ÿ>™>¨/Ó:Ä"Ç)Á)ÔLˆÜ˜%Ó ˆä�h‰h¸vÀoÑ?VÖW¨|˜ TÓ*ÒWÓXˆØ˜šQ  d˜]Ñ+Ñ+ˆØ—‘œRŸX™XÓ&ˆÙØ"'ˆJ�wÑÜ,¨UÓ3ˆ
�7ÑÜ%'§X¡XØ=CÀOÑ=TÖU¨\ˆ\˜-Ó(ÒUÔ]_×]eÑ]eô&
ˆ
�>Ñ"ô !#§
¡
Ø9?ÀÑ9PÖQ¨ˆ\˜)Ó$ÒQÔY[×YaÑYaô!
ˆ
�9Ñô  ŸZ™ZØ6<¸_Ñ6MÖN lˆ\˜&Ó!ÒNÔVX×V`ÑV`ô
ˆ
�6Ñð Ðùò! Xùò Vùò Rùò Os   ÄH)Æ	H.ÇH3ÈH8Ú
input_sizeÚtarget_sizec                 óÔ  — |\  }}|\  }}t         j                  j                  | j                  dd«      d«      }	|	j                  d   dk(  r(t        j                  ||ft
        j                  ¬«      }	n!|	j                  d«      j                  ||«      }	|r'|j                  «       D ]  }
|
D ]  }|
d   |	|	|k(  <   Œ Œ t        |	«      }t        |||ft        j                  ¬«      }|S )Nr   r‘   r²   r}   ©Úresample)ÚscipyÚspecialÚsoftmaxÚ	transposer:   rM   r’   r“   Úargmaxr¸   rˆ   r   r   r   ÚNEAREST)r¦   ré   rê   Ústuff_equiv_classesÚdeduplicaterÍ   rÎ   Úfinal_hÚfinal_wÚm_idÚequivÚeq_idÚseg_imgs                rA   Úget_segmentation_imagerü   Ù  sà   € ð �D€A€qØ"Ñ€GˆWä�=‰=× Ñ  §¡°°AÓ!6¸Ó;€Dà‡z�z�"�~˜Òä�x‰x˜˜A˜¤b§h¡hÔ/‰à�{‰{˜2‹×&Ñ& q¨!Ó,ˆáà(×/Ñ/Ó1ò 	/ˆEØò /�Ø&+¨A¡h��T˜U‘]Ò#ñ/ð	/ô ˜‹o€GÜ�W˜w¨Ð0Ô;M×;UÑ;UÔV€GØ€NrY   rû   Ú	n_classesc                 óæ   — |\  }}| j                  t        j                  «      }|j                  ||d«      }t	        |«      }t        |«      D �cg c]  }||k(  j                  «       ‘Œ }}|S c c}w )Nr   )rä   rM   r    r¸   r   ÚrangeÚsum)	rû   rê   rý   rö   r÷   Ú
np_seg_imgrø   Úir°   s	            rA   Úget_mask_arear  ó  si   € Ø"Ñ€GˆWØ—‘¤§¡Ó)€JØ×#Ñ# G¨W°aÓ8€JÜ�ZÓ €DÜ',¨YÓ'7Ö8 !ˆT�Q‰Y�O‰OÕÐ8€DÐ8Ø€Kùò 9s   ÁA.Úlogitsc                 óæ   — t         j                  j                  | d¬«      }|j                  dd¬«      }t	        j
                  ||d¬«      }|j                  d«      |j                  d«      }}||fS )Nr²   rw   T)Úkeepdims)rî   rï   rð   rò   rM   Útake_along_axisrx   )r  ÚprobsÚlabelsÚscoress       rA   Ú%score_labels_from_class_probabilitiesr  ý  sf   € Ü�M‰M×!Ñ! &¨rÐ!Ó2€EØ�\‰\˜" tˆ\Ó,€FÜ×Ñ  v°BÔ7€FØ—^‘^ BÓ'¨¯©¸Ó);ˆF€FØ�6ˆ>ÐrY   ç      à?rµ   Ú	thresholdrí   c                 ó(  — t        d„ t        ||«      D «       «      }|\  }}i }||d<   | j                  «       D ]Ñ  \  }	}
|	dk(  r4|
}|t        j                  ||||gt        j
                  ¬«      z  }||d<   Œ?|	dk(  r|
}|||z  z  }||d<   ŒT|	dk(  ri|
dd…df   }t        j                  |D �cg c]  }t        |||¬«      ‘Œ c}«      }|j                  t        j
                  «      }|dd…d	f   |kD  }||d<   ŒÂ|	dk(  r||d<   ŒÍ|
||	<   ŒÓ |S c c}w )
ax  
    Resizes an annotation to a target size.

    Args:
        annotation (`Dict[str, Any]`):
            The annotation dictionary.
        orig_size (`Tuple[int, int]`):
            The original size of the input image.
        target_size (`Tuple[int, int]`):
            The target size of the image, as returned by the preprocessing `resize` step.
        threshold (`float`, *optional*, defaults to 0.5):
            The threshold used to binarize the segmentation masks.
        resample (`PILImageResampling`, defaults to `PILImageResampling.NEAREST`):
            The resampling filter to use when resizing the masks.
    c              3   óP   K  — | ]  \  }}t        |«      t        |«      z  –— Œ  y ­w©N)rH   )Ú.0ÚsÚs_origs      rA   ú	<genexpr>z$resize_annotation.<locals>.<genexpr>  s!   è ø€ ÒY±	°°6”5˜“8œe F›mÕ+ÑYùs   ‚$&rD   r|   r}   r°   r¦   Nrì   r   )	re   rŠ   r   rM   r€   r�   ri   r   rä   )rz   rµ   rê   r  rí   ÚratiosÚratio_heightÚratio_widthÚnew_annotationr…   r†   r|   Úscaled_boxesr°   Úscaled_arear¦   r–   s                    rA   Úresize_annotationr    s?  € ô, ÑY¼SÀÈiÓ=XÔYÓY€FØ &Ñ€L�+à€NØ(€N�6Ñà ×&Ñ&Ó(ò (‰
ˆˆUØ�'Š>ØˆEØ ¤2§:¡:¨{¸LÈ+ÐWcÐ.dÔln×lvÑlvÔ#wÑwˆLØ&2ˆN˜7Ò#Ø�FŠ]ØˆDØ +°Ñ"<Ñ=ˆKØ%0ˆN˜6Ò"Ø�GŠ^Øš!˜T˜'‘NˆEÜ—H‘HÐW\Ö]Ètœf T¨;ÀÖJÒ]Ó^ˆEØ—L‘L¤§¡Ó,ˆEØš!˜Q˜$‘K )Ñ+ˆEØ&+ˆN˜7Ò#Ø�FŠ]Ø%0ˆN˜6Ò"à"'ˆN˜3Òð%(ð( Ðùò ^s   Â.D
c                 ó  — t        | «      r| j                  «       } | j                  «       }t        j                  dg|dgg«      }t        j
                  |dd |dd k7  «      d   dz   }|ddd…xx   |ddd…   z  cc<   t        |«      S )aÅ  
    Converts given binary mask of shape `(height, width)` to the run-length encoding (RLE) format.

    Args:
        mask (`torch.Tensor` or `numpy.array`):
            A binary mask tensor of shape `(height, width)` where 0 denotes background and 1 denotes the target
            segment_id or class_id.
    Returns:
        `List`: Run-length encoded list of the binary mask. Refer to COCO API for more information about the RLE
        format.
    r   r‘   Nr²   rš   )r0   ro   ÚflattenrM   ÚconcatenateÚwhererd   )r–   ÚpixelsÚrunss      rA   Úbinary_mask_to_rler"  :  sŠ   € ô �tÔØ�z‰z‹|ˆà�\‰\‹^€FÜ�^‰^˜a˜S &¨1¨#Ð.Ó/€FÜ�8‰8�F˜1˜2�J &¨¨" +Ñ-Ó.¨qÑ1°AÑ5€DØˆˆˆAˆƒJ�$‘s˜�s‘)ÑƒJÜ�‹:ÐrY   c                 ó®   — t        j                  | «      }g }|D ]8  }t        j                  | |k(  dd«      }t        |«      }|j	                  |«       Œ: |S )a’  
    Converts given segmentation map of shape `(height, width)` to the run-length encoding (RLE) format.

    Args:
        segmentation (`torch.Tensor` or `numpy.array`):
            A segmentation map of shape `(height, width)` where each value denotes a segment or class id.
    Returns:
        `List[List]`: A list of lists, where each list is the run-length encoding of a segment / class id.
    r‘   r   )rl   Úuniquer  r"  r¢   )r·   Úsegment_idsÚrun_length_encodingsÚidxr–   Úrles         rA   Úconvert_segmentation_to_rler)  Q  s^   € ô —,‘,˜|Ó,€KàÐØò )ˆÜ�{‰{˜<¨3Ñ.°°1Ó5ˆÜ  Ó&ˆØ×#Ñ# CÕ(ð)ð
  ÐrY   c                 óÞ   — | j                   d   |j                   d   cxk(  r|j                   d   k(  st        d«      ‚ t        d«      ‚|j                  |«      ||kD  z  }| |   ||   ||   fS )a	  
    Binarize the given masks using `object_mask_threshold`, it returns the associated values of `masks`, `scores` and
    `labels`.

    Args:
        masks (`torch.Tensor`):
            A tensor of shape `(num_queries, height, width)`.
        scores (`torch.Tensor`):
            A tensor of shape `(num_queries)`.
        labels (`torch.Tensor`):
            A tensor of shape `(num_queries)`.
        object_mask_threshold (`float`):
            A number between 0 and 1 used to binarize the masks.
    Raises:
        `ValueError`: Raised when the first dimension doesn't match in all input tensors.
    Returns:
        `Tuple[`torch.Tensor`, `torch.Tensor`, `torch.Tensor`]`: The `masks`, `scores` and `labels` without the region
        < `object_mask_threshold`.
    r   z1mask, scores and labels must have the same shape!)r:   r<   Úne)r¦   r
  r	  Úobject_mask_thresholdÚ
num_labelsÚto_keeps         rA   Úremove_low_and_no_objectsr/  g  sy   € ð( �K‰K˜‰N˜fŸl™l¨1™oÔ@°·±¸a±Ò@ÜÐLÓMÐMð AÜÐLÓMÐMà�i‰i˜
Ó# vÐ0EÑ'EÑF€Gà�‰>˜6 '™?¨F°7©OÐ;Ð;rY   c                 ó°   — | |k(  }|j                  «       }||   |k\  j                  «       }|dkD  xr |dkD  }|r||z  }	|	j                  «       |kD  sd}||fS )Nr   F)r   Úitem)
Úmask_labelsÚ
mask_probsÚkÚmask_thresholdÚoverlap_mask_area_thresholdÚmask_kÚmask_k_areaÚoriginal_areaÚmask_existsÚ
area_ratios
             rA   Úcheck_segment_validityr<  „  sr   € à˜AÑ€FØ—*‘*“,€Kð   ‘] nÑ4×9Ñ9Ó;€MØ ‘/Ò7 m°aÑ&7€Kñ Ø  =Ñ0ˆ
Ø�‰Ó Ð#>Ò>ØˆKà˜ÐÐrY   r5  r6  Úlabel_ids_to_fusec                 ó¾  — |€| j                   d   n|d   }|€| j                   d   n|d   }t        j                  ||ft        j                  | j                  ¬«      }	g }
|�5t
        j                  j                  | j                  d«      |dd¬«      d   } d}| |j                  ddd«      z  } | j                  d«      }i }t        |j                   d   «      D ]}  }||   j                  «       }||v }t        || |||«      \  }}|sŒ/||v r||   }n|dz  }||	|<   t        ||   j                  «       d	«      }|
j                  ||||d
œ«       |sŒy|||<   Œ |	|
fS )Nr‘   r   rš   )r~   ÚdeviceÚbilinearF)rD   ÚmodeÚalign_cornersr²   é   )rÜ   Úlabel_idÚ	was_fusedÚscore)r:   rl   r’   Úint32r?  r3   Ú
functionalÚinterpolateÚ	unsqueezeÚviewrò   rÿ   r1  r<  rL   r¢   )r3  Úpred_scoresÚpred_labelsr5  r6  r=  rê   rO   rP   r·   ÚsegmentsÚcurrent_segment_idr2  Ústuff_memory_listr4  Ú
pred_classÚshould_fuser:  r7  Úsegment_scores                       rA   Úcompute_segmentsrT  —  s´  € ð %0Ð$7ˆZ×Ñ˜aÒ ¸[È¹^€FØ#.Ð#6ˆJ×Ñ˜QÒ¸KÈ¹N€Eä—;‘; ¨˜´e·k±kÈ*×J[ÑJ[Ô\€LØ€HàÐÜ—]‘]×.Ñ.Ø× Ñ  Ó#¨+¸JÐV[ð /ó 
à
ñˆ
ð Ðð �+×"Ñ" 2 q¨!Ó,Ñ,€JØ×#Ñ# AÓ&€Kð )+ÐÜ�;×$Ñ$ QÑ'Ó(ò CˆØ  ‘^×(Ñ(Ó*ˆ
Ø Ð$5Ð5ˆô 5Ø˜ Q¨Ð8Só
Ñˆ�Vò ØÐ.Ñ.Ø%6°zÑ%BÑ"à" aÑ'Ð"ð $6ˆL˜Ñ Ü! +¨a¡.×"5Ñ"5Ó"7¸Ó;ˆMØ�O‰Oà,Ø *Ø!,Ø*ñ	ôò Ø0BÐ! *Ò-ð7Cð: ˜Ð!Ð!rY   c            (       óü  ‡ — e Zd ZdZddgZej                  ddej                  ddddddddfde	e
ef   ded	ee
ef   d
edede	eef   dede	eee   f   de	eee   f   dee   dedeee
ef      ddfˆ fd„Zedee
ef   fˆ fd„«       Z	 	 	 	 d5dej,                  dedee   dee   dee	e
ej0                  f      dee	e
ef      defd„Zej                  ddfdej,                  d	ee
ef   d
edee   dee	e
ef      dej,                  fd„Zej8                  fd
edefd„Z	 	 d6dej,                  dedee	e
ef      dee	e
ef      dej,                  f
d „Zd!ed"eeef   defd#„Z d!ed$eeef   d%eeef   defd&„Z!	 	 	 	 	 d7dej,                  d'eeef   d!eee
ef      d(e	ee"e   f   dee   dee	e
ef      d)edej,                  fd*„Z#	 	 	 	 	 	 	 	 d8d+eej,                     d,eeee
ef         d(e	ee"e   f   d-ed.ee	e
e$f      dee   dee	e
ef      d)edeee
ef      de%fd/„Z&dddddddddddddddejN                  ddfd+e(d,ee	e)ee)   f      dee   dee	e
ej0                  f      dee   d	eee
ef      dee   dee	eef      dee   dee	eee   f      dee	eee   f      dee   dee   dee	e
ef      d.ee	e$e
f      de	e
ef   dee	e
ef      deee
ef      de%f&d0„Z*d1„ Z+	 d9d2ed3e	e$ee   f   fd4„Z,ˆ xZ-S ):ÚYolosImageProcessoraG  
    Constructs a Detr image processor.

    Args:
        format (`str`, *optional*, defaults to `"coco_detection"`):
            Data format of the annotations. One of "coco_detection" or "coco_panoptic".
        do_resize (`bool`, *optional*, defaults to `True`):
            Controls whether to resize the image's (height, width) dimensions to the specified `size`. Can be
            overridden by the `do_resize` parameter in the `preprocess` method.
        size (`Dict[str, int]` *optional*, defaults to `{"shortest_edge": 800, "longest_edge": 1333}`):
            Size of the image's `(height, width)` dimensions after resizing. Can be overridden by the `size` parameter
            in the `preprocess` method. Available options are:
                - `{"height": int, "width": int}`: The image will be resized to the exact size `(height, width)`.
                    Do NOT keep the aspect ratio.
                - `{"shortest_edge": int, "longest_edge": int}`: The image will be resized to a maximum size respecting
                    the aspect ratio and keeping the shortest edge less or equal to `shortest_edge` and the longest edge
                    less or equal to `longest_edge`.
                - `{"max_height": int, "max_width": int}`: The image will be resized to the maximum size respecting the
                    aspect ratio and keeping the height less or equal to `max_height` and the width less or equal to
                    `max_width`.
        resample (`PILImageResampling`, *optional*, defaults to `PILImageResampling.BILINEAR`):
            Resampling filter to use if resizing the image.
        do_rescale (`bool`, *optional*, defaults to `True`):
            Controls whether to rescale the image by the specified scale `rescale_factor`. Can be overridden by the
            `do_rescale` parameter in the `preprocess` method.
        rescale_factor (`int` or `float`, *optional*, defaults to `1/255`):
            Scale factor to use if rescaling the image. Can be overridden by the `rescale_factor` parameter in the
            `preprocess` method.
        do_normalize:
            Controls whether to normalize the image. Can be overridden by the `do_normalize` parameter in the
            `preprocess` method.
        image_mean (`float` or `List[float]`, *optional*, defaults to `IMAGENET_DEFAULT_MEAN`):
            Mean values to use when normalizing the image. Can be a single value or a list of values, one for each
            channel. Can be overridden by the `image_mean` parameter in the `preprocess` method.
        image_std (`float` or `List[float]`, *optional*, defaults to `IMAGENET_DEFAULT_STD`):
            Standard deviation values to use when normalizing the image. Can be a single value or a list of values, one
            for each channel. Can be overridden by the `image_std` parameter in the `preprocess` method.
        do_pad (`bool`, *optional*, defaults to `True`):
            Controls whether to pad the image. Can be overridden by the `do_pad` parameter in the `preprocess`
            method. If `True`, padding will be applied to the bottom and right of the image with zeros.
            If `pad_size` is provided, the image will be padded to the specified dimensions.
            Otherwise, the image will be padded to the maximum height and width of the batch.
        pad_size (`Dict[str, int]`, *optional*):
            The size `{"height": int, "width" int}` to pad the images to. Must be larger than any image size
            provided for preprocessing. If `pad_size` is not provided, images will be padded to the largest
            height and width in the batch.
    Úpixel_valuesÚ
pixel_maskTNgp?ÚformatÚ	do_resizerD   rí   Ú
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanÚ	image_stdÚdo_convert_annotationsÚdo_padÚpad_sizer6   c                 óÀ  •— d|v r|j                  d«      }d|v r't        j                  d«       |j                  d«      }n|€d nd}|�|ndddœ}t        ||d¬«      }|
€|}
t	        ‰| �  d
i |¤Ž || _        || _        || _        || _	        || _
        || _        || _        |
| _        |�|nt        | _        |	�|	nt         | _        || _        || _        g d	¢| _        y )NÚpad_and_return_pixel_maskrE   úvThe `max_size` parameter is deprecated and will be removed in v4.26. Please specify in `size['longest_edge'] instead`.i5  i   )Úshortest_edgeÚlongest_edgeF©rE   Údefault_to_square)r4   r­   rª   rØ   rZ  rD   rí   r[  r\  r]  r^  r_  r`  ra  rb  rY  Úreturn_tensorsÚdata_formatr5   © )ÚpopÚloggerÚwarning_oncer   ÚsuperÚ__init__rY  rZ  rD   rí   r[  r\  r]  r`  r   r^  r   r_  ra  rb  Ú_valid_processor_keys)ÚselfrY  rZ  rD   rí   r[  r\  r]  r^  r_  r`  ra  rb  ÚkwargsrE   Ú	__class__s                  €rA   rq  zYolosImageProcessor.__init__  s  ø€ ð  '¨&Ñ0Ø—Z‘ZÐ ;Ó<ˆFà˜ÑÜ×ÑðDôð —z‘z *Ó-‰Hà#˜|‘t°ˆHàÐ'‰t¸sÐTXÑ-YˆÜ˜T¨HÈÔNˆð "Ð)Ø%1Ð"ä‰ÑÑ"˜6Ò"ØˆŒØ"ˆŒØˆŒ	Ø ˆŒØ$ˆŒØ,ˆÔØ(ˆÔØ&<ˆÔ#Ø(2Ð(>™*ÔDYˆŒØ&/Ð&;™ÔAUˆŒØˆŒØ ˆŒò&
ˆÕ"rY   Úimage_processor_dictc                 ó¤   •— |j                  «       }d|v r|j                  d«      |d<   d|v r|j                  d«      |d<   t        ‰| �  |fi |¤ŽS )a  
        Overrides the `from_dict` method from the base class to make sure parameters are updated if image processor is
        created using from_dict and kwargs e.g. `YolosImageProcessor.from_pretrained(checkpoint, size=600,
        max_size=800)`
        rE   rd  )Úcopyrm  rp  Ú	from_dict)Úclsrv  rt  ru  s      €rA   ry  zYolosImageProcessor.from_dictL  sd   ø€ ð  4×8Ñ8Ó:ÐØ˜ÑØ/5¯z©z¸*Ó/EÐ  Ñ,Ø&¨&Ñ0Ø@FÇ
Á
ÐKfÓ@gÐ Ð!<Ñ=Ü‰wÑ Ð!5Ñ@¸Ñ@Ð@rY   rŒ   rº   rª   rØ   r5   c                 óê   — |�|n| j                   }|t        j                  k(  r|€dn|}t        ||||¬«      }|S |t        j                  k(  r|€dn|}t        |||||¬«      }|S t        d|› d�«      ‚)zD
        Prepare an annotation for feeding into DETR model.
        F©r5   T)rØ   rÙ   r5   zFormat z is not supported.)rY  r   ÚCOCO_DETECTIONrÁ   ÚCOCO_PANOPTICrè   r<   )rs  rŒ   rº   rY  rª   rØ   r5   s          rA   Úprepare_annotationz&YolosImageProcessor.prepare_annotation\  s£   € ð "Ð-‘°4·;±;ˆàÔ%×4Ñ4Ò4Ø1JÐ1R©ÐXqÐ%Ü6Ø�vÐ8ÐL]ôˆFð ˆð Ô'×5Ñ5Ò5Ø0IÐ0Q©ÐWpÐ%Ü5ØØØ%Ø6Ø"3ôˆFð ˆô ˜w v hÐ.@ÐAÓBÐBrY   rk  c                 óv  — d|v r't         j                  d«       |j                  d«      }nd}t        ||d¬«      }d|v rd|v rt	        ||d   |d   |¬«      }nNd	|v rd
|v rt        ||d	   |d
   |¬«      }n0d|v rd|v r|d   |d   f}nt        d|j                  «       › d�«      ‚t        |f||||dœ|¤Ž}|S )aÊ  
        Resize the image to the given size. Size can be `min_size` (scalar) or `(height, width)` tuple. If size is an
        int, smaller edge of the image will be matched to this number.

        Args:
            image (`np.ndarray`):
                Image to resize.
            size (`Dict[str, int]`):
                Size of the image's `(height, width)` dimensions after resizing. Available options are:
                    - `{"height": int, "width": int}`: The image will be resized to the exact size `(height, width)`.
                        Do NOT keep the aspect ratio.
                    - `{"shortest_edge": int, "longest_edge": int}`: The image will be resized to a maximum size respecting
                        the aspect ratio and keeping the shortest edge less or equal to `shortest_edge` and the longest edge
                        less or equal to `longest_edge`.
                    - `{"max_height": int, "max_width": int}`: The image will be resized to the maximum size respecting the
                        aspect ratio and keeping the height less or equal to `max_height` and the width less or equal to
                        `max_width`.
            resample (`PILImageResampling`, *optional*, defaults to `PILImageResampling.BILINEAR`):
                Resampling filter to use if resizing the image.
            data_format (`str` or `ChannelDimension`, *optional*):
                The channel dimension format for the output image. If unset, the channel dimension format of the input
                image is used.
            input_data_format (`ChannelDimension` or `str`, *optional*):
                The channel dimension format of the input image. If not provided, it will be inferred.
        rE   re  NFrh  rf  rg  r|  r?   r@   rO   rP   z\Size must contain 'height' and 'width' keys or 'shortest_edge' and 'longest_edge' keys. Got ú.)rD   rí   rk  r5   )	rn  ro  rm  r   rf   ra   r<   Úkeysr   )	rs  rŒ   rD   rí   rk  r5   rt  rE   Únew_sizes	            rA   r   zYolosImageProcessor.resize}  s  € ðD ˜ÑÜ×ÑðDôð —z‘z *Ó-‰HàˆHÜ˜T¨HÈÔNˆØ˜dÑ" ~¸Ñ'=Ü3Ø�t˜OÑ,¨d°>Ñ.BÐVgô‰Hð ˜TÑ! k°TÑ&9Ü:Ø�t˜LÑ)¨4°Ñ+<ÐPaô‰Hð ˜Ñ '¨T¡/Ø˜X™¨¨W©Ð6‰HäðØ—I‘I“K�= ð#óð ô Øð
àØØ#Ø/ñ
ð ñ
ˆð ˆrY   c                 ó    — t        ||||¬«      S )z—
        Resize the annotation to match the resized image. If size is an int, smaller edge of the mask will be matched
        to this number.
        )rµ   rê   rí   )r  )rs  rz   rµ   rD   rí   s        rA   r  z%YolosImageProcessor.resize_annotationÂ  s   € ô ! °yÈdÐ]eÔfÐfrY   c                 ó    — t        ||||¬«      S )a  
        Rescale the image by the given factor. image = image * rescale_factor.

        Args:
            image (`np.ndarray`):
                Image to rescale.
            rescale_factor (`float`):
                The value to use for rescaling.
            data_format (`str` or `ChannelDimension`, *optional*):
                The channel dimension format for the output image. If unset, the channel dimension format of the input
                image is used. Can be one of:
                - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
                - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
            input_data_format (`str` or `ChannelDimension`, *optional*):
                The channel dimension format for the input image. If unset, is inferred from the input image. Can be
                one of:
                - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
                - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
        )rk  r5   )r   )rs  rŒ   r\  rk  r5   s        rA   r   zYolosImageProcessor.rescaleÐ  s   € ô4 �u˜n¸+ÐYjÔkÐkrY   rz   rC   c                 ó   — t        ||¬«      S )zÛ
        Normalize the boxes in the annotation from `[top_left_x, top_left_y, bottom_right_x, bottom_right_y]` to
        `[center_x, center_y, width, height]` format and from absolute to relative pixel values.
        )rC   )r‡   )rs  rz   rC   s      rA   r‡   z(YolosImageProcessor.normalize_annotationí  s   € ô
 $ J¸:ÔFÐFrY   Úinput_image_sizeÚoutput_image_sizec           
      óŒ  — i }||d<   |j                  «       D ]©  \  }}|dk(  r@|}	t        |	|t        j                  dt        j
                  ¬«      }	t        |	d«      }	|	|d<   ŒK|dk(  rJ|rH|}
|
t        j                  |d   |d   z  |d   |d   z  |d   |d   z  |d   |d   z  g«      z  }
|
|d<   Œš|dk(  r||d<   Œ¥|||<   Œ« |S )z;
        Update the annotation for a padded image.
        rD   r¦   r   )rA  Úconstant_valuesr5   r‘   r|   )	r   r   r   ÚCONSTANTr   r8   ry   rM   r€   )rs  rz   r‡  rˆ  ÚpaddingÚupdate_bboxesr  r…   r†   r¦   r|   s              rA   Ú#_update_annotation_for_padded_imagez7YolosImageProcessor._update_annotation_for_padded_imageõ  s  € ð ˆØ!2ˆ�vÑà$×*Ñ*Ó,ò 	,‰JˆC�Ø�gŠ~Ø�ÜØØÜ$×-Ñ-Ø$%Ü&6×&<Ñ&<ô�ô % U¨AÓ.�Ø*/�˜wÒ'Ø˜’¡MØ�ØœŸ™à(¨Ñ+Ð.?ÀÑ.BÑBØ(¨Ñ+Ð.?ÀÑ.BÑBØ(¨Ñ+Ð.?ÀÑ.BÑBØ(¨Ñ+Ð.?ÀÑ.BÑBð	óñ �ð +0�˜wÒ'Ø˜’Ø):�˜vÒ&à&+�˜sÒ#ð5	,ð6 ÐrY   r�   rŠ  r�  c                 óÌ   — t        ||¬«      \  }}	|\  }
}|
|z
  }||	z
  }d|fd|ff}t        ||t        j                  |||¬«      }|�| j	                  |||	f|
|f||«      }||fS )z<
        Pad an image with zeros to the given size.
        r�   r   )rA  rŠ  rk  r5   )r    r   r   r‹  rŽ  )rs  rŒ   r�   rz   rŠ  rk  r5   r�  r”   r•   Úoutput_heightÚoutput_widthÚ
pad_bottomÚ	pad_rightrŒ  Úpadded_images                   rA   Ú
_pad_imagezYolosImageProcessor._pad_image!  s¤   € ô %3°5ÐFWÔ$XÑ!ˆ�kØ&1Ñ#ˆ�|à" \Ñ1ˆ
Ø  ;Ñ.ˆ	Ø�z�? Q¨	 NÐ3ˆÜØØÜ×%Ñ%Ø+Ø#Ø/ô
ˆð Ð!Ø×AÑAØ˜\¨;Ð7¸-ÈÐ9VÐX_ÐanóˆJð ˜ZÐ'Ð'rY   r4   r­   Úreturn_pixel_maskrj  c
           
      óä  — |	�|	n| j                   }	|	�|	d   |	d   f}
nt        ||¬«      }
|�|ndgt        |«      z  }g }g }t        ||«      D ]B  \  }}| j	                  ||
|||||¬«      \  }}|j                  |«       |j                  |«       ŒD d|i}|r |D �cg c]  }t        ||
|¬«      ‘Œ }}||d<   t        ||¬	«      }|�|D �cg c]  }t        ||¬
«      ‘Œ c}|d<   |S c c}w c c}w )a;	  
        Pads a batch of images to the bottom and right of the image with zeros to the size of largest height and width
        in the batch and optionally returns their corresponding pixel mask.

        Args:
            image (`np.ndarray`):
                Image to pad.
            annotations (`List[Dict[str, any]]`, *optional*):
                Annotations to pad along with the images. If provided, the bounding boxes will be updated to match the
                padded images.
            constant_values (`float` or `Iterable[float]`, *optional*):
                The value to use for the padding if `mode` is `"constant"`.
            return_pixel_mask (`bool`, *optional*, defaults to `True`):
                Whether to return a pixel mask.
            return_tensors (`str` or `TensorType`, *optional*):
                The type of tensors to return. Can be one of:
                    - Unset: Return a list of `np.ndarray`.
                    - `TensorType.TENSORFLOW` or `'tf'`: Return a batch of type `tf.Tensor`.
                    - `TensorType.PYTORCH` or `'pt'`: Return a batch of type `torch.Tensor`.
                    - `TensorType.NUMPY` or `'np'`: Return a batch of type `np.ndarray`.
                    - `TensorType.JAX` or `'jax'`: Return a batch of type `jax.numpy.ndarray`.
            data_format (`str` or `ChannelDimension`, *optional*):
                The channel dimension format of the image. If not provided, it will be the same as the input image.
            input_data_format (`ChannelDimension` or `str`, *optional*):
                The channel dimension format of the input image. If not provided, it will be inferred.
            update_bboxes (`bool`, *optional*, defaults to `True`):
                Whether to update the bounding boxes in the annotations to match the padded images. If the
                bounding boxes have not been converted to relative coordinates and `(centre_x, centre_y, width, height)`
                format, the bounding boxes will not be updated.
            pad_size (`Dict[str, int]`, *optional*):
                The size `{"height": int, "width" int}` to pad the images to. Must be larger than any image size
                provided for preprocessing. If `pad_size` is not provided, images will be padded to the largest
                height and width in the batch.
        NrO   rP   r|  )rŠ  rk  r5   r�  rW  )rŒ   r�   r5   rX  ©ÚdataÚtensor_type©rš  r	  )rb  rB   rŸ   rŠ   r•  r¢   r—   r   )rs  r4   r­   rŠ  r–  rj  rk  r5   r�  rb  Úpadded_sizeÚannotation_listÚpadded_imagesÚpadded_annotationsrŒ   rz   r”  Úpadded_annotationr™  r¦   Úencoded_inputss                        rA   r   zYolosImageProcessor.padB  sP  € ð\  (Ð3‘8¸¿¹ˆØÐØ# HÑ-¨x¸Ñ/@ÐA‰Kä.¨vÐIZÔ[ˆKà)4Ð)@™+ÀtÀfÌsÐSYË{ÑFZˆØˆØÐÜ!$ V¨_Ó!=ò 	9ÑˆE�:Ø.2¯o©oØØØØ /Ø'Ø"3Ø+ð />ó /Ñ+ˆLÐ+ð × Ñ  Ô.Ø×%Ñ%Ð&7Õ8ð	9ð  Ð.ˆáð $öàô   e¸ÐXiÖjðˆEð ð "'ˆD�Ñä%¨4¸^ÔLˆàÐ"àWiö(ØIS”˜Z°^ÖDò(ˆN˜8Ñ$ð Ðùòùò(s   ÂC(ÃC-c                 ó&	  — d|v r&t         j                  d«       |j                  d«      }d|v r&t         j                  d«       |j                  d«      }|€| j                  n|}|€| j                  n|}t        |d¬«      }|€| j                  n|}|€| j                  n|}|	€| j                  n|	}	|
€| j                  n|
}
|€| j                  n|}|€| j                  n|}|€| j                  n|}|€| j                  n|}|€| j                  n|}|€| j                  n|}t!        |j#                  «       | j$                  ¬«       t'        |«      }t)        |«      st+        d«      ‚t-        ||	|
|||||¬	«       |�t/        |t0        «      r|g}|�;t3        |«      t3        |«      k7  r$t+        d
t3        |«      › dt3        |«      › d�«      ‚t5        |«      }|�t7        |t8        |«       |�K|t4        j:                  k(  r8t/        |t<        j>                  t@        f«      st+        dtC        |«      › d�«      ‚|D �cg c]  }tE        |«      ‘Œ }}|r#tG        |d   «      rt         j                  d«       |€tI        |d   «      }|�Wg }g }tK        ||«      D ]>  \  }}| jM                  ||||||¬«      }|jO                  |«       |jO                  |«       Œ@ |}|}~~|r£|�g g }}tK        ||«      D ]e  \  }}tQ        ||«      }| jS                  ||||¬«      }| jU                  ||tQ        ||«      «      }|jO                  |«       |jO                  |«       Œg |}|}~~n"|D �cg c]  }| jS                  ||||¬«      ‘Œ }}|r!|D �cg c]  }| jW                  ||	|¬«      ‘Œ }}|
r"|D �cg c]  }| jY                  ||||¬«      ‘Œ }}|r:|�8tK        ||«      D ��cg c]!  \  }}| j[                  |tQ        ||«      «      ‘Œ# }}}|r| j]                  ||d|||||¬«      }|S |D �cg c]  }t_        |||¬«      ‘Œ }}ta        d|i|¬«      }|�|D �cg c]  }ta        ||¬«      ‘Œ c}|d<   |S c c}w c c}w c c}w c c}w c c}}w c c}w c c}w )a`  
        Preprocess an image or a batch of images so that it can be used by the model.

        Args:
            images (`ImageInput`):
                Image or batch of images to preprocess. Expects a single or batch of images with pixel values ranging
                from 0 to 255. If passing in images with pixel values between 0 and 1, set `do_rescale=False`.
            annotations (`AnnotationType` or `List[AnnotationType]`, *optional*):
                List of annotations associated with the image or batch of images. If annotation is for object
                detection, the annotations should be a dictionary with the following keys:
                - "image_id" (`int`): The image id.
                - "annotations" (`List[Dict]`): List of annotations for an image. Each annotation should be a
                  dictionary. An image can have no annotations, in which case the list should be empty.
                If annotation is for segmentation, the annotations should be a dictionary with the following keys:
                - "image_id" (`int`): The image id.
                - "segments_info" (`List[Dict]`): List of segments for an image. Each segment should be a dictionary.
                  An image can have no segments, in which case the list should be empty.
                - "file_name" (`str`): The file name of the image.
            return_segmentation_masks (`bool`, *optional*, defaults to self.return_segmentation_masks):
                Whether to return segmentation masks.
            masks_path (`str` or `pathlib.Path`, *optional*):
                Path to the directory containing the segmentation masks.
            do_resize (`bool`, *optional*, defaults to self.do_resize):
                Whether to resize the image.
            size (`Dict[str, int]`, *optional*, defaults to self.size):
                Size of the image's `(height, width)` dimensions after resizing. Available options are:
                    - `{"height": int, "width": int}`: The image will be resized to the exact size `(height, width)`.
                        Do NOT keep the aspect ratio.
                    - `{"shortest_edge": int, "longest_edge": int}`: The image will be resized to a maximum size respecting
                        the aspect ratio and keeping the shortest edge less or equal to `shortest_edge` and the longest edge
                        less or equal to `longest_edge`.
                    - `{"max_height": int, "max_width": int}`: The image will be resized to the maximum size respecting the
                        aspect ratio and keeping the height less or equal to `max_height` and the width less or equal to
                        `max_width`.
            resample (`PILImageResampling`, *optional*, defaults to self.resample):
                Resampling filter to use when resizing the image.
            do_rescale (`bool`, *optional*, defaults to self.do_rescale):
                Whether to rescale the image.
            rescale_factor (`float`, *optional*, defaults to self.rescale_factor):
                Rescale factor to use when rescaling the image.
            do_normalize (`bool`, *optional*, defaults to self.do_normalize):
                Whether to normalize the image.
            image_mean (`float` or `List[float]`, *optional*, defaults to self.image_mean):
                Mean to use when normalizing the image.
            image_std (`float` or `List[float]`, *optional*, defaults to self.image_std):
                Standard deviation to use when normalizing the image.
            do_convert_annotations (`bool`, *optional*, defaults to self.do_convert_annotations):
                Whether to convert the annotations to the format expected by the model. Converts the bounding
                boxes from the format `(top_left_x, top_left_y, width, height)` to `(center_x, center_y, width, height)`
                and in relative coordinates.
            do_pad (`bool`, *optional*, defaults to self.do_pad):
                Whether to pad the image. If `True`, padding will be applied to the bottom and right of
                the image with zeros. If `pad_size` is provided, the image will be padded to the specified
                dimensions. Otherwise, the image will be padded to the maximum height and width of the batch.
            format (`str` or `AnnotationFormat`, *optional*, defaults to self.format):
                Format of the annotations.
            return_tensors (`str` or `TensorType`, *optional*, defaults to self.return_tensors):
                Type of tensors to return. If `None`, will return the list of images.
            data_format (`str` or `ChannelDimension`, *optional*, defaults to self.data_format):
                The channel dimension format of the image. If not provided, it will be the same as the input image.
            input_data_format (`ChannelDimension` or `str`, *optional*):
                The channel dimension format for the input image. If unset, the channel dimension format is inferred
                from the input image. Can be one of:
                - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
                - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
                - `"none"` or `ChannelDimension.NONE`: image in (height, width) format.
            pad_size (`Dict[str, int]`, *optional*):
                The size `{"height": int, "width" int}` to pad the images to. Must be larger than any image size
                provided for preprocessing. If `pad_size` is not provided, images will be padded to the largest
                height and width in the batch.
        rd  zjThe `pad_and_return_pixel_mask` argument is deprecated and will be removed in v4.33, use `do_pad` instead.rE   zgThe `max_size` argument is deprecated and will be removed in v4.33, use `size['longest_edge']` instead.F)rD   ri  )Úcaptured_kwargsÚvalid_processor_keyszkInvalid image type. Must be of type PIL.Image.Image, numpy.ndarray, torch.Tensor, tf.Tensor or jax.ndarray.)r[  r\  r]  r^  r_  rZ  rD   rí   zThe number of images (z) and annotations (z) do not match.zxThe path to the directory containing the mask PNG files should be provided as a `pathlib.Path` or string object, but is z	 instead.r   z­It looks like you are trying to rescale already rescaled images. If the input images have pixel values between 0 and 1, set `do_rescale=False` to avoid rescaling them again.)rª   rØ   r5   )rD   rí   r5   r|  )r­   r–  rk  r5   r�  rj  rb  )Úinput_channel_dimrW  r˜  r›  r	  )1rn  ro  rm  rZ  rD   r   rí   r[  r\  r]  r^  r_  r`  ra  rb  rY  r'   r‚  rr  r#   r%   r<   r(   rc   ÚdictrŸ   r   r&   ÚSUPPORTED_ANNOTATION_FORMATSr~  rÞ   rß   Ústrrp   r$   r"   r!   rŠ   r  r¢   r    r   r  r   Ú	normalizer‡   r   r   r   ) rs  r4   r­   rª   rØ   rZ  rD   rí   r[  r\  r]  r^  r_  r`  ra  rY  rj  rk  r5   rb  rt  rŒ   Úprepared_imagesÚprepared_annotationsrº   Úresized_imagesÚresized_annotationsrµ   Úresized_imageÚresized_annotationrz   r¡  s                                    rA   Ú
preprocesszYolosImageProcessor.preprocess˜  su  € ð| '¨&Ñ0Ü×Ñð(ôð —Z‘ZÐ ;Ó<ˆFà˜ÑÜ×Ñð3ôð —:‘:˜jÓ)ˆDà&/Ð&7�D—N’N¸Yˆ	Ø ˜Lˆt�yŠy¨dˆÜ $¸%Ô@ˆØ$,Ð$4�4—=’=¸(ˆØ(2Ð(:�T—_’_À
ˆ
Ø0>Ð0F˜×,Ò,ÈNˆØ,8Ð,@�t×(Ò(ÀlˆØ(2Ð(:�T—_’_À
ˆ
Ø&/Ð&7�D—N’N¸Yˆ	à+AÐ+IˆD×'Ò'ÐOeð 	ð !' �—’°FˆØ$,Ð$4�4—=’=¸(ˆØ & �—’°FˆÜ¨¯©«ÈD×LfÑLfÕgä$ VÓ,ˆä˜FÔ#Üð:óð ô
 	&Ø!Ø)Ø%Ø!ØØØØõ		
ð Ð"¤z°+¼tÔ'DØ&˜-ˆKàÐ"¤s¨6£{´c¸+Ó6FÒ'FÜØ(¬¨V«¨Ð5HÌÈ[ÓIYÐHZÐZiÐjóð ô " &Ó)ˆØÐ"Ü  Ô)EÀ{ÔSð Ð"ØÔ*×8Ñ8Ò8Ü˜z¬G¯L©L¼#Ð+>Ô?äð<Ü<@ÀÓ<LÐ;MÈYðXóð ð 6<Ö<¨E”. Õ'Ð<ˆÐ<áœ/¨&°©)Ô4Ü×Ñðsôð
 Ð$ä >¸vÀa¹yÓ IÐð Ð"Ø ˆOØ#%Ð Ü!$ V¨[Ó!9ò 
4‘��vØ×0Ñ0ØØØØ.GØ)Ø&7ð 1ó �ð  ×&Ñ& uÔ-Ø$×+Ñ+¨FÕ3ð
4ð %ˆFØ.ˆKØÐ!5ñ ØÐ&Ø68¸"Ð 3�Ü%(¨°Ó%=ò 	C‘M�E˜6Ü .¨uÐ6GÓ H�IØ$(§K¡KØ D°8ÐO`ð %0ó %�Mð *.×)?Ñ)?Ø 	¬>¸-ÐIZÓ+[ó*Ð&ð #×)Ñ)¨-Ô8Ø'×.Ñ.Ð/AÕBð	Cð (�Ø1�Ø"Ñ$7ð "(öàð —K‘K ¨D¸8ÐWh�KÕið�ð ñ
 ØlrÖsÐch�d—l‘l 5¨.ÐL]�lÕ^ÐsˆFÐsáàouöØfk�—‘˜u j°)ÐO`�ÕaðˆFð ñ " kÐ&=ô *-¨[¸&Ó)A÷á%�J ð ×)Ñ)¨*´nÀUÐL]Ó6^Õ_ðˆKñ ñ
 à!ŸX™XØØ'Ø"'Ø'Ø"3Ø4Ø-Ø!ð &ó 	ˆNð* Ðð $öàô ,¨E°;ÐRcÖdðˆFð ô *°ÀÐ/GÐUcÔdˆNØÐ&à[fö,ØMW”L ¸ÖHò,�˜xÑ(ð Ðùòw =ùòbùò tùòùó
ùò$ùò,s*   È<Q/Í%Q4Î	Q9Î,Q>Ï&RÐ'R	ÑRc           	      ór  — t         j                  d«       |j                  |j                  }}t	        |«      t	        |«      k7  rt        d«      ‚|j                  d   dk7  rt        d«      ‚t        j                  j                  |d«      }|ddd…f   j                  d«      \  }}t        |«      }|j                  d«      \  }	}
t        j                  |
|	|
|	gd¬	«      j                  |j                   «      }||dd…ddd…f   z  }t#        |||«      D ���cg c]  \  }}}|||d
œ‘Œ }}}}|S c c}}}w )a[  
        Converts the raw output of [`YolosForObjectDetection`] into final bounding boxes in (top_left_x, top_left_y,
        bottom_right_x, bottom_right_y) format. Only supports PyTorch.

        Args:
            outputs ([`YolosObjectDetectionOutput`]):
                Raw outputs of the model.
            target_sizes (`torch.Tensor` of shape `(batch_size, 2)`):
                Tensor containing the size (height, width) of each image of the batch. For evaluation, this must be the
                original image size (before any data augmentation). For visualization, this should be the image size
                after data augment, but before padding.
        Returns:
            `List[Dict]`: A list of dictionaries, each dictionary containing the scores, labels and boxes for an image
            in the batch as predicted by the model.
        z§`post_process` is deprecated and will be removed in v5 of Transformers, please use `post_process_object_detection` instead, with `threshold=0.` for equivalent results.úTMake sure that you pass in as many target sizes as the batch dimension of the logitsr‘   rš   zTEach element of target_sizes must contain the size (h, w) of each image of the batchr²   .N©Údim©r
  r	  r|   )rn  ro  r  Ú
pred_boxesrŸ   r<   r:   r3   rH  rð   rJ   r   Úunbindrl   r£   Útor?  rŠ   )rs  ÚoutputsÚtarget_sizesÚ
out_logitsÚout_bboxÚprobr
  r	  r|   Úimg_hÚimg_wÚ	scale_fctr  ÚlÚbÚresultss                   rA   Úpost_processz YolosImageProcessor.post_processž  s5  € ô  	×Ñðdô	
ð
  'Ÿ~™~¨w×/AÑ/A�Hˆ
äˆz‹?œc ,Ó/Ò/ÜÐsÓtÐtØ×Ñ˜aÑ  AÒ%ÜÐsÓtÐtä�}‰}×$Ñ$ Z°Ó4ˆØ˜c 3 B 3˜h™×+Ñ+¨BÓ/‰ˆ�ô )¨Ó2ˆà#×*Ñ*¨1Ó-‰ˆˆuÜ—K‘K ¨¨u°eÐ <À!ÔD×GÑGÈÏÉÓUˆ	Ø˜	¢! Tª1 *Ñ-Ñ-ˆäILÈVÐU[Ð]bÓIc×dÐd¹g¸aÀÀA˜a¨1°qÓ9ÐdˆÒdØˆùô es   ÄD2r  rº  c                 ó  — |j                   |j                  }}|�"t        |«      t        |«      k7  rt        d«      ‚t        j
                  j                  |d«      }|ddd…f   j                  d«      \  }}t        |«      }	|�´t        |t        «      rMt        j                  |D �
cg c]  }
|
d   ‘Œ	 c}
«      }t        j                  |D �
cg c]  }
|
d   ‘Œ	 c}
«      }n|j                  d«      \  }}t        j                  ||||gd¬«      j                  |	j                   «      }|	|dd…ddd…f   z  }	g }t#        |||	«      D ]3  \  }}}|||kD     }|||kD     }|||kD     }|j%                  |||dœ«       Œ5 |S c c}
w c c}
w )	a‘  
        Converts the raw output of [`YolosForObjectDetection`] into final bounding boxes in (top_left_x, top_left_y,
        bottom_right_x, bottom_right_y) format. Only supports PyTorch.

        Args:
            outputs ([`YolosObjectDetectionOutput`]):
                Raw outputs of the model.
            threshold (`float`, *optional*):
                Score threshold to keep object detection predictions.
            target_sizes (`torch.Tensor` or `List[Tuple[int, int]]`, *optional*):
                Tensor of shape `(batch_size, 2)` or list of tuples (`Tuple[int, int]`) containing the target size
                `(height, width)` of each image in the batch. If unset, predictions will not be resized.
        Returns:
            `List[Dict]`: A list of dictionaries, each dictionary containing the scores, labels and boxes for an image
            in the batch as predicted by the model.
        Nr²  r²   .r   r‘   r³  rµ  )r  r¶  rŸ   r<   r3   rH  rð   rJ   r   rc   r   rl   ÚTensorr·  r£   r¸  r?  rŠ   r¢   )rs  r¹  r  rº  r»  r¼  r½  r
  r	  r|   r  r¾  r¿  rÀ  rÃ  r  rÁ  rÂ  rF  ÚlabelÚboxs                        rA   Úpost_process_object_detectionz1YolosImageProcessor.post_process_object_detectionÈ  s‘  € ð&  'Ÿ~™~¨w×/AÑ/A�Hˆ
àÐ#Ü�:‹¤# lÓ"3Ò3Ü Øjóð ô �}‰}×$Ñ$ Z°Ó4ˆØ˜c 3 B 3˜h™×+Ñ+¨BÓ/‰ˆ�ô )¨Ó2ˆð Ð#Ü˜,¬Ô-ÜŸ™°LÖ%A¨q a¨£dÒ%AÓB�ÜŸ™°LÖ%A¨q a¨£dÒ%AÓB‘à+×2Ñ2°1Ó5‘��uäŸ™ U¨E°5¸%Ð$@ÀaÔH×KÑKÈEÏLÉLÓYˆIØ˜I¢a¨ªq jÑ1Ñ1ˆEàˆÜ˜6 6¨5Ó1ò 	M‰GˆAˆq�!Ø�a˜)‘mÑ$ˆEØ�a˜)‘mÑ$ˆEØ�A˜	‘MÑ"ˆCØ�N‰N e°uÀsÑKÕLð		Mð ˆùò &BùÚ%As   Â(F ÃF)NNNN©NN)Nr   NNT)Nr   FNNNTN)r  N).Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úmodel_input_namesr   r}  r   ÚBILINEARr   r¨  rË   r   rK   rH   r   r   rq  Úclassmethodr   ry  rM   rh   rÞ   rß   r   r  r   ró   r  r   r
   r‡   rŽ  r   r•  r)   r   r   r8   r   r   r°  rÄ  rÉ  Ú__classcell__)ru  s   @rA   rV  rV  Ó  sã  ø„ ñ.ð` (¨Ð6Ðð 0@×/NÑ/NØØ#Ø'9×'BÑ'BØØ,3Ø!Ø04Ø/3Ø15ØØ-1ñD
à�cÐ+Ð+Ñ,ðD
ð ðD
ð �3˜�8‰nð	D
ð
 %ðD
ð ðD
ð ˜c 5˜jÑ)ðD
ð ðD
ð ˜%  e¡Ð,Ñ-ðD
ð ˜  U¡Ð+Ñ,ðD
ð !)¨¡ðD
ð ðD
ð ˜4  S ™>Ñ*ðD
ð 
õD
ðL ðA¨T°#°s°(©^ô Aó ðAð$ .2Ø48Ø9=ØDHñà�z‰zðð ðð Ð)Ñ*ð	ð
 $,¨D¡>ðð ˜U 3¨¯©Ð#4Ñ5Ñ6ðð $ E¨#Ð/?Ð*?Ñ$@ÑAðð 
óðJ (:×'BÑ'BØ26ØDHñBà�z‰zðBð �3˜�8‰nðBð %ð	Bð
 Ð.Ñ/ðBð $ E¨#Ð/?Ð*?Ñ$@ÑAðBð 
�‰óBðT (:×'AÑ'Añgð
 %ðgð 
ógð$ ?CØDHñlà�z‰zðlð ðlð ˜e CÐ)9Ð$9Ñ:Ñ;ð	lð
 $ E¨#Ð/?Ð*?Ñ$@ÑAðlð 
�‰ólð:G¨tð GÀÀsÈCÀxÁð GÐUYó Gð)àð)ð    S ™/ð)ð !  c ™?ð	)ð 
ó)ð` 04Ø9:Ø26ØDHØ"ñ(à�z‰zð(ð ˜3 ˜8‘_ð(ð ˜T # s (™^Ñ,ð	(ð
 ˜u h¨u¡oÐ5Ñ6ð(ð Ð.Ñ/ð(ð $ E¨#Ð/?Ð*?Ñ$@ÑAð(ð ð(ð 
�‰ó(ðH 7;Ø9:Ø"'Ø;?Ø26ØDHØ"Ø-1ñTà�R—Z‘ZÑ ðTð ˜d 4¨¨S¨¡>Ñ2Ñ3ðTð ˜u h¨u¡oÐ5Ñ6ð	Tð
  ðTð !  s¨J Ñ!7Ñ8ðTð Ð.Ñ/ðTð $ E¨#Ð/?Ð*?Ñ$@ÑAðTð ðTð ˜4  S ™>Ñ*ðTð 
óTðr NRØ48Ø9=Ø$(Ø)-ØØ%)Ø6:Ø'+Ø:>Ø9=Ø15Ø!%Ø9=Ø;?Ø4D×4JÑ4JØDHØ-1ñ)BàðBð ˜e N°D¸Ñ4HÐ$HÑIÑJðBð $,¨D¡>ð	Bð
 ˜U 3¨¯©Ð#4Ñ5Ñ6ðBð ˜D‘>ðBð �t˜C ˜H‘~Ñ&ðBð ˜T‘NðBð !  s¨E zÑ!2Ñ3ðBð ˜t‘nðBð ˜U 5¨$¨u©+Ð#5Ñ6Ñ7ðBð ˜E %¨¨e©Ð"4Ñ5Ñ6ðBð !)¨¡ðBð ˜‘ðBð  ˜˜sÐ$4Ð4Ñ5Ñ6ð!Bð" !  z°3 Ñ!7Ñ8ð#Bð$ ˜3Ð 0Ð0Ñ1ð%Bð& $ E¨#Ð/?Ð*?Ñ$@ÑAð'Bð( ˜4  S ™>Ñ*ð)Bð, 
ó-BòL'ðV _cñ3Ø"'ð3Ø=BÀ:ÈtÐTYÉ{ÐCZÑ=[÷3rY   rV  r  )Né   rÊ  )FN)TN)F)r  çš™™™™™é?)r  rÔ  NN)drÎ  rÞ   Útypingr   r   r   r   r   r   r	   r
   r   ro   rM   Úfeature_extraction_utilsr   Úimage_processing_utilsr   r   Úimage_transformsr   r   r   r   r   r   r   r   r   Úimage_utilsr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   Úutilsr)   r*   r+   r,   r-   r.   r/   r0   r1   r2   rl   r3   rà   Úscipy.specialrî   Úscipy.statsÚ
get_loggerrË  rn  r}  r~  r§  rh   r¨  rK   rB   rX   ra   rf   rt   ry   r‡   r9   r—   r©   rË   rÁ   r×   rß   rè   rü   r  r  ró   rH   r  r"  r)  r/  r<  rT  rV  Ú__all__rl  rY   rA   ú<module>rß     sî  ðñ 'ã ß S× SÕ Sã å 4ß G÷
÷ 
õ 
÷÷ ÷ ÷ ó ÷$÷ ÷ ñ ÔÛÝñ ÔÛñ ÔÛÛà	ˆ×	Ñ	˜HÓ	%€à 0× ?Ñ ?ÐAQ×A_ÑA_Ð`Ð ð
 [_ñ#Ø�—‘Ñð#Ø19¸%ÀÐEUÐ@UÑ:VÑ1Wð#à	ˆ#�Yó#ð& ]_ñ.Ø�c˜3�h‘ð.Ø'*ð.Ø6>¸s±mð.ØVYð.à
ˆ3�ˆ8�_ó.ðl AEñ	 !Ø—‘ð !àð !ð ð !ð    cÐ+;Ð&;Ñ <Ñ=ð	 !ð
 ˆ3�ˆ8�_ó !ðN #Ø@Dñ	BØ—‘ðBà
��U˜3 ˜8‘_ d¨3¡iÐ/Ñ
0ðBð �s‰mðBð    cÐ+;Ð&;Ñ <Ñ=ð	Bð
 ˆ3�ˆ8�_óBð:C hó Cñ2
�b—j‘jð 
¨°©ð 
ÀÇÁó 
ð Tð °u¸SÀ#¸X±ð È4ó ð8˜x¨™}ð 8°°c±ó 8ð rvñØ�:‰:ðØ$)¨#¨s¨(¡OðØHPÐQVÐWZÐ\lÐWlÑQmÑHnðà‡Z�Zóð&°Sð Àð ÈÏÉó ðL ',Ø@Dñ	9ð  $ð9ð   Ð&6¸Ð&;Ñ <Ñ=ó	9ðz5˜"Ÿ*™*ð 5¨¯©ó 5ðN Ø6:ñ&Ø�:‰:ð&àð&ð �c˜7Ÿ<™<Ð'Ñ(ð&ð ð	&ð
 Ð-¨sÐ2Ñ3ð&ð 
ó&ðV `eñØ�:‰:ðØ#(ðØ7<óð4˜2Ÿ:™:ð °E¸#¸s¸(±Oð ÐPSð ÐXZ×XbÑXbó ð°"·*±*ð ÀÀrÇzÁzÐSU×S]ÑS]ÐG]ÑA^ó ð Ø#5×#=Ñ#=ñ0Ø�S˜#�X‘ð0à�S˜#�X‰ð0ð �s˜C�x‘ð0ð ð	0ð
 !ó0òhò. ò,<ó:ð.  Ø),Ø,0Ø#'ñ9"ð ð	9"ð
 "'ð9"ð    C¡Ñ)ð9"ð �s˜C�x‘ó9"ôxhÐ,ô hðV !Ð
!�rY   