§
    l¬¸jã  ã                  ó‚   — d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ  G d„ dej        j        ¦  «        Zd	S )
é    )Úannotations)Úcopy)ÚPath)Úyolo)ÚSegmentationModel)ÚDEFAULT_CFGÚRANKc                  ó<   ‡ — e Zd ZdZeddfdˆ fd„Zddd„Zd„ Zˆ xZS )ÚSegmentationTrainera¯  A class extending the DetectionTrainer class for training based on a segmentation model.

    This trainer specializes in handling segmentation tasks, extending the detection trainer with segmentation-specific
    functionality including model initialization, validation, and visualization.

    Attributes:
        loss_names (tuple[str]): Names of the loss components, derived from the loss dict returned by the criterion.

    Examples:
        >>> from ultralytics.models.yolo.segment import SegmentationTrainer
        >>> args = dict(model="yolo26n-seg.pt", data="coco8-seg.yaml", epochs=3)
        >>> trainer = SegmentationTrainer(overrides=args)
        >>> trainer.train()
    NÚ	overridesúdict | NoneÚ
_callbacksc                ó`   •— |€i }d|d<   t          ¦   «                              |||¦  «         dS )ad  Initialize a SegmentationTrainer object.

        Args:
            cfg (dict): Configuration dictionary with default training settings.
            overrides (dict, optional): Dictionary of parameter overrides for the default configuration.
            _callbacks (dict, optional): Dictionary of callback functions to be executed during training.
        NÚsegmentÚtask)ÚsuperÚ__init__)ÚselfÚcfgr   r   Ú	__class__s       €úu/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/ultralytics/models/yolo/segment/train.pyr   zSegmentationTrainer.__init__   s<   ø€ ð ÐØˆIØ%ˆ	�&ÑÝ‰Œ×Ò˜˜i¨Ñ4Ô4Ð4Ð4Ð4ó    Tr   údict | str | NoneÚweightsústr | Path | NoneÚverboseÚboolc           	     óÂ   — |                       t          || j        d         | j        d         |o
t          dk    ¬¦  «        ¦  «        }|r|                     |¦  «         |S )aÎ  Initialize and return a SegmentationModel with specified configuration and weights.

        Args:
            cfg (dict | str, optional): Model configuration. Can be a dictionary, a path to a YAML file, or None.
            weights (str | Path, optional): Path to pretrained weights file.
            verbose (bool): Whether to display model information during initialization.

        Returns:
            (SegmentationModel): Initialized segmentation model with loaded weights if specified.

        Examples:
            >>> trainer = SegmentationTrainer()
            >>> model = trainer.get_model(cfg="yolo26n-seg.yaml")
            >>> model = trainer.get_model(weights="yolo26n-seg.pt", verbose=False)
        ÚncÚchannelséÿÿÿÿ)r   Úchr   )Úset_model_names_for_loadr   Údatar	   Úload)r   r   r   r   Úmodels        r   Ú	get_modelzSegmentationTrainer.get_model*   sh   € ð  ×-Ò-Ý˜c d¤i°¤o¸$¼)ÀJÔ:OÐY`ÐYoÕeiÐmoÒeoÐpÑpÔpñ
ô 
ˆð ð 	 Ø�JŠJ�wÑÔÐàˆr   c                óŠ   — t           j                             | j        | j        t          | j        ¦  «        | j        ¬¦  «        S )zIReturn an instance of SegmentationValidator for validation of YOLO model.)Úsave_dirÚargsr   )r   r   ÚSegmentationValidatorÚtest_loaderr)   r   r*   Ú	callbacks)r   s    r   Úget_validatorz!SegmentationTrainer.get_validatorB   s;   € åŒ|×1Ò1ØÔ t¤}½4ÀÄ	¹?¼?ÐW[ÔWeð 2ñ 
ô 
ð 	
r   )r   r   r   r   )NNT)r   r   r   r   r   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r'   r.   Ú__classcell__)r   s   @r   r   r      s~   ø€ € € € € ðð ð 'ÀÐaeð 5ð 5ð 5ð 5ð 5ð 5ð 5ðð ð ð ð ð0
ð 
ð 
ð 
ð 
ð 
ð 
r   r   N)Ú
__future__r   r   Úpathlibr   Úultralytics.modelsr   Úultralytics.nn.tasksr   Úultralytics.utilsr   r	   ÚdetectÚDetectionTrainerr   © r   r   ú<module>r<      s²   ðð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à #Ð #Ð #Ð #Ð #Ð #Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /ð9
ð 9
ð 9
ð 9
ð 9
˜$œ+Ô6ñ 9
ô 9
ð 9
ð 9
ð 9
r   