o
    oi^	                     @  sx   d dl mZ d dlZd dlmZmZ d dlmZmZm	Z	m
Z
mZ d dlZd dlmZ e
dZG dd deeee ZdS )	    )annotationsN)ABCabstractmethod)AnyGenericOptionalTypeVarcast)ModuleModelConfigc                   @  sH   e Zd ZdZddd	d
Zeed ddZdddddddd!ddZdS )"	ModelBasez2Abstract model class with some utilities function.N
checkpointstrdeviceOptional[torch.device]returnNonec                 C  sd   t j|r#t|d}tj||d}W d   n1 sw   Y  ntjj||d}| | dS )zLoad checkpoint from a given url or file.

        Args:
            checkpoint: The url or filepath for the respective checkpoint
            device: The desired device to load the weights and move the model

        rb)map_locationN)	ospathisfileopentorchloadhubload_state_dict_from_urlload_state_dict)selfr   r   f
state_dict r!   N/home/ubuntu/.local/lib/python3.10/site-packages/kornia/contrib/models/base.pyload_checkpoint"   s   zModelBase.load_checkpointconfigr   ModelBase[ModelConfig]c                 C  s   t )zsBuild/load the model.

        Args:
            config: The specifications for the model be build/loaded

        )NotImplementedError)r$   r!   r!   r"   from_config2   s   	zModelBase.from_configFinductor	fullgraphdynamicbackendmodeoptionsdisabler*   boolr+   r,   r-   Optional[str]r.   Optional[dict[Any, Any]]r/   c             	   C  s*   t j| ||||||d}ttt |}|S )Nr)   )r   compiler	   r   r   )r   r*   r+   r,   r-   r.   r/   compiledr!   r!   r"   r3   =   s
   
zModelBase.compile)N)r   r   r   r   r   r   )r$   r   r   r%   )r*   r0   r+   r0   r,   r   r-   r1   r.   r2   r/   r0   r   r%   )	__name__
__module____qualname____doc__r#   staticmethodr   r'   r3   r!   r!   r!   r"   r      s    r   )
__future__r   r   abcr   r   typingr   r   r   r   r	   r   kornia.corer
   r   r   r!   r!   r!   r"   <module>   s   