ó
    Äö‘j˜N  ã                   ó@  • S SK r S SKrS SKrS SKrS SKJrJrJrJr  S SK	r	S SK
Jr  S SKJs  Jr   S SKJr  SrS SKJr  S SKr/ SQr " S S	5      r " S
 S5      r " S S\R0                  5      r " S S5      r\" \S5      (       a‡  \R8                  R:                  S\R8                  R<                  S\R8                  R>                  S\R8                  R@                  S\R8                  RB                  S\R8                  RD                  S0r#OJ\R:                  S\R<                  S\R>                  S\R@                  S\RB                  S\RD                  S0r#\#RI                  5        V Vs0 s H  u  pX_M	     snn r%\(       ap  \R:                  S\R<                  S\R>                  S\R@                  S\RB                  S\RD                  S0r&\&RI                  5        V Vs0 s H  u  pX_M	     snn r'O0 r(0 r&S r)S r*S r+\*" S5      \*" S5      4r,S2S jr- " S S5      r.  S3S\	R^                  S\\0\\0   4   S\\0\\0\0\04   4   S \1S!\	R^                  4
S" jjr2 " S# S$\	Rf                  Rh                  5      r5  S3S\	R^                  S%\0S&\0S'\0S(\0S\\0\\0\0\04   4   S \1S!\	R^                  4S) jjr6 " S* S+\	Rf                  Rh                  5      r7 " S, S-5      r8 " S. S/5      r9 " S0 S1\	Rf                  Rh                  5      r:g! \ a    Sr GN×f = fs  snn f s  snn f )4é    N)ÚListÚSequenceÚTupleÚUnion)ÚInterpolationModeTF)ÚImage)ÚToNumpyÚToTensorÚstr_to_interp_modeÚstr_to_pil_interpÚinterp_mode_to_strÚ!RandomResizedCropAndInterpolationÚCenterCropOrPadÚcenter_crop_or_padÚcrop_or_padÚRandomCropOrPadÚ	RandomPadÚResizeKeepRatioÚ
TrimBorderÚMaybeToTensorÚMaybePILToTensorc                   ó   • \ rS rSrS rSrg)r	   é   c                 óÄ   • [         R                  " U[         R                  S9nUR                  S:  a  [         R                  " USS9n[         R
                  " US5      nU$ )N©Údtypeé   éÿÿÿÿ)Úaxisé   )ÚnpÚarrayÚuint8ÚndimÚexpand_dimsÚrollaxis)ÚselfÚpil_imgÚnp_imgs      Ú¢C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\timm/data/transforms.pyÚ__call__ÚToNumpy.__call__   sF   € Ü—’˜'¬¯©Ñ2ˆØ�;‰;˜‹?Ü—^’^ F°Ñ4ˆFÜ—’˜V QÓ'ˆØˆó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r+   Ú__static_attributes__r.   r-   r*   r	   r	      s   † õr-   r	   c                   ó>   • \ rS rSrSr\R                  4S jrS rSr	g)r
   é#   z$ToTensor with no rescaling of valuesc                 ó   • Xl         g ©Nr   )r'   r   s     r*   Ú__init__ÚToTensor.__init__%   s   € Ø�
r-   c                 ó\   • [         R                  " U5      R                  U R                  S9$ )Nr   )ÚFÚpil_to_tensorÚtor   )r'   r(   s     r*   r+   ÚToTensor.__call__(   s#   € Ü�Š˜wÓ'×*Ñ*°·±Ð*Ð<Ð<r-   r   N)
r/   r0   r1   r2   Ú__doc__ÚtorchÚfloat32r8   r+   r3   r.   r-   r*   r
   r
   #   s   † Ù/Ø"Ÿ]™]ô õ=r-   r
   c                   ó`   ^ • \ rS rSrSrSU 4S jjrS\R                  4S jrS\	4S jr
SrU =r$ )	r   é,   zFConvert a PIL Image or ndarray to tensor if it's not already one.
    Úreturnc                 ó"   >• [         TU ]  5         g r7   ©Úsuperr8   ©r'   Ú	__class__s    €r*   r8   ÚMaybeToTensor.__init__0   ó   ø€ Ü‰ÑÕr-   c                 óp   • [        U[        R                  5      (       a  U$ [        R                  " U5      $ )zu
Args:
    pic (PIL Image or numpy.ndarray): Image to be converted to tensor.

Returns:
    Tensor: Converted image.
)Ú
isinstancer@   ÚTensorr;   Ú	to_tensor©r'   Úpics     r*   r+   ÚMaybeToTensor.__call__3   s)   € ô �cœ5Ÿ<™<×(Ñ(ØˆJÜ�{Š{˜3ÓÐr-   c                 ó4   • U R                   R                   S3$ ©Nz()©rI   r/   ©r'   s    r*   Ú__repr__ÚMaybeToTensor.__repr__?   ó   € Ø—.‘.×)Ñ)Ð*¨"Ð-Ð-r-   r.   ©rD   N)r/   r0   r1   r2   r?   r8   r@   rN   r+   ÚstrrW   r3   Ú__classcell__©rI   s   @r*   r   r   ,   s.   ø† ñ÷ð
 ˜uŸ|™|ô 
 ð.˜#÷ .ò .r-   r   c                   óD   ^ • \ rS rSrSrSU 4S jjrS rS\4S jrSr	U =r
$ )	r   éC   zSConvert a PIL Image to a tensor of the same type - this does not scale values.
    rD   c                 ó"   >• [         TU ]  5         g r7   rF   rH   s    €r*   r8   ÚMaybePILToTensor.__init__G   rK   r-   c                 óp   • [        U[        R                  5      (       a  U$ [        R                  " U5      $ )z�
Note: A deep copy of the underlying array is performed.

Args:
    pic (PIL Image): Image to be converted to tensor.

Returns:
    Tensor: Converted image.
)rM   r@   rN   r;   r<   rP   s     r*   r+   ÚMaybePILToTensor.__call__J   s)   € ô �cœ5Ÿ<™<×(Ñ(ØˆJÜ�Š˜sÓ#Ð#r-   c                 ó4   • U R                   R                   S3$ rT   rU   rV   s    r*   rW   ÚMaybePILToTensor.__repr__X   rY   r-   r.   rZ   )r/   r0   r1   r2   r?   r8   r+   r[   rW   r3   r\   r]   s   @r*   r   r   C   s#   ø† ñ÷ò$ð.˜#÷ .ò .r-   r   Ú
ResamplingÚnearestÚbilinearÚbicubicÚboxÚhammingÚlanczosc                 ó   • [         U    $ r7   )Ú_str_to_pil_interpolation©Úmode_strs    r*   r   r   „   s   € Ü$ XÑ.Ð.r-   c                 ó<   • [         (       a	  [        U    $ [        U    $ r7   )Úhas_interpolation_modeÚ_str_to_torch_interpolationrn   ro   s    r*   r   r   ˆ   s   € ßÒÜ*¨8Ñ4Ð4ä(¨Ñ2Ð2r-   c                 ó<   • [         (       a	  [        U    $ [        U    $ r7   )rr   Ú_torch_interpolation_to_strÚ_pil_interpolation_to_str)Úmodes    r*   r   r   �   s   € ßÒÜ*¨4Ñ0Ð0ä(¨Ñ.Ð.r-   c                 ó   • [        U [        R                  5      (       a  [        U 5      [        U 5      4$ [        U [        5      (       a  [        U 5      S:X  a
  U S   U S   4$ [        U 5      S:w  a  [        U5      eU $ )Né   r   r    )rM   ÚnumbersÚNumberÚintr   ÚlenÚ
ValueError)ÚsizeÚ	error_msgs     r*   Ú_setup_sizer�   ™   sk   € Ü�$œŸ™×'Ñ'Ü�4‹yœ#˜d›)Ð#Ð#ä�$œ×!Ñ!¤c¨$£i°1£nØ�A‰w˜˜Q™ÐÐä
ˆ4ƒy�Aƒ~Ü˜Ó#Ð#à€Kr-   c                   óD   • \ rS rSrSr   S	S jr\S 5       rS rS r	Sr
g)
r   é¦   a1  Crop the given PIL Image to random size and aspect ratio with random interpolation.

A crop of random size (default: of 0.08 to 1.0) of the original size and a random
aspect ratio (default: of 3/4 to 4/3) of the original aspect ratio is made. This crop
is finally resized to given size.
This is popularly used to train the Inception networks.

Args:
    size: expected output size of each edge
    scale: range of size of the origin size cropped
    ratio: range of aspect ratio of the origin aspect ratio cropped
    interpolation: Default: PIL.Image.BILINEAR
c                 ó$  • [        U[        [        45      (       a  [        U5      U l        OX4U l        US   US   :”  d  US   US   :”  a  [        R
                  " S5        US:X  a  [        U l        O[        U5      U l        X l	        X0l
        g )Nr   ry   z"range should be of kind (min, max)Úrandom)rM   ÚlistÚtupler   ÚwarningsÚwarnÚ_RANDOM_INTERPOLATIONÚinterpolationr   ÚscaleÚratio)r'   r   rŒ   r�   r‹   s        r*   r8   Ú*RandomResizedCropAndInterpolation.__init__µ   s|   € ô �dœT¤5˜M×*Ñ*Ü˜d›ˆD�Ià˜ˆDŒIØ�!‰H�u˜Q‘xÓ U¨1¡X°°a±Ó%8Ü�MŠMÐ>Ô?à˜HÓ$Ü!6ˆDÕä!3°MÓ!BˆDÔØŒ
Ø�
r-   c           	      ój  • [         R                  " U 5      u  p4X4-  n[        S5       GH
  n[        R                  " U6 U-  n[
        R                  " US   5      [
        R                  " US   5      4n[
        R                  " [        R                  " U6 5      n	[        [        [
        R                  " Xy-  5      5      5      n
[        [        [
        R                  " Xy-  5      5      5      nX£::  d  MÎ  X´::  d  MÕ  [        R                  " SXK-
  5      n[        R                  " SX:-
  5      nXÍXº4s  $    X4-  nU[        U5      :  a#  Un
[        [        U
[        U5      -  5      5      nO6U[        U5      :”  a#  Un[        [        U[        U5      -  5      5      n
OUn
UnXK-
  S-  nX:-
  S-  nXÍXº4$ )aQ  Get parameters for ``crop`` for a random sized crop.

Args:
    img (PIL Image): Image to be cropped.
    scale (tuple): range of size of the origin size cropped
    ratio (tuple): range of aspect ratio of the origin aspect ratio cropped

Returns:
    tuple: params (i, j, h, w) to be passed to ``crop`` for a random
        sized crop.
é
   r   ry   r    )r;   Úget_image_sizeÚranger…   ÚuniformÚmathÚlogÚexpr|   ÚroundÚsqrtÚrandintÚminÚmax)ÚimgrŒ   r�   Úimg_wÚimg_hÚareaÚattemptÚtarget_areaÚ	log_ratioÚaspect_ratioÚtarget_wÚtarget_hÚiÚjÚin_ratios                  r*   Ú
get_paramsÚ,RandomResizedCropAndInterpolation.get_paramsÊ   su  € ô ×'Ò'¨Ó,‰ˆØ‰}ˆä˜R—yˆGÜ Ÿ.š.¨%Ð0°4Ñ7ˆKÜŸš %¨¡(Ó+¬T¯XªX°e¸A±hÓ-?Ð@ˆIÜŸ8š8¤F§N¢N°IÐ$>Ó?ˆLäœ5¤§¢¨;Ñ+EÓ!FÓGÓHˆHÜœ5¤§¢¨;Ñ+EÓ!FÓGÓHˆHØÕ  XÕ%6Ü—N’N 1 eÑ&6Ó7�Ü—N’N 1 eÑ&6Ó7�Ø˜XÐ/Ò/ñ !ð ‘=ˆØ”c˜%“jÓ ØˆHÜœ5 ¬C°«JÑ!6Ó7Ó8‰HØœ˜E›
Ó"ØˆHÜœ5 ¬C°«JÑ!6Ó7Ó8‰HàˆHØˆHØÑ !Ñ#ˆØÑ !Ñ#ˆØ�XÐ'Ð'r-   c           	      ó>  • U R                  XR                  U R                  5      u  p#pE[        U R                  [
        [        45      (       a!  [        R                  " U R                  5      nOU R                  n[        R                  " XX4XPR                  U5      $ )zz
Args:
    img (PIL Image): Image to be cropped and resized.

Returns:
    PIL Image: Randomly cropped and resized image.
)r©   rŒ   r�   rM   r‹   r‡   r†   r…   Úchoicer;   Úresized_cropr   )r'   rœ   r¦   r§   ÚhÚwr‹   s          r*   r+   Ú*RandomResizedCropAndInterpolation.__call__õ   so   € ð —_‘_ S¯*©*°d·j±jÓA‰
ˆˆaÜ�d×(Ñ(¬5´$¨-×8Ñ8Ü"ŸMšM¨$×*<Ñ*<Ó=‰Mà ×.Ñ.ˆMÜ�~Š~˜c a¨A¯y©y¸-ÓHÐHr-   c                 ó4  • [        U R                  [        [        45      (       a6  SR	                  U R                   Vs/ s H  n[        U5      PM     sn5      nO[        U R                  5      nU R                  R                  SR                  U R                  5      -   nUSR                  [        S U R                   5       5      5      -  nUSR                  [        S U R                   5       5      5      -  nUSR                  U5      -  nU$ s  snf )NÚ ú	(size={0}z, scale={0}c              3   ó:   #   • U  H  n[        US 5      v •  M     g7f©é   N©r—   )Ú.0Úss     r*   Ú	<genexpr>Ú=RandomResizedCropAndInterpolation.__repr__.<locals>.<genexpr>
  ó   é € Ð3TÊÀA´E¸!¸Q·K°KÊùó   ‚z, ratio={0}c              3   ó:   #   • U  H  n[        US 5      v •  M     g7frµ   r·   )r¸   Úrs     r*   rº   r»     r¼   r½   z, interpolation={0}))rM   r‹   r‡   r†   Újoinr   rI   r/   Úformatr   rŒ   r�   ©r'   ÚxÚinterpolate_strÚformat_strings       r*   rW   Ú*RandomResizedCropAndInterpolation.__repr__  sá   € Ü�d×(Ñ(¬5´$¨-×8Ñ8Ø!Ÿh™hÀt×GYÒGYÓ'ZÒGYÀ!Ô(:¸1Ö(=ÑGYÑ'ZÓ[‰Oä0°×1CÑ1CÓDˆOØŸ™×/Ñ/°+×2DÑ2DÀTÇYÁYÓ2OÑOˆØ˜×-Ñ-¬eÑ3TÈÏÊÓ3TÓ.TÓUÑUˆØ˜×-Ñ-¬eÑ3TÈÏÊÓ3TÓ.TÓUÑUˆØÐ/×6Ñ6°ÓGÑGˆØÐùò ([s   ¿D)r‹   r�   rŒ   r   N))g{®Gáz´?ç      ð?)g      è?gUUUUUUõ?rh   ©r/   r0   r1   r2   r?   r8   Ústaticmethodr©   r+   rW   r3   r.   r-   r*   r   r   ¦   s7   † ñð" Ø$Ø$ôð* ñ((ó ð((òTIõ	r-   r   rœ   Úoutput_sizeÚfillÚpadding_moderD   c                 óæ  • [        U5      nUu  pE[        R                  " U 5      u  pgnXX:”  d  XG:”  av  XX:”  a  XX-
  S-  OSXG:”  a  XG-
  S-  OSXX:”  a
  XX-
  S-   S-  OSXG:”  a
  XG-
  S-   S-  OS/n	[        R                  " X	X#S9n [        R                  " U 5      u  pgnXX:X  a  XG:X  a  U $ [	        [        Xt-
  S-  5      5      n
[	        [        X…-
  S-  5      5      n[        R                  " X
X´U5      $ )a?  Center crops and/or pads the given image.

If the image is torch Tensor, it is expected
to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions.
If image size is smaller than output size along any edge, image is padded with 0 and then center cropped.

Args:
    img (PIL Image or Tensor): Image to be cropped.
    output_size (sequence or int): (height, width) of the crop box. If int or sequence with single int,
        it is used for both directions.
    fill (int, Tuple[int]): Padding color

Returns:
    PIL Image or Tensor: Cropped image.
r    r   ry   ©rË   rÌ   g       @)r�   r;   Úget_dimensionsÚpadr|   r—   Úcrop)rœ   rÊ   rË   rÌ   Úcrop_heightÚ
crop_widthÚ_Úimage_heightÚimage_widthÚpadding_ltrbÚcrop_topÚ	crop_lefts               r*   r   r     s
  € ô* ˜kÓ*€KØ)Ñ€KÜ#$×#3Ò#3°CÓ#8Ñ €A�[àÓ ;Ó#=à/9Ó/GˆZÑ%¨!Ò+ÈQØ1<Ó1Kˆ[Ñ'¨AÒ-ÐQRØ3=Ó3KˆZÑ%¨Ñ)¨aÒ/ÐQRØ5@Ó5Oˆ[Ñ'¨!Ñ+°Ò1ÐUVð	
ˆô �eŠe�C¨DÑLˆÜ'(×'7Ò'7¸Ó'<Ñ$ˆ˜ØÓ$¨Ó)DØˆJä”5˜,Ñ4¸Ñ;Ó<Ó=€HÜ”E˜;Ñ3°sÑ:Ó;Ó<€IÜ�6Š6�# ¸ÓDÐDr-   c            
       ó~   ^ • \ rS rSrSr  SS\\\\   4   S\\\\\\4   4   S\	4U 4S jjjr
S rS\	4S	 jrS
rU =r$ )r   i:  a  Crops the given image at the center.
If the image is torch Tensor, it is expected
to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions.
If image size is smaller than output size along any edge, image is padded with 0 and then center cropped.

Args:
    size (sequence or int): Desired output size of the crop. If size is an
        int instead of sequence like (h, w), a square crop (size, size) is
        made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).
r   rË   rÌ   c                 óZ   >• [         TU ]  5         [        U5      U l        X l        X0l        g r7   ©rG   r8   r�   r   rË   rÌ   ©r'   r   rË   rÌ   rI   s       €r*   r8   ÚCenterCropOrPad.__init__F  ó'   ø€ ô 	‰ÑÔÜ Ó%ˆŒ	ØŒ	Ø(Õr-   c                 óT   • [        XR                  U R                  U R                  S9$ )úm
Args:
    img (PIL Image or Tensor): Image to be cropped.

Returns:
    PIL Image or Tensor: Cropped image.
rÎ   )r   r   rË   rÌ   )r'   rœ   s     r*   ÚforwardÚCenterCropOrPad.forwardQ  s!   € ô " #§y¡y°t·y±yÈt×O`ÑO`ÑaÐar-   rD   c                 óN   • U R                   R                   SU R                   S3$ ©Nz(size=Ú)©rI   r/   r   rV   s    r*   rW   ÚCenterCropOrPad.__repr__[  ó$   € Ø—.‘.×)Ñ)Ð*¨&°·±°¸1Ð=Ð=r-   ©rË   rÌ   r   ©r   Úconstant)r/   r0   r1   r2   r?   r   r|   r   r   r[   r8   râ   rW   r3   r\   r]   s   @r*   r   r   :  so   ø† ñ	ð 67Ø *ñ		)à˜˜T #™Y˜Ñ'ð	)ð ˜˜U 3¨¨S =Ñ1Ð1Ñ2ð	)ð ÷		)ð 	)òbð>˜#÷ >ò >r-   r   ÚtopÚleftÚheightÚwidthc           
      ó¾  • [         R                  " U 5      u  pxn	X$-   n
X-   nUS:  d  US:  d
  X©:”  d  X¸:”  aw  [        U* [        SU
5      -   S5      [        U* [        SU5      -   S5      [        U
[        X’5      -
  S5      [        U[        X�5      -
  S5      /n[         R                  " XXVS9n [        US5      n[        US5      n[         R
                  " XX#U5      $ )zZCrops and/or pads image to meet target size, with control over fill and padding_mode.
    r   rÎ   )r;   rÏ   r›   rš   rÐ   rÑ   )rœ   rí   rî   rï   rð   rË   rÌ   rÔ   rÕ   rÖ   ÚrightÚbottomr×   s                r*   r   r   _  sÖ   € ô $%×#3Ò#3°CÓ#8Ñ €A�[Ø‰L€EØ‰\€FØˆaƒx�3˜“7˜eÓ1°VÓ5Jä��œ˜A˜u›Ñ% qÓ)Ü��”s˜1˜f“~Ñ% qÓ)Ü�œ˜KÓ.Ñ.°Ó2Ü�œ˜\Ó/Ñ/°Ó3ð	
ˆô �eŠe�C¨DÑLˆä
ˆc�1‹+€CÜˆt�Q‹<€DÜ�6Š6�#˜D¨%Ó0Ð0r-   c            
       óŽ   ^ • \ rS rSrSr  SS\\\\   4   S\\\\\\4   4   S\	4U 4S jjjr
\S 5       rS rS	\	4S
 jrSrU =r$ )r   i{  zOCrop and/or pad image with random placement within the crop or pad margin.
    r   rË   rÌ   c                 óZ   >• [         TU ]  5         [        U5      U l        X l        X0l        g r7   rÜ   rÝ   s       €r*   r8   ÚRandomCropOrPad.__init__  rß   r-   c           
      óN  • [         R                  " U 5      u  p#nX1S   -
  nXAS   -
  n[        [        R                  " [
        R                  " S[        U5      5      U5      5      n[        [        R                  " [
        R                  " S[        U5      5      U5      5      nXx4$ )Nr   ry   )r;   rÏ   r|   r”   Úcopysignr…   r™   Úabs)	rœ   r   rÔ   rÕ   rÖ   Údelta_heightÚdelta_widthrí   rî   s	            r*   r©   ÚRandomCropOrPad.get_paramsŠ  s�   € ä'(×'7Ò'7¸Ó'<Ñ$ˆ˜Ø#¨1¡gÑ-ˆØ!¨¡GÑ+ˆÜ”$—-’-¤§¢¨q´#°lÓ2CÓ DÀlÓSÓTˆÜ”4—=’=¤§¢°´3°{Ó3CÓ!DÀkÓRÓSˆØˆyÐr-   c           
      ó¶   • U R                  XR                  5      u  p#[        UUUU R                  S   U R                  S   U R                  U R                  S9$ )rá   r   ry   )rí   rî   rï   rð   rË   rÌ   )r©   r   r   rË   rÌ   )r'   rœ   rí   rî   s       r*   râ   ÚRandomCropOrPad.forward“  sT   € ð —O‘O C¯©Ó3‰	ˆÜØØØØ—9‘9˜Q‘<Ø—)‘)˜A‘,Ø—‘Ø×*Ñ*ñ
ð 	
r-   rD   c                 óN   • U R                   R                   SU R                   S3$ rå   rç   rV   s    r*   rW   ÚRandomCropOrPad.__repr__¦  ré   r-   rê   rë   )r/   r0   r1   r2   r?   r   r|   r   r   r[   r8   rÉ   r©   râ   rW   r3   r\   r]   s   @r*   r   r   {  s‚   ø† ñð 67Ø *ñ		)à˜˜T #™Y˜Ñ'ð	)ð ˜˜U 3¨¨S =Ñ1Ð1Ñ2ð	)ð ÷		)ð 	)ð ñó ðò
ð&>˜#÷ >ò >r-   r   c                   ó4   • \ rS rSrSS jr\S 5       rS rSrg)r   iª  c                 ó   • Xl         X l        g r7   )Ú
input_sizerË   )r'   r  rË   s      r*   r8   ÚRandomPad.__init__«  s   € Ø$ŒØ�	r-   c                 óî   • [         R                  " U 5      u  p#[        US   U-
  S5      n[        US   U-
  S5      n[        R                  " SU5      n[        R                  " SU5      nXF-
  nXW-
  n	XgX‰4$ )Nry   r   )r;   r‘   r›   r…   r™   )
rœ   r  rð   rï   rû   rú   Úpad_leftÚpad_topÚ	pad_rightÚ
pad_bottoms
             r*   r©   ÚRandomPad.get_params¯  sy   € ä×(Ò(¨Ó-‰ˆÜ˜* Q™-¨%Ñ/°Ó3ˆÜ˜: a™=¨6Ñ1°1Ó5ˆÜ—>’> ! [Ó1ˆÜ—.’.  LÓ1ˆØÑ*ˆ	Ø!Ñ+ˆ
Ø )Ð7Ð7r-   c                 ó~   • U R                  XR                  5      n[        R                  " XU R                  5      nU$ r7   )r©   r  r;   rÐ   rË   )r'   rœ   Úpaddings      r*   r+   ÚRandomPad.__call__º  s-   € Ø—/‘/ #§¡Ó7ˆÜ�eŠe�C $§)¡)Ó,ˆØˆ
r-   )rË   r  N)r   )	r/   r0   r1   r2   r8   rÉ   r©   r+   r3   r.   r-   r*   r   r   ª  s    † ôð ñ8ó ð8õr-   r   c                   óZ   • \ rS rSrSr       S	S jr\     S
S j5       rS rS r	Sr
g)r   iÀ  z!Resize and Keep Aspect Ratio
    c	                 ó  • [        U[        [        45      (       a  [        U5      U l        OX4U l        US:X  a  [        U l        O[        U5      U l        [        U5      U l        X@l	        XPl
        X`l        Xpl        X€l        g)z©

Args:
    size:
    longest:
    interpolation:
    random_scale_prob:
    random_scale_range:
    random_scale_area:
    random_aspect_prob:
    random_aspect_range:
r…   N)rM   r†   r‡   r   rŠ   r‹   r   ÚfloatÚlongestÚrandom_scale_probÚrandom_scale_rangeÚrandom_scale_areaÚrandom_aspect_probÚrandom_aspect_range)	r'   r   r  r‹   r  r  r  r  r  s	            r*   r8   ÚResizeKeepRatio.__init__Ä  so   € ô. �dœT¤5˜M×*Ñ*Ü˜d›ˆD�Ià˜ˆDŒIØ˜HÓ$Ü!6ˆDÕä!3°MÓ!BˆDÔÜ˜W“~ˆŒØ!2ÔØ"4ÔØ!2ÔØ"4ÔØ#6Õ r-   c                 ó  • [         R                  " U 5      SS =u  p‰n
Uu  p¼X‹-  nXœ-  n[        XÞ5      U-  [        XÞ5      SU-
  -  -   nUS:”  a[  [        R                  " 5       U:  aB  [        R
                  " US   US   5      nU(       a  S[        R                  " U5      -  nUU4nOSnUS:”  a˜  [        R                  " 5       U:  a  [        R                  " US   5      [        R                  " US   5      4n[        R                  " [        R
                  " U6 5      n[        R                  " U5      nUS   U-  US   U-  4n[        U
U5       VVs/ s H  u  nn[        UU-  U-  5      PM     nnnU$ s  snnf )zGet parameters
        ry   NrÇ   r   )rÇ   rÇ   )r;   rÏ   r›   rš   r…   r“   r”   r˜   r•   r–   Úzipr—   )rœ   Útarget_sizer  r  r  r  r  r  rž   r�   Úimg_sizer¥   r¤   Úratio_hÚratio_wr�   Úratio_factorÚ
log_aspectÚaspect_factorrÃ   Úfr   s                         r*   r©   ÚResizeKeepRatio.get_paramsê  sr  € ô #$×"2Ò"2°3Ó"7¸¸Ð";Ð;‰ˆ�xØ(ÑˆØÑ"ˆØÑ"ˆÜ�GÓ%¨Ñ/´#°gÓ2GÈ2ÐPWÉ<Ñ2XÑXˆà˜qÓ ¤V§]¢]£_Ð7HÓ%HÜ!Ÿ>š>Ð*<¸QÑ*?ÐASÐTUÑAVÓWˆLÞ ð  "¤D§I¢I¨lÓ$;Ñ;�Ø(¨,Ð7‰Là#ˆLà Ó!¤f§m¢m£oÐ8JÓ&JÜŸ(š(Ð#6°qÑ#9Ó:¼D¿HºHÐEXÐYZÑE[Ó<\Ð]ˆJÜ ŸHšH¤V§^¢^°ZÐ%@ÓAˆMÜ ŸIšI mÓ4ˆMð )¨™O¨mÑ;¸\È!¹_È}Ñ=\Ð]ˆLä14°X¸|Ô1LÔMÒ1L©¨¨A”�a˜!‘e˜e‘mÖ$Ñ1LˆÑMØˆùó Ns   ÅE=c           
      ó’  • U R                  XR                  U R                  U R                  U R                  U R
                  U R                  U R                  5      n[        U R                  [        [        45      (       a!  [        R                  " U R                  5      nOU R                  n[        R                  " XU5      nU$ )z§
Args:
    img (PIL Image): Image to be cropped and resized.

Returns:
    PIL Image: Resized, padded to at least target size, possibly cropped to exactly target size
)r©   r   r  r  r  r  r  r  rM   r‹   r‡   r†   r…   r¬   r;   Úresize)r'   rœ   r   r‹   s       r*   r+   ÚResizeKeepRatio.__call__  s–   € ð �‰Ø—‘˜DŸL™LØ×"Ñ" D×$;Ñ$;¸T×=SÑ=SØ×#Ñ# T×%=Ñ%=ó
ˆô
 �d×(Ñ(¬5´$¨-×8Ñ8Ü"ŸMšM¨$×*<Ñ*<Ó=‰Mà ×.Ñ.ˆMÜ�hŠh�s -Ó0ˆØˆ
r-   c                 óv  • [        U R                  [        [        45      (       a6  SR	                  U R                   Vs/ s H  n[        U5      PM     sn5      nO[        U R                  5      nU R                  R                  SR                  U R                  5      -   nUSU 3-  nUSU R                  S 3-  nUSU R                  S 3-  nUSU R                  S   S S	U R                  S
   S S3-  nUSU R                  S 3-  nUSU R                  S   S S	U R                  S
   S S3-  nU$ s  snf )Nr²   r³   z, interpolation=z
, longest=z.3fz, random_scale_prob=z, random_scale_range=(r   z, ry   ræ   z, random_aspect_prob=z, random_aspect_range=(z)))rM   r‹   r‡   r†   rÀ   r   rI   r/   rÁ   r   r  r  r  r  r  rÂ   s       r*   rW   ÚResizeKeepRatio.__repr__&  sd  € Ü�d×(Ñ(¬5´$¨-×8Ñ8Ø!Ÿh™hÀt×GYÒGYÓ'ZÒGYÀ!Ô(:¸1Ö(=ÑGYÑ'ZÓ[‰Oä0°×1CÑ1CÓDˆOØŸ™×/Ñ/°+×2DÑ2DÀTÇYÁYÓ2OÑOˆØÐ+¨OÐ+<Ð=Ñ=ˆØ˜: d§l¡l°3Ð%7Ð8Ñ8ˆØÐ/°×0FÑ0FÀsÐ/KÐLÑLˆØÐ1Ø ×3Ñ3°AÑ6°sÐ;¸2¸d×>UÑ>UÐVWÑ>XÐY\Ð=]Ð]^ð`ñ 	`ˆàÐ0°×1HÑ1HÈÐ0MÐNÑNˆØÐ2Ø ×4Ñ4°QÑ7¸Ð<¸B¸t×?WÑ?WÐXYÑ?ZÐ[^Ð>_Ð_aðcñ 	cˆàÐùò ([s   ¿D6)r‹   r  r  r  r  r  r  r   N)ç        rh   r(  )g333333ë?gÍÌÌÌÌÌð?Fr(  ©gÍÌÌÌÌÌì?gÃõ(\�Âñ?)r(  )rÇ   gHáz®Gõ?Fr(  r)  rÈ   r.   r-   r*   r   r   À  sT   † ñð Ø$Ø Ø+Ø#Ø!Ø +ô$7ðL ð
 !Ø*Ø#Ø!Ø +ó%ó ð%òNõ(r-   r   c                   ó6   ^ • \ rS rSrS\4U 4S jjrS rSrU =r$ )r   i7  Úborder_sizec                 ó.   >• [         TU ]  5         Xl        g r7   )rG   r8   r+  )r'   r+  rI   s     €r*   r8   ÚTrimBorder.__init__9  s   ø€ ô 	‰ÑÔØ&Õr-   c                 ó  • [         R                  " U5      u  p#U R                  =pE[        XC5      n[        XS5      n[	        SUSU R                  -  -
  5      n[	        SUSU R                  -  -
  5      n[         R
                  " XXVU5      $ )Nr   r    )r;   r‘   r+  rš   r›   rÑ   )r'   rœ   r¯   r®   rí   rî   rï   rð   s           r*   râ   ÚTrimBorder.forward@  s   € Ü×Ò Ó$‰ˆØ×%Ñ%Ð%ˆÜ�#‹kˆÜ�4‹|ˆÜ�Q˜˜A × 0Ñ 0Ñ0Ñ0Ó1ˆÜ�A�q˜1˜t×/Ñ/Ñ/Ñ/Ó0ˆÜ�vŠv�c ¨eÓ4Ð4r-   )r+  )	r/   r0   r1   r2   r|   r8   râ   r3   r\   r]   s   @r*   r   r   7  s   ø† ð'à÷'÷5ð 5r-   r   )z3Please provide only two dimensions (h, w) for size.rë   );r”   rz   r…   rˆ   Útypingr   r   r   r   r@   Útorchvision.transformsÚ
transformsÚ!torchvision.transforms.functionalÚ
functionalr;   r   rr   ÚImportErrorÚPILr   Únumpyr!   Ú__all__r	   r
   r   r   Úhasattrrf   ÚNEARESTÚBILINEARÚBICUBICÚBOXÚHAMMINGÚLANCZOSrv   Úitemsrn   ru   rs   Ú_pil_interpolation_to_torchr   r   r   rŠ   r�   r   rN   r|   r[   r   ÚnnÚModuler   r   r   r   r   r   )ÚaÚbs   00r*   Ú<module>rF     sj  ðÛ Û Û Û ß /Ó /ã Ý +ß -Ð -ð#ÝCØ!Ðõ Û ò€÷ñ ÷=ñ =ô.�J×'Ñ'ô .÷..ñ .ñ8 ˆ5�,×Ñà×Ñ× Ñ  )Ø×Ñ×!Ñ! :Ø×Ñ× Ñ  )Ø×Ñ×Ñ˜eØ×Ñ× Ñ  )Ø×Ñ× Ñ  )ð!Ñð 	�‰�yØ�‰˜
Ø�‰�yØ�	‰	�5Ø�‰�yØ�‰�yð!Ðð /H×.MÑ.MÔ.OÔPÒ.O¡d a˜QšTÑ.OÒPÐ ö à×!Ñ! 9Ø×"Ñ" JØ×!Ñ! 9Ø×Ñ˜uØ×!Ñ! 9Ø×!Ñ! 9ð#Ðð 5P×4UÑ4UÔ4WÔ"XÒ4W©D¨A 1¢4Ñ4WÒ"XÑà"$ÐØ"$Ðò/ò3ò/ñ ,¨JÓ7Ñ9KÈIÓ9VÐWÐ ô
÷gñ gðZ 23Ø&ñ	'EØ�\‰\ð'Eà˜3  S¡	˜>Ñ*ð'Eð �C˜˜s C¨˜}Ñ-Ð-Ñ.ð'Eð ð	'Eð
 ‡\�\õ'EôT">�e—h‘h—o‘oô ">ðV 23Ø&ñ1Ø�\‰\ð1àð1ð ð1ð ð	1ð
 ð1ð �C˜˜s C¨˜}Ñ-Ð-Ñ.ð1ð ð1ð ‡\�\õ1ô8,>�e—h‘h—o‘oô ,>÷^ñ ÷,tñ tôn5�—‘—‘õ 5øðU ó #Ø"Óð#üóJ Qùó #Ys   ±L Å,LÇ"LÌLÌL