U
    ­Ê¹jG!  ã                   @   s¬   d Z ddlmZmZmZ ddlZddlmZmZ ddlm	Z
mZ ddd	d
dgZG dd„ dejƒZG dd„ dejƒZG dd	„ d	ejƒZG dd
„ d
ejƒZG dd„ dejƒZdS )zÙ
This file is part of the private API. Please do not use directly these classes as they will be modified on
future versions without warning. The classes should be accessed only via the transforms argument of Weights.
é    )ÚOptionalÚTupleÚUnionN)ÚnnÚTensoré   )Ú
functionalÚInterpolationModeÚObjectDetectionÚImageClassificationÚVideoClassificationÚSemanticSegmentationÚOpticalFlowc                   @   s8   e Zd Zeedœdd„Zedœdd„Zedœdd„Zd	S )
r
   ©ÚimgÚreturnc                 C   s"   t |tƒst |¡}t |tj¡S ©N)Ú
isinstancer   ÚFÚpil_to_tensorÚconvert_image_dtypeÚtorchÚfloat©Úselfr   © r   ú^/var/www/html/bwave/python/venv/lib/python3.8/site-packages/torchvision/transforms/_presets.pyÚforward   s    

zObjectDetection.forward©r   c                 C   s   | j jd S ©Nz()©Ú	__class__Ú__name__©r   r   r   r   Ú__repr__   s    zObjectDetection.__repr__c                 C   s   dS )Nz“Accepts ``PIL.Image``, batched ``(B, C, H, W)`` and single ``(C, H, W)`` image ``torch.Tensor`` objects. The images are rescaled to ``[0.0, 1.0]``.r   r#   r   r   r   Údescribe   s    ÿzObjectDetection.describeN)r"   Ú
__module__Ú__qualname__r   r   Ústrr$   r%   r   r   r   r   r
      s   c                
       s†   e Zd Zdddejddœeeeedf eedf eee	e
ef  ddœ‡ fd	d
„Zeedœdd„Ze
dœdd„Ze
dœdd„Z‡  ZS )r   é   ©g
×£p=
ß?gÉv¾Ÿ/Ý?g–C‹lçûÙ?©gZd;ßOÍ?gyé&1¬Ì?gÍÌÌÌÌÌÌ?Úwarn)Úresize_sizeÚmeanÚstdÚinterpolationÚ	antialias.N)Ú	crop_sizer-   r.   r/   r0   r1   r   c                   s>   t ƒ  ¡  |g| _|g| _t|ƒ| _t|ƒ| _|| _|| _d S r   )	ÚsuperÚ__init__r2   r-   Úlistr.   r/   r0   r1   )r   r2   r-   r.   r/   r0   r1   ©r!   r   r   r4   '   s    



zImageClassification.__init__r   c                 C   s`   t j|| j| j| jd�}t  || j¡}t|tƒs:t  	|¡}t  
|tj¡}t j|| j| jd�}|S ©N©r0   r1   ©r.   r/   )r   Úresizer-   r0   r1   Úcenter_cropr2   r   r   r   r   r   r   Ú	normalizer.   r/   r   r   r   r   r   9   s    

zImageClassification.forwardr   c                 C   sh   | j jd }|d| j› �7 }|d| j› �7 }|d| j› �7 }|d| j› �7 }|d| j› �7 }|d7 }|S ©Nú(z
    crop_size=ú
    resize_size=ú

    mean=ú	
    std=ú
    interpolation=ú
)©r!   r"   r2   r-   r.   r/   r0   ©r   Úformat_stringr   r   r   r$   B   s    zImageClassification.__repr__c                 C   s.   d| j › d| j› d| j› d| j› d| j› d�S )Nú‘Accepts ``PIL.Image``, batched ``(B, C, H, W)`` and single ``(C, H, W)`` image ``torch.Tensor`` objects. The images are resized to ``resize_size=ú`` using ``interpolation=ú.``, followed by a central crop of ``crop_size=ú]``. Finally the values are first rescaled to ``[0.0, 1.0]`` and then normalized using ``mean=ú`` and ``std=ú``.©r-   r0   r2   r.   r/   r#   r   r   r   r%   L   s    ,ÿzImageClassification.describe)r"   r&   r'   r	   ÚBILINEARÚintr   r   r   r   r(   Úboolr4   r   r   r$   r%   Ú__classcell__r   r   r6   r   r   &   s"   ø

÷	
c                       s„   e Zd Zddejdœeeef eeef eedf eedf eddœ‡ fdd„Ze	e	d	œd
d„Z
edœdd„Zedœdd„Z‡  ZS )r   )gFë¨j‚¨Û?gñõµ.5BÙ?g�¥½ÁØ?)grá@H0Í?gcÙ=yXÌ?gD¾K©KÆË?)r.   r/   r0   .N)r2   r-   r.   r/   r0   r   c                   s<   t ƒ  ¡  t|ƒ| _t|ƒ| _t|ƒ| _t|ƒ| _|| _d S r   )r3   r4   r5   r2   r-   r.   r/   r0   )r   r2   r-   r.   r/   r0   r6   r   r   r4   V   s    	




zVideoClassification.__init__)Úvidr   c                 C   sÆ   d}|j dk r|jdd�}d}|j\}}}}}| d|||¡}tj|| j| jdd�}t || j	¡}t 
|tj¡}tj|| j| jd�}| j	\}}| |||||¡}| dd	d
dd¡}|rÂ|jdd�}|S )NFé   r   )ÚdimTéÿÿÿÿr8   r9   é   r   é   é   )ÚndimZ	unsqueezeÚshapeÚviewr   r:   r-   r0   r;   r2   r   r   r   r<   r.   r/   ZpermuteZsqueeze)r   rR   Zneed_squeezeÚNÚTÚCÚHÚWr   r   r   r   f   s     

zVideoClassification.forwardr   c                 C   sh   | j jd }|d| j› �7 }|d| j› �7 }|d| j› �7 }|d| j› �7 }|d| j› �7 }|d7 }|S r=   rD   rE   r   r   r   r$   ~   s    zVideoClassification.__repr__c                 C   s.   d| j › d| j› d| j› d| j› d| j› d�S )NzŽAccepts batched ``(B, T, C, H, W)`` and single ``(T, C, H, W)`` video frame ``torch.Tensor`` objects. The frames are resized to ``resize_size=rH   rI   rJ   rK   zP``. Finally the output dimensions are permuted to ``(..., C, T, H, W)`` tensors.rM   r#   r   r   r   r%   ˆ   s    ,ÿzVideoClassification.describe)r"   r&   r'   r	   rN   r   rO   r   r4   r   r   r(   r$   r%   rQ   r   r   r6   r   r   U   s   ù



ø
c                	       s†   e Zd Zddejddœee eedf eedf eee	e
ef  ddœ‡ fdd	„Zeed
œdd„Ze
dœdd„Ze
dœdd„Z‡  ZS )r   r*   r+   r,   )r.   r/   r0   r1   .N)r-   r.   r/   r0   r1   r   c                   sB   t ƒ  ¡  |d k	r|gnd | _t|ƒ| _t|ƒ| _|| _|| _d S r   )r3   r4   r-   r5   r.   r/   r0   r1   )r   r-   r.   r/   r0   r1   r6   r   r   r4   “   s    	


zSemanticSegmentation.__init__r   c                 C   s^   t | jtƒr$tj|| j| j| jd�}t |tƒs8t |¡}t 	|t
j¡}tj|| j| jd�}|S r7   )r   r-   r5   r   r:   r0   r1   r   r   r   r   r   r<   r.   r/   r   r   r   r   r   £   s    

zSemanticSegmentation.forwardr   c                 C   sX   | j jd }|d| j› �7 }|d| j› �7 }|d| j› �7 }|d| j› �7 }|d7 }|S )Nr>   r?   r@   rA   rB   rC   )r!   r"   r-   r.   r/   r0   rE   r   r   r   r$   ¬   s    zSemanticSegmentation.__repr__c              	   C   s&   d| j › d| j› d| j› d| j› d�	S )NrG   rH   rJ   rK   rL   )r-   r0   r.   r/   r#   r   r   r   r%   µ   s    $ÿzSemanticSegmentation.describe)r"   r&   r'   r	   rN   r   rO   r   r   r   r(   rP   r4   r   r   r$   r%   rQ   r   r   r6   r   r   ’   s   ù

ø		c                   @   sB   e Zd Zeeeeef dœdd„Zedœdd„Zedœdd„Zd	S )
r   )Úimg1Úimg2r   c                 C   s”   t |tƒst |¡}t |tƒs(t |¡}t |tj¡}t |tj¡}tj|dddgdddgd�}tj|dddgdddgd�}| ¡ }| ¡ }||fS )Ng      à?r9   )	r   r   r   r   r   r   r   r<   Ú
contiguous)r   ra   rb   r   r   r   r   ¿   s    



zOpticalFlow.forwardr   c                 C   s   | j jd S r   r    r#   r   r   r   r$   Ñ   s    zOpticalFlow.__repr__c                 C   s   dS )Nz”Accepts ``PIL.Image``, batched ``(B, C, H, W)`` and single ``(C, H, W)`` image ``torch.Tensor`` objects. The images are rescaled to ``[-1.0, 1.0]``.r   r#   r   r   r   r%   Ô   s    ÿzOpticalFlow.describeN)	r"   r&   r'   r   r   r   r(   r$   r%   r   r   r   r   r   ¾   s   )Ú__doc__Útypingr   r   r   r   r   r   Ú r   r   r	   Ú__all__ÚModuler
   r   r   r   r   r   r   r   r   Ú<module>   s   û	/=,