o
    ‹ÄŽiº  ã                	   @  s`   d dl mZ d dlmZ d dlmZ d dlmZ ddddd	d
dddœZg d¢Z	G dd„ dƒZ
dS )é    )Úannotations)ÚAny)ÚDetectionModel)Úimport_model_classÚUltralyticsDetectionModelÚRTDetrDetectionModelÚMmdetDetectionModelÚYolov5DetectionModelÚDetectron2DetectionModelÚHuggingfaceDetectionModelÚTorchVisionDetectionModelÚRoboflowDetectionModel)ÚultralyticsÚrtdetrÚmmdetÚyolov5Ú
detectron2ÚhuggingfaceÚtorchvisionÚroboflow)Úyolov8Úyolov11Úyolo11r   c                   @  s0   e Zd Ze										dddd„ƒZdS )ÚAutoDetectionModelNç      à?ç333333Ó?TÚ
model_typeÚstrÚ
model_pathú
str | NoneÚmodelú
Any | NoneÚconfig_pathÚdeviceÚmask_thresholdÚfloatÚconfidence_thresholdÚcategory_mappingúdict | NoneÚcategory_remappingÚload_at_initÚboolÚ
image_sizeú
int | NoneÚreturnr   c                 K  sB   | t v rd} t|  }t| |ƒ}|d|||||||||	|
dœ
|¤ŽS )a‚  Loads a DetectionModel from given path.

        Args:
            model_type: str
                Name of the detection framework (example: "ultralytics", "huggingface", "torchvision")
            model_path: str
                Path of the detection model (ex. 'model.pt')
            model: Any
                A pre-initialized model instance, if available
            config_path: str
                Path of the config file (ex. 'mmdet/configs/cascade_rcnn_r50_fpn_1x.py')
            device: str
                Device, "cpu" or "cuda:0"
            mask_threshold: float
                Value to threshold mask pixels, should be between 0 and 1
            confidence_threshold: float
                All predictions with score < confidence_threshold will be discarded
            category_mapping: dict: str to str
                Mapping from category id (str) to category name (str) e.g. {"1": "pedestrian"}
            category_remapping: dict: str to int
                Remap category ids based on category names, after performing inference e.g. {"car": 3}
            load_at_init: bool
                If True, automatically loads the model at initialization
            image_size: int
                Inference input size.

        Returns:
            Returns an instance of a DetectionModel

        Raises:
            ImportError: If given {model_type} framework is not installed
        r   )
r   r    r"   r#   r$   r&   r'   r)   r*   r,   N© )ÚULTRALYTICS_MODEL_NAMESÚMODEL_TYPE_TO_MODEL_CLASS_NAMEr   )r   r   r    r"   r#   r$   r&   r'   r)   r*   r,   ÚkwargsÚmodel_class_namer   r/   r/   úK/home/jeff/fluffinator/venv/lib/python3.10/site-packages/sahi/auto_model.pyÚfrom_pretrained   s$   /
öõz"AutoDetectionModel.from_pretrained)
NNNNr   r   NNTN)r   r   r   r   r    r!   r"   r   r#   r   r$   r%   r&   r%   r'   r(   r)   r(   r*   r+   r,   r-   r.   r   )Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr5   r/   r/   r/   r4   r      s    õr   N)Ú
__future__r   Útypingr   Úsahi.models.baser   Úsahi.utils.filer   r1   r0   r   r/   r/   r/   r4   Ú<module>   s    ø