+
    œ°³jï»  ã                   óð  € R t ^ RIt^ RIHtHt ^ RIt^ RIt^ RIHt ^ RI	H
t
 ^ RIHt ^RIHt ^RIHt ^RIHtHt ^R	IHtHtHtHt ^R
IHtHtHtHtHtH t H!t!H"t"H#t#H$t$H%t%H&t& ^RI'H(t(H)t) ^RI*H+t+H,t,H-t- ]-P\                  ! ]/4      t0]Pb                  ]Pd                  3t3 ! R R](RR7      t4R t5R t6R t7R"R lt8R#R R llt9R R lt:R$R R llt;R R lt<R t=R%R R llt>], ! R  R!]4      4       t?R!.t@R# )&zImage processor class for DETR.N)ÚAnyÚOptional)Únn)Ú
read_image)Ú
functional)ÚTorchvisionBackend)Ú'SemanticSegmentationPostProcessorOutput)ÚBatchFeatureÚget_size_dict)Úcenter_to_corners_formatÚcorners_to_center_formatÚget_size_with_aspect_ratioÚsafe_squeeze)ÚIMAGENET_DEFAULT_MEANÚIMAGENET_DEFAULT_STDÚAnnotationFormatÚAnnotationTypeÚChannelDimensionÚ
ImageInputÚPILImageResamplingÚSizeDictÚget_image_sizeÚ#get_image_size_for_max_height_widthÚget_max_height_widthÚvalidate_annotations)ÚImagesKwargsÚUnpack)Ú
TensorTypeÚauto_docstringÚloggingc                   ó0   a € ] tR t^=t o RtV 3R ltRtV tR# )ÚDetrImageProcessorKwargsa  
format (`str`, *optional*, defaults to `AnnotationFormat.COCO_DETECTION`):
    Data format of the annotations. One of "coco_detection" or "coco_panoptic".
do_convert_annotations (`bool`, *optional*, defaults to `True`):
    Controls whether to convert the annotations to the format expected by the DETR model. Converts the
    bounding boxes to the format `(center_x, center_y, width, height)` and in the range `[0, 1]`.
    Can be overridden by the `do_convert_annotations` parameter in the `preprocess` method.
c                óB   <€ V ^8„  d   Qh/ S[ S[,          ;R&   S[;R&   # )é   ÚformatÚdo_convert_annotations)Ústrr   Úbool)r$   Ú__classdict__s   "€Úo/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/detr/image_processing_detr.pyÚ__annotate__Ú%DetrImageProcessorKwargs.__annotate__=   s%   ø‡ ‚ ñ Ñ"Õ"Ñ"ñ ñ !Ñ ò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r(   s   @r)   r!   r!   =   s   ø‡ € ñ÷ ƒ r,   r!   F)Útotalc                óP  € ^RI Hp V! V 4      '       d   V P                  4       p V P                  4       p\        P
                  ! ^ .V^ ..4      p\        P                  ! VR,          VRR 8g  4      ^ ,          ^,           pVR;;,          VR,          ,          uu&   \        V4      # )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.
)Úis_torch_tensorºé   NNNºr:   Nr#   :NNr#   éÿÿÿÿ)Úutilsr8   ÚnumpyÚflattenÚnpÚconcatenateÚwhereÚlist)Úmaskr8   ÚpixelsÚrunss   &   r)   Úbinary_mask_to_rlerG   K   s„   € õ )á�t×ÒØ�z‰z‹|ˆà�\‰\‹^€FÜ�^Š^˜a˜S &¨1¨#Ð.Ó/€FÜ�8Š8�F˜2•J &¨¨" +Ñ-Ó.¨qÕ1°AÕ5€DØˆ‡J�$�s•)ÕƒJÜ�‹:Ðr,   c                ó´   € \         P                  ! V 4      p. pV F9  p\         P                  ! W8H  ^^ 4      p\        V4      pVP	                  V4       K;  	  V# )av  
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.
)ÚtorchÚuniquerB   rG   Úappend)ÚsegmentationÚsegment_idsÚrun_length_encodingsÚidxrD   Úrles   &     r)   Úconvert_segmentation_to_rlerQ   c   sW   € ô —,’,˜|Ó,€KàÐÛˆÜ�{Š{˜<Ñ.°°1Ó5ˆÜ  Ó&ˆØ×#Ñ# CÖ(ñ ð
  Ðr,   c                ó  € V P                   ^ ,          VP                   ^ ,          u;8X  d   VP                   ^ ,          8X  g   M \        R4      hVP                  V4      W8„  ,          pW,          W,          W%,          3# )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`.
z1mask, scores and labels must have the same shape!)ÚshapeÚ
ValueErrorÚne)ÚmasksÚscoresÚlabelsÚobject_mask_thresholdÚ
num_labelsÚto_keeps   &&&&& r)   Úremove_low_and_no_objectsr\   x   s^   € ð( �K‰K˜�N˜fŸl™l¨1�oÖ@°·±¸aµÖ@ÜÐLÓMÐMà�i‰i˜
Ó# vÑ'EÕF€Gà�>˜6�?¨F­OÐ;Ð;r,   c                 óÔ   € W8H  pVP                  4       pW,          V8¬  P                  4       pV^ 8„  ;'       d    V^ 8„  pV'       d    Wg,          p	V	P                  4       V8”  g   RpW…3# )é    F)ÚsumÚitem)
Úmask_labelsÚ
mask_probsÚkÚmask_thresholdÚoverlap_mask_area_thresholdÚmask_kÚmask_k_areaÚoriginal_areaÚmask_existsÚ
area_ratios
   &&&&&     r)   Úcheck_segment_validityrk   ”   sm   € àÑ€FØ—*‘*“,€Kð  •] nÑ4×9Ñ9Ó;€MØ ‘/×7Ð7 m°aÑ&7€K÷ Ø Õ0ˆ
Ø�‰Ó Ð#>Ô>ØˆKàÐÐr,   c          
      óœ   € V ^8„  d   QhR\         R\         R\        \        ,          R,          R\        \        \        3,          R,          /# )r#   rd   re   Úlabel_ids_to_fuseNÚtarget_size)ÚfloatÚsetÚintÚtuple)r$   s   "r)   r*   r*   ¦   sI   € ÷ 9"ñ 9"ô ð	9"ô
 "'ð9"ô œ3•x $•ð9"ô ”sœC�x• 4Õ'ñ9"r,   c                 ó:  € Vf   V P                   ^,          MV^ ,          pVf   V P                   ^,          MV^,          p\        P                  ! Wx3\        P                  V P                  R7      p	. p
Ve:   \
        P                  P                  V P                  ^ 4      VRRR7      ^ ,          p ^ pWP                  R	^^4      ,          p V P                  ^ 4      p/ p\        VP                   ^ ,          4       Fš  pW.,          P                  4       pWõ9   p\        WÀWãV4      w  ppV'       g   K7  Wý9   d
   Wß,          pM	V^,          pW¹V&   \        W,          P                  4       ^4      pV
P                  RVRVRVRV/4       V'       g   K–  W½V&   Kœ  	  Wš3# )
N©ÚdtypeÚdeviceÚbilinearF©ÚsizeÚmodeÚalign_cornersÚidÚlabel_idÚ	was_fusedÚscorer<   )rS   rI   ÚzerosÚint32rv   r   r   ÚinterpolateÚ	unsqueezeÚviewÚargmaxÚranger`   rk   ÚroundrK   )rb   Úpred_scoresÚpred_labelsrd   re   rm   rn   ÚheightÚwidthrL   ÚsegmentsÚcurrent_segment_idra   Ústuff_memory_listrc   Ú
pred_classÚshould_fuseri   rf   Úsegment_scores   &&&&&&&             r)   Úcompute_segmentsr’   ¦   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Õ'Ö(ˆØ •^×(Ñ(Ó*ˆ
Ø Ñ5ˆô 5Ø QÐ8Só
Ñˆ�V÷ ‰;ØÔ.Ø%6Õ%BÑ"à" aÕ'Ð"ð $6˜Ñ Ü! +¥.×"5Ñ"5Ó"7¸Ó;ˆMØ�O‰OàÐ,Ø 
Ø Ø˜]ð	ô÷ ‰{Ø0B *Ó-ñ7 )ð: Ð!Ð!r,   c                óp   € V ^8„  d   QhR\         R\         R\        P                  R\        P                  /# )r#   rŠ   r‹   rv   Úreturn)rq   rI   rv   ÚTensor)r$   s   "r)   r*   r*   ã   s3   € ÷ ñ ´Sð Äð ÌeÏlÉlð Ô_d×_kÑ_kñ r,   c                ó   €  ^ RI Hp . pT  F™  pTP                  YaT4      pTP	                  T4      p\        TP                  4      ^8  d
   TR,          p\        P                  ! T\        P                  TR7      p\        P                  ! T^R7      pTP                  T4       K›  	  T'       d   \        P                  ! T^ R7      pT# \        P                  ! ^ Y3\        P                  TR7      pT#   \         d    \        R4      hi ; i)a  
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.
)rD   z1Pycocotools is not installed in your environment.rt   )Úaxis).N)ÚpycocotoolsrD   ÚImportErrorÚfrPyObjectsÚdecodeÚlenrS   rI   Ú	as_tensorÚuint8ÚanyrK   Ústackr€   )	ÚsegmentationsrŠ   r‹   rv   Ú	coco_maskrV   ÚpolygonsÚrlesrD   s	   &&&&     r)   Úconvert_coco_poly_to_maskr¥   ã   sæ   € ðOÝ1ð €EÛ!ˆØ×$Ñ$ X°uÓ=ˆØ×Ñ Ó%ˆÜˆt�z‰z‹?˜QÔØ˜	•?ˆDÜ�Š˜t¬5¯;©;¸vÔFˆÜ�yŠy˜ AÔ&ˆØ�‰�TÖñ "÷ Ü—’˜E¨Ô*ˆð €Lô —’˜Q Ð.´e·k±kÈ&ÔQˆà€Løô# ô OÜÐMÓNÐNðOús   ‚C6 Ã6Dc                óT   € V ^8„  d   QhR\         R\        \        ,          R,          /# )r#   Úreturn_segmentation_masksÚinput_data_formatN)r'   r   r&   )r$   s   "r)   r*   r*     s*   € ÷ =ñ =ô  $ð=ô (¬#Õ-°Õ4ñ	=r,   c                óÌ  € V P                  4       RR w  rEVR,          p\        P                  ! V.\        P                  V P                  R7      pVR,          p. p. p	. p
. pV Fƒ  pRV9  g   VR,          ^ 8X  g   K  VP                  VR,          4       V	P                  VR,          4       V
P                  VR,          4       R	V9   g   Kk  VP                  VR	,          4       K…  	  \        P                  ! V\        P                  V P                  R7      p\        P                  ! V	\        P                  V P                  R7      p	\        P                  ! V\        P                  V P                  R7      p\        P                  ! V
\        P                  V P                  R7      P                  R^4      p
V
R;;,          V
R,          ,          uu&   V
R,          P                  ^ VR
7      V
R&   V
R,          P                  ^ VR
7      V
R&   V
R,          V
R,          8„  V
R,          V
R,          8„  ,          pRVRWŽ,          RW®,          RWž,          RWÞ,          R\        P                  ! \        V4      \        V4      .\        P                  V P                  R7      /pV'       dl   \        P                  ! V\        P                  V P                  R7      pW¾,          pVP                  ^ ,          pV'       d   VP                  R4      MTpW¿R	&   V'       d<   V Uu. uF  qÌR,          NK  	  pp\        VWEV P                  R7      pVV,          VR&   V# u upi )zE
Convert the target in COCO format into the format expected by DETR.
NÚimage_idrt   ÚannotationsÚiscrowdÚcategory_idÚareaÚbboxÚ	keypoints)ÚminÚmaxÚclass_labelsÚboxesÚ	orig_sizerL   ©rv   rV   éþÿÿÿr<   )ºNNN:r#   NN)r¸   :Nr#   N)r¸   :r^   Nr#   )r¸   r;   )r¸   é   )r¸   r:   )r¸   r#   ©r¸   r^   )r<   r¹   )ry   rI   r�   Úint64rv   rK   Úfloat32Ú
zeros_likeÚreshapeÚcliprq   rS   r¥   )ÚimageÚtargetr§   r¨   Úimage_heightÚimage_widthrª   r«   Úclassesr®   r´   r°   Úobjr¬   ÚkeepÚ
new_targetÚnum_keypointsÚsegmentation_masksrV   s   &&&&               r)   Ú!prepare_coco_detection_annotationrÊ     sª  € ð !&§
¡
£¨R¨SÐ 1Ñ€Là�jÕ!€HÜ�Š ˜z´·±ÀUÇ\Á\ÔR€Hð ˜Õ'€KØ€GØ€DØ€EØ€IÛˆØ˜CÔ 3 y¥>°QÖ#6Ø�N‰N˜3˜}Õ-Ô.Ø�K‰K˜˜F�Ô$Ø�L‰L˜˜V�Ô%Ø˜cÖ!Ø× Ñ   [Õ!1Ö2ñ ô �oŠo˜g¬U¯[©[ÀÇÁÔN€GÜ�?Š?˜4¤u§}¡}¸U¿\¹\ÔJ€DÜ×Ò˜w¬e¯k©kÀ%Ç,Á,ÔO€Gä�OŠO˜E¬¯©¸u¿|¹|ÔL×TÑTÐUWÐYZÓ[€EØ	ˆ%‡L�E˜%•LÕ ƒLØ˜7•^×(Ñ(¨Q°KÐ(Ó@€Eˆ'�NØ˜7•^×(Ñ(¨Q°LÐ(ÓA€Eˆ'�Nà�$�K˜% �+Ñ%¨%°­+¸¸d½Ñ*CÕD€Dð 	�HØ˜�Ø�•Ø�•
Ø�7•=Ø”U—_’_¤c¨,Ó&7¼¸[Ó9IÐ%JÔRW×R]ÑR]Ðfk×frÑfrÔsð€J÷ Ü—O’O I´U·]±]È5Ï<É<ÔXˆ	à•Oˆ	Ø!Ÿ™¨Õ*ˆß2?�I×%Ñ% gÔ.ÀYˆ	Ø"+�;Ñç Ù=HÓI¹[°c .×1Ð1¹[ÐÐIÜ)Ð*<¸lÐ`e×`lÑ`lÔmˆØ# D�kˆ
�7ÑàÐùò	 Js   Ì(M!c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# )r#   rV   r”   )rI   r•   )r$   s   "r)   r*   r*   F  s"   € ÷ 8ñ 8œ%Ÿ,™,ð 8¬5¯<©<ñ 8r,   c           	     ó  € V P                  4       ^ 8X  d#   \        P                  ! RV P                  R7      # V P                  RR w  r\        P
                  ! ^ V\        P                  V P                  R7      p\        P
                  ! ^ V\        P                  V P                  R7      p\        P                  ! W4RR7      w  r4V \        P                  ! V^ 4      ,          pVP                  VP                  ^ ,          R	4      P                  R	4      ^ ,          p\        P                  ! WP                  ^ 4      \        P                  ! RV P                  R7      4      P                  V P                  ^ ,          R	4      P                  R	4      ^ ,          pV \        P                  ! V^ 4      ,          pVP                  VP                  ^ ,          R	4      P                  R	4      ^ ,          p	\        P                  ! WP                  ^ 4      \        P                  ! RV P                  R7      4      P                  V P                  ^ ,          R	4      P                  R	4      ^ ,          p
\        P                  ! WzWi.^4      # )
zÿ
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¶   Nrt   Úij)Úindexingg    „×—A)r^   é   r·   r<   )ÚnumelrI   r€   rv   rS   Úaranger¼   Úmeshgridrƒ   r„   r²   rB   Útensorr±   r    )rV   ÚhÚwÚyÚxÚx_maskÚx_maxÚx_minÚy_maskÚy_maxÚy_mins   &          r)   Úmasks_to_boxesrÞ   F  sÅ  € ð ‡{�{ƒ}˜ÔÜ�{Š{˜6¨%¯,©,Ô7Ð7à�;‰;�r�sÐ�D€AÜ�Š�Q˜¤§¡°u·|±|ÔD€AÜ�Š�Q˜¤§¡°u·|±|ÔD€Aä�>Š>˜!¨Ô.�D€Aà”U—_’_ Q¨Ó*Õ*€FØ�K‰K˜Ÿ™ Q�¨Ó,×0Ñ0°Ó4°QÕ7€Eä�Š�EŸ;™; q›>¬5¯<ª<¸ÀEÇLÁLÔ+QÓR×WÑWÐX]×XcÑXcÐdeÕXfÐhjÓk×oÑoÐprÓsÐtuÕvð 
ð ”U—_’_ Q¨Ó*Õ*€FØ�K‰K˜Ÿ™ Q�¨Ó,×0Ñ0°Ó4°QÕ7€Eä�Š�EŸ;™; q›>¬5¯<ª<¸ÀEÇLÁLÔ+QÓR×WÑWÐX]×XcÑXcÐdeÕXfÐhjÓk×oÑoÐprÓsÐtuÕvð 
ô �;Š;˜ eÐ3°QÓ7Ð7r,   c                óÐ  € \        V \        P                  4      '       dŒ   \        V P                  4      ^8X  dr   V P
                  \        P                  8X  d    V P                  \        P                  4      p V R,          RV R,          ,          ,           RV R,          ,          ,           # \        V ^ ,          RV ^,          ,          ,           RV ^,          ,          ,           4      # )z"
Converts RGB color to unique ID.
é   )r¸   r¸   r^   )r¸   r¸   r:   i   )r¸   r¸   r#   )
Ú
isinstancerI   r•   rœ   rS   ru   rž   Útor�   rq   )Úcolors   &r)   Ú	rgb_to_idrä   k  s—   € ô �%œŸ™×&Ò&¬3¨u¯{©{Ó+;¸qÔ+@Ø�;‰;œ%Ÿ+™+Ô%Ø—H‘HœUŸ[™[Ó)ˆEØ�W�~  e¨G¥nÕ 4Õ4°yÀ5ÈÅ>Õ7QÕQÐQÜˆu�Q�x˜#  a¥�.Õ(¨9°u¸QµxÕ+?Õ?Ó@Ð@r,   c                ó´   € V ^8„  d   QhR\         P                  R\        R\        \        P
                  ,          R\        R\        \        ,          R\        /# )r#   rÀ   rÁ   Ú
masks_pathÚreturn_masksr¨   r”   )rI   r•   Údictr&   ÚpathlibÚPathr'   r   )r$   s   "r)   r*   r*   v  sV   € ÷ .ñ .Ü�<‰<ð.äð.ô ”g—l‘lÕ"ð.ô ð	.ô
 (¬#Õ-ð.ô 
ñ.r,   c                óž  € \        WR7      w  rV\        P                  ! V4      VR,          ,          p/ p\        P                  ! RV9   d
   VR,          MVR,          .\        P
                  V P                  R7      VR&   \        P                  ! WV.\        P
                  V P                  R7      VR&   \        P                  ! WV.\        P
                  V P                  R7      VR&   RV9   EdÇ   \        V4      P                  ^^^ 4      P                  \        P                  V P                  R7      p	\        V	4      p	\        P                  ! VR,           U
u. uF  qªR,          NK  	  up
V P                  R	7      pW›R,          8H  p	V	P                  \        P                  4      p	V'       d   W˜R
&   \        V	4      VR&   \        P                  ! VR,           U
u. uF  qªR,          NK  	  up
\        P
                  V P                  R7      VR&   \        P                  ! VR,           U
u. uF  qªR,          NK  	  up
\        P
                  V P                  R7      VR&   \        P                  ! VR,           U
u. uF  qªR,          NK  	  up
\        P                  V P                  R7      VR&   V# u up
i u up
i u up
i u up
i )z.
Prepare a coco panoptic annotation for DETR.
)Úchannel_dimÚ	file_namerª   r|   rt   ry   rµ   Úsegments_infor¶   rV   r´   r­   r³   r¬   r®   )r¸   NN)r   ré   rê   rI   r�   r»   rv   r   Úpermuterâ   r�   rä   r'   rÞ   r¼   )rÀ   rÁ   ræ   rç   r¨   rÂ   rÃ   Úannotation_pathrÇ   rV   Úsegment_infoÚidss   &&&&&       r)   Ú prepare_coco_panoptic_annotationró   v  sM  € ô !/¨uÔ TÑ€LÜ—l’l :Ó.°¸Õ1DÕD€Oà€JÜ"Ÿ_š_Ø)¨VÔ3ˆ�
Ö	¸À½ÐFÌeÏkÉkÐbg×bnÑbnô€JˆzÑô Ÿš¨,Ð)DÌEÏKÉKÐ`e×`lÑ`lÔm€JˆvÑÜ#Ÿošo¨|Ð.IÔQV×Q\ÑQ\Ðej×eqÑeqÔr€Jˆ{Ñà˜&Õ Ü˜?Ó+×3Ñ3°A°q¸!Ó<×?Ñ?ÄeÇkÁkÐZ_×ZfÑZfÐ?ÓgˆÜ˜%Ó ˆä�oŠoÀfÈ_ÖF]Ó^ÑF]°l¨D×1Ð1ÑF]Ñ^Ðgl×gsÑgsÔtˆØ˜]Õ+Ñ+ˆØ—‘œŸ™Ó$ˆßØ"'�wÑÜ,¨UÓ3ˆ
�7ÑÜ%*§_¢_Ø=CÀOÖ=TÓUÑ=T¨\˜-×(Ð(Ñ=TÑUÜ—+‘+Ø—<‘<ô&
ˆ
�>Ñ"ô
 !&§¢Ø9?ÀÖ9PÓQÑ9P¨˜)×$Ð$Ñ9PÑQÜ—+‘+Ø—<‘<ô!
ˆ
�9Ñô
 #Ÿ_š_Ø6<¸_Ö6MÓNÑ6M l˜&×!Ð!Ñ6MÑNÜ—-‘-Ø—<‘<ô
ˆ
�6Ñð Ðùò- _ùò Vùò
 Rùò
 Os   ÅJ;Ç!K È2KÊK
c                   óÒ  a a€ ] tR tRt o]t]P                  t]	t
]t]P                  tRtRtRtRtRRRR/tRtRR	.tV3R
 lV 3R lltR&V3R lR lltR'V3R lV 3R llltR]P4                  3V3R lV 3R llltV3R lR ltV3R lR ltR(V3R lR llt]R)V3R lV 3R lll4       t V3R lR lt!R*V3R lR llt"R+V3R lR  llt#R,V3R! lR" llt$R-V3R# lR$ llt%R%t&Vt'V ;t(# ).ÚDetrImageProcessori§  TÚshortest_edgeé   Úlongest_edgeé5  FÚpixel_valuesÚ
pixel_maskc                ó4   <€ V ^8„  d   QhRS[ S[,          RR/# )r#   Úkwargsr”   N)r   r!   )r$   r(   s   "€r)   r*   ÚDetrImageProcessor.__annotate__¶  s!   ø€ ÷ #ñ #¡Ñ(@Õ!Að #Àdñ #r,   c                ó¤  <€ VP                  R VP                  RV P                  4      4       VP                  RR4      pVf   RMVP                  RR4      pVe   TMRRRR/p\        W#R	R
7      VR&   VP	                  R4      pVP	                  R4      pVf'   \        V RR4      f   Ve   TMV P                  V n        \        SV `$  ! R/ VB  R# )Údo_padÚpad_and_return_pixel_maskry   NÚmax_sizerù   rö   r÷   rø   F)r  Údefault_to_squarer%   Údo_normalizer-   )
Ú
setdefaultÚpopr   r
   ÚgetÚgetattrr  r%   ÚsuperÚ__init__)Úselfrý   ry   r  r%   r  Ú	__class__s   &,    €r)   r
  ÚDetrImageProcessor.__init__¶  sÌ   ø€ Ø×Ñ˜( F§J¡JÐ/JÈDÏKÉKÓ$XÔYà�z‰z˜& $Ó'ˆØš<‘4¨V¯Z©Z¸
ÀDÓ-IˆØÒ'‰t¨o¸sÀNÐTXÐ-Yˆä& tÐRWÔXˆˆv‰ð "(§¡Ð,DÓ!EÐØ—z‘z .Ó1ˆØ!Ò)¬g°dÐ<TÐVZÓ.[Ò.cØ:FÒ:R©,ÐX\×XiÑXiˆDÔ'ä‰ÒÑ"˜6Ô"r,   c                óÄ   <€ V ^8„  d   QhRS[ P                  RS[RS[R,          RS[R,          RS[S[P                  ,          R,          RS[S[,          R,          RS[/# )	r#   rÀ   rÁ   r$   Nr§   ræ   r¨   r”   )	rI   r•   rè   r   r'   r&   ré   rê   r   )r$   r(   s   "€r)   r*   rþ   Ç  sw   ø€ ÷ ñ á�|‰|ðñ ðñ ! 4Õ'ð	ñ
 $(¨$¥;ðñ ™'Ÿ,™,Õ&¨Õ-ðñ Ñ!1Õ1°DÕ8ðñ 
ñr,   c                óú   € Ve   TMV P                   pV\        P                  8X  d   Vf   RMTp\        WWFR7      pV# V\        P                  8X  d   Vf   RMTp\        VVVVVR7      pV# \        RV R24      h)z4
Prepare an annotation for feeding into DETR model.
F)r¨   T)ræ   rç   r¨   zFormat z is not supported.)r$   r   ÚCOCO_DETECTIONrÊ   ÚCOCO_PANOPTICró   rT   )r  rÀ   rÁ   r$   r§   ræ   r¨   s   &&&&&&&r)   Úprepare_annotationÚ%DetrImageProcessor.prepare_annotationÇ  sž   € ð "Ò-‘°4·;±;ˆàÔ%×4Ñ4Ô4Ø1JÒ1R©ÐXqÐ%Ü6ØÐ8ôˆFð ˆð Ô'×5Ñ5Ô5Ø0IÒ0Q©ÐWpÐ%Ü5ØØØ%Ø6Ø"3ôˆFð ˆô ˜w v hÐ.@ÐAÓBÐBr,   c                óh   <€ V ^8„  d   QhRS[ P                  RS[RS[R,          RS[ P                  /# )r#   rÀ   ry   Úresampleú0PILImageResampling | tvF.InterpolationMode | intr”   )rI   r•   r   r   )r$   r(   s   "€r)   r*   rþ   ç  sA   ø€ ÷ +ñ +á�|‰|ð+ñ ð+ñ ÐMÕNð	+ñ 
�‰ñ+r,   c           	     óH  <€ VP                   '       dB   VP                  '       d0   \        VP                  RR VP                   VP                  4      pMŸVP                  '       dB   VP
                  '       d0   \        VP                  RR VP                  VP
                  4      pMLVP                  '       d,   VP                  '       d   VP                  VP                  3pM\        RV R24      h\        SV `,  ! V3R\        V^ ,          V^,          R7      RV/VB pV# )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 (`torch.Tensor`):
        Image to resize.
    size (`SizeDict`):
        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 | tvF.InterpolationMode | int`, *optional*, defaults to `PILImageResampling.BILINEAR`):
        Resampling filter to use if resizing the image.
Nz\Size must contain 'height' and 'width' keys or 'shortest_edge' and 'longest_edge' keys. Got Ú.ry   ©rŠ   r‹   r  r·   )rö   rø   r   rS   Ú
max_heightÚ	max_widthr   rŠ   r‹   rT   r	  Úresizer   )r  rÀ   ry   r  rý   Únew_sizer  s   &&&&, €r)   r  ÚDetrImageProcessor.resizeç  sù   ø€ ð6 ××Ð $×"3×"3Ð"3ô 2°%·+±+¸b¸cÐ2BÀD×DVÑDVÐX\×XiÑXiÓj‰HØ�_�_ˆ_ §§ Ü:¸5¿;¹;ÀrÀsÐ;KÈTÏ_É_Ð^b×^lÑ^lÓm‰HØ�[�[ˆ[˜TŸZŸZ˜ZØŸ™ T§Z¡ZÐ0‰HäØnÐosÐntÐtuÐvóð ô ‘’Øñ
Ü ¨°­¸8ÀA½;ÔGð
ØRZð
Ø^dñ
ˆð ˆr,   ç      à?c                óˆ   <€ V ^8„  d   QhRS[ S[S[3,          RS[S[S[3,          RS[S[S[3,          RS[RS[R,          /# )r#   Ú
annotationrµ   rn   Ú	thresholdr  r  )rè   r&   r   rr   rq   ro   r   )r$   r(   s   "€r)   r*   rþ     s[   ø€ ÷ 7ñ 7á™™c˜•Nð7ñ ™™c˜•?ð7ñ ™3¡˜8•_ð	7ñ
 ð7ñ ÐMÕNñ7r,   c                óÌ  <€ \        W24       UUu. uF  w  rgWg,          NK  	  uppw  r‰/ p
W:R&   VP                  4        EF  w  r¼VR8X  dC   TpV\        P                  ! W˜W˜.\        P                  VP
                  R7      ,          pWêR&   KO  VR8X  d   TpWùV,          ,          pVV
R&   Kn  VR8X  d�   VR,          pV Uu. uF2  p\        \        V `#  V\        V^ ,          V^,          R7      VR7      NK4  	  pp\        P                  ! V4      P                  \        P                  4      pVR	,          V8„  pVV
R&   EK  VR8X  d   W:R&   EK  WÊV&   EK  	  V
# u uppi u upi )
ak  
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 | tvF.InterpolationMode | int`, defaults to `tvF.InterpolationMode.NEAREST_EXACT`):
        The resampling filter to use when resizing the masks.
ry   r´   rt   r®   rV   r  ©ry   r  )r¸   Nrº   )ÚzipÚitemsrI   r�   r¼   rv   r	  rõ   r  r   r    râ   )r  r!  rµ   rn   r"  r  rÁ   ÚorigÚratio_heightÚratio_widthÚnew_annotationÚkeyÚvaluer´   Úscaled_boxesr®   Úscaled_arearV   rD   r  s   &&&&&&             €r)   Úresize_annotationÚ$DetrImageProcessor.resize_annotation  sw  ø€ ô. HKÈ;ÔGbÔ$cÑGb±|°v V§] ]ÑGbÒ$cÑ!ˆàˆØ!,�vÑà$×*Ñ*×,‰JˆCØ�gŒ~Ø�Ø$¤u§¢Ø °ÐJÔRW×R_ÑR_Ðhm×htÑhtô(õ  �ð +7˜wÓ'Ø˜”Ø�Ø"°LÕ&@ÕA�Ø)4�˜vÓ&Ø˜”Ø˜g��ñ
 !&ó	ñ !&˜ô Ô,¨dÑ:Ø¤8°;¸qµ>ÈÐUVÍÔ#XÐckð ;ö ñ !&ð	 ð ô Ÿš EÓ*×-Ñ-¬e¯m©mÓ<�Ø˜d� iÑ/�Ø*/�˜wÔ'Ø˜”Ø)4˜vÔ&à&+˜sÔ#ñ3 -ð6 ÐùóA %dùò$s   �EÃ8E!c                óB   <€ V ^8„  d   QhRS[ RS[S[S[3,          RS[ /# )r#   r!  Ú
image_sizer”   ©rè   rr   rq   )r$   r(   s   "€r)   r*   rþ   M  s+   ø€ ÷ ñ ©tð ÁÁsÉCÀxÅð ÑUYñ r,   c                óô   € Vw  r4/ pVP                  4        F]  w  rgVR 8X  dN   Tp\        V4      pV\        P                  ! WCWC.\        P                  VP
                  R7      ,          pW…V&   KY  WuV&   K_  	  V# )r´   rt   )r&  r   rI   r�   r¼   rv   )	r  r!  r2  rÂ   rÃ   Únorm_annotationr+  r,  r´   s	   &&&      r)   Únormalize_annotationÚ'DetrImageProcessor.normalize_annotationM  sƒ   € Ø$.Ñ!ˆØˆØ$×*Ñ*Ö,‰JˆCØ�gŒ~Ø�Ü0°Ó7�ØœŸšØ °ÐJÔRW×R_ÑR_Ðhm×htÑhtôõ �ð (- Ó$à', Ó$ñ -ð Ðr,   c                ó^   <€ V ^8„  d   QhRS[ RS[S[S[3,          RS[S[S[3,          RS[ /# )r#   r!  Úinput_image_sizeÚoutput_image_sizer”   r3  )r$   r(   s   "€r)   r*   rþ   \  sC   ø€ ÷ !ñ !áð!ñ  ¡¡S �/ð!ñ !¡¡c �?ð	!ñ 
ñ!r,   c                óz  € / pW6R&   R \        W24       4       w  rxVP                  4        FŒ  w  ršV	R8X  d.   T
p\        P                  ! VV^ R7      p\	        V^4      pW¶R&   K9  V	R8X  d<   V'       d4   T
pV\
        P                  ! W‡W‡.VP                  R7      ,          pWÆR&   K{  V	R8X  d   W6R&   Kˆ  W¦V	&   KŽ  	  V# )z+
Update the annotation for a padded image.
ry   c              3   ó6   "  € T F  w  rW!,          x € K  	  R # 5i©Nr-   )Ú.0ÚoutputÚinputs   &  r)   Ú	<genexpr>ÚIDetrImageProcessor._update_annotation_for_padded_image.<locals>.<genexpr>i  s   é € Ð$rÑIq¹¸ U§^¢^ÓIqùs   ‚rV   ©Úfillr´   r¶   )r%  r&  ÚtvFÚpadr   rI   r�   rv   )r  r!  r9  r:  ÚpaddingÚupdate_bboxesr*  r(  r)  r+  r,  rV   r´   s   &&&&&&       r)   Ú#_update_annotation_for_padded_imageÚ6DetrImageProcessor._update_annotation_for_padded_image\  sÈ   € ð ˆØ!2�vÑÙ$rÌÐM^ÔIqÓ$rÑ!ˆà$×*Ñ*Ö,‰JˆCØ�gŒ~Ø�ÜŸšØØØô�ô
 % U¨AÓ.�Ø*/˜wÓ'Ø˜”§MØ�ØœŸš¨+À[Ð)_Ðhm×htÑhtÔuÕu�Ø*/˜wÓ'Ø˜”Ø):˜vÓ&à&+˜sÓ#ñ# -ð$ Ðr,   c          
      ó†   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          RS[S[S[3,          R,          RS[RS[/# )r#   rÀ   Úpadded_sizer!  NrH  rD  )rI   r•   rr   rq   rè   r&   r   r'   )r$   r(   s   "€r)   r*   rþ     sV   ø€ ÷ -ñ -á�|‰|ð-ñ ™3¡˜8•_ð-ñ ™™c˜•N TÕ)ð	-ñ
 ð-ñ ñ-r,   c                óÔ  € VP                  4       RR pV^ ,          V^ ,          ,
          pV^,          V^,          ,
          pV^ 8  g   V^ 8  d   \        RV RV R24      hWb8w  d5   ^ ^ W‡.p	\        P                  ! WVR7      pVe   V P	                  W6W)V4      p\
        P                  ! V\
        P                  VP                  R7      p
^V
RV^ ,          1RV^,          13&   WV3# )r#   NzzPadding dimensions are negative. Please make sure that the padded size is larger than the original size. Got padded size: z, original size: r  rC  rt   r·   )	ry   rT   rE  rF  rI  rI   r€   r»   rv   )r  rÀ   rL  r!  rH  rD  Úoriginal_sizeÚpadding_bottomÚpadding_rightrG  rû   s   &&&&&&     r)   rF  ÚDetrImageProcessor.pad  s  € ð Ÿ
™
› R SÐ)ˆØ$ Q�¨-¸Õ*:Õ:ˆØ# A�¨°qÕ)9Õ9ˆØ˜AÔ °Ô!2Üð3Ø3>°-Ð?PÐQ^ÐP_Ð_`ðbóð ð Ô'Ø˜!˜]Ð;ˆGÜ—G’G˜E°Ô6ˆEØÒ%Ø!×EÑEØ¨{À]ó�
ô
 —[’[ ´E·K±KÈÏÉÔUˆ
Ø=>ˆ
Ð%�] 1Õ%Ð%Ð'9¨°qÕ)9Ð'9Ð9Ñ:à *Ð,Ð,r,   c                ó¼   <€ V ^8„  d   QhRS[ RS[S[S[,          ,          R,          RS[R,          RS[S[P                  ,          R,          RS[S[,          RS[	/# )r#   Úimagesr«   Nr§   ræ   rý   r”   )
r   r   rC   r'   r&   ré   rê   r   r!   r	   )r$   r(   s   "€r)   r*   rþ   ž  sv   ø€ ÷ hñ háðhñ $¡d©>Õ&:Õ:¸TÕAðhñ $(¨$¥;ð	hñ
 ™'Ÿ,™,Õ&¨Õ-ðhñ Ñ1Õ2ðhñ 
ñhr,   c                ó(   <€ \         SV `  ! WW43/ VB # )a“  
annotations (`AnnotationType` or `list[AnnotationType]`, *optional*):
    Annotations to transform according to the padding that is applied to the images.
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.
)r	  Ú
preprocess)r  rS  r«   r§   ræ   rý   r  s   &&&&&,€r)   rU  ÚDetrImageProcessor.preprocess�  s   ø€ ô" ‰wÒ! &Ð7PÑgÐ`fÑgÐgr,   c          $      ó˜  <€ V ^8„  d   QhRS[ R,          RS[S[ S[,          ,          R,          RS[RS[S[P
                  ,          R,          RS[RS[R	R
RS[RS[RS[RS[RS[S[ S[,          ,          R,          RS[S[ S[,          ,          R,          RS[RS[R,          RS[S[,          R,          RS[S[	,          R,          RS[
/# )r#   rS  ztorch.Tensorr«   Nr§   ræ   Ú	do_resizery   r  z7PILImageResampling | tvF.InterpolationMode | int | NoneÚ
do_rescaleÚrescale_factorr  r%   Ú
image_meanÚ	image_stdr   Úpad_sizer$   Úreturn_tensorsr”   )rC   r   r'   r&   ré   rê   r   ro   r   r   r	   )r$   r(   s   "€r)   r*   rþ   °  s+  ø€ ÷ rñ rá�^Õ$ðrñ $¡d©>Õ&:Õ:¸TÕAðrñ $(ð	rñ
 ™'Ÿ,™,Õ&¨Õ-ðrñ ðrñ ðrð Lðrñ ðrñ ðrñ ðrñ !%ðrñ ™D¡�KÕ'¨$Õ.ðrñ ™4¡�;Õ&¨Õ-ðrñ ðrñ  ˜T•/ð!rñ" Ñ&Õ&¨Õ-ð#rñ$ ™jÕ(¨4Õ/ð%rñ( 
ñ)rr,   c           
     óz  € Ve   \        V\        4      '       d   V.pVe>   \        V4      \        V4      8w  d%   \        R\        V4       R\        V4       R24      h\	        V4      pVe   \        V\        V4       VeT   V\        P                  8X  d?   \        V\        P                  \        34      '       g   \        R\        V4       R24      h/ p. p. p. p\        Ye   TMR.\        V4      ,          4       Fò  w  ppVe&   V P                  VVVVV\        P                  R7      pV'       dP   V P!                  VWgR7      pVe7   V P#                  VVP%                  4       RR VP%                  4       RR R	7      pTpV P'                  VW‰W¬V4      pV'       d/   Ve+   V P)                  V\+        V\        P                  4      4      pVP-                  V4       VP-                  V4       Kô  	  TpVe   TMRpV'       EdT   Ve   VP.                  VP0                  3pM\3        V4      p. p. p\        Ye   TMR.\        V4      ,          4       FÎ  w  ppVVP%                  4       RR 8X  de   VP-                  V4       VP-                  \4        P6                  ! V\4        P8                  VP:                  R
7      4       VP-                  V4       K‚  V P=                  VVVVR7      w  pppVP-                  V4       VP-                  V4       VP-                  V4       KÐ  	  TpVe   TMRpVP?                  R\4        P@                  ! V^ R7      /4       VP?                  R\4        P@                  ! V^ R7      /4       \C        VVR7      pVe!   V Uu. uF  p\C        VVR7      NK  	  upVR&   V# u upi )zO
Preprocess an image or a batch of images so that it can be used by the model.
Nz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§   ræ   r¨   r$  )rµ   rn   rt   )r!  rH  rû   ©Údimrú   )Útensor_typerX   r·   )"rá   rè   rœ   rT   r   r   ÚSUPPORTED_ANNOTATION_FORMATSr  ré   rê   r&   Útyper%  r  r   ÚFIRSTr  r/  ry   Úrescale_and_normalizer6  r   rK   rŠ   r‹   r   rI   Úonesr»   rv   rF  Úupdater    r	   )r  rS  r«   r§   ræ   rX  ry   r  rY  rZ  r  r%   r[  r\  r   r]  r$   r^  rý   ÚdataÚprocessed_imagesÚprocessed_annotationsÚpixel_masksrÀ   r!  Úresized_imagerL  Úpadded_imagesÚpadded_annotationsrû   Úencoded_inputss   &&&&&&&&&&&&&&&&&&,            r)   Ú_preprocessÚDetrImageProcessor._preprocess°  s¯  € ð0 Ò"¤z°+¼t×'DÒ'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óð ð
 ˆàÐØ "ÐØˆÜ!$ VÒ<S©[ÐZ^ÐY_ÔbeÐflÓbmÕYmÖ!nÑˆE�:àÒ&Ø!×4Ñ4ØØØØ.GØ)Ü&6×&<Ñ&<ð 5ó �
÷ Ø $§¡¨E¸ Ó P�ØÒ*Ø!%×!7Ñ!7Ø"Ø"'§*¡*£,¨r¨sÐ"3Ø$1×$6Ñ$6Ó$8¸¸Ð$=ð "8ó "�Jð
 &�à×.Ñ.¨u°jÐR^ÐluÓvˆEß%¨+Ò*AØ!×6Ñ6°zÄ>ÐRWÔYi×YoÑYoÓCpÓq�
à×#Ñ# EÔ*Ø!×(Ñ(¨Ö4ñ7 "oð8 "ˆØ/:Ò/FÑ+ÈDˆçˆ6àÒ#Ø'Ÿ™°·±Ð?‘ä2°6Ó:�àˆMØ!#ÐÜ%(¨Ò@W±Ð^bÐ]cÔfiÐjpÓfqÕ]qÖ%rÑ!��zà %§*¡*£,¨r¨sÐ"3Ô3Ø!×(Ñ(¨Ô/Ø×&Ñ&¤u§z¢z°+ÄUÇ[Á[ÐY^×YeÑYeÔ'fÔgØ&×-Ñ-¨jÔ9ÙØ04·±Ø˜;°:ÐMcð 19ó 1Ñ-��z :ð ×$Ñ$ UÔ+Ø"×)Ñ)¨*Ô5Ø×"Ñ" :Ö.ñ &sð #ˆFØ0;Ò0GÑ,ÈTˆKØ�K‰K˜¤u§{¢{°;ÀAÔ'FÐGÔHà�‰�^¤U§[¢[°¸QÔ%?Ð@ÔAÜ% d¸ÔGˆØÒ"áWbó(ÙWbÈ”˜Z°^×DÑWbñ(ˆN˜8Ñ$ð Ðùò(s   ÎN8c                óT   <€ V ^8„  d   QhRS[ RS[S[S[,          ,          R,          /# )r#   r"  Útarget_sizesN)ro   r   rC   rr   )r$   r(   s   "€r)   r*   rþ   %  s,   ø€ ÷ 3ñ 3Ù"'ð3Ù=GÉ$ÉuÍ+Õ=UÐX\Õ=\ñ3r,   c           	     ó\  € VP                   VP                  rTVe%   \        V4      \        V4      8w  d   \        R4      h\        P
                  P                  VR4      pVRRR13,          P                  R4      w  rx\        V4      p	VeÅ   \        V\        4      '       dZ   \        P                  ! V U
u. uF  qª^ ,          NK  	  up
4      p\        P                  ! V U
u. uF  qª^,          NK  	  up
4      pMVP                  ^4      w  r¼\        P                  ! WËWË.^R7      P                  V	P                   4      pW�R	,          ,          p	. p\#        WxV	4       F?  w  pppWÿV8„  ,          pVWò8„  ,          pVWò8„  ,          pVP%                  RVRVRV/4       KA  	  V# u up
i u up
i )
a  
Converts the raw output of [`DetrForObjectDetection`] into final bounding boxes in (top_left_x, top_left_y,
bottom_right_x, bottom_right_y) format. Only supports PyTorch.

Args:
    outputs ([`DetrObjectDetectionOutput`]):
        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.
NúTMake sure that you pass in as many target sizes as the batch dimension of the logits.r`  rW   rX   r´   r<   )r¸   Nr¸   )ÚlogitsÚ
pred_boxesrœ   rT   r   r   Úsoftmaxr²   r   rá   rC   rI   r•   Úunbindr    râ   rv   r%  rK   )r  Úoutputsr"  rt  Ú
out_logitsÚout_bboxÚprobrW   rX   r´   ÚiÚimg_hÚimg_wÚ	scale_fctÚresultsÚsÚlÚbr   ÚlabelÚboxs   &&&&                 r)   Úpost_process_object_detectionÚ0DetrImageProcessor.post_process_object_detection%  s�  € ð&  'Ÿ~™~¨w×/AÑ/A�HàÒ#Ü�:‹¤# lÓ"3Ô3Ü Øjóð ô �}‰}×$Ñ$ Z°Ó4ˆØ˜c 3 B 3˜h�×+Ñ+¨BÓ/‰ˆô )¨Ó2ˆð Ò#Ü˜,¬×-Ò-ÜŸš±LÓ%A±L¨q¨§d d±LÑ%AÓB�ÜŸš±LÓ%A±L¨q¨§d d±LÑ%AÓB‘à+×2Ñ2°1Ó5‘�äŸš U°5Ð$@ÀaÔH×KÑKÈEÏLÉLÓYˆIØ jÕ1Õ1ˆEàˆÜ˜6¨5Ö1‰GˆAˆq�!Ø˜)‘mÕ$ˆEØ�a‘mÕ$ˆEØ�A‘MÕ"ˆCØ�N‰N˜H e¨X°u¸gÀsÐKÖLñ	 2ð ˆùò &BùÚ%As   Â7F$Ã#F)c                ó^   <€ V ^8„  d   QhRS[ S[S[S[3,          ,          R,          RS[RR/# )r#   rt  NÚreturn_segmentation_scoresr”   zBlist[torch.Tensor] | list[SemanticSegmentationPostProcessorOutput])rC   rr   rq   r'   )r$   r(   s   "€r)   r*   rþ   Z  sC   ø€ ÷ E%ñ E%ñ ™5¡¡c �?Õ+¨dÕ2ðE%ñ %)ð	E%ð
 
NñE%r,   c           
     ó,  € VP                   pVP                  pVP                  RR7      RRR13,          pVP                  4       p\        P
                  ! RWg4      pVP                  ^ ,          p	Ve¯   V	\        V4      8w  d   \        R4      h. p
\        V	4       F�  p\        P                  P                  W‹,          P                  ^ R7      W+,          RRR7      pV^ ,          P                  ^ R7      pV
P                  \!        R	VR
V^ ,          /R7      4       Kƒ  	  MFVP                  ^R7      p\        V	4       Uu. uF  p\!        R	WÞ,          R
WŽ,          /R7      NK!  	  p
pV'       g   V
 Uu. uF  qÿP"                  NK  	  p
pV
# u upi u upi )ap  
Converts the output of [`DetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.

Args:
    outputs ([`DetrForSegmentation`]):
        Raw outputs of the model.
    target_sizes (`list[tuple[int, int]]`, *optional*):
        A 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.
    return_segmentation_scores (`bool`, *optional*, defaults to `False`):
        Whether to return segmentation scores alongside the segmentation map. When `True`, each element of
        the returned list is a [`SemanticSegmentationPostProcessorOutput`] with fields `segmentation`
        (class IDs, shape `(height, width)`) and `segmentation_scores` (shape `(num_classes, height, width)`).

Returns:
    `list[torch.Tensor]` or `list[SemanticSegmentationPostProcessorOutput]`: When
    `return_segmentation_scores=False` (default), a list of length `batch_size` where each item is a
    segmentation map of shape `(height, width)` with class IDs. When `return_segmentation_scores=True`,
    a list of [`SemanticSegmentationPostProcessorOutput`] with fields `segmentation` (class IDs, shape
    `(height, width)`) and `segmentation_scores` (shape `(num_classes, height, width)`). In both cases,
    `(height, width)` corresponds to the target size (if `target_sizes` is specified).
r`  .Nzbqc, bqhw -> bchwrv  rw   Frx   rL   Úsegmentation_scores)ri  r<   )rw  Ú
pred_masksry  ÚsigmoidrI   ÚeinsumrS   rœ   rT   r†   r   r   r‚   rƒ   r…   rK   r   rL   )r  r{  rt  rŒ  Úclass_queries_logitsÚmasks_queries_logitsÚmasks_classesÚmasks_probsrL   Ú
batch_sizeÚsemantic_segmentationrO   Úresized_logitsÚsemantic_mapr  r`   s   &&&&            r)   Ú"post_process_semantic_segmentationÚ5DetrImageProcessor.post_process_semantic_segmentationZ  s®  € ð8  'Ÿ~™~ÐØ&×1Ñ1Ðð -×4Ñ4¸Ð4Ó<¸SÀ#À2À#¸XÕFˆØ*×2Ñ2Ó4ˆô —|’|Ð$7¸ÓTˆØ)×/Ñ/°Õ2ˆ
ð Ò#ØœS Ó.Ô.Ü Øjóð ð %'Ð!Ü˜ZÖ(�Ü!#§¡×!:Ñ!:Ø Õ%×/Ñ/°AÐ/Ó6¸\Õ=NÐU_Ðotð ";ó "�ð  .¨aÕ0×7Ñ7¸AÐ7Ó>�Ø%×,Ñ,Ü;Ø,¨lÐ<QÐSaÐbcÕSdÐeôöò )ð (×.Ñ.°1Ð.Ó5ˆLô
 ˜zÔ*ó	%ñ +�Aô 8Ø(¨,­/Ð;PÐR^ÕRaÐb÷ñ +ð	 "ð %÷ *ÙCXÓ$YÑCX¸4×%6Ô%6ÑCXÐ!Ð$Yà$Ð$ùò%ùò %Zs   Å%FÅ4Fc                ó�   <€ V ^8„  d   QhRS[ RS[ RS[ RS[S[S[S[3,          ,          R,          RS[R,          RS[S[,          /# )r#   r"  rd   re   rt  NÚreturn_coco_annotationr”   )ro   rC   rr   rq   r'   rè   )r$   r(   s   "€r)   r*   rþ   ¡  sk   ø€ ÷ Qñ Qñ ðQñ ð	Qñ
 &+ðQñ ™5¡¡c �?Õ+¨dÕ2ðQñ !% t¥ðQñ 
‰d�ñQr,   c                óú  € VP                   pVP                  pVP                  ^ ,          p	VP                  R,          ^,
          p
VP                  4       p\        P
                  P                  VRR7      P                  R4      w  rÍ. p\        V	4       Fâ  p\        W¿,          WÏ,          Wß,          W*4      w  pppVP                  ^ ,          ^ 8:  dY   Ve	   W_,          MVP                  R,          w  pp\        P                  ! VV34      ^,
          pVP                  RVR. /4       K—  Ve	   W_,          MRp\        VVVVV. VR7      w  ppV'       d   \        V4      pVP                  RVRV/4       Kä  	  V# )a  
Converts the output of [`DetrForSegmentation`] into instance segmentation predictions. Only supports PyTorch.

Args:
    outputs ([`DetrForSegmentation`]):
        Raw outputs of the model.
    threshold (`float`, *optional*, defaults to 0.5):
        The probability score threshold to keep predicted instance masks.
    mask_threshold (`float`, *optional*, defaults to 0.5):
        Threshold to use when turning the predicted masks into binary values.
    overlap_mask_area_threshold (`float`, *optional*, defaults to 0.8):
        The overlap mask area threshold to merge or discard small disconnected parts within each binary
        instance mask.
    target_sizes (`list[Tuple]`, *optional*):
        List of length (batch_size), where each list item (`tuple[int, int]]`) corresponds to the requested
        final size (height, width) of each prediction. If unset, predictions will not be resized.
    return_coco_annotation (`bool`, *optional*):
        Defaults to `False`. If set to `True`, segmentation maps are returned in COCO run-length encoding (RLE)
        format.
Returns:
    `list[Dict]`: A list of dictionaries, one per image, each dictionary containing two keys:
    - **segmentation** -- A tensor of shape `(height, width)` where each pixel represents a `segment_id` or
      `list[List]` run-length encoding (RLE) of the segmentation map if return_coco_annotation is set to
      `True`. Set to `None` if no mask if found above `threshold`.
    - **segments_info** -- A dictionary that contains additional information on each segment.
        - **id** -- An integer representing the `segment_id`.
        - **label_id** -- An integer representing the label / semantic class id corresponding to `segment_id`.
        - **score** -- Prediction score of segment with `segment_id`.
r`  Nr9   rL   rî   ©rb   rˆ   r‰   rd   re   rm   rn   r<   )rw  r�  rS   r�  r   r   ry  r²   r†   r\   rI   r€   rK   r’   rQ   )r  r{  r"  rd   re   rt  r�  r’  r“  r–  rZ   rb   rˆ   r‰   rƒ  r  Úmask_probs_itemÚpred_scores_itemÚpred_labels_itemrŠ   r‹   rL   rn   rŒ   s   &&&&&&&                 r)   Ú"post_process_instance_segmentationÚ5DetrImageProcessor.post_process_instance_segmentation¡  su  € ðL  'Ÿ~™~ÐØ&×1Ñ1Ðà)×/Ñ/°Õ2ˆ
Ø)×/Ñ/°Õ3°aÕ7ˆ
à)×1Ñ1Ó3ˆ
ô $&§=¡=×#8Ñ#8Ð9MÐSUÐ#8Ó#V×#ZÑ#ZÐ[]Ó#^Ñ ˆð 02ˆä�zÖ"ˆAÜB[Ø•˜{�~¨{­~¸yóCÑ?ˆOÐ-Ð/?ð
 ×$Ñ$ QÕ'¨1Ô,Ø3?Ò3K ¦ÐQ`×QfÑQfÐgiÕQj‘�˜Ü$Ÿ{š{¨F°E¨?Ó;¸aÕ?�Ø—‘ °¸oÈrÐRÔSÙð .:Ò-E˜,ž/È4ˆKÜ%5Ø*Ø,Ø,Ø-Ø,GØ"$Ø'ô&Ñ"ˆL˜(÷ &Ü:¸<ÓH�à�N‰N˜N¨L¸/È8ÐTÖUñ9 #ð: ˆr,   c                ó    <€ V ^8„  d   QhRS[ RS[ RS[ RS[S[,          R,          RS[S[S[S[3,          ,          R,          RS[S[,          /# )r#   r"  rd   re   rm   Nrt  r”   )ro   rp   rq   rC   rr   rè   )r$   r(   s   "€r)   r*   rþ   ô  so   ø€ ÷ Vñ Vñ ðVñ ð	Vñ
 &+ðVñ ™s�8 d�?ðVñ ™5¡¡c �?Õ+¨dÕ2ðVñ 
‰d�ñVr,   c                ó  € Vf    \         P                  R4       \        4       pVP                  pVP                  pVP
                  ^ ,          p	VP
                  R,          ^,
          p
VP                  4       p\        P                  P                  VRR7      P                  R4      w  rÍ. p\        V	4       FÏ  p\        W¿,          WÏ,          Wß,          W*4      w  pppVP
                  ^ ,          ^ 8:  dY   Ve	   Wo,          MVP
                  R,          w  pp\        P                  ! VV34      ^,
          pVP                  RVR. /4       K—  Ve	   Wo,          MRp\!        VVVVVVVR7      w  ppVP                  RVRV/4       KÑ  	  V# )	am  
Converts the output of [`DetrForSegmentation`] into image panoptic segmentation predictions. Only supports
PyTorch.

Args:
    outputs ([`DetrForSegmentation`]):
        The outputs from [`DetrForSegmentation`].
    threshold (`float`, *optional*, defaults to 0.5):
        The probability score threshold to keep predicted instance masks.
    mask_threshold (`float`, *optional*, defaults to 0.5):
        Threshold to use when turning the predicted masks into binary values.
    overlap_mask_area_threshold (`float`, *optional*, defaults to 0.8):
        The overlap mask area threshold to merge or discard small disconnected parts within each binary
        instance mask.
    label_ids_to_fuse (`Set[int]`, *optional*):
        The labels in this state will have all their instances be fused together. For instance we could say
        there can only be one sky in an image, but several persons, so the label ID for sky would be in that
        set, but not the one for person.
    target_sizes (`list[Tuple]`, *optional*):
        List of length (batch_size), where each list item (`tuple[int, int]]`) corresponds to the requested
        final size (height, width) of each prediction in batch. If unset, predictions will not be resized.
Returns:
    `list[Dict]`: A list of dictionaries, one per image, each dictionary containing two keys:
    - **segmentation** -- a tensor of shape `(height, width)` where each pixel represents a `segment_id` or
      `None` if no mask is found above `threshold`. If `target_sizes` is specified, segmentation is resized to
      the corresponding `target_sizes` entry.
    - **segments_info** -- A dictionary that contains additional information on each segment.
        - **id** -- an integer representing the `segment_id`.
        - **label_id** -- An integer representing the label / semantic class id corresponding to `segment_id`.
        - **was_fused** -- a boolean, `True` if `label_id` was in `label_ids_to_fuse`, `False` otherwise.
          Multiple instances of the same class / label were fused and assigned a single `segment_id`.
        - **score** -- Prediction score of segment with `segment_id`.
Nz5`label_ids_to_fuse` unset. No instance will be fused.r`  r9   rL   rî   rŸ  r<   )ÚloggerÚwarning_oncerp   rw  r�  rS   r�  r   r   ry  r²   r†   r\   rI   r€   rK   r’   )r  r{  r"  rd   re   rm   rt  r’  r“  r–  rZ   rb   rˆ   r‰   rƒ  r  r   r¡  r¢  rŠ   r‹   rL   rn   rŒ   s   &&&&&&&                 r)   Ú"post_process_panoptic_segmentationÚ5DetrImageProcessor.post_process_panoptic_segmentationô  s…  € ðV Ò$Ü×ÑÐ WÔXÜ #£Ðà&Ÿ~™~ÐØ&×1Ñ1Ðà)×/Ñ/°Õ2ˆ
Ø)×/Ñ/°Õ3°aÕ7ˆ
à)×1Ñ1Ó3ˆ
ô $&§=¡=×#8Ñ#8Ð9MÐSUÐ#8Ó#V×#ZÑ#ZÐ[]Ó#^Ñ ˆð 02ˆä�zÖ"ˆAÜB[Ø•˜{�~¨{­~¸yóCÑ?ˆOÐ-Ð/?ð
 ×$Ñ$ QÕ'¨1Ô,Ø3?Ò3K ¦ÐQ`×QfÑQfÐgiÕQj‘�˜Ü$Ÿ{š{¨F°E¨?Ó;¸aÕ?�Ø—‘ °¸oÈrÐRÔSÙð .:Ò-E˜,ž/È4ˆKÜ%5Ø*Ø,Ø,Ø-Ø,GØ"3Ø'ô&Ñ"ˆL˜(ð �N‰N˜N¨L¸/È8ÐTÖUñ1 #ð2 ˆr,   )r%   )NNNNr=  )NTr^   )NNN)r  N)NF)r  r  çš™™™™™é?NF)r  r  r«  NN))r.   r/   r0   r1   r!   Úvalid_kwargsr   ÚBILINEARr  r   r[  r   r\  r   r  r$   rX  rY  r  r   ry   r  Úmodel_input_namesr
  r  r  ÚNEARESTr/  r6  rI  rF  r   rU  rq  r‰  rš  r£  r©  r4   r5   Ú__classcell__)r  r(   s   @@r)   rõ   rõ   §  s  ù‡ € à+€LØ!×*Ñ*€HØ&€JØ$€IØ×,Ñ,€FØ€IØ€JØ€LØ€FØ˜S .°$Ð7€DØÐØ'¨Ð6Ð÷#ó #÷"ò ÷@+õ +ðd ØQc×QkÑQk÷7õ 7÷rð ÷!ð !÷F-ò -ð< ÷hô hó ðh÷$rð r÷j3ò 3÷jE%ò E%÷NQò Q÷fV÷ Vò Vr,   rõ   )r  r«  )r  r«  NN)FN)TN)Ar2   ré   Útypingr   r   r>   r@   rI   r   Útorchvision.ior   Útorchvision.transforms.v2r   rE  Úimage_processing_backendsr   Úimage_processing_outputsr   Úimage_processing_utilsr	   r
   Úimage_transformsr   r   r   r   Úimage_utilsr   r   r   r   r   r   r   r   r   r   r   r   Úprocessing_utilsr   r   r=   r   r   r   Ú
get_loggerr.   r§  r  r  rc  r!   rG   rQ   r\   rk   r’   r¥   rÊ   rÞ   rä   ró   rõ   Ú__all__r-   r,   r)   Ú<module>r¼     sï   ðñ &ã ß  ã Û Ý Ý %Ý 7å ;Ý Oß A÷ó ÷÷ ÷ ó ÷ 5÷ñ ð 
×	Ò	˜HÓ	%€à 0× ?Ñ ?ÐAQ×A_ÑA_Ð`Ð ô!˜|°5õ !òò0 ò*<ô8÷$9"õz÷F=õ@8òJA÷.ðb ôb
Ð+ó b
ó ðb
ðJ  Ð
 ‚r,   