ó
    qyüié  ã                   óÎ   • S r SSKJr  SSKJr  SSKrSSKJr  SSK	J
r
  SSKJr  SS	KJrJr  SS
KJrJrJrJr  SSKJrJr  SSKJrJr   " S S\SS9r\ " S S\
5      5       rS/rg)z'Image processor class for EfficientNet.é    )Ú	lru_cache)ÚOptionalN)Ú
functionalé   )ÚTorchvisionBackend)ÚBatchFeature)Úgroup_images_by_shapeÚreorder_images)ÚIMAGENET_STANDARD_MEANÚIMAGENET_STANDARD_STDÚPILImageResamplingÚSizeDict)ÚImagesKwargsÚUnpack)Ú
TensorTypeÚauto_docstringc                   ó.   • \ rS rSr% Sr\\S'   \\S'   Srg)Ú EfficientNetImageProcessorKwargsé#   aW  
rescale_offset (`bool`, *optional*, defaults to `self.rescale_offset`):
    Whether to rescale the image between [-max_range/2, scale_range/2] instead of [0, scale_range].
include_top (`bool`, *optional*, defaults to `self.include_top`):
    Normalize the image again with the standard deviation only for image classification if set to True.
Úrescale_offsetÚinclude_top© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚboolÚ__annotations__Ú__static_attributes__r   ó    Ú{/home/mande/repo/quber/.venv/lib/python3.13/site-packages/transformers/models/efficientnet/image_processing_efficientnet.pyr   r   #   s   ‡ ñð ÓØÖr!   r   F)Útotalc            %       ó(  ^ • \ rS rSrSr\r\R                  r	\
r\rSSS.rSSS.rSrSrSrSrSrSrSrS	\\   4U 4S
 jjr S,SSS\S\SS4S jjr\" SS9       S-S\S-  S\\\   -  S-  S\\\   -  S-  S\S-  S\S-  S\S   S\S-  S\4S jj5       r  S,SSS\S\S\S\\\   -  S\\\   -  S\SS4S jjr!  S.S\S   S\S \"S!S"S#\S$\"S\S\S\S\\\   -  S-  S\\\   -  S-  S%\S-  S&\"S-  S'\S-  S(\#\$-  S-  S\S)\S\%4$S* jjr&S+r'U =r($ )/ÚEfficientNetImageProcessoré/   zITorchvision backend for EfficientNet with rescale offset and include_top.iZ  )ÚheightÚwidthi!  TFgp?Úkwargsc                 ó&   >• [         TU ]  " S0 UD6  g )Nr   )ÚsuperÚ__init__)Úselfr)   Ú	__class__s     €r"   r,   Ú#EfficientNetImageProcessor.__init__B   s   ø€ Ü‰ÒÑ"˜6Ó"r!   Úimageztorch.TensorÚscaleÚoffsetÚreturnc                 ó&   • X-  nU(       a  US-  nU$ )z@Rescale by scale; if offset=True then image = image * scale - 1.é   r   )r-   r0   r1   r2   r)   Úrescaleds         r"   ÚrescaleÚ"EfficientNetImageProcessor.rescaleE   s   € ð ‘=ˆÞØ˜‰MˆHØˆr!   é
   )ÚmaxsizeNÚdo_normalizeÚ
image_meanÚ	image_stdÚ
do_rescaleÚrescale_factorÚdeviceztorch.devicer   c                 ó    • U(       aD  U(       a=  U(       d6  [         R                  " X&S9SU-  -  n[         R                  " X6S9SU-  -  nSnX#U4$ )N)r@   g      ð?F)ÚtorchÚtensor)r-   r;   r<   r=   r>   r?   r@   r   s           r"   Ú!_fuse_mean_std_and_rescale_factorÚ<EfficientNetImageProcessor._fuse_mean_std_and_rescale_factorR   sK   € ö ž,®~ÜŸš jÑ@ÀCÈ.ÑDXÑYˆJÜŸš YÑ>À#ÈÑBVÑWˆIØˆJØ jÐ0Ð0r!   Úimagesc           
      óà   • U R                  UUUUUUR                  US9u  pVnU(       a  U R                  XUS9nU(       a-  U R                  UR	                  [
        R                  S9XV5      nU$ )N)r;   r<   r=   r>   r?   r@   r   )r2   )Údtype)rD   r@   r7   Ú	normalizeÚtorB   Úfloat32)r-   rF   r>   r?   r;   r<   r=   r   s           r"   Ú"rescale_and_normalize_efficientnetÚ=EfficientNetImageProcessor.rescale_and_normalize_efficientnetc   sv   € ð -1×,RÑ,RØ%Ø!ØØ!Ø)Ø—=‘=Ø)ð -Sð -
Ñ)ˆ
˜zö Ø—\‘\ &À�\ÐPˆFÞØ—^‘^ F§I¡I´E·M±M IÐ$BÀJÓZˆFØˆr!   Ú	do_resizeÚsizeÚresamplez7PILImageResampling | tvF.InterpolationMode | int | NoneÚdo_center_cropÚ	crop_sizeÚdo_padÚpad_sizeÚdisable_groupingÚreturn_tensorsr   c           
      óÂ  • [        XS9u  nn0 nUR                  5        H$  u  nnU(       a  U R                  UX45      nUUU'   M&     [        UU5      n[        UUS9u  nn0 nUR                  5        HS  u  nnU(       a  U R	                  UU5      nU R                  UXxXšUU5      nU(       a  U R                  USU5      nUUU'   MU     [        UU5      n[        SU0US9$ )z&Custom preprocessing for EfficientNet.)rU   r   Úpixel_values)ÚdataÚtensor_type)r	   ÚitemsÚresizer
   Úcenter_croprL   rI   r   )r-   rF   rN   rO   rP   rQ   rR   r>   r?   r;   r<   r=   rS   rT   rU   rV   r   r   r)   Úgrouped_imagesÚgrouped_images_indexÚresized_images_groupedÚshapeÚstacked_imagesÚresized_imagesÚprocessed_images_groupedÚprocessed_imagess                              r"   Ú_preprocessÚ&EfficientNetImageProcessor._preprocess}   s  € ô, 0EÀVÑ/oÑ,ˆÐ,Ø!#ÐØ%3×%9Ñ%9Ö%;Ñ!ˆE�>ÞØ!%§¡¨^¸TÓ!L�Ø,:Ð" 5Ó)ñ &<ô (Ð(>Ð@TÓUˆä/DÀ^ÐfvÑ/wÑ,ˆÐ,Ø#%Ð Ø%3×%9Ñ%9Ö%;Ñ!ˆE�>ÞØ!%×!1Ñ!1°.À)Ó!L�Ø!×DÑDØ 
¸LÐV_ÐaoóˆNö Ø!%§¡°ÀÀ9Ó!M�Ø.<Ð$ UÓ+ñ &<ô *Ð*BÐDXÓYÐÜ .Ð2BÐ!CÐQ_Ñ`Ð`r!   r   )F)NNNNNNF)FT))r   r   r   r   r   r   Úvalid_kwargsr   ÚBICUBICrP   r   r<   r   r=   rO   rR   rN   rQ   r>   r?   r   r;   r   r   r,   Úfloatr   r7   r   Úlistr   ÚtuplerD   rL   r   Ústrr   r   rf   r    Ú__classcell__)r.   s   @r"   r%   r%   /   sÃ  ø† áSà3€Là!×)Ñ)€HØ'€JØ%€IØ CÑ(€DØ¨Ñ-€IØ€IØ€NØ€JØ€NØ€NØ€LØ€Kð# Ð(HÑ!I÷ #ð ñ	àðð ðð ð	ð 
õñ �rÑð %)Ø15Ø04Ø"&Ø'+Ø+/Ø&+ñ1à˜T‘kð1ð ˜D ™KÑ'¨$Ñ.ð1ð ˜4 ™;Ñ&¨Ñ-ð	1ð
 ˜4‘Kð1ð  ™ð1ð ˜Ñ(ð1ð ˜t™ð1ð 
ô1ó ð1ð0  %ñàðð ðð ð	ð
 ðð ˜D ™KÑ'ðð ˜4 ™;Ñ&ðð ðð 
õðV  %Ø ñ%*aà�^Ñ$ð*að ð*að ð	*að
 Lð*að ð*að ð*að ð*að ð*að ð*að ˜D ™KÑ'¨$Ñ.ð*að ˜4 ™;Ñ&¨Ñ-ð*að �t‘ð*að ˜T‘/ð*að  ™+ð*að  ˜jÑ(¨4Ñ/ð!*að" ð#*að$ ð%*að( 
÷)*aó *ar!   r%   )r   Ú	functoolsr   Útypingr   rB   Útorchvision.transforms.v2r   ÚtvFÚimage_processing_backendsr   Úimage_processing_utilsr   Úimage_transformsr	   r
   Úimage_utilsr   r   r   r   Úprocessing_utilsr   r   Úutilsr   r   r   r%   Ú__all__r   r!   r"   Ú<module>rz      sl   ðñ .å Ý ã Ý 7å ;Ý 2ß E÷ó ÷ 5ß /ô	 |¸5ò 	ð ôwaÐ!3ó waó ðwaðt (Ð
(�r!   