§
    ù²ÅjîŸ  ã                   óž  — d dl mZmZ d dlZd dlmZ d dlmc mZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ ddlmZ dd	lmZ d
dlmZmZmZ d
dlmZ ddlmZmZmZ dZ G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z  G d„ dej        ¦  «        Z! G d„ dej        ¦  «        Z" G d„ dej        ¦  «        Z#d„ Z$ G d„ dej        ¦  «        Z% G d„ dej        ¦  «        Z& G d„ d ej        ¦  «        Z' G d!„ d"ej        ¦  «        Z( G d#„ d$ej        ¦  «        Z) G d%„ d&ej        ¦  «        Z*d'd(iZ+ G d)„ d*e¦  «        Z, G d+„ d,e¦  «        Z-dd-d.œd/„Z. e¦   «          ed0e,j/        f¬1¦  «        dd2d.œd3ee,         d4e*fd5„¦   «         ¦   «         Z0 e¦   «          ed0e-j1        f¬1¦  «        dd2d.œd3ee-         d4e*fd6„¦   «         ¦   «         Z2dS )7é    )ÚListÚOptionalN)ÚTensor)ÚBatchNorm2d)ÚInstanceNorm2d)ÚConv2dNormActivationé   )ÚOpticalFlow)Ú_log_api_usage_onceé   )Úregister_modelÚWeightsÚWeightsEnum)Úhandle_legacy_interfaceé   )Úgrid_sampleÚmake_coords_gridÚupsample_flow)ÚRAFTÚ
raft_largeÚ
raft_smallÚRaft_Large_WeightsÚRaft_Small_Weightsc                   ó6   ‡ — e Zd ZdZdddœdefˆ fd„Zd„ Zˆ xZS )ÚResidualBlockz<Slightly modified Residual block with extra relu and biases.r   F)ÚstrideÚalways_projectr   c          	      ó^  •— t          ¦   «                              ¦   «          t          |||d|d¬¦  «        | _        t          |||dd¬¦  «        | _        |  |dk    r|st          j        ¦   «         | _        nt          |||d|dd ¬¦  «        | _        t          j        d¬¦  «        | _	        d S )Nr	   T©Ú
norm_layerÚkernel_sizer   Úbias©r    r!   r"   r   ©r    r!   r   r"   Úactivation_layer©Úinplace)
ÚsuperÚ__init__r   Úconvnormrelu1Úconvnormrelu2ÚnnÚIdentityÚ
downsampleÚReLUÚrelu)ÚselfÚin_channelsÚout_channelsr    r   r   Ú	__class__s         €úUC:\Projects\Historical\venv\Lib\site-packages\torchvision/models/optical_flow/raft.pyr)   zResidualBlock.__init__   sÏ   ø€ Ý‰Œ×ÒÑÔÐõ 2Ø˜°*È!ÐTZÐaeð
ñ 
ô 
ˆÔõ 2Ø˜,°:È1ÐSWð
ñ 
ô 
ˆÔð
 	Ð"à�QŠ;ˆ;˜~ˆ;Ý œk™mœmˆDŒOˆOå2ØØØ%ØØØØ!%ðñ ô ˆDŒOõ ”G DÐ)Ñ)Ô)ˆŒ	ˆ	ˆ	ó    c                 ó´   — |}|                       |¦  «        }|                      |¦  «        }|                      |¦  «        }|                      ||z   ¦  «        S ©N)r*   r+   r.   r0   ©r1   ÚxÚys      r5   ÚforwardzResidualBlock.forward@   sT   € ØˆØ×Ò˜qÑ!Ô!ˆØ×Ò˜qÑ!Ô!ˆà�OŠO˜AÑÔˆà�yŠy˜˜Q™ÑÔÐr6   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úboolr)   r<   Ú__classcell__©r4   s   @r5   r   r      sk   ø€ € € € € ØFÐFàHIÐbgð  *ð  *ð  *Ð[_ð  *ð  *ð  *ð  *ð  *ð  *ðD ð  ð  ð  ð  ð  ð  r6   r   c                   ó.   ‡ — e Zd ZdZddœˆ fd„
Zd„ Zˆ xZS )ÚBottleneckBlockz:Slightly modified BottleNeck block (extra relu and biases)r   )r   c          	      ó¢  •— t          ¦   «                              ¦   «          t          ||dz  |dd¬¦  «        | _        t          |dz  |dz  |d|d¬¦  «        | _        t          |dz  ||dd¬¦  «        | _        t          j        d¬¦  «        | _        |dk    rt          j	        ¦   «         | _
        d S t          |||d|dd ¬¦  «        | _
        d S )	Né   r   Tr#   r	   r   r&   r$   )r(   r)   r   r*   r+   Úconvnormrelu3r,   r/   r0   r-   r.   )r1   r2   r3   r    r   r4   s        €r5   r)   zBottleneckBlock.__init__M   s   ø€ Ý‰Œ×ÒÑÔÐõ 2Ø˜¨Ñ*°zÈqÐW[ð
ñ 
ô 
ˆÔõ 2Ø˜AÑ˜|¨qÑ0¸ZÐUVÐ_eÐlpð
ñ 
ô 
ˆÔõ 2Ø˜AÑ˜|¸
ÐPQÐX\ð
ñ 
ô 
ˆÔõ ”G DÐ)Ñ)Ô)ˆŒ	à�QŠ;ˆ;Ý œk™mœmˆDŒOˆOˆOå2ØØØ%ØØØØ!%ðñ ô ˆDŒOˆOˆOr6   c                 óÞ   — |}|                       |¦  «        }|                      |¦  «        }|                      |¦  «        }|                      |¦  «        }|                      ||z   ¦  «        S r8   )r*   r+   rH   r.   r0   r9   s      r5   r<   zBottleneckBlock.forwardi   sg   € ØˆØ×Ò˜qÑ!Ô!ˆØ×Ò˜qÑ!Ô!ˆØ×Ò˜qÑ!Ô!ˆà�OŠO˜AÑÔˆà�yŠy˜˜Q™ÑÔÐr6   ©r=   r>   r?   r@   r)   r<   rB   rC   s   @r5   rE   rE   J   sZ   ø€ € € € € ØDÐDàHIð ð ð ð ð ð ð ð8 ð  ð  ð  ð  ð  ð  r6   rE   c                   óD   ‡ — e Zd ZdZeddej        dœˆ fd„
Zd„ Zd„ Z	ˆ xZ
S )ÚFeatureEncoderz†The feature encoder, used both as the actual feature encoder, and as the context encoder.

    It must downsample its input by 8.
    ©é@   rN   é`   é€   é   )r   r   r   r   )ÚblockÚlayersÚstridesr    c                ó   •— t          ¦   «                              ¦   «          t          |¦  «        dk    rt          dt          |¦  «        › �¦  «        ‚t	          d|d         |d|d         d¬¦  «        | _        |                      ||d         |d         ||d         ¬	¦  «        | _        |                      ||d         |d
         ||d
         ¬	¦  «        | _        |                      ||d
         |d         ||d         ¬	¦  «        | _	        t          j        |d         |d         d¬¦  «        | _        |                      ¦   «         D ]Â}t          |t          j        ¦  «        r(t          j                             |j        dd¬¦  «         ŒDt          |t          j        t          j        f¦  «        rX|j        �%t          j                             |j        d¦  «         |j        �%t          j                             |j        d¦  «         ŒÃt          t-          t/          d„ |¦  «        ¦  «        ¦  «        }|d         | _        d
|z  | _        d S )Né   z0The expected number of layers is 5, instead got r	   r   é   Tr   r   )r    Úfirst_strider   rG   )r!   Úfan_outr0   )ÚmodeÚnonlinearityc                 ó   — | dk    S )Nr   © )Úss    r5   ú<lambda>z)FeatureEncoder.__init__.<locals>.<lambda>–   s
   € °A¸²F€ r6   éÿÿÿÿ)r(   r)   ÚlenÚ
ValueErrorr   ÚconvnormreluÚ_make_2_blocksÚlayer1Úlayer2Úlayer3r,   ÚConv2dÚconvÚmodulesÚ
isinstanceÚinitÚkaiming_normal_Úweightr   r   Ú	constant_r"   ÚlistÚfilterÚ
output_dimÚdownsample_factor)r1   rR   rS   rT   r    ÚmÚnum_downsamplesr4   s          €r5   r)   zFeatureEncoder.__init__z   s  ø€ õ 	‰Œ×ÒÑÔÐåˆv‰;Œ;˜!ÒÐÝÐ]ÕPSÐTZÑP[ÔP[Ð]Ð]Ñ^Ô^Ð^õ 1Øˆv�aŒy Z¸QÀwÈqÄzÐX\ð
ñ 
ô 
ˆÔð ×)Ò)¨%°¸´¸FÀ1¼IÐR\ÐkrÐstÔkuÐ)ÑvÔvˆŒØ×)Ò)¨%°¸´¸FÀ1¼IÐR\ÐkrÐstÔkuÐ)ÑvÔvˆŒØ×)Ò)¨%°¸´¸FÀ1¼IÐR\ÐkrÐstÔkuÐ)ÑvÔvˆŒå”I˜f Qœi¨°¬ÀÐBÑBÔBˆŒ	à—’‘”ð 	1ð 	1ˆAÝ˜!�RœYÑ'Ô'ð 1Ý”×'Ò'¨¬°yÈvÐ'ÑVÔVÐVÐVÝ˜A¥¤µÔ0AÐBÑCÔCð 1Ø”8Ð'Ý”G×%Ò% a¤h°Ñ2Ô2Ð2Ø”6Ð%Ý”G×%Ò% a¤f¨aÑ0Ô0Ð0øå�d¥6Ð*:Ð*:¸GÑ#DÔ#DÑEÔEÑFÔFˆØ  œ*ˆŒØ!" OÑ!3ˆÔÐÐr6   c                 óh   —  |||||¬¦  «        } ||||d¬¦  «        }t          j        ||¦  «        S )N)r    r   r   )r,   Ú
Sequential)r1   rR   r2   r3   r    rX   Úblock1Úblock2s           r5   rd   zFeatureEncoder._make_2_blocksš   sF   € Ø��{ L¸ZÐP\Ð]Ñ]Ô]ˆØ��| \¸jÐQRÐSÑSÔSˆÝŒ}˜V VÑ,Ô,Ð,r6   c                 óØ   — |                       |¦  «        }|                      |¦  «        }|                      |¦  «        }|                      |¦  «        }|                      |¦  «        }|S r8   )rc   re   rf   rg   ri   ©r1   r:   s     r5   r<   zFeatureEncoder.forwardŸ   sV   € Ø×Ò˜aÑ Ô ˆà�KŠK˜‰NŒNˆØ�KŠK˜‰NŒNˆØ�KŠK˜‰NŒNˆà�IŠI�a‰LŒLˆàˆr6   )r=   r>   r?   r@   r   r,   r   r)   rd   r<   rB   rC   s   @r5   rL   rL   t   s{   ø€ € € € € ðð ð %Ð-CÈ\ÐfhÔftð4ð 4ð 4ð 4ð 4ð 4ð 4ð@-ð -ð -ð
	ð 	ð 	ð 	ð 	ð 	ð 	r6   rL   c                   ó2   ‡ — e Zd ZdZddddœˆ fd„
Zd„ Zˆ xZS )ÚMotionEncoderz§The motion encoder, part of the update block.

    Takes the current predicted flow and the correlation features as input and returns an encoded version of these.
    ©rQ   éÀ   ©rP   rN   rP   )Úcorr_layersÚflow_layersr3   c                óÎ  •— t          ¦   «                              ¦   «          t          |¦  «        dk    rt          dt          |¦  «        › �¦  «        ‚t          |¦  «        dvrt          dt          |¦  «        › �¦  «        ‚t	          ||d         d d¬¦  «        | _        t          |¦  «        dk    r%t	          |d         |d         d d¬¦  «        | _        nt          j        ¦   «         | _        t	          d|d         d d	¬¦  «        | _	        t	          |d         |d         d d¬¦  «        | _
        t	          |d
         |d
         z   |dz
  d d¬¦  «        | _        || _        d S )Nr   z5The expected number of flow_layers is 2, instead got ©r   r   z8The number of corr_layers should be 1 or 2, instead got r   r   ©r    r!   r	   rW   r`   )r(   r)   ra   rb   r   Ú	convcorr1Ú	convcorr2r,   r-   Ú	convflow1Ú	convflow2ri   r3   )r1   Úin_channels_corrr�   r‚   r3   r4   s        €r5   r)   zMotionEncoder.__init__±   sg  ø€ Ý‰Œ×ÒÑÔÐåˆ{ÑÔ˜qÒ Ð ÝÐgÕUXÐYdÑUeÔUeÐgÐgÑhÔhÐhÝˆ{ÑÔ 6Ð)Ð)ÝÐjÕX[Ð\gÑXhÔXhÐjÐjÑkÔkÐkå-Ð.>ÀÈAÄÐ[_ÐmnÐoÑoÔoˆŒÝˆ{ÑÔ˜qÒ Ð Ý1°+¸a´.À+ÈaÄ.Ð]aÐopÐqÑqÔqˆDŒNˆNåœ[™]œ]ˆDŒNå-¨a°¸Q´ÈDÐ^_Ð`Ñ`Ô`ˆŒÝ-¨k¸!¬n¸kÈ!¼nÐY]ÐklÐmÑmÔmˆŒõ )Ø˜ŒO˜k¨"œoÑ-¨|¸aÑ/?ÈDÐ^_ð
ñ 
ô 
ˆŒ	ð )ˆÔÐÐr6   c                 ó8  — |                       |¦  «        }|                      |¦  «        }|}|                      |¦  «        }|                      |¦  «        }t	          j        ||gd¬¦  «        }|                      |¦  «        }t	          j        ||gd¬¦  «        S ©Nr   ©Údim)r†   r‡   rˆ   r‰   ÚtorchÚcatri   )r1   ÚflowÚcorr_featuresÚcorrÚ	flow_origÚ	corr_flows         r5   r<   zMotionEncoder.forwardÉ   sŽ   € Ø�~Š~˜mÑ,Ô,ˆØ�~Š~˜dÑ#Ô#ˆàˆ	Ø�~Š~˜dÑ#Ô#ˆØ�~Š~˜dÑ#Ô#ˆå”I˜t T˜l°Ð2Ñ2Ô2ˆ	Ø—I’I˜iÑ(Ô(ˆ	ÝŒy˜) YÐ/°QÐ7Ñ7Ô7Ð7r6   rJ   rC   s   @r5   r}   r}   «   sg   ø€ € € € € ðð ð
 9CÐPYÐhkð )ð )ð )ð )ð )ð )ð )ð0
8ð 
8ð 
8ð 
8ð 
8ð 
8ð 
8r6   r}   c                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )ÚConvGRUzConvolutional Gru unit.c                ó  •— t          ¦   «                              ¦   «          t          j        ||z   |||¬¦  «        | _        t          j        ||z   |||¬¦  «        | _        t          j        ||z   |||¬¦  «        | _        d S )N©r!   Úpadding)r(   r)   r,   rh   ÚconvzÚconvrÚconvq©r1   Ú
input_sizeÚhidden_sizer!   rš   r4   s        €r5   r)   zConvGRU.__init__Ù   s€   ø€ Ý‰Œ×ÒÑÔÐÝ”Y˜{¨ZÑ7¸ÐR]ÐgnÐoÑoÔoˆŒ
Ý”Y˜{¨ZÑ7¸ÐR]ÐgnÐoÑoÔoˆŒ
Ý”Y˜{¨ZÑ7¸ÐR]ÐgnÐoÑoÔoˆŒ
ˆ
ˆ
r6   c                 ón  — t          j        ||gd¬¦  «        }t          j        |                      |¦  «        ¦  «        }t          j        |                      |¦  «        ¦  «        }t          j        |                      t          j        ||z  |gd¬¦  «        ¦  «        ¦  «        }d|z
  |z  ||z  z   }|S rŒ   )r�   r�   Úsigmoidr›   rœ   Útanhr�   )r1   Úhr:   ÚhxÚzÚrÚqs          r5   r<   zConvGRU.forwardß   s™   € ÝŒY˜˜1�v 1Ð%Ñ%Ô%ˆÝŒM˜$Ÿ*š* R™.œ.Ñ)Ô)ˆÝŒM˜$Ÿ*š* R™.œ.Ñ)Ô)ˆÝŒJ�t—z’z¥%¤)¨Q°©U°A¨J¸AÐ">Ñ">Ô">Ñ?Ô?Ñ@Ô@ˆØ�‰U�a‰K˜!˜a™%ÑˆØˆr6   rJ   rC   s   @r5   r—   r—   Ö   sR   ø€ € € € € Ø!Ð!ðpð pð pð pð pðð ð ð ð ð ð r6   r—   c                 ó   — | S r8   r]   )r¤   Ú_s     r5   Ú_pass_through_hr«   è   s   € à€Hr6   c                   ó0   ‡ — e Zd ZdZdddœˆ fd„
Zd„ Zˆ xZS )ÚRecurrentBlockz¼Recurrent block, part of the update block.

    Takes the current hidden state and the concatenation of (motion encoder output, context) as input.
    Returns an updated hidden state.
    ©)r   rV   )rV   r   ©)r   r   )r   r   r™   c                ó$  •— t          ¦   «                              ¦   «          t          |¦  «        t          |¦  «        k    r/t          dt          |¦  «        › dt          |¦  «        › �¦  «        ‚t          |¦  «        dvrt          dt          |¦  «        › �¦  «        ‚t	          |||d         |d         ¬¦  «        | _        t          |¦  «        dk    r%t	          |||d         |d         ¬¦  «        | _        nt          | _        || _        d S )	NzSkernel_size should have the same length as padding, instead got len(kernel_size) = z and len(padding) = r„   z.kernel_size should either 1 or 2, instead got r   ©rŸ   r    r!   rš   r   r   )	r(   r)   ra   rb   r—   Úconvgru1Úconvgru2r«   r    rž   s        €r5   r)   zRecurrentBlock.__init__ô   sC  ø€ Ý‰Œ×ÒÑÔÐåˆ{ÑÔ�s 7™|œ|Ò+Ð+Ýð [ÕfiÐjuÑfvÔfvð  [ð  [õ  MPð  QXñ  MYô  MYð  [ð  [ñô ð õ ˆ{ÑÔ 6Ð)Ð)ÝÐ`ÍcÐR]ÑN^ÔN^Ð`Ð`ÑaÔaÐaåØ!¨{ÈÐTUÌÐ`gÐhiÔ`jð
ñ 
ô 
ˆŒõ ˆ{ÑÔ˜qÒ Ð Ý#Ø%°;ÈKÐXYÌNÐdkÐlmÔdnðñ ô ˆDŒMˆMõ ,ˆDŒMà&ˆÔÐÐr6   c                 ó^   — |                       ||¦  «        }|                      ||¦  «        }|S r8   )r²   r³   )r1   r¤   r:   s      r5   r<   zRecurrentBlock.forward
  s-   € Ø�MŠM˜!˜QÑÔˆØ�MŠM˜!˜QÑÔˆØˆr6   rJ   rC   s   @r5   r­   r­   í   se   ø€ € € € € ðð ð @PÐYið 'ð 'ð 'ð 'ð 'ð 'ð 'ð,ð ð ð ð ð ð r6   r­   c                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )ÚFlowHeadz�Flow head, part of the update block.

    Takes the hidden state of the recurrent unit as input, and outputs the predicted "delta flow".
    c                óð   •— t          ¦   «                              ¦   «          t          j        ||dd¬¦  «        | _        t          j        |ddd¬¦  «        | _        t          j        d¬¦  «        | _        d S )Nr	   r   ©rš   r   Tr&   )r(   r)   r,   rh   Úconv1Úconv2r/   r0   )r1   r2   r    r4   s      €r5   r)   zFlowHead.__init__  se   ø€ Ý‰Œ×ÒÑÔÐÝ”Y˜{¨K¸ÀAÐFÑFÔFˆŒ
Ý”Y˜{¨A¨q¸!Ð<Ñ<Ô<ˆŒ
Ý”G DÐ)Ñ)Ô)ˆŒ	ˆ	ˆ	r6   c                 óx   — |                       |                      |                      |¦  «        ¦  «        ¦  «        S r8   )rº   r0   r¹   r{   s     r5   r<   zFlowHead.forward  s*   € Ø�zŠz˜$Ÿ)š) D§J¢J¨q¡M¤MÑ2Ô2Ñ3Ô3Ð3r6   rJ   rC   s   @r5   r¶   r¶     sQ   ø€ € € € € ðð ð
*ð *ð *ð *ð *ð4ð 4ð 4ð 4ð 4ð 4ð 4r6   r¶   c                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )ÚUpdateBlockzÍThe update block which contains the motion encoder, the recurrent block, and the flow head.

    It must expose a ``hidden_state_size`` attribute which is the hidden state size of its recurrent block.
    c                óŠ   •— t          ¦   «                              ¦   «          || _        || _        || _        |j        | _        d S r8   )r(   r)   Úmotion_encoderÚrecurrent_blockÚ	flow_headr    Úhidden_state_size)r1   r¿   rÀ   rÁ   r4   s       €r5   r)   zUpdateBlock.__init__&  sA   ø€ Ý‰Œ×ÒÑÔÐØ,ˆÔØ.ˆÔØ"ˆŒà!0Ô!<ˆÔÐÐr6   c                 ó¼   — |                       ||¦  «        }t          j        ||gd¬¦  «        }|                      ||¦  «        }|                      |¦  «        }||fS rŒ   )r¿   r�   r�   rÀ   rÁ   )r1   Úhidden_stateÚcontextr’   r‘   Úmotion_featuresr:   Ú
delta_flows           r5   r<   zUpdateBlock.forward.  sa   € Ø×-Ò-¨d°MÑBÔBˆÝŒI�w Ð0°aÐ8Ñ8Ô8ˆà×+Ò+¨L¸!Ñ<Ô<ˆØ—^’^ LÑ1Ô1ˆ
Ø˜ZÐ'Ð'r6   rJ   rC   s   @r5   r½   r½      sQ   ø€ € € € € ðð ð
=ð =ð =ð =ð =ð(ð (ð (ð (ð (ð (ð (r6   r½   c                   ó.   ‡ — e Zd ZdZddœˆ fd„
Zd„ Zˆ xZS )ÚMaskPredictorzÄMask predictor to be used when upsampling the predicted flow.

    It takes the hidden state of the recurrent unit as input and outputs the mask.
    This is not used in the raft-small model.
    ç      Ð?)Ú
multiplierc                óÀ   •— t          ¦   «                              ¦   «          t          ||d d¬¦  «        | _        t	          j        |ddd¬¦  «        | _        || _        d S )Nr	   r…   i@  r   r   r¸   )r(   r)   r   Úconvrelur,   rh   ri   rË   )r1   r2   r    rË   r4   s       €r5   r)   zMaskPredictor.__init__>  s\   ø€ Ý‰Œ×ÒÑÔÐÝ,¨[¸+ÐRVÐdeÐfÑfÔfˆŒõ ”I˜k¨9°aÀÐCÑCÔCˆŒ	ð %ˆŒˆˆr6   c                 ój   — |                       |¦  «        }|                      |¦  «        }| j        |z  S r8   )rÍ   ri   rË   r{   s     r5   r<   zMaskPredictor.forwardK  s/   € Ø�MŠM˜!ÑÔˆØ�IŠI�a‰LŒLˆØŒ Ñ"Ð"r6   rJ   rC   s   @r5   rÉ   rÉ   7  sb   ø€ € € € € ðð ð @Dð %ð %ð %ð %ð %ð %ð %ð#ð #ð #ð #ð #ð #ð #r6   rÉ   c                   óF   ‡ — e Zd ZdZdddœdedefˆ fd„Zd„ Zd„ Zd	„ Zˆ xZ	S )
Ú	CorrBlockaË  The correlation block.

    Creates a correlation pyramid with ``num_levels`` levels from the outputs of the feature encoder,
    and then indexes from this pyramid to create correlation features.
    The "indexing" of a given centroid pixel x' is done by concatenating its surrounding neighbors that
    are within a ``radius``, according to the infinity norm (see paper section 3.2).
    Note: typo in the paper, it should be infinity norm, not 1-norm.
    rG   ©Ú
num_levelsÚradiusrÒ   rÓ   c                ó¾   •— t          ¦   «                              ¦   «          || _        || _        t	          j        d¦  «        g| _        |d|z  dz   dz  z  | _        d S )Nr   r   r   )r(   r)   rÒ   rÓ   r�   ÚtensorÚcorr_pyramidr3   )r1   rÒ   rÓ   r4   s      €r5   r)   zCorrBlock.__init__[  s\   ø€ Ý‰Œ×ÒÑÔÐØ$ˆŒØˆŒå+0¬<¸©?¬?Ð*;ˆÔð '¨!¨f©*°q©.¸QÑ)>Ñ>ˆÔÐÐr6   c                 óZ  ‡	— |j         |j         k    r t          d|j         › d|j         › d�¦  «        ‚dd| j        dz
  z  z  Š	t          ˆ	fd„|j         dd…         D ¦   «         ¦  «        r,t          d	‰	› d
|j         dd…         › d‰	› dd‰	z  › d�	¦  «        ‚|                      ||¦  «        }|j         \  }}}}}}|                     ||z  |z  |||¦  «        }|g| _        t          | j        dz
  ¦  «        D ]3}t          j	        |dd¬¦  «        }| j         
                    |¦  «         Œ4dS )aL  Build the correlation pyramid from two feature maps.

        The correlation volume is first computed as the dot product of each pair (pixel_in_fmap1, pixel_in_fmap2)
        The last 2 dimensions of the correlation volume are then pooled num_levels times at different resolutions
        to build the correlation pyramid.
        z;Input feature maps should have the same shape, instead got z (fmap1.shape) != z (fmap2.shape)r   r   c              3   ó$   •K  — | ]
}|‰k     V — Œd S r8   r]   )Ú.0Ú	fmap_sizeÚmin_fmap_sizes     €r5   ú	<genexpr>z*CorrBlock.build_pyramid.<locals>.<genexpr>y  s(   øè è € ÐKÐK¨Yˆy˜=Ò(ÐKÐKÐKÐKÐKÐKr6   éþÿÿÿNzuFeature maps are too small to be down-sampled by the correlation pyramid. H and W of feature maps should be at least z; got: zv. Remember that input images to the model are downsampled by 8, so that means their dimensions should be at least 8 * z = é   ú.)r!   r   )Úshaperb   rÒ   ÚanyÚ_compute_corr_volumeÚreshaperÖ   ÚrangeÚFÚ
avg_pool2dÚappend)
r1   Úfmap1Úfmap2Úcorr_volumeÚ
batch_sizer¤   ÚwÚnum_channelsrª   rÛ   s
            @r5   Úbuild_pyramidzCorrBlock.build_pyramidh  sÁ  ø€ ð Œ;˜%œ+Ò%Ð%Ýð IÈeÌkð  Ið  IÐmrÔmxð  Ið  Ið  Iñô ð ð ˜Q 4¤?°QÑ#6Ñ7Ñ8ˆÝÐKÐKÐKÐK¸%¼+ÀbÀcÀcÔ:JÐKÑKÔKÑKÔKð 	Ýð\Ø>Kð\ð \ØTYÔT_Ð`bÐ`cÐ`cÔTdð\ð \ð 6Cð\ð \ð HIÈ=ÑGXð\ð \ð \ñô ð ð ×/Ò/°°uÑ=Ô=ˆà/:Ô/@Ñ,ˆ
�A�q˜,¨¨1Ø!×)Ò)¨*°q©.¸1Ñ*<¸lÈAÈqÑQÔQˆØ(˜MˆÔÝ�t”¨Ñ*Ñ+Ô+ð 	2ð 	2ˆAÝœ, {ÀÈ!ÐLÑLÔLˆKØÔ×$Ò$ [Ñ1Ô1Ð1Ð1ð	2ð 	2r6   c                 ó^  — d| j         z  dz   }t          j        | j          | j         |¦  «        }t          j        | j          | j         |¦  «        }t          j        t          j        ||d¬¦  «        d¬¦  «                             |j        ¦  «        }|                     d||d¦  «        }|j        \  }}}}	| 	                    dddd¦  «         
                    ||z  |	z  ddd¦  «        }g }
| j        D ]J}||z   }t          ||d	d
¬¦  «                             |||	d¦  «        }|
                     |¦  «         |dz  }ŒKt          j        |
d¬¦  «         	                    dddd¦  «                             ¦   «         }|| j        ||	f}|j        |k    rt#          d|› d|j        › �¦  «        ‚|S )z9Return correlation features by indexing from the pyramid.r   r   Úij)Úindexingr`   r�   r   r	   TÚbilinear)Úalign_cornersrZ   z6Output shape of index pyramid is incorrect. Should be z, got )rÓ   r�   ÚlinspaceÚstackÚmeshgridÚtoÚdeviceÚviewrà   Úpermuterã   rÖ   r   rç   r�   Ú
contiguousr3   rb   )r1   Úcentroids_coordsÚneighborhood_side_lenÚdiÚdjÚdeltarë   rª   r¤   rì   Úindexed_pyramidrê   Úsampling_coordsÚindexed_corr_volumer’   Úexpected_output_shapes                   r5   Úindex_pyramidzCorrBlock.index_pyramidŠ  sã  € à ! D¤K¡°!Ñ 3ÐÝŒ^˜Tœ[˜L¨$¬+Ð7LÑMÔMˆÝŒ^˜Tœ[˜L¨$¬+Ð7LÑMÔMˆÝ”�EœN¨2¨r¸DÐAÑAÔAÀrÐJÑJÔJ×MÒMÐN^ÔNeÑfÔfˆØ—
’
˜1Ð3Ð5JÈAÑNÔNˆà.Ô4Ñˆ
�A�q˜!Ø+×3Ò3°A°q¸!¸QÑ?Ô?×GÒGÈ
ÐUVÉÐYZÑHZÐ\]Ð_`ÐbcÑdÔdÐàˆØÔ,ð 	4ð 	4ˆKØ.°Ñ6ˆOÝ"-¨k¸?ÐZ^ÐeoÐ"pÑ"pÔ"p×"uÒ"uØ˜A˜q "ñ#ô #Ðð ×"Ò"Ð#6Ñ7Ô7Ð7Ø/°!Ñ3ÐÐåœ	 /°rÐ:Ñ:Ô:×BÒBÀ1ÀaÈÈAÑNÔN×YÒYÑ[Ô[ˆà!+¨TÔ->ÀÀ1Ð EÐØÔÐ"7Ò7Ð7ÝØ{ÐI^Ð{Ð{ÐfsÔfyÐ{Ð{ñô ð ð Ðr6   c                 óZ  — |j         \  }}}}|                     ||||z  ¦  «        }|                     ||||z  ¦  «        }t          j        |                     dd¦  «        |¦  «        }|                     |||d||¦  «        }|t          j        t          j        |¦  «        ¦  «        z  S )Nr   r   )rà   rù   r�   ÚmatmulÚ	transposeÚsqrtrÕ   )r1   rè   ré   rë   rí   r¤   rì   r“   s           r5   râ   zCorrBlock._compute_corr_volume¨  s�   € Ø).¬Ñ&ˆ
�L ! QØ—
’
˜: |°Q¸±UÑ;Ô;ˆØ—
’
˜: |°Q¸±UÑ;Ô;ˆåŒ|˜EŸOšO¨A¨qÑ1Ô1°5Ñ9Ô9ˆØ�yŠy˜ Q¨¨1¨a°Ñ3Ô3ˆØ•e”j¥¤¨lÑ!;Ô!;Ñ<Ô<Ñ<Ð<r6   )
r=   r>   r?   r@   Úintr)   rî   r  râ   rB   rC   s   @r5   rÐ   rÐ   Q  s”   ø€ € € € € ðð ð -.¸Qð ?ð ?ð ? cð ?°sð ?ð ?ð ?ð ?ð ?ð ?ð 2ð  2ð  2ðDð ð ð<=ð =ð =ð =ð =ð =ð =r6   rÐ   c                   ó2   ‡ — e Zd Zddœˆ fd„
Zddefd„Zˆ xZS )r   N)Úmask_predictorc                óô   •— t          ¦   «                              ¦   «          t          | ¦  «         || _        || _        || _        || _        || _        t          | j        d¦  «        st          d¦  «        ‚dS )a‚	  RAFT model from
        `RAFT: Recurrent All Pairs Field Transforms for Optical Flow <https://arxiv.org/abs/2003.12039>`_.

        args:
            feature_encoder (nn.Module): The feature encoder. It must downsample the input by 8.
                Its input is the concatenation of ``image1`` and ``image2``.
            context_encoder (nn.Module): The context encoder. It must downsample the input by 8.
                Its input is ``image1``. As in the original implementation, its output will be split into 2 parts:

                - one part will be used as the actual "context", passed to the recurrent unit of the ``update_block``
                - one part will be used to initialize the hidden state of the recurrent unit of
                  the ``update_block``

                These 2 parts are split according to the ``hidden_state_size`` of the ``update_block``, so the output
                of the ``context_encoder`` must be strictly greater than ``hidden_state_size``.

            corr_block (nn.Module): The correlation block, which creates a correlation pyramid from the output of the
                ``feature_encoder``, and then indexes from this pyramid to create correlation features. It must expose
                2 methods:

                - a ``build_pyramid`` method that takes ``feature_map_1`` and ``feature_map_2`` as input (these are the
                  output of the ``feature_encoder``).
                - a ``index_pyramid`` method that takes the coordinates of the centroid pixels as input, and returns
                  the correlation features. See paper section 3.2.

                It must expose an ``out_channels`` attribute.

            update_block (nn.Module): The update block, which contains the motion encoder, the recurrent unit, and the
                flow head. It takes as input the hidden state of its recurrent unit, the context, the correlation
                features, and the current predicted flow. It outputs an updated hidden state, and the ``delta_flow``
                prediction (see paper appendix A). It must expose a ``hidden_state_size`` attribute.
            mask_predictor (nn.Module, optional): Predicts the mask that will be used to upsample the predicted flow.
                The output channel must be 8 * 8 * 9 - see paper section 3.3, and Appendix B.
                If ``None`` (default), the flow is upsampled using interpolation.
        rÂ   zIThe update_block parameter should expose a 'hidden_state_size' attribute.N)
r(   r)   r   Úfeature_encoderÚcontext_encoderÚ
corr_blockÚupdate_blockr  Úhasattrrb   )r1   r  r  r  r  r  r4   s         €r5   r)   zRAFT.__init__³  sƒ   ø€ õH 	‰Œ×ÒÑÔÐÝ˜DÑ!Ô!Ð!à.ˆÔØ.ˆÔØ$ˆŒØ(ˆÔà,ˆÔå�tÔ(Ð*=Ñ>Ô>ð 	jÝÐhÑiÔiÐið	jð 	jr6   é   Únum_flow_updatesc           
      óœ  — |j         \  }}}}||f|j         dd …         k    r%t          d|› d|› d|j         dd …         › �¦  «        ‚|dz  dk    s|dz  dk    rt          d|› d|› d	�¦  «        ‚|                      t          j        ||gd¬
¦  «        ¦  «        }t          j        |dd¬¦  «        \  }	}
|	j         dd …         |dz  |dz  fk    rt          d¦  «        ‚| j                             |	|
¦  «         |                      |¦  «        }|j         dd …         |dz  |dz  fk    rt          d¦  «        ‚| j	        j
        }|j         d         |z
  }|dk    r!t          d|j         d         › d|› d�¦  «        ‚t          j        |||gd¬
¦  «        \  }}t          j        |¦  «        }t          j        |¦  «        }t          ||dz  |dz  ¦  «                             |	j        ¦  «        }t          ||dz  |dz  ¦  «                             |	j        ¦  «        }g }t%          |¦  «        D ]�}|                     ¦   «         }| j                             |¬¦  «        }||z
  }|  	                    ||||¦  «        \  }}||z   }| j        €d n|                      |¦  «        }t-          ||z
  |¬¦  «        }|                     |¦  «         Œž|S )NrÝ   z6input images should have the same shape, instead got (z, z) != rÞ   r   z:input image H and W should be divisible by 8, instead got z	 (h) and z (w)r�   r   )ÚchunksrŽ   z2The feature encoder should downsample H and W by 8z2The context encoder should downsample H and W by 8r   zThe context encoder outputs zA channels, but it should have at strictly more than hidden_state=z	 channels)rü   )r‘   Úup_mask)rà   rb   r  r�   r�   Úchunkr  rî   r  r  rÂ   Úsplitr£   rå   r0   r   r÷   rø   rä   Údetachr  r  r   rç   )r1   Úimage1Úimage2r  rë   rª   r¤   rì   Úfmapsrè   ré   Úcontext_outrÂ   Úout_channels_contextrÄ   rÅ   Úcoords0Úcoords1Úflow_predictionsr’   r‘   rÇ   r  Úupsampled_flows                           r5   r<   zRAFT.forwardä  sG  € à$œlÑˆ
�A�q˜!Øˆqˆ6�V”\ " # #Ô&Ò&Ð&ÝÐvÐVWÐvÐvÐ[\ÐvÐvÐciÔcoÐprÐpsÐpsÔctÐvÐvÑwÔwÐwØ�A‘˜’
�
  Q¡¨!¢ ÝÐmÐZ[ÐmÐmÐfgÐmÐmÐmÑnÔnÐnà×$Ò$¥U¤Y°¸Ð/?ÀQÐ%GÑ%GÔ%GÑHÔHˆÝ”{ 5°¸Ð:Ñ:Ô:‰ˆˆuØŒ;�r�s�sÔ  Q¡¨¨Q©Ð/Ò/Ð/ÝÐQÑRÔRÐRàŒ×%Ò% e¨UÑ3Ô3Ð3à×*Ò*¨6Ñ2Ô2ˆØÔ˜R˜S˜SÔ! a¨1¡f¨a°1©fÐ%5Ò5Ð5ÝÐQÑRÔRÐRð
 !Ô-Ô?ÐØ*Ô0°Ô3Ð6GÑGÐØ 1Ò$Ð$Ýð c¨{Ô/@ÀÔ/Cð  cð  cð  GXð  cð  cð  cñô ð õ !&¤¨KÐ:KÐMaÐ9bÐhiÐ jÑ jÔ jÑˆ�gÝ”z ,Ñ/Ô/ˆÝ”&˜‘/”/ˆå" :¨q°A©v°q¸A±vÑ>Ô>×AÒAÀ%Ä,ÑOÔOˆÝ" :¨q°A©v°q¸A±vÑ>Ô>×AÒAÀ%Ä,ÑOÔOˆàÐÝÐ'Ñ(Ô(ð 	4ð 	4ˆAØ—n’nÑ&Ô&ˆGØ œO×9Ò9È7Ð9ÑSÔSˆMà˜WÑ$ˆDØ'+×'8Ò'8¸ÀwÐP]Ð_cÑ'dÔ'dÑ$ˆL˜*à 
Ñ*ˆGà"Ô1Ð9�d�d¸t×?RÒ?RÐS_Ñ?`Ô?`ˆGÝ*°¸7Ñ1BÈWÐUÑUÔUˆNØ×#Ò# NÑ3Ô3Ð3Ð3àÐr6   )r  )r=   r>   r?   r)   r
  r<   rB   rC   s   @r5   r   r   ²  sm   ø€ € € € € Øeið /jð /jð /jð /jð /jð /jð /jðb1 ð 1 ¸ð 1 ð 1 ð 1 ð 1 ð 1 ð 1 ð 1 ð 1 r6   r   Úmin_size)rP   rP   c                   óš  — e Zd ZdZ edei e¥ddddiddidd	d
œdœddddœ¥¬¦  «        Z edei e¥ddddiddiddd
œdœddddœ¥¬¦  «        Z edei e¥ddddiddidœddddœ¥¬¦  «        Z	 edei e¥ddddiddidœddd dœ¥¬¦  «        Z
 ed!ei e¥ddd"d#d$iiddd%dœ¥¬¦  «        Z ed&ei e¥ddd"d#d'iiddd(dœ¥¬¦  «        Ze
Zd)S )*r   áÅ  The metrics reported here are as follows.

    ``epe`` is the "end-point-error" and indicates how far (in pixels) the
    predicted flow is from its true value. This is averaged over all pixels
    of all images. ``per_image_epe`` is similar, but the average is different:
    the epe is first computed on each image independently, and then averaged
    over all images. This corresponds to "Fl-epe" (sometimes written "F1-epe")
    in the original paper, and it's only used on Kitti. ``fl-all`` is also a
    Kitti-specific metric, defined by the author of the dataset and used for the
    Kitti leaderboard. It corresponds to the average of pixels whose epe is
    either <3px, or <5% of flow's 2-norm.
    zBhttps://download.pytorch.org/models/raft_large_C_T_V1-22a6c225.pthi@9P ú$https://github.com/princeton-vl/RAFTÚepegæ?¤ß¾÷?gÿ²{ò°P@gýöuàœ@gÞ“‡…Zs1@©Úper_image_epeÚfl_all©zSintel-Train-CleanpasszSintel-Train-FinalpasszKitti-TraingNbX9`j@g/Ý$!4@ú»These weights were ported from the original paper. They
            are trained on :class:`~torchvision.datasets.FlyingChairs` +
            :class:`~torchvision.datasets.FlyingThings3D`.©Ú
num_paramsÚrecipeÚ_metricsÚ_opsÚ
_file_sizeÚ_docs©ÚurlÚ
transformsÚmetazBhttps://download.pytorch.org/models/raft_large_C_T_V2-1bb1363a.pthúChttps://github.com/pytorch/vision/tree/main/references/optical_flowgÌH¿}ö?g&S£’º@g_˜L@gþe÷äa0@úŸThese weights were trained from scratch on
            :class:`~torchvision.datasets.FlyingChairs` +
            :class:`~torchvision.datasets.FlyingThings3D`.zGhttps://download.pytorch.org/models/raft_large_C_T_SKHT_V1-0b8c9e55.pthg
×£p=
ÿ?gq=
×£p	@)zSintel-Test-CleanpasszSintel-Test-Finalpassa0  
                These weights were ported from the original paper. They are
                trained on :class:`~torchvision.datasets.FlyingChairs` +
                :class:`~torchvision.datasets.FlyingThings3D` and fine-tuned on
                Sintel. The Sintel fine-tuning step is a combination of
                :class:`~torchvision.datasets.Sintel`,
                :class:`~torchvision.datasets.KittiFlow`,
                :class:`~torchvision.datasets.HD1K`, and
                :class:`~torchvision.datasets.FlyingThings3D` (clean pass).
            zGhttps://download.pytorch.org/models/raft_large_C_T_SKHT_V2-ff5fadd5.pthg´Èv¾Ÿý?gð§ÆK7‰@a/  
                These weights were trained from scratch. They are
                pre-trained on :class:`~torchvision.datasets.FlyingChairs` +
                :class:`~torchvision.datasets.FlyingThings3D` and then
                fine-tuned on Sintel. The Sintel fine-tuning step is a
                combination of :class:`~torchvision.datasets.Sintel`,
                :class:`~torchvision.datasets.KittiFlow`,
                :class:`~torchvision.datasets.HD1K`, and
                :class:`~torchvision.datasets.FlyingThings3D` (clean pass).
            zIhttps://download.pytorch.org/models/raft_large_C_T_SKHT_K_V1-4a6a5039.pthz
Kitti-Testr+  gffffff@a�  
                These weights were ported from the original paper. They are
                pre-trained on :class:`~torchvision.datasets.FlyingChairs` +
                :class:`~torchvision.datasets.FlyingThings3D`,
                fine-tuned on Sintel, and then fine-tuned on
                :class:`~torchvision.datasets.KittiFlow`. The Sintel fine-tuning
                step was described above.
            zIhttps://download.pytorch.org/models/raft_large_C_T_SKHT_K_V2-b5c70766.pthgÃõ(\�Â@a“  
                These weights were trained from scratch. They are
                pre-trained on :class:`~torchvision.datasets.FlyingChairs` +
                :class:`~torchvision.datasets.FlyingThings3D`,
                fine-tuned on Sintel, and then fine-tuned on
                :class:`~torchvision.datasets.KittiFlow`. The Sintel fine-tuning
                step was described above.
            N)r=   r>   r?   r@   r   r
   Ú_COMMON_METAÚC_T_V1ÚC_T_V2ÚC_T_SKHT_V1ÚC_T_SKHT_V2ÚC_T_SKHT_K_V1ÚC_T_SKHT_K_V2ÚDEFAULTr]   r6   r5   r   r     s�  € € € € € ðð ð ˆWàPØð
Øð
à!Ø<à+0°&¨/Ø+0°&¨/Ø17À7ÐKÐKðð ð
 Ø ð>ð
ð 
ð 
ð	ñ ô €Fð* ˆWØPØð
Øð
à!Ø[à+0°&¨/Ø+0°&¨/Ø17À7ÐKÐKðð ð
 Ø ð>ð
ð 
ð 
ðñ ô €Fð( �'àUØð
Øð
à!Ø<à*/°¨Ø*/°¨ðð ð Ø ð	ð
ð 
ð 
ð	ñ ô €Kð6 �'ØUØð
Øð
à!Ø[à*/°¨Ø*/°¨ðð ð Ø ð	ð
ð 
ð 
ðñ ô €Kð4 �GàWØð
Øð
à!Ø<à˜x¨Ð.ðð Ø ðð
ð 
ð 
ð	ñ ô €Mð0 �GØWØð
Øð
à!Ø[à˜x¨Ð.ðð Ø ðð
ð 
ð 
ðñ ô €Mð. €G€G€Gr6   r   c                   ó¦   — e Zd ZdZ edei e¥ddddiddidd	d
œdœddddœ¥¬¦  «        Z edei e¥ddddiddiddd
œdœddddœ¥¬¦  «        ZeZ	dS )r   r&  zBhttps://download.pytorch.org/models/raft_small_C_T_V1-ad48884c.pthiÒ r'  r(  gÎQÚü @g¬Zd;
@gåòÒoŸ@gœ3¢´G9@r)  r,  g¤p=
×ÓG@gÅ °rh‘@r-  r.  r5  zBhttps://download.pytorch.org/models/raft_small_C_T_V2-01064c6d.pthr9  gHPüs×ÿ?gûËîÉC
@gù1æ®%d@g"lxz¥<9@r:  N)
r=   r>   r?   r@   r   r
   r;  r<  r=  rB  r]   r6   r5   r   r   »  sÿ   € € € € € ðð ð ˆWàPØð
Øð
à Ø<à+0°&¨/Ø+0°&¨/Ø17À7ÐKÐKðð ð
 Øð>ð
ð 
ð 
ð	ñ ô €Fð( ˆWØPØð
Øð
à Ø[à+0°&¨/Ø+0°&¨/Ø17À7ÐKÐKðð ð
 Øð>ð
ð 
ð 
ðñ ô €Fð( €G€G€Gr6   r   F)ÚweightsÚprogressc           	      óº  — |                      dd ¦  «        pt          |||¬¦  «        }|                      dd ¦  «        pt          |||¬¦  «        }|                      dd ¦  «        pt          ||	¬¦  «        }|                      dd ¦  «        }|€at          |j        |
||¬¦  «        }|d         |z
  }t          |j        |z   |||¬	¦  «        }t          ||¬
¦  «        }t          |||¬¦  «        }|                      dd ¦  «        }|€|rt          |dd¬¦  «        }t          d|||||dœ|¤Ž}| �*| 
                    |                      |d¬¦  «        ¦  «         |S )Nr  )rR   rS   r    r  r  rÑ   r  )rŠ   r�   r‚   r3   r`   r±   )r2   r    )r¿   rÀ   rÁ   r  rQ   rÊ   )r2   r    rË   )r  r  r  r  r  T)rE  Ú
check_hashr]   )ÚpoprL   rÐ   r}   r3   r­   r¶   r½   rÉ   r   Úload_state_dictÚget_state_dict)rD  rE  Úfeature_encoder_layersÚfeature_encoder_blockÚfeature_encoder_norm_layerÚcontext_encoder_layersÚcontext_encoder_blockÚcontext_encoder_norm_layerÚcorr_block_num_levelsÚcorr_block_radiusÚmotion_encoder_corr_layersÚmotion_encoder_flow_layersÚmotion_encoder_out_channelsÚ!recurrent_block_hidden_state_sizeÚrecurrent_block_kernel_sizeÚrecurrent_block_paddingÚflow_head_hidden_sizeÚuse_mask_predictorÚkwargsr  r  r  r  r¿   r  rÀ   rÁ   r  Úmodels                                r5   Ú_raftr]  ô  sß  € ð: —j’jÐ!2°DÑ9Ô9ð ½^Ø#Ð,BÐOið>ñ >ô >€Oð —j’jÐ!2°DÑ9Ô9ð ½^Ø#Ð,BÐOið>ñ >ô >€Oð —’˜L¨$Ñ/Ô/Ðxµ9ÐH]ÐfwÐ3xÑ3xÔ3x€Jà—:’:˜n¨dÑ3Ô3€LØÐÝ&Ø'Ô4Ø2Ø2Ø4ð	
ñ 
ô 
ˆð  6°bÔ9Ð<]Ñ]ÐÝ(Ø%Ô2Ð5IÑIØ9Ø3Ø+ð	
ñ 
ô 
ˆõ Ð)JÐXmÐnÑnÔnˆ	å"°.ÐRaÐmvÐwÑwÔwˆà—Z’ZÐ 0°$Ñ7Ô7€NØÐÐ"4ÐÝ&Ø9ØØð
ñ 
ô 
ˆõ ð Ø'Ø'ØØ!Ø%ðð ð ðð €Eð ÐØ×Ò˜g×4Ò4¸hÐSWÐ4ÑXÔXÑYÔYÐYà€Lr6   Ú
pretrained)rD  TrD  Úreturnc                 óâ   — t                                | ¦  «        } t          di d| “d|“dd“dt          “dt          “dd“dt          “d	t
          “d
d“dd“dd“dd“dd“dd“dd“dd“dd“dd“|¤ŽS )aó  RAFT model from
    `RAFT: Recurrent All Pairs Field Transforms for Optical Flow <https://arxiv.org/abs/2003.12039>`_.

    Please see the example below for a tutorial on how to use this model.

    Args:
        weights(:class:`~torchvision.models.optical_flow.Raft_Large_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.optical_flow.Raft_Large_Weights`
            below for more details, and possible values. By default, no
            pre-trained weights are used.
        progress (bool): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.optical_flow.RAFT``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/optical_flow/raft.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.optical_flow.Raft_Large_Weights
        :members:
    rD  rE  rK  rM   rL  rM  rN  rO  rP  rQ  rG   rR  rS  r~   rT  r€   rU  rP   rV  rW  r®   rX  r¯   rY  rQ   rZ  Tr]   )r   Úverifyr]  r   r   r   ©rD  rE  r[  s      r5   r   r   G  s  € õ0 !×'Ò'¨Ñ0Ô0€Gåð ð ð Ø�ðà�ðð  6Ð5ð	õ
 ,˜mðõ $2 >ðð  6Ð5ðõ ,˜mðõ $/ ;ðð  ˜aðð ˜!ðð $. :ðð  $- 9ð!ð" %( Cð#ð& +.¨#ð'ð( %5Ð$4ð)ð* !1Ð 0ð+ð. "˜cð/ð2  ˜4Ø
ð5ð ð r6   c                 óØ   — t                                | ¦  «        } t          d i d| “d|“dd“dt          “dt          “dd“d	t          “d
d“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“|¤ŽS )!aü  RAFT "small" model from
    `RAFT: Recurrent All Pairs Field Transforms for Optical Flow <https://arxiv.org/abs/2003.12039>`__.

    Please see the example below for a tutorial on how to use this model.

    Args:
        weights(:class:`~torchvision.models.optical_flow.Raft_Small_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.optical_flow.Raft_Small_Weights`
            below for more details, and possible values. By default, no
            pre-trained weights are used.
        progress (bool): If True, displays a progress bar of the download to stderr. Default is True.
        **kwargs: parameters passed to the ``torchvision.models.optical_flow.RAFT``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/optical_flow/raft.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.optical_flow.Raft_Small_Weights
        :members:
    rD  rE  rK  )é    rd  rN   rO   rP   rL  rM  rN  )rd  rd  rN   rO   é    rO  rP  NrQ  rG   rR  r	   rS  )rO   rT  )rN   rd  rU  éR   rV  rO   rW  )r	   rX  )r   rY  rP   rZ  Fr]   )r   ra  r]  rE   r   rb  s      r5   r   r     s  € õ. !×'Ò'¨Ñ0Ô0€Gåð ð ð Ø�ðà�ðð  5Ð4ð	õ
 .˜oðõ $2 >ðð  5Ð4ðõ .˜oðð $( 4ðð  ˜aðð ˜!ðð $) 5ðð  $, 8ð!ð" %' Bð#ð& +-¨"ð'ð( %) Dð)ð* !% ð+ð. "˜cð/ð2 !˜5Ø
ð5ð ð r6   )3Útypingr   r   r�   Útorch.nnr,   Útorch.nn.functionalÚ
functionalrå   r   Útorch.nn.modules.batchnormr   Útorch.nn.modules.instancenormr   Útorchvision.opsr   Útransforms._presetsr
   Úutilsr   Ú_apir   r   r   Ú_utilsr   r   r   r   Ú__all__ÚModuler   rE   rL   r}   r—   r«   r­   r¶   r½   rÉ   rÐ   r   r;  r   r   r]  r?  r   r=  r   r]   r6   r5   ú<module>rt     sœ  ðØ !Ð !Ð !Ð !Ð !Ð !Ð !Ð !à €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0à .Ð .Ð .Ð .Ð .Ð .Ø (Ð (Ð (Ð (Ð (Ð (Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @ð€ð, ð , ð , ð , ð , �B”Iñ , ô , ð , ð^' ð ' ð ' ð ' ð ' �b”iñ ' ô ' ð ' ðT4ð 4ð 4ð 4ð 4�R”Yñ 4ô 4ð 4ðn(8ð (8ð (8ð (8ð (8�B”Iñ (8ô (8ð (8ðVð ð ð ð ˆbŒiñ ô ð ð$ð ð ð
 ð  ð  ð  ð  �R”Yñ  ô  ð  ðF4ð 4ð 4ð 4ð 4ˆrŒyñ 4ô 4ð 4ð (ð (ð (ð (ð (�"”)ñ (ô (ð (ð.#ð #ð #ð #ð #�B”Iñ #ô #ð #ð4^=ð ^=ð ^=ð ^=ð ^=�”	ñ ^=ô ^=ð ^=ðBc ð c ð c ð c ð c ˆ2Œ9ñ c ô c ð c ðN �
ð€ð
[ð [ð [ð [ð [˜ñ [ô [ð [ð|6ð 6ð 6ð 6ð 6˜ñ 6ô 6ð 6ðv ØðPð Pð Pð Pð Pðf €ÑÔØÐ ,Ð0BÔ0NÐ!OÐPÑPÔPØ:>Èð 3ð 3ð 3˜8Ð$6Ô7ð 3Ð\`ð 3ð 3ð 3ñ QÔPñ Ôð3ðl €ÑÔØÐ ,Ð0BÔ0IÐ!JÐKÑKÔKØ:>Èð 2ð 2ð 2˜8Ð$6Ô7ð 2Ð\`ð 2ð 2ð 2ñ LÔKñ Ôð2ð 2ð 2r6   