
    Z jt                         S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	J
r
  SSKJrJr  SSKJrJrJr  / S	Qr/ S
Qr " S S\SS9r\ " S S\5      5       rS/rg)z"Image processor class for Idefics.    )Callable   )TorchvisionBackend)BatchFeature)
ImageInputPILImageResamplingmake_flat_list_of_images)ImagesKwargsUnpack)
TensorTypeauto_docstringis_torch_available)g3<4'?gwgM?gy{ ?)gB91?gwt.?g	U?c                   >    \ rS rSr% Sr\S-  \S'   \\S'   \\S'   Srg)IdeficsImageProcessorKwargs!   a  
transform (`Callable`, *optional*, defaults to `None`):
    A custom transform function that accepts a single image can be passed for training. For example,
    `torchvision.Compose` can be used to compose multiple transforms. If `None` - an inference mode is
    assumed - and then a preset of inference-specific transforms will be applied to the images.
image_size (`int`, *optional*, defaults to `self.image_size`):
    Resize to image size. This is a backward-compatible alias for `size`. When provided, it overrides
    `size` and sets it to `{"height": image_size, "width": image_size}`.
image_num_channels (`int`, *optional*, defaults to `3`):
    The number of channels of the image.
N	transform
image_sizeimage_num_channels )	__name__
__module____qualname____firstlineno____doc__r   __annotations__int__static_attributes__r       څ/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/models/idefics/image_processing_idefics.pyr   r   !   s    
 $Or   r   F)totalc                      ^  \ rS rSr\r\R                  r\	r
\rSSS.rSrSrSrSrSrS\\   4U 4S jjr\S\S\\   S	S
4U 4S jj5       rSrU =r$ )IdeficsImageProcessor3      heightwidthTr   kwargsc                    > UR                  SS 5      nUb  X"S.US'   [        TU ]  " S0 UD6  U R                  R                  U l        g )Nr   r%   sizer   )popsuper__init__r*   r&   r   )selfr(   r   	__class__s      r   r-   IdeficsImageProcessor.__init__@   sF    ZZd3
!(2HF6N"6"))**r   imagesreturnzTensorType | BatchFeaturec                 2  > UR                  SS 5      nUbb  [        5       (       d  [        S5      eSS KnU R	                  U5      n[        U5      nU Vs/ s H
  oS" U5      PM     nnUR                  U5      $ [        TU ]   " U40 UD6R                  $ s  snf )Nr   z.To pass in `transform` torch must be installedr   )
r+   r   ImportErrortorchfetch_imagesr	   stackr,   
preprocesspixel_values)r.   r1   r(   r   r5   xr/   s         r   r8    IdeficsImageProcessor.preprocessG   s     JJ{D1	 %''!"RSS&&v.F-f5F,23FqilFF3;;v&&w!&3F3@@@ 4s   B)r   )r   r   r   r   r   valid_kwargsr   BICUBICresampleIDEFICS_STANDARD_MEAN
image_meanIDEFICS_STANDARD_STD	image_stdr*   	do_resize
do_rescaledo_normalizedo_convert_rgbr   r   r-   r   r   r8   r   __classcell__)r/   s   @r   r"   r"   3   s    .L!))H&J$IC(DIJLN+(C!D + AA 45A 
%	A Ar   r"   N)r   collections.abcr   image_processing_backendsr   image_processing_utilsr   image_utilsr   r   r	   processing_utilsr
   r   utilsr   r   r   r?   rA   r   r"   __all__r   r   r   <module>rO      sn    ) $ ; 2 
 5 C C < ; ,e $ #A. #A #AL #
#r   