§
    l¬¸j|7  ã                  ó¨   — d dl mZ d dlmZ d dlZd dlmc mZ d dlmZ d dl	m
Z
 d dlmZ ddlmZ  G d	„ d
¦  «        Z G d„ dej        ¦  «        ZdS )é    )Úannotations)ÚPathN)Únn)ÚDetect)Ú	copy_attré   )Úload_checkpointc                  ó"   — e Zd ZdZdd„Zdd„ZdS )ÚFeatureHookzCPicklable forward hook that stores layer output into a shared dict.Ú	feat_dictÚdictÚidxÚintÚreturnÚNonec                ó"   — || _         || _        dS )z\Initialize the hook with the shared feature dict and the layer index to store outputs under.N©r   r   )Úselfr   r   s      úl/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/ultralytics/nn/distill_model.pyÚ__init__zFeatureHook.__init__   s   € à"ˆŒØˆŒˆˆó    Úmoduleú	nn.ModuleÚinputsÚtuplec                ó$   — || j         | j        <   dS )zÄStore the layer's forward output into the shared feature dict under its index.

        The output is a tensor for neck layers but a tuple/dict for the Detect head, so it is left untyped.
        Nr   )r   r   r   Úoutputs       r   Ú__call__zFeatureHook.__call__   s   € ð
 $*ˆŒ�t”xÑ Ð Ð r   N)r   r   r   r   r   r   )r   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r      sB   € € € € € ØMÐMðð ð ð ð
*ð *ð *ð *ð *ð *r   r   c                  ó(  ‡ — e Zd ZdZd1ˆ fd„Zd„ Zd„ Zd2d„Zed3d„¦   «         Z	d2d„Z
ed4d„¦   «         Zd„ Zd5d6ˆ fd„Zd„ Zd7d8d„Zd9d„Zd:d&„Zed'„ ¦   «         Zej        d2d(„¦   «         Zd)„ Zed*„ ¦   «         Zej        d+„ ¦   «         Zd,„ Zd;d<d0„Zˆ xZS )=ÚDistillationModelaé  YOLO knowledge distillation model.

    This class wraps a teacher-student pair for knowledge distillation training. Features are extracted from both models
    via forward hooks for distillation.

    Attributes:
        teacher_model (nn.Module): Frozen teacher model providing features.
        student_model (nn.Module): Trainable student model being distilled.
        feats_idx (list): Layer indices for feature extraction.
        projector (nn.ModuleList): MLP projector aligning student features to teacher dimensions.
        dis (float): Distillation loss weight factor.

    Methods:
        get_distill_layers: Auto-detect distillation feature layers from the Detect head.
        forward: Run the student model, or compute the combined loss when given a training batch.
        loss: Compute combined detection and distillation loss.
        loss_sl2: Compute score-weighted L2 distillation loss for a feature pair.
        decouple_outputs: Normalize teacher/student head outputs across train/val formats.
        fuse: Fuse and return the student model for inference and export.
        train: Set training mode while keeping teacher frozen.

    Examples:
        Train a student model with knowledge distillation from a larger teacher (the trainer builds the
        DistillationModel internally when the ``distill_model`` argument is set)
        >>> from ultralytics import YOLO
        >>> model = YOLO("yolo26n.pt")
        >>> model.train(data="coco8.yaml", distill_model="yolo26s.pt")
    Úteacher_modelústr | Path | nn.ModuleÚstudent_modelr   c                óÄ  •‡ — t          ¦   «                              ¦   «          |j                             dd¦  «        }t	          |t
          t          f¦  «        r‰t          |¦  «        d         }|j                             dd¦  «        |k    rU|} t          |¦  «        |j         	                    ¦   «         ||j        d         d¬¦  «        }| 
                    |¦  «         t          |                     ¦   «         ¦  «        j        }|                     |¦  «        ‰ _        ‰                      ¦   «          |‰ _        ‰                      |¦  «        ‰ _        i ‰ _        i ‰ _        g ‰ _        g ‰ _        ‰                      ¦   «          |j        j        }|                     ¦   «          t9          j        ¦   «         5  t9          j        d||||¬¦  «        } ||¦  «          ||¦  «         d	d	d	¦  «         n# 1 swxY w Y   |                     ¦   «          ˆ fd
„‰ j        D ¦   «         }ˆ fd„‰ j        D ¦   «         }	tA          ‰ |¦  «         ‰ j        j        j!        ‰ _!        g }
tE          |	d	d…         |d	d…         ¦  «        D ]¯\  }}‰  #                    |¦  «        j$        d         }‰  #                    |¦  «        j$        d         }|
 %                    tM          j'        tM          j(        ||ddd¬¦  «        tM          j)        d¬¦  «        tM          j(        ||ddd¬¦  «        ¦  «        ¦  «         Œ°tM          j*        |
¦  «                             |¦  «        ‰ _+        d	S )a  Initialize the distillation model with teacher, student, and feature extraction hooks.

        Args:
            teacher_model (str | Path | nn.Module): Teacher model checkpoint path or module.
            student_model (nn.Module): Student model module to be trained.
        Úchannelsé   r   ÚncF)Úchr,   Úverboseé   ©ÚdeviceNc                ó*   •— g | ]}‰j         |         ‘ŒS r#   ©Ú_teacher_feats©Ú.0r   r   s     €r   ú
<listcomp>z.DistillationModel.__init__.<locals>.<listcomp>c   ó!   ø€ ÐMÐMÐM°s˜$Ô-¨cÔ2ÐMÐMÐMr   c                ó*   •— g | ]}‰j         |         ‘ŒS r#   )Ú_student_featsr5   s     €r   r7   z.DistillationModel.__init__.<locals>.<listcomp>d   r8   r   éÿÿÿÿr   )Úkernel_sizeÚstrideÚpaddingT)Úinplace),Úsuperr   ÚyamlÚgetÚ
isinstanceÚstrr   r	   ÚtypeÚcopyÚloadÚnextÚ
parametersr1   Útor&   Ú_freeze_teacherr(   Úget_distill_layersÚ	feats_idxr4   r:   Ú_teacher_hooksÚ_student_hooksÚ_register_feature_hooksÚargsÚimgszÚevalÚtorchÚno_gradÚzerosÚtrainr   ÚdisÚzipÚdecouple_outputsÚshapeÚappendr   Ú
SequentialÚConv2dÚReLUÚ
ModuleListÚ	projector)r   r&   r(   r-   Úweightsr1   rR   ÚimÚteacher_outputÚstudent_outputÚ
projectorsÚstudent_outÚteacher_outÚstudent_dimÚteacher_dimÚ	__class__s   `              €r   r   zDistillationModel.__init__?   s‚  øø€ õ 	‰Œ×ÒÑÔÐØÔ×#Ò# J°Ñ2Ô2ˆÝ�m¥c­4 [Ñ1Ô1ð 	,Ý+¨MÑ:Ô:¸1Ô=ˆMØÔ!×%Ò% j°!Ñ4Ô4¸Ò:Ð:Ø'�Ø -¥ W¡¤¨g¬l×.?Ò.?Ñ.AÔ.AÀbÈWÌ\ÐZ^ÔM_ÐinÐ oÑ oÔ o�Ø×"Ò" 7Ñ+Ô+Ð+Ý�m×.Ò.Ñ0Ô0Ñ1Ô1Ô8ˆØ*×-Ò-¨fÑ5Ô5ˆÔØ×ÒÑÔÐØ*ˆÔØ×0Ò0°Ñ?Ô?ˆŒð 8:ˆÔØ79ˆÔØ$&ˆÔØ$&ˆÔØ×$Ò$Ñ&Ô&Ð&ð Ô"Ô(ˆØ×ÒÑÔÐÝŒ]‰_Œ_ð 	ð 	Ý”˜Q  E¨5¸Ð@Ñ@Ô@ˆBØˆM˜"ÑÔÐØˆM˜"ÑÔÐð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	×ÒÑÔÐØMÐMÐMÐM¸d¼nÐMÑMÔMˆØMÐMÐMÐM¸d¼nÐMÑMÔMˆå�$˜Ñ&Ô&Ð&ØÔ%Ô*Ô.ˆŒØˆ
Ý(+¨N¸3¸B¸3Ô,?ÀÐPSÐQSÐPSÔATÑ(UÔ(Uð 		ð 		Ñ$ˆK˜Ø×/Ò/°Ñ<Ô<ÔBÀ1ÔEˆKØ×/Ò/°Ñ<Ô<ÔBÀ1ÔEˆKØ×ÒÝ”Ý”I˜k¨;ÀAÈaÐYZÐ[Ñ[Ô[Ý”G DÐ)Ñ)Ô)Ý”I˜k¨;ÀAÈaÐYZÐ[Ñ[Ô[ñô ñô ð ð õ œ zÑ2Ô2×5Ò5°fÑ=Ô=ˆŒˆˆs   Æ;0G7Ç7G;Ç>G;c                ó°   — | j                              ¦   «          | j                             ¦   «          | j                             ¦   «         }g |d<   g |d<   |S )aŠ  Return a copy of state for pickling without captured features or hook handles.

        Clears the feature dicts in place (rather than replacing the attributes) because the registered
        FeatureHooks share these exact dict objects; otherwise a deepcopy/pickle of a mid-training model would
        still reach the hook-held tensors (which carry grad_fn and cannot be deep-copied).
        rN   rO   )r4   Úclearr:   Ú__dict__rF   ©r   Ústates     r   Ú__getstate__zDistillationModel.__getstate__u   s\   € ð 	Ô×!Ò!Ñ#Ô#Ð#ØÔ×!Ò!Ñ#Ô#Ð#Ø”×"Ò"Ñ$Ô$ˆØ"$ˆÐÑØ"$ˆÐÑØˆr   c                ó~   — | j                              |¦  «         i | _        i | _        |                      ¦   «          dS )zOClear stale features and hooks, and re-register forward hooks after unpickling.N)rn   Úupdater4   r:   rP   ro   s     r   Ú__setstate__zDistillationModel.__setstate__ƒ   s@   € àŒ×Ò˜UÑ#Ô#Ð#Ø ˆÔØ ˆÔØ×$Ò$Ñ&Ô&Ð&Ð&Ð&r   r   r   c                óô   — | j         D ]}|                     ¦   «          Œ| j                              ¦   «          | j        �9| j        D ]}|                     ¦   «          Œ| j                             ¦   «          dS dS )z7Remove any previously registered feature-capture hooks.N)rO   Úremoverm   r&   rN   )r   Úhandles     r   Ú_remove_feature_hooksz'DistillationModel._remove_feature_hooksŠ   s…   € àÔ)ð 	ð 	ˆFØ�MŠM‰OŒOˆOˆOØÔ×!Ò!Ñ#Ô#Ð#ØÔÐ)ØÔ-ð  ð  �Ø—’‘”��ØÔ×%Ò%Ñ'Ô'Ð'Ð'Ð'ð *Ð)r   r   c                ó˜   — t          | j                             ¦   «         ¦  «        D ]"\  }}t          |t          ¦  «        r| j        |= Œ#dS )z?Remove any FeatureHook instances from a module's forward hooks.N)ÚlistÚ_forward_hooksÚitemsrC   r   )r   Ú	handle_idÚhooks      r   Ú_clear_feature_hooksz&DistillationModel._clear_feature_hooks”   sV   € õ  $ FÔ$9×$?Ò$?Ñ$AÔ$AÑBÔBð 	5ð 	5‰OˆI�tÝ˜$¥Ñ,Ô,ð 5ØÔ)¨)Ð4øð	5ð 	5r   c           	     ó$  — |                       ¦   «          | j        D ]ó}|                      | j        j        |         ¦  «         | j                             | j        j        |                              t          | j	        |¦  «        ¦  «        ¦  «         | j
        �u|                      | j
        j        |         ¦  «         | j                             | j
        j        |                              t          | j        |¦  «        ¦  «        ¦  «         ŒôdS )zKRegister feature-capture hooks, removing stale FeatureHook instances first.N)rx   rM   r   r(   ÚmodelrO   r\   Úregister_forward_hookr   r:   r&   rN   r4   )r   r   s     r   rP   z)DistillationModel._register_feature_hooks›   s  € à×"Ò"Ñ$Ô$Ð$Ø”>ð 		ð 		ˆCØ×%Ò% dÔ&8Ô&>¸sÔ&CÑDÔDÐDØÔ×&Ò&ØÔ"Ô(¨Ô-×CÒCÅKÐPTÔPcÐehÑDiÔDiÑjÔjñô ð ð Ô!Ð-Ø×)Ò)¨$Ô*<Ô*BÀ3Ô*GÑHÔHÐHØÔ#×*Ò*ØÔ&Ô,¨SÔ1×GÒGÍÐTXÔTgÐilÑHmÔHmÑnÔnñô ð øð		ð 		r   r�   ú	list[int]c                óœ   — | j         D ]6}t          |t          ¦  «        rg t          |j        ¦  «        ¢|j        ‘c S Œ7t          d¦  «        ‚)zìAuto-detect distillation feature layers from the model's Detect head.

        Returns the Detect head's input layer indices plus the head layer index itself.
        E.g. YOLO26 -> [16, 19, 22, 23], YOLOv8 -> [15, 18, 21, 22].
        zNo Detect head found in model)r�   rC   r   rz   ÚfÚiÚ
ValueError)r�   Úms     r   rL   z$DistillationModel.get_distill_layers©   s[   € ð ”ð 	)ð 	)ˆAÝ˜!�VÑ$Ô$ð )Ø(�˜aœc™œÐ( A¤CÐ(Ð(Ð(Ð(ð)åÐ8Ñ9Ô9Ð9r   c                óž   — | j         €dS | j                              ¦   «          | j                              ¦   «         D ]}|j        rd|_        ŒdS )z$Keep teacher fixed for distillation.NF)r&   rS   rI   Úrequires_grad)r   Úvs     r   rK   z!DistillationModel._freeze_teacherµ   s_   € àÔÐ%ØˆFØÔ×ÒÑ!Ô!Ð!ØÔ#×.Ò.Ñ0Ô0ð 	(ð 	(ˆAØŒð (Ø"'�”øð	(ð 	(r   TÚmodeÚboolc                ór   •— t          ¦   «                              |¦  «         |                      ¦   «          | S )z?Set model train mode while keeping teacher frozen in eval mode.)r@   rW   rK   )r   rŒ   rk   s     €r   rW   zDistillationModel.train¾   s0   ø€ å‰Œ�Š�dÑÔÐØ×ÒÑÔÐØˆr   c                óz   — t          |t          ¦  «        r | j        |g|¢R i |¤ŽS  | j        j        |g|¢R i |¤ŽS )z'Forward pass through the student model.)rC   r   Úlossr(   Úpredict)r   ÚxrQ   Úkwargss       r   ÚforwardzDistillationModel.forwardÄ   s\   € å�a�ÑÔð 	1Ø�4”9˜QÐ0 Ð0Ð0Ð0¨Ð0Ð0Ð0Ø)ˆtÔ!Ô)¨!Ð=¨dÐ=Ð=Ð=°fÐ=Ð=Ð=r   é€  r.   rR   úint | list[int, int]c                ób   — |                       ¦   «          | j                             ||¬¦  «        S )zSFuse and return the student model, dropping the training-only distillation wrapper.)r.   rR   )rx   r(   Úfuse)r   r.   rR   s      r   r˜   zDistillationModel.fuseÊ   s0   € à×"Ò"Ñ$Ô$Ð$ØÔ!×&Ò&¨w¸eÐ&ÑDÔDÐDr   Nc                óž  ‡ — t          j        d|d         j        ¬¦  «        }‰ j        sj|€‰                      |d         ¦  «        }‰ j                             ||¦  «        \  }}|                     ¦   «         |d<   t          j        ||g¦  «        |fS ‰ j         	                    ¦   «          ‰ j
         	                    ¦   «          t          j        ¦   «         5  ‰                      |d         ¦  «         ddd¦  «         n# 1 swxY w Y   ‰                      |d         ¦  «        }‰ j                             ||¦  «        \  }}‰ j        ‰ j        d                  }‰                      |d¬¦  «        d	         ‰                      |d
¬¦  «        d	         z   dz  }ˆ fd„‰ j        dd…         D ¦   «         }t          j        |d„ |D ¦   «         d¬¦  «        }	t!          d„ |	D ¦   «         ¦  «        }t#          ‰ j        dd…         ¦  «        D ]}\  }
}‰                      ‰ j        |         ¦  «        } ‰ j        |
         ‰                      ‰ j
        |         ¦  «        ¦  «        }|‰                      |||
|¬¦  «        ‰ j        z  z  }Œ~|                     ¦   «         |d<   ||d         j        d         z  }t          j        ||g¦  «        |fS )z§Compute loss.

        Args:
            batch (dict): Batch to compute loss on.
            preds (torch.Tensor | list[torch.Tensor], optional): Predictions.
        r   Úimgr0   NÚdis_lossr;   Úone2many)ÚbranchÚscoresÚone2oner/   c                ó*   •— g | ]}‰j         |         ‘ŒS r#   r3   r5   s     €r   r7   z*DistillationModel.loss.<locals>.<listcomp>í   s!   ø€ ÐNÐNÐN°3�dÔ)¨#Ô.ÐNÐNÐNr   c                óD   — g | ]}|j         d          |j         d         z  ‘ŒS )éþÿÿÿr;   )r[   )r6   r…   s     r   r7   z*DistillationModel.loss.<locals>.<listcomp>î   s)   € Ð,[Ð,[Ð,[È1¨Q¬W°R¬[¸1¼7À2¼;Ñ-FÐ,[Ð,[Ð,[r   )Údimc              3  ór   K  — | ]2}|                      ¦   «                              d d¬¦  «        j        V — Œ3dS )r   T)r£   ÚkeepdimN)ÚsigmoidÚmaxÚvalues)r6   Úps     r   ú	<genexpr>z)DistillationModel.loss.<locals>.<genexpr>ï   s=   è è € ÐZÐZÈq˜qŸyšy™{œ{Ÿš°1¸d˜ÑCÔCÔJÐZÐZÐZÐZÐZÐZr   )Úfeat_idxÚteacher_scoresr   )rT   rV   r1   Útrainingr(   r�   ÚdetachÚcatr4   rm   r:   rU   r&   rM   rZ   Úsplitr   Ú	enumeratera   Úloss_sl2rX   r[   )r   ÚbatchÚpredsÚloss_distillÚregular_lossÚ
loss_itemsÚteacher_head_featr¬   Ú
neck_featsÚpartsr†   r«   Úteacher_featÚstudent_feats   `             r   r�   zDistillationModel.lossÏ   s  ø€ õ ”{ 1¨U°5¬\Ô-@ÐAÑAÔAˆØŒ}ð 	GØˆ}Ø×*Ò*¨5°¬<Ñ8Ô8�Ø'+Ô'9×'>Ò'>¸uÀeÑ'LÔ'LÑ$ˆL˜*Ø%1×%8Ò%8Ñ%:Ô%:ˆJ�zÑ"Ý”9˜l¨LÐ9Ñ:Ô:¸JÐFÐFð 	Ô×!Ò!Ñ#Ô#Ð#ØÔ×!Ò!Ñ#Ô#Ð#åŒ]‰_Œ_ð 	-ð 	-Ø×Ò˜u Uœ|Ñ,Ô,Ð,ð	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-à×"Ò" 5¨¤<Ñ0Ô0ˆà#'Ô#5×#:Ò#:¸5À%Ñ#HÔ#HÑ ˆ�jØ Ô/°´¸rÔ0BÔCÐà×!Ò!Ð"3¸JÐ!ÑGÔGÈÔQØ×#Ò#Ð$5¸iÐ#ÑHÔHÈÔRñSàñˆð
 OÐNÐNÐN¸$¼.ÈÈ"ÈÔ:MÐNÑNÔNˆ
Ý”˜NÐ,[Ð,[ÐPZÐ,[Ñ,[Ô,[ÐacÐdÑdÔdˆÝÐZÐZÐTYÐZÑZÔZÑZÔZˆÝ$ T¤^°C°R°CÔ%8Ñ9Ô9ð 	ð 	‰KˆAˆxØ×0Ò0°Ô1DÀXÔ1NÑOÔOˆLØ,˜4œ>¨!Ô,¨T×-BÒ-BÀ4ÔCVÐW_ÔC`Ñ-aÔ-aÑbÔbˆLØØ—’˜l¨LÀ1ÐUc�ÑdÔdÐgkÔgoÑoñˆLˆLð ".×!4Ò!4Ñ!6Ô!6ˆ
�:ÑØ# e¨E¤lÔ&8¸Ô&;Ñ;ˆÝŒy˜,¨Ð5Ñ6Ô6¸
ÐBÐBs   ÃDÄDÄDr¼   útorch.Tensorr»   r«   r   r¬   r   c                ó(  — ||         }|j         dd…         \  }}|                     ||d¦  «        }|                     ||d¦  «        }t          j        ||d¬¦  «        }||z                       ¦   «         |                     ¦   «         |z  dz   z  }	|	S )a   Compute score-weighted L2 distillation loss for a feature pair.

        Args:
            student_feat (torch.Tensor): Student feature tensor of shape (N, C, H, W).
            teacher_feat (torch.Tensor): Teacher feature tensor of shape (N, C, H, W).
            feat_idx (int): Index of the feature level for selecting teacher scores.
            teacher_scores (tuple): Tuple of score tensors for each feature level.

        Returns:
            (torch.Tensor): The computed score-weighted L2 loss.
        Nr/   r;   Únone)Ú	reductiong•Ö&è.>)r[   ÚviewÚFÚmse_lossÚsum)
r   r¼   r»   r«   r¬   Úteacher_scoreÚnÚcÚmseÚweighted_mses
             r   r²   zDistillationModel.loss_sl2û   sŸ   € ð ' xÔ0ˆØÔ! " 1 "Ô%‰ˆˆ1Ø#×(Ò(¨¨A¨rÑ2Ô2ˆØ#×(Ò(¨¨A¨rÑ2Ô2ˆÝŒj˜ |¸vÐFÑFÔFˆØ˜mÑ+×0Ò0Ñ2Ô2°m×6GÒ6GÑ6IÔ6IÈAÑ6MÐPTÑ6TÑUˆØÐr   c                ó   — | j         j        S )z)Get the criterion from the student model.©r(   Ú	criterion©r   s    r   rÌ   zDistillationModel.criterion  s   € ð Ô!Ô+Ð+r   c                ó   — || j         _        dS )z Set value for student criterion.NrË   ©r   Úvalues     r   rÌ   zDistillationModel.criterion  s   € ð (-ˆÔÔ$Ð$Ð$r   c                ó4   — | j                              ¦   «         S )z4Initialize the loss criterion via the student model.)r(   Úinit_criterionrÍ   s    r   rÒ   z DistillationModel.init_criterion  s   € àÔ!×0Ò0Ñ2Ô2Ð2r   c                ó.   — t          | j        dd¦  «        S )z?Expose student end-to-end mode for validator/predictor control.Úend2endF)Úgetattrr(   rÍ   s    r   rÔ   zDistillationModel.end2end  s   € õ �tÔ)¨9°eÑ<Ô<Ð<r   c                ó   — || j         _        dS )z4Forward end-to-end mode update to the student model.N)r(   rÔ   rÏ   s     r   rÔ   zDistillationModel.end2end$  s   € ð &+ˆÔÔ"Ð"Ð"r   c                ó*   —  | j         j        di |¤Ž dS )zZForward head-attribute updates (e.g. max_det, agnostic_nms, end2end) to the student model.Nr#   )r(   Úset_head_attr)r   r“   s     r   rØ   zDistillationModel.set_head_attr)  s$   € à(ˆÔÔ(Ð2Ð2¨6Ð2Ð2Ð2Ð2Ð2r   rŸ   r�   rD   c                ó‚   — t          |t          ¦  «        r|d         }t          |t          ¦  «        r||v r||         }|S )a  Decouple outputs for teacher/student models.

        This method handles different output formats from YOLO models, including
        tuple outputs (train/val mode), dict outputs with branches (one2one/one2many),
        and direct tensor outputs.

        Args:
            preds (torch.Tensor | tuple | dict): Model predictions in various formats.
            branch (str): Which branch to extract from dict outputs ("one2one" or "one2many").

        Returns:
            (torch.Tensor | dict): The decoupled predictions.
        r   )rC   r   r   )r   r´   r�   s      r   rZ   z"DistillationModel.decouple_outputs-  sG   € õ �e�UÑ#Ô#ð 	Ø˜!”HˆEÝ�e�TÑ"Ô"ð 	" v°  Ø˜&”MˆEØˆr   )r&   r'   r(   r   )r   r   )r   r   r   r   )r�   r   r   rƒ   )T)rŒ   r�   )Tr•   )r.   r�   rR   r–   )N)
r¼   r½   r»   r½   r«   r   r¬   r   r   r½   )rŸ   )r�   rD   )r   r    r!   r"   r   rq   rt   rx   Ústaticmethodr   rP   rL   rK   rW   r”   r˜   r�   r²   ÚpropertyrÌ   ÚsetterrÒ   rÔ   rØ   rZ   Ú__classcell__)rk   s   @r   r%   r%   !   s  ø€ € € € € ðð ð:4>ð 4>ð 4>ð 4>ð 4>ð 4>ðlð ð ð'ð 'ð 'ð(ð (ð (ð (ð ð5ð 5ð 5ñ „\ð5ðð ð ð ð ð	:ð 	:ð 	:ñ „\ð	:ð(ð (ð (ðð ð ð ð ð ð ð>ð >ð >ðEð Eð Eð Eð Eð
*Cð *Cð *Cð *CðXð ð ð ð, ð,ð ,ñ „Xð,ð Ôð-ð -ð -ñ Ôð-ð3ð 3ð 3ð ð=ð =ñ „Xð=ð „^ð+ð +ñ „^ð+ð3ð 3ð 3ðð ð ð ð ð ð ð ð r   r%   )Ú
__future__r   Úpathlibr   rT   Útorch.nn.functionalr   Ú
functionalrÂ   Úultralytics.nn.modules.headr   Úultralytics.utils.torch_utilsr   Útasksr	   r   ÚModuler%   r#   r   r   ú<module>ræ      sÿ   ðð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð à €€€Ø Ð Ð Ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à .Ð .Ð .Ð .Ð .Ð .Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3à "Ð "Ð "Ð "Ð "Ð "ð*ð *ð *ð *ð *ñ *ô *ð *ð ^ð ^ð ^ð ^ð ^˜œ	ñ ^ô ^ð ^ð ^ð ^r   