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_slowfastcreate_slowfast_with_roi_head)load_state_dict_from_urlz5https://dl.fbaipublicfiles.com/pytorchvideo/model_zooz/kinetics/SLOWFAST_8x8_R50.pythz$/ava/SLOWFAST_8x8_R50_DETECTION.pythz /kinetics/SLOWFAST_8x8_R101.pythz'/kinetics/SLOWFAST_16x8_R101_50_50.pyth)slowfast_r50slowfast_r50_detectionslowfast_r101slowfast_16x8_r101_50_50FT 
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   T/home/ubuntu/.local/lib/python3.10/site-packages/pytorchvideo/models/hub/slowfast.py	_slowfast   s   
r   c                 K      t d| |td ddd|S )a  
    SlowFast R50 model architecture [1] trained with an 8x8 setting on the
    Kinetics dataset. Model with pretrained weights has top1 accuracy of 76.4.

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

    Args:
        pretrained (bool): If True, returns a model pre-trained on 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/slowfast.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   2   )      r   r   r   r   model_depth slowfast_fusion_conv_kernel_sizeNr   r   checkpoint_pathsr   r   r   r   r   r   r   %      r   c                 K   r   )a  
    SlowFast R101 model architecture [1] trained with an 8x8 setting on the
    Kinetics dataset. Model with pretrained weights has top1 accuracy of 77.9.

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

    Args:
        pretrained (bool): If True, returns a model pre-trained on 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/slowfast.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	   e      r   r   r    Nr   r#   r%   r   r   r   r	   E   r&   r	   c              
   K   s&   d}t d| |td dd|dd|S )	a%  
    SlowFast R101_50_50 model architecture [1] trained with an 16x8 setting on the
    Kinetics dataset. Model with pretrained weights has top1 accuracy of 78.7.

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

    Args:
        pretrained (bool): If True, returns a model pre-trained on 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/slowfast.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*   r*   r*   r*   r*   r*   r*   r*   r*   r*   r*   r*   r*   r*   r*   r*   r*   r,   )r,   r,   r+   r,   r
   r'   r(   ))   r   r   )@   r   r   )r   r   r   r!   r"   stage_conv_a_kernel_sizeshead_pool_kernel_sizesNr   r#   )r   r   r   r0   r   r   r   r
   e   s   r
   c                 K   s   t d| |td td|S )aY  
    SlowFast R50 model architecture [1] with pretrained weights based on 8x8 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

    Args:
        pretrained (bool): If True, returns a model pre-trained on 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/slowfast.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   Nr   )r   r$   r   r%   r   r   r   r      s   r   )FT)typingr   r   torch.nnnnpytorchvideo.models.slowfastr   r   	torch.hubr   root_dirr$   boolstrModuler   r   r	   r
   r   r   r   r   r   <module>   s   	

!
!
2