
    kh                     f    d dl Z d dlmZmZmZ d dlZd dlZd dl	Z	d dl
mZ d dlmZ  G d de      Zy)    N)AnyDictUnion)
functional)	Transformc                        e Zd ZdZej
                  j
                  ej                  fZd fdZ	de
ej
                  j
                  ej                  f   deeef   dej                  fdZ xZS )ToTensora  [DEPRECATED] Use ``v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])`` instead.

    Convert a PIL Image or ndarray to tensor and scale the values accordingly.

    .. warning::
        :class:`v2.ToTensor` is deprecated and will be removed in a future release.
        Please use instead ``v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])``.
        Output is equivalent up to float precision.

    This transform does not support torchscript.


    Converts a PIL Image or numpy.ndarray (H x W x C) in the range
    [0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0]
    if the PIL Image belongs to one of the modes (L, LA, P, I, F, RGB, YCbCr, RGBA, CMYK, 1)
    or if the numpy.ndarray has dtype = np.uint8

    In the other cases, tensors are returned without scaling.

    .. note::
        Because the input image is scaled to [0.0, 1.0], this transformation should not be used when
        transforming target image masks. See the `references`_ for implementing the transforms for image masks.

    .. _references: https://github.com/pytorch/vision/tree/main/references/segmentation
    returnc                 L    t        j                  d       t        |           y )NzThe transform `ToTensor()` is deprecated and will be removed in a future release. Instead, please use `v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])`.Output is equivalent up to float precision.)warningswarnsuper__init__)self	__class__s    a/var/www/teggl/fontify/venv/lib/python3.12/site-packages/torchvision/transforms/v2/_deprecated.pyr   zToTensor.__init__)   s!    :	

 	    inptparamsc                 ,    t        j                  |      S )N)_F	to_tensor)r   r   r   s      r   	transformzToTensor.transform1   s    ||D!!r   )r
   N)__name__
__module____qualname____doc__PILImagenpndarray_transformed_typesr   r   r   strr   torchTensorr   __classcell__)r   s   @r   r	   r	      sf    4 ))//2::6"eCIIOORZZ$?@ "$sTWx. "]b]i]i "r   r	   )r   typingr   r   r   numpyr    	PIL.Imager   r$   torchvision.transformsr   r   torchvision.transforms.v2r   r	    r   r   <module>r-      s)     # #    3 /&"y &"r   