o
    Vh
                     @   sD   d dl mZ d dlmZ ddlmZ ddlmZ G dd deZdS )	    )Path)Model   )FastSAMPredictor)FastSAMValidatorc                       s<   e Zd ZdZd fdd	Zd fdd	Zed	d
 Z  ZS )FastSAMaD  
    FastSAM model interface for segment anything tasks.

    This class extends the base Model class to provide specific functionality for the FastSAM (Fast Segment Anything Model)
    implementation, allowing for efficient and accurate image segmentation.

    Attributes:
        model (str): Path to the pre-trained FastSAM model file.
        task (str): The task type, set to "segment" for FastSAM models.

    Examples:
        >>> from ultralytics import FastSAM
        >>> model = FastSAM("last.pt")
        >>> results = model.predict("ultralytics/assets/bus.jpg")
    FastSAM-x.ptc                    s:   t |dkrd}t|jdvsJ dt j|dd dS )zDInitialize the FastSAM model with the specified pre-trained weights.z
FastSAM.ptr   >   .yml.yamlz/FastSAM models only support pre-trained models.segment)modeltaskN)strr   suffixsuper__init__)selfr   	__class__ T/var/www/vscode/kcb/lib/python3.10/site-packages/ultralytics/models/fastsam/model.pyr      s   zFastSAM.__init__FNc           	         s*   t ||||d}t j||fd|i|S )a  
        Perform segmentation prediction on image or video source.

        Supports prompted segmentation with bounding boxes, points, labels, and texts. The method packages these
        prompts and passes them to the parent class predict method.

        Args:
            source (str | PIL.Image | numpy.ndarray): Input source for prediction, can be a file path, URL, PIL image,
                or numpy array.
            stream (bool): Whether to enable real-time streaming mode for video inputs.
            bboxes (list): Bounding box coordinates for prompted segmentation in format [[x1, y1, x2, y2], ...].
            points (list): Point coordinates for prompted segmentation in format [[x, y], ...].
            labels (list): Class labels for prompted segmentation.
            texts (list): Text prompts for segmentation guidance.
            **kwargs (Any): Additional keyword arguments passed to the predictor.

        Returns:
            (list): List of Results objects containing the prediction results.
        )bboxespointslabelstextsprompts)dictr   predict)	r   sourcestreamr   r   r   r   kwargsr   r   r   r   r   #   s   zFastSAM.predictc                 C   s   dt tdiS )z[Returns a dictionary mapping segment task to corresponding predictor and validator classes.r   )	predictor	validator)r   r   )r   r   r   r   task_map:   s   zFastSAM.task_map)r   )FNNNN)	__name__
__module____qualname____doc__r   r   propertyr#   __classcell__r   r   r   r   r      s    r   N)	pathlibr   ultralytics.engine.modelr   r   r   valr   r   r   r   r   r   <module>   s
   