o
    ϯi                     @   s  d dl mZmZ d dlmZ d dlmZmZ d dlm	Z	 	 dZ
e
 de
 de
 de
 d	d
ZdddefdedededededejfddZ	ddedededejfddZ	ddedededejfddZ	ddedededejfddZ	ddedededejfddZdS )    )AnyCallableN)create_resnetcreate_resnet_with_roi_head)load_state_dict_from_urlz5https://dl.fbaipublicfiles.com/pytorchvideo/model_zooz/kinetics/SLOW_8x8_R50.pythz!/ava/SLOW_4x16_R50_DETECTION.pythz/kinetics/C2D_8x8_R50.pythz/kinetics/I3D_8x8_R50.pyth)slow_r50slow_r50_detectionc2d_r50i3d_r50FT 
pretrainedprogresscheckpoint_pathmodel_builderkwargsreturnc                 K   s6   |di |}| rt ||dd}|d }|| |S )Ncpu)r   map_locationmodel_state )r   load_state_dict)r   r   r   r   r   model
checkpoint
state_dictr   r   R/home/ubuntu/.local/lib/python3.10/site-packages/pytorchvideo/models/hub/resnet.py_resnet   s   
r   c              	   K   s    t d| |td dddd|S )a4  
    Slow R50 model architecture [1] with pretrained weights based on 8x8 setting
    on the Kinetics dataset. Model with pretrained weights has top1 accuracy of 74.58.

    [1] "SlowFast Networks for Video Recognition"
        Christoph Feichtenhofer et al
        https://arxiv.org/pdf/1812.03982.pdf

    Args:
        pretrained (bool): If True, returns a model pre-trained on the Kinetics dataset
        progress (bool): If True, displays a progress bar of the download to stderr
        kwargs: use these to modify any of the other model settings. All the
            options are defined in pytorchvideo/models/resnet.py

    NOTE: to use the pretrained model, do not modify the model configuration
    via the kwargs. Only modify settings via kwargs to initialize a new model
    without pretrained weights.
    r         r   )   r   r   2   )r   r   r   stem_conv_kernel_sizehead_pool_kernel_sizemodel_depthNr   )r   checkpoint_pathsr   r   r   r   r   r   r   )   s   r   c                 K   s   t d| |td td|S )aW  
    Slow R50 model architecture [1] with pretrained weights based on 4x16 setting.
    The model is initially trained on Kinetics dataset for classification and later
    finetuned on AVA dataset for detection.

    [1] Christoph Feichtenhofer et al, "SlowFast Networks for Video Recognition"
        https://arxiv.org/pdf/1812.03982.pdf
    r   )r   r   r   r   Nr   )r   r$   r   r%   r   r   r   r   I   s   r   c              	   K   s"   t d| |td dtjdd|S )a  
    C2D R50 model architecture with pretrained weights based on 8x8 setting
    on the Kinetics dataset. Model with pretrained weights has top1 accuracy of 71.46.

    Args:
        pretrained (bool): If True, returns a model pre-trained on the Kinetics dataset
        progress (bool): If True, displays a progress bar of the download to stderr
        kwargs: use these to modify any of the other model settings. All the
            options are defined in pytorchvideo/models/resnet.py

    NOTE: to use the pretrained model, do not modify the model configuration
    via the kwargs. Only modify settings via kwargs to initialize a new model
    without pretrained weights.
    r	   r   )r   r   r   r&   r&   r&   r   r   r   r!   stage1_poolstage_conv_a_kernel_sizeNr   r   r$   nn	MaxPool3dr%   r   r   r   r	   ]   s   r	   c                 K   s6   t d| |td dtjdddgddgddgfd|S )aR  
    I3D R50 model architecture from [1] with pretrained weights based on 8x8 setting
    on the Kinetics dataset. Model with pretrained weights has top1 accuracy of 73.27.

    [1] "Quo Vadis, Action Recognition? A New Model and the Kinetics Dataset"
        Joao Carreira, Andrew Zisserman
        https://arxiv.org/abs/1705.07750

    Args:
        pretrained (bool): If True, returns a model pre-trained on the Kinetics dataset
        progress (bool): If True, displays a progress bar of the download to stderr
        kwargs: use these to modify any of the other model settings. All the
            options are defined in pytorchvideo/models/resnet.py

    NOTE: to use the pretrained model, do not modify the model configuration
    via the kwargs. Only modify settings via kwargs to initialize a new model
    without pretrained weights.
    r
   )   r   r   )   r   r   r&   r'   Nr   r*   r%   r   r   r   r
   ~   s   r
   )FT)typingr   r   torch.nnr+   pytorchvideo.models.resnetr   r   	torch.hubr   root_dirr$   boolstrModuler   r   r   r	   r
   r   r   r   r   <module>   s   	

!

"