Ë
    ëÓ^jŸ  ã                   ó‚  — U d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	m
Z
mZmZmZ d dlZd dlmZmZmZmZmZ d dlmZ e	d   Zeed<   eez  Zeed<    G d	„ d
e«      Zdefd„Z e«       Zeed<    G d„ de«      Z G d„ de«      Z  G d„ de «      Z! G d„ de!«      Z" G d„ de!«      Z# G d„ de!«      Z$ G d„ de!«      Z% G d„ de «      Z& G d„ de!«      Z' G d „ d!e!«      Z( G d"„ d#e!«      Z) G d$„ d%e!«      Z* G d&„ d'e!«      Z+ G d(„ d)e!«      Z, G d*„ d+e!«      Z- G d,„ d-e!«      Z. G d.„ d/e«      Z/ G d0„ d1e/«      Z0 G d2„ d3e/«      Z1y)4é    N)ÚPath)	ÚAnyÚClassVarÚDictÚListÚLiteralÚMappingÚOptionalÚ	TypeAliasÚUnion)Ú	BaseModelÚ
ConfigDictÚFieldÚfield_validatorÚmodel_validator)ÚPydanticUndefined)Údinov2_windowed_smallÚdinov2_windowed_baseÚdinov2_registers_windowed_smallÚEncoderNameÚPathLikeStrc                   ó   — e Zd ZdZy)Ú#PretrainWeightsCompatibilityWarninguý   Warning emitted when ``ModelConfig`` overrides are likely to prevent the variant's published pretrained weights
    from loading into the model â€” leaving large portions of the model randomly initialized and typically producing much
    lower accuracy.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úX/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/rfdetr/config.pyr   r      s   „ òr   r   Úreturnc                  óx  — t        t        dd«      } t        | dd«      }|�	 	  |d¬«      }|�t	        |«      S yt        j                  j                  «       ryt        j                  j                  j                  «       ryy# t        $ r  |«       }|�| j                  «       sd}Y Œ}w xY w# t
        $ r Y yw xY w)	u   Detect the best available device **without** initialising the CUDA runtime.

    ``torch.cuda.is_available()`` creates a CUDA driver context that makes ``_is_in_bad_fork()`` return ``True`` in
    child processes.  This breaks fork-based DDP strategies (e.g. ``ddp_notebook``) in notebook environments.

    We defer to :func:`torch.accelerator.current_accelerator` (PyTorch â‰¥ 2.4) when available â€” it queries the driver
    through NVML without creating a primary context.  On older builds we fall back to ``torch.cuda.is_available()``.

    ``check_available=True`` is required: without it ``current_accelerator()`` only reports the *compile-time*
    accelerator, so the default CUDA wheel on a machine without an NVIDIA driver yields ``"cuda"`` and every model build
    crashes with "Found no NVIDIA driver".  The runtime check is NVML-backed and still avoids creating a CUDA context.
    Builds whose ``current_accelerator`` predates the ``check_available`` kwarg get the same runtime verification via
    ``torch.accelerator.is_available``.
    ÚacceleratorNÚcurrent_acceleratorT)Úcheck_availableÚcpuÚcudaÚmps)	ÚgetattrÚtorchÚ	TypeErrorÚis_availableÚstrÚRuntimeErrorr'   Úbackendsr(   )r#   r$   Úaccels      r    Ú_detect_devicer1      sÅ   € ô œ% °Ó5€KÜ! +Ð/DÀdÓKÐØÐ&ð	ð!Ù+¸DÔA�ð
 Ð Ü˜5“zÐ!Øô ‡z�z×ÑÔ ØÜ‡~�~×Ñ×&Ñ&Ô(ØØøô ò !Ù+Ó-�ØÐ$¨[×-EÑ-EÔ-GØ �Eùð!ûô ò 	Ùð	ús.   £	B ¬B- Â$B*Â'B- Â)B*Â*B- Â-	B9Â8B9ÚDEVICEc                   óˆ   ‡ — e Zd ZU dZ edd¬«      Zee   ed<    ed¬«      e	de
d	e
fd
„«       «       Zdede
d	dfˆ fd„Zˆ xZS )Ú
BaseConfigzÍBase configuration class that validates input parameters against the defined model schema.

    If any unknown fields are provided, a ValueError is raised listing the unknown and available parameters.
    ÚforbidT©ÚextraÚvalidate_assignmentÚmodel_configÚbefore©ÚmodeÚvaluesr!   c                 ón  — t        |t        «      s|S | j                  j                  d«      dk7  r|S t	        | j
                  j                  «       «      }t	        |«      }||z
  }|rMdj                  d„ t        |«      D «       «      }dj                  t        |«      «      }t        d|› d|› d�«      ‚|S )Nr7   r5   z, c              3   ó(   K  — | ]
  }d |› d �–— Œ y­w)ú'Nr   )Ú.0Úparams     r    ú	<genexpr>z/BaseConfig.catch_typo_kwargs.<locals>.<genexpr>W   s   è ø€ Ò+]¸U¨a°¨w°a¬LÑ+]ùs   ‚zUnknown parameter(s): z. Available parameter(s): ú.)
Ú
isinstancer	   r9   ÚgetÚsetÚmodel_fieldsÚkeysÚjoinÚsortedÚ
ValueError)Úclsr=   Úallowed_paramsÚprovided_paramsÚunknown_paramsÚunknown_params_listÚallowed_params_lists          r    Úcatch_typo_kwargszBaseConfig.catch_typo_kwargsL   sº   € ô ˜&¤'Ô*ØˆMØ×Ñ×Ñ Ó(¨HÒ4ØˆMÜ˜S×-Ñ-×2Ñ2Ó4Ó5ˆÜ˜f›+ˆØ(¨>Ñ9ˆÙØ"&§)¡)Ñ+]ÄfÈ^ÓF\Ô+]Ó"]ÐØ"&§)¡)¬F°>Ó,BÓ"CÐÜØ(Ð)<Ð(=Ð=WÐXkÐWlÐlmÐnóð ð ˆr   ÚnameÚvalueNc                 ó”   •— |j                  d«      s|t        | «      j                  v rt        ‰| �  ||«       y t        d|› d�«      ‚)NÚ_zUnknown attribute: 'z'.)Ú
startswithÚtyperH   ÚsuperÚ__setattr__rL   )ÚselfrT   rU   Ú	__class__s      €r    r[   zBaseConfig.__setattr__^   sG   ø€ Ø�?‰?˜3Ô 4¬4°«:×+BÑ+BÑ#BÜ‰GÑ  eÔ,ØÜÐ/°¨v°RÐ8Ó9Ð9r   )r   r   r   r   r   r9   r   Ú__annotations__r   Úclassmethodr   rS   r-   r[   Ú__classcell__)r]   s   @r    r4   r4   D   sm   ø… ññ
 *4¸(ÐX\Ô)]€L�(˜:Ñ&Ó]á˜(Ô#Øð sð ¨sò ó ó $ðð : ð :¨Cð :°D÷ :ñ :r   r4   c                   ó|  — e Zd ZU eed<   ee   ed<   eed<   dZeed<   ee	d      ed<   eed<   eed	<   eed
<   eed<   eed<   eed<   dZ
eed<   dZeed<    edd¬«      Zeed<   dZeed<   dZeed<   dZeed<   dZeed<    edd¬«      Zeed<   dZeed<   dZee   ed<   eZeed <   eed!<   d"Zeed#<   d$Zeed%<   d$Zeed&<   dZeed'<   eed(<   dZeed)<   d*Z eed+<   d$Z!eed,<   d$Z"eed-<   dZ#eed.<   d$Z$eed/<   dZ%eed0<   d$Z&eed1<   d$Z'eed2<    ee(¬3«      Z)ee   ed4<   d5Z*eed6<   d7Z+eed8<   d$Z,eed9<   d$Z-eed:<   d;Z.eed<<    edd=¬>«      Z/ee   ed?<    e0d@¬A«      dJdC„«       Z1 e0d@¬A«      dJdD„«       Z2 e0d@¬A«      dJdE„«       Z3 e4ddF¬A«      e5dGedz  dBedz  fdH„«       «       Z6 e4d dF¬A«      e5dGe7dBefdI„«       «       Z8y)KÚModelConfigÚencoderÚout_feature_indexesÚ
dec_layersTÚ	two_stage©ÚP3ÚP4ÚP5Úprojector_scaleÚ
hidden_dimÚ
patch_sizeÚnum_windowsÚ	sa_nheadsÚ	ca_nheadsÚdec_n_pointsé,  Únum_queriesÚ
num_selectgš™™™™™É?ç        ©ÚdefaultÚgeÚpostprocess_trace_alphaÚbbox_reparamÚlite_refpoint_refineÚ
layer_normÚampé   é   Únum_channelséZ   Únum_classesNÚpretrain_weightsÚdeviceÚ
resolutioné   Ú
group_detrFÚgradient_checkpointingÚcompileÚfused_optimizerÚpositional_encoding_sizeÚia_bce_lossç      ð?Úcls_loss_coefÚsegmentation_headÚuse_grouppose_keypointsÚkeypoint_cross_attnÚinter_instance_kp_attnÚ grouppose_keypoint_dim_downscaleÚdual_projectorÚdual_projector_kp_only©Údefault_factoryÚnum_keypoints_per_classr   Únum_decoder_registersé   Úmask_downsample_ratioÚbackbone_loraÚfreeze_encoderz
Apache-2.0ÚlicensezþName of the model class stored in training checkpoints (e.g. ``"RFDETRLarge"``). Set automatically by ``RFDETR.train()`` before saving. Used by ``RFDETR.from_checkpoint()`` to resolve the correct subclass directly without inspecting ``pretrain_weights``.©rw   ÚdescriptionÚ
model_nameÚafterr;   r!   c                 óZ   — d| j                   v rt        j                  dt        d¬«       | S )a  Emit DeprecationWarning when cls_loss_coef is explicitly set on ModelConfig.

        ``cls_loss_coef`` ownership is moving to ``TrainConfig`` (Item #3, v1.7). Setting it on ``ModelConfig`` is
        deprecated.  Use ``TrainConfig(cls_loss_coef=...)`` instead.
        rŽ   z}ModelConfig.cls_loss_coef is deprecated since v1.7.0 and will be removed in v1.9.0. Set cls_loss_coef on TrainConfig instead.é   ©Ú
stacklevel©Úmodel_fields_setÚwarningsÚwarnÚDeprecationWarning)r\   s    r    Ú$_warn_deprecated_model_config_fieldsz0ModelConfig._warn_deprecated_model_config_fieldsŸ   s2   € ð ˜d×3Ñ3Ñ3ô
 �M‰Mð<ä"Øõ	ð ˆr   c                 óž  — d| j                   vsd| j                   v r| S t        | «      }|j                  d   j                  }|j                  d   j                  }|j                  d   j                  }t	        |t
        «      r t	        |t
        «      rt	        |t
        «      s| S |||z  k(  r| j                  | j                  z  | _        | S )a?  Auto-update positional_encoding_size when resolution is explicitly provided.

        When a user provides a custom ``resolution`` at construction time (e.g., ``RFDETRLarge(resolution=640)``),
        ``positional_encoding_size`` is updated proportionally, provided the class-default PE is formula-derived
        (``default_pe == default_resolution // patch_size``).

        Configs with a pretrained-specific PE (e.g., ``RFDETRBaseConfig`` with ``positional_encoding_size=37`` for
        DINOv2's native 518 px grid, while ``resolution=560``) are left unchanged.
        r…   r‹   rm   )	r¨   rY   rH   rw   rE   Úintr…   rm   r‹   )r\   rM   Údefault_resolutionÚ
default_peÚdefault_patch_sizes        r    Ú_sync_pe_with_resolutionz$ModelConfig._sync_pe_with_resolution³   sÆ   € ð ˜t×4Ñ4Ñ4Ð8RÐVZ×VkÑVkÑ8kØˆKä�4‹jˆØ ×-Ñ-¨lÑ;×CÑCÐØ×%Ñ%Ð&@ÑA×IÑIˆ
Ø ×-Ñ-¨lÑ;×CÑCÐô Ð-¬sÔ3Ü˜j¬#Ô.ÜÐ0´#Ô6àˆKð Ð+Ð/AÑAÒAØ,0¯O©O¸t¿¹Ñ,NˆDÔ)àˆr   c                 óÀ  — t        | «      }| j                  }d|v }|r]| j                  €Q|j                  d   j                  }|t
        ur.|�,t        j                  |j                  › d|›d�t        d¬«       | S |rS| j                  �G|j                  d   j                  }|�*|t
        ur"|j                  |«      }| j                  |k7  r| S | S |j                  d   j                  }|�|t
        u r| S g }d}	d}
|	D ]p  }||vrŒ|j                  j                  |«      }|�|j                  «       rŒ6|j                  }|t
        u rŒKt        | |«      }||k7  sŒ]|j                  |||f«       Œr |
D ]‘  }||vrŒ|j                  j                  |«      }|�|j                  «       rŒ6|j                  }|t
        u st        |t         «      sŒ[t        | |«      }t        |t         «      sŒx||kD  sŒ~|j                  |||f«       Œ“ d|v rr| j"                  rf|j                  j                  d«      }|�I|j                  «       s9|j                  }|t
        ur%t        | d«      }||k7  r|j                  d||f«       |r`|j                  d   j                  }d	j%                  d
„ |D «       «      }t        j                  |j                  › d|›d|› d�t        d¬«       | S )uf  Warn when overrides are likely to prevent published pretrained weights from loading.

        Three cases:

        1. ``pretrain_weights`` was explicitly set to ``None`` and the variant
           has a non-``None`` default â†’ warn that the model is being initialised from scratch.
        2. ``pretrain_weights`` was explicitly set to a non-``None`` custom path
           â†’ suppress the architecture-override check (we cannot know the architecture stored in a user-supplied
           checkpoint at config time). The load-time partial-load detector in
           :func:`rfdetr.models.weights.load_pretrain_weights` covers this case by inspecting the checkpoint contents
           directly.
        3. ``pretrain_weights`` is the variant's published default â†’ check
           architecture-affecting fields against the variant defaults and emit a single consolidated warning listing
           every load-breaking override.

        The warning class is :class:`PretrainWeightsCompatibilityWarning` (a :class:`UserWarning` subclass), silenceable
        via the standard ``warnings.filterwarnings`` machinery.
        rƒ   z² was instantiated with pretrain_weights=None. The model will be initialised from scratch, which typically produces lower accuracy than fine-tuning from the published checkpoint (z).r¤   r¥   )rc   rl   re   rn   ro   rp   rq   rd   rk   rz   r{   r|   rf   rm   r�   r€   )rs   r‡   r›   ú
c              3   ó<   K  — | ]  \  }}}d |› d|›d|›d�–— Œ y­w)z  z: z (variant default: ú)Nr   )rA   rT   Úcurrentrw   s       r    rC   z;ModelConfig._warn_pretrain_compatibility.<locals>.<genexpr>`  s3   è ø€ ò ÙLbÈDÐRYÐ[b�"�T�F˜"˜W˜KÐ':¸7¸+ÀQÔGñùs   ‚z~ was instantiated with overrides that differ from the variant defaults in ways that prevent the published pretrained weights (z) from loading correctly:
aF  
Loading the checkpoint with this configuration will leave significant portions of the model randomly initialised, which typically produces lower accuracy. To suppress this warning: revert the override(s), pick a variant whose defaults match, or pass pretrain_weights=None to acknowledge that you intend to train from scratch.)rY   r¨   rƒ   rH   rw   r   r©   rª   r   r   Úexpand_pathrF   Úis_requiredr)   ÚappendrE   r®   r�   rJ   )r\   rM   Ú
fields_setÚpretrain_user_setÚdefault_pretrainÚ_default_pretrainÚ_expanded_defaultÚ_class_default_pretrainÚ	overridesÚbreaking_fieldsÚbreaking_on_increaserT   Ú
field_inforw   r·   Ú	_mdr_infoÚ_mdr_defaultÚ_mdr_currentÚliness                      r    Ú_warn_pretrain_compatibilityz(ModelConfig._warn_pretrain_compatibility×   sE  € ô( �4‹jˆØ×*Ñ*ˆ
Ø.°*Ð<Ðá ×!6Ñ!6Ð!>Ø"×/Ñ/Ð0BÑC×KÑKÐØÔ'8Ñ8Ð=MÐ=YÜ—‘Ø—|‘|�nð %#ð $4Ð"6°bð:ô 8Ø õð ˆKá ×!6Ñ!6Ð!Bð !$× 0Ñ 0Ð1CÑ D× LÑ LÐØ Ð,Ð1BÔJ[Ñ1[Ø$'§O¡OÐ4EÓ$FÐ!Ø×(Ñ(Ð,=Ò=Ø�Kð �ð #&×"2Ñ"2Ð3EÑ"F×"NÑ"NÐØ"Ð*Ð.EÔIZÑ.ZØˆKà02ˆ	ð,
ˆð(1
Ðð
 $ò 	;ˆDØ˜:Ñ%ØØ×)Ñ)×-Ñ-¨dÓ3ˆJØÐ! Z×%;Ñ%;Ô%=ØØ ×(Ñ(ˆGØÔ+Ñ+ØÜ˜d DÓ)ˆGØ˜'Ó!Ø× Ñ  $¨°Ð!9Õ:ð	;ð )ò 	;ˆDØ˜:Ñ%ØØ×)Ñ)×-Ñ-¨dÓ3ˆJØÐ! Z×%;Ñ%;Ô%=ØØ ×(Ñ(ˆGØÔ+Ñ+´:¸gÄsÔ3KØÜ˜d DÓ)ˆGÜ˜'¤3Õ'¨G°gÓ,=Ø× Ñ  $¨°Ð!9Õ:ð	;ð # jÑ0°T×5KÒ5KØ×(Ñ(×,Ñ,Ð-DÓEˆIØÐ$¨Y×-BÑ-BÔ-DØ(×0Ñ0�ØÔ'8Ñ8Ü#*¨4Ð1HÓ#I�LØ# |Ò3Ø!×(Ñ(Ð*AÀ<ÐQ]Ð)^Ô_áØ"×/Ñ/Ð0BÑC×KÑKÐØ—I‘Iñ Øfoôó ˆEô �M‰MØ—<‘<�.ð !à$Ð'Ð'BØ�'ð  ð ô 4Øõð ˆr   r:   Úvc                 ó@  — |€|S t         j                  j                  t        j                  |«      «      }t         j                  j	                  |«      s+ddlm} t         j                  j                   |«       |«      S t         j                  j                  |«      S )a  Expand and resolve the pretrain_weights path.

        Bare filenames (no directory component, e.g. ``rf-detr-base.pth``) are resolved to the model cache directory so
        weights land in a stable, user-configurable location (``~/.roboflow/models`` by default, or the path set via the
        ``RF_HOME`` environment variable) instead of CWD.

        Paths that already contain a directory separator (e.g. ``~/models/x.pth``, ``/abs/path/x.pth``,
        ``models/x.pth``) are normalised with ``os.path.realpath`` as before.
        r   )Úget_model_cache_dir)	ÚosÚpathÚ
expanduserÚfspathÚdirnameÚrfdetr.assets.model_weightsrÌ   rJ   Úrealpath)rM   rÊ   ÚexpandedrÌ   s       r    r¸   zModelConfig.expand_paths  sk   € ð ˆ9ØˆHÜ—7‘7×%Ñ%¤b§i¡i°£lÓ3ˆÜ�w‰w�‰˜xÔ(åGä—7‘7—<‘<Ñ 3Ó 5°xÓ@Ð@Ü�w‰w×Ñ Ó)Ð)r   c                 ó  — t        |t        j                  «      rt        |«      S t        |t        «      r	 t        t        j                  |«      «      S t        d«      ‚# t        t
        t        f$ r}t        d|›d�«      |‚d}~ww xY w)a  Normalize supported device inputs to a canonical torch-style string.

        Args:
            v: Device specifier provided by callers. Supported values are
                ``str`` (for example ``"cpu"``, ``"cuda"``, ``"cuda:1"``) and ``torch.device``.

        Returns:
            Canonical string form of the parsed device (for example ``"cuda:1"``).

        Raises:
            ValueError: If a string value cannot be parsed as a valid torch device.
            ValueError: If ``v`` is not a string or ``torch.device``.
        zInvalid device specifier: rD   Nz(device must be a string or torch.device.)rE   r*   r„   r-   r+   rL   r.   )rM   rÊ   Úexcs      r    Ú_normalize_devicezModelConfig._normalize_device‰  s~   € ô  �aœŸ™Ô&Ü�q“6ˆMÜ�aœÔðOÜœ5Ÿ<™<¨›?Ó+Ð+ô ÐCÓDÐDøô œz¬<Ð8ò OÜ Ð#=¸a¸UÀ!Ð!DÓEÈ3ÐNûðOús   ·A  Á B	Á4BÂB	)r!   rb   )9r   r   r   r   r^   r   r®   rf   Úboolr   rs   rt   r   ry   Úfloatrz   r{   r|   r}   r€   r‚   rƒ   r
   r   r2   r„   r-   r‡   rˆ   r‰   rŠ   rŒ   rŽ   r�   r�   r‘   r’   r“   r”   r•   Úlistr˜   r™   r›   rœ   r�   rž   r¡   r   r¬   r²   rÉ   r   r_   r¸   r   r×   r   r   r    rb   rb   e   s�  … ØÓØ˜c™Ó"ØƒOØ€IˆtÓØ˜'Ð"2Ñ3Ñ4Ó4ØƒOØƒOØÓØƒNØƒNØÓØ€K�Óð €J�ÓÙ%*°3¸3Ô%?Ð˜UÓ?Ø€L�$ÓØ!%Ð˜$Ó%Ø€J�ÓØ€CˆÓÙ a¨AÔ.€L�#Ó.Ø€K�ÓØ.2Ð�h˜{Ñ+Ó2à€FˆCÓØƒOØ€J�ÓØ#(Ð˜DÓ(Ø€GˆTÓØ €O�TÓ Ø!Ó!Ø€K�ÓØ€M�5ÓØ#Ð�tÓ#Ø$)Ð˜TÓ)Ø $Ð˜Ó$Ø#(Ð˜DÓ(Ø,-Ð$ cÓ-Ø €N�DÓ Ø#(Ð˜DÓ(Ù).¸tÔ)DÐ˜T #™YÓDØ!"Ð˜3Ó"Ø!"Ð˜3Ó"Ø€M�4ÓØ €N�DÓ Ø€GˆSÓÙ %Øð7ô!€J�˜‘ó ñ ˜'Ô"òó #ðñ& ˜'Ô"ò!ó #ð!ñF ˜'Ô"òYó #ðYñv Ð'¨hÔ7Øð*˜K¨$Ñ.ð *°3¸±:ò *ó ó 8ð*ñ( �X HÔ-ØðE #ð E¨#ò Eó ó .ñEr   rb   c                   ó  — e Zd ZU dZdZeed<   dZeed<   dZ	eed<   dZ
eed	<   d
Zeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dgZeed      ed<   g d¢Zee   ed<   dZee   ed<   dZeed<   dZeed<   y )!ÚRFDETRBaseConfigz,The configuration for an RF-DETR Base model.r   rc   é   rl   é   rm   rš   rn   r~   re   é   ro   é   rp   r¤   rq   rr   rs   rt   ri   rg   rk   )r¤   é   rß   é   rd   zrf-detr-base.pthrƒ   i0  r…   é%   r‹   N)r   r   r   r   rc   r   r^   rl   r®   rm   rn   re   ro   rp   rq   rs   rt   rk   r   r   rd   rƒ   r
   r   r…   r‹   r   r   r    rÜ   rÜ   £  s´   … Ù6à2€Gˆ[Ó2Ø€J�ÓØ€J�ÓØ€K�ÓØ€J�ÓØ€IˆsÓØ€IˆsÓØ€L�#ÓØ€K�ÓØ€J�ÓØ8<°v€O�T˜'Ð"2Ñ3Ñ4Ó=Ú%2Ð˜˜c™Ó2Ø.@Ð�h˜{Ñ+Ó@Ø€J�ÓØ$&Ð˜cÔ&r   rÜ   c                   óŠ   — e Zd ZU dZdZeed<   dZeed<   dZ	eed<   dZ
eed	<   d
Zeed<   ddgZeed      ed<   dZee   ed<   y)ÚRFDETRLargeDeprecatedConfigz-The configuration for an RF-DETR Large model.r   rc   é€  rl   é   ro   é   rp   rš   rq   rh   rj   rg   rk   zrf-detr-large.pthrƒ   N)r   r   r   r   rc   r   r^   rl   r®   ro   rp   rq   rk   r   r   rƒ   r
   r   r   r   r    rå   rå   ·  s`   … Ù7à1€Gˆ[Ó1Ø€J�ÓØ€IˆsÓØ€IˆsÓØ€L�#ÓØ8<¸d°|€O�T˜'Ð"2Ñ3Ñ4ÓCØ.AÐ�h˜{Ñ+ÔAr   rå   c                   ó„   — e Zd ZU dZg d¢Zee   ed<   dZeed<   dZ	eed<   dZ
eed<   d	Zeed
<   dZeed<   dZee   ed<   y)ÚRFDETRNanoConfigz,The configuration for an RF-DETR Nano model.©r~   é   é	   rç   rd   r¤   rn   re   rà   rm   ræ   r…   rè   r‹   zrf-detr-nano.pthrƒ   N©r   r   r   r   rd   r   r®   r^   rn   re   rm   r…   r‹   rƒ   r
   r   r   r   r    rê   rê   Ã  sW   … Ù6â%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$&Ð˜cÓ&Ø.@Ð�h˜{Ñ+Ô@r   rê   c                   ó„   — e Zd ZU dZg d¢Zee   ed<   dZeed<   dZ	eed<   dZ
eed	<   d
Zeed<   dZeed<   dZee   ed<   y)ÚRFDETRSmallConfigz-The configuration for an RF-DETR Small model.rë   rd   r¤   rn   r~   re   rà   rm   i   r…   é    r‹   zrf-detr-small.pthrƒ   Nrî   r   r   r    rð   rð   Ï  sW   … Ù7â%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$&Ð˜cÓ&Ø.AÐ�h˜{Ñ+ÔAr   rð   c                   ó„   — e Zd ZU dZg d¢Zee   ed<   dZeed<   dZ	eed<   dZ
eed	<   d
Zeed<   dZeed<   dZee   ed<   y)ÚRFDETRMediumConfigz.The configuration for an RF-DETR Medium model.rë   rd   r¤   rn   rš   re   rà   rm   é@  r…   é$   r‹   zrf-detr-medium.pthrƒ   Nrî   r   r   r    ró   ró   Û  sW   … Ù8â%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$&Ð˜cÓ&Ø.BÐ�h˜{Ñ+ÔBr   ró   c                   ó  — e Zd ZU dZed   ed<   dZeed<   dZeed<   dZ	eed<   d	Z
eed
<   dZeed<   dZeed<   d	Zeed<   dgZeed      ed<   g d¢Zee   ed<   dZeed<   dZeed<   dZee   ed<   dZeed<   dZeed<   dZeed<   y) ÚRFDETRLargeConfigr   rc   rÝ   rl   rš   re   rß   ro   rà   rp   r¤   rq   rn   rm   ri   )ri   rk   rë   rd   r�   r‚   é,   r‹   zrf-detr-large-2026.pthrƒ   iÀ  r…   rr   rs   rt   N)r   r   r   rc   r   r^   rl   r®   re   ro   rp   rq   rn   rm   rk   r   rd   r‚   r‹   rƒ   r
   r   r…   rs   rt   r   r   r    r÷   r÷   è  sÁ   … Ø0G€GˆWÐ,Ñ-ÓGØ€J�ÓØ€J�ÓØ€IˆsÓØ€IˆsÓØ€L�#ÓØ€K�ÓØ€J�ÓØ-1¨F€O�T˜' %™.Ñ)Ó2Ú%2Ð˜˜c™Ó2Ø€K�ÓØ$-Ð˜cÓ-Ø.FÐ�h˜{Ñ+ÓFØ€J�Óð
 €K�ÓØ€J�Ôr   r÷   c                   ó¸   — e Zd ZU dZeed<   g d¢Zee   ed<   dZ	eed<   dZ
eed<   d	Zeed
<   dZeed<   dZeed<   dZeed<   dZeed<   dZee   ed<   dZeed<   y)ÚRFDETRSegPreviewConfigTr�   rë   rd   r¤   rn   rš   re   rç   rm   é°  r…   rõ   r‹   éÈ   rs   rt   zrf-detr-seg-preview.ptrƒ   r�   r‚   N©r   r   r   r�   rØ   r^   rd   r   r®   rn   re   rm   r…   r‹   rs   rt   rƒ   r
   r   r‚   r   r   r    rú   rú   ÿ  s}   … Ø"Ð�tÓ"Ú%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$&Ð˜cÓ&Ø€K�ÓØ€J�ÓØ.FÐ�h˜{Ñ+ÓFØ€K�Ôr   rú   c                   ó¸   — e Zd ZU dZeed<   g d¢Zee   ed<   dZ	eed<   dZ
eed<   d	Zeed
<   dZeed<   dZeed<   dZeed<   dZeed<   dZee   ed<   dZeed<   y)ÚRFDETRSegNanoConfigTr�   rë   rd   r   rn   rš   re   rç   rm   i8  r…   é   r‹   éd   rs   rt   zrf-detr-seg-nano.ptrƒ   r�   r‚   Nrý   r   r   r    rÿ   rÿ     s}   … Ø"Ð�tÓ"Ú%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$-Ð˜cÓ-Ø€K�ÓØ€J�ÓØ.CÐ�h˜{Ñ+ÓCØ€K�Ôr   rÿ   c                   ó¸   — e Zd ZU dZeed<   g d¢Zee   ed<   dZ	eed<   dZ
eed<   d	Zeed
<   dZeed<   dZeed<   dZeed<   dZeed<   dZee   ed<   dZeed<   y)ÚRFDETRSegSmallConfigTr�   rë   rd   r¤   rn   rš   re   rç   rm   ræ   r…   rñ   r‹   r  rs   rt   zrf-detr-seg-small.ptrƒ   r�   r‚   Nrý   r   r   r    r  r    ó}   … Ø"Ð�tÓ"Ú%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$-Ð˜cÓ-Ø€K�ÓØ€J�ÓØ.DÐ�h˜{Ñ+ÓDØ€K�Ôr   r  c                   ó¸   — e Zd ZU dZeed<   g d¢Zee   ed<   dZ	eed<   dZ
eed<   d	Zeed
<   dZeed<   dZeed<   dZeed<   dZeed<   dZee   ed<   dZeed<   y)ÚRFDETRSegMediumConfigTr�   rë   rd   r¤   rn   rá   re   rç   rm   rû   r…   rõ   r‹   rü   rs   rt   zrf-detr-seg-medium.ptrƒ   r�   r‚   Nrý   r   r   r    r  r  )  ó}   … Ø"Ð�tÓ"Ú%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$-Ð˜cÓ-Ø€K�ÓØ€J�ÓØ.EÐ�h˜{Ñ+ÓEØ€K�Ôr   r  c                   ó¸   — e Zd ZU dZeed<   g d¢Zee   ed<   dZ	eed<   dZ
eed<   d	Zeed
<   dZeed<   dZeed<   dZeed<   dZeed<   dZee   ed<   dZeed<   y)ÚRFDETRSegLargeConfigTr�   rë   rd   r¤   rn   rá   re   rç   rm   iø  r…   é*   r‹   rü   rs   rt   zrf-detr-seg-large.ptrƒ   r�   r‚   Nrý   r   r   r    r	  r	  7  r  r   r	  c                   ó¸   — e Zd ZU dZeed<   g d¢Zee   ed<   dZ	eed<   dZ
eed<   d	Zeed
<   dZeed<   dZeed<   dZeed<   dZeed<   dZee   ed<   dZeed<   y)ÚRFDETRSegXLargeConfigTr�   rë   rd   r¤   rn   rì   re   rç   rm   ip  r…   é4   r‹   rr   rs   rt   zrf-detr-seg-xlarge.ptrƒ   r�   r‚   Nrý   r   r   r    r  r  E  r  r   r  c                   ó¸   — e Zd ZU dZeed<   g d¢Zee   ed<   dZ	eed<   dZ
eed<   d	Zeed
<   dZeed<   dZeed<   dZeed<   dZeed<   dZee   ed<   dZeed<   y)ÚRFDETRSeg2XLargeConfigTr�   rë   rd   r¤   rn   rì   re   rç   rm   i   r…   é@   r‹   rr   rs   rt   zrf-detr-seg-xxlarge.ptrƒ   r�   r‚   Nrý   r   r   r    r  r  S  s}   … Ø"Ð�tÓ"Ú%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$-Ð˜cÓ-Ø€K�ÓØ€J�ÓØ.FÐ�h˜{Ñ+ÓFØ€K�Ôr   r  c                   ó  — e Zd ZU dZdZeed<   dZeed<   dZeed<   dgZ	e
e   ed<   dZeed<   d	Zeed
<   dZeed<   g d¢Ze
e   ed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZee   ed<   dZeed<   y )!ÚRFDETRKeypointPreviewConfigz-Configuration for the preview keypoint model.Tr�   r”   r•   é   r˜   r‘   Fr’   r   r“   rë   rd   r¤   rn   rš   re   rç   rm   rô   r…   é0   r‹   r  rs   rt   z#rf-detr-keypoint-preview-xlarge.pthrƒ   r�   r‚   N)r   r   r   r   r�   rØ   r^   r”   r•   r˜   r   r®   r‘   r’   r“   rd   rn   re   rm   r…   r‹   rs   rt   rƒ   r
   r   r‚   r   r   r    r  r  a  sÇ   … Ù7à$(Ð˜TÓ(Ø€N�DÓØ#'Ð˜DÓ'Ø*,¨Ð˜T #™YÓ-Ø $Ð˜Ó$Ø#(Ð˜DÓ(Ø,-Ð$ cÓ-Ú%2Ð˜˜c™Ó2Ø€K�ÓØ€J�ÓØ€J�ÓØ€J�ÓØ$-Ð˜cÓ-Ø€K�ÓØ€J�ÓØ.SÐ�h˜{Ñ+ÓSØ€K�Ôr   r  c                   óø  — e Zd ZU dZ edd¬«      Zee   ed<   dZe	ed<   dZ
e	ed	<   d
Zeed   z  ed<   d
Zeed<   dZeed<   dZeed<   dZe	ed<   dZeed<   dZee   ed<   dZe	ed<   dZeed<   dZeed<    edd¬«      Zeed<    edd¬«      Zeed <   d!Ze	ed"<   d!Ze	ed#<   d$Ze	ed%<   dZe	ed&<   d!Z e	ed'<   d(Z!eed)<   dZ"e#ed*<   d+Z$e	ed,<   d-Z%eed.<    ee&¬/«      Z'e(e   ed0<   dZ)e	ed1<   dZ*e	ed2<   dZ+e	ed3<   dZ,e	ed4<   dZ-e(e	   dz  ed5<   d6Z.ed7   ed8<   dZ/e#ed9<   ee   ed:<   d;Z0eed<<   dZ1e#ed=<   dZ2e#ed><   d?Z3e#ed@<   dZ4e#edA<   dZ5eedB<   dCZ6eedD<   dZ7e	edE<    eddF¬G«      Z8edH   edI<   d?Z9e#edJ<   dZ:eedK<   dLZ;e	edM<   d?Z<e#edN<   dZ=eedO      edP<   dZ>e#edQ<   d?Z?e#edR<   d?Z@e#edS<   d?ZAe#edT<   dZBeeC   edU<   dZDeeC   edV<   dZEee(eC      edW<   d?ZFe#edX<   d?ZGe#edY<   dZZHeed[<   dZIeed\<   dZJe#ed]<   dZKeeLeCeMf      ed^<   d_ZNed`   eda<   d?ZOe#edb<    eddc¬G«      ZPeeM   edd<    eQde¬f«      dŒdh„«       ZR eSdPdi¬f«      eTdjeMdgeMfdk„«       «       ZU eSdIdi¬f«      eTdjeMdgeMfdl„«       «       ZVdZWeCedm<   dnZXe	edo<   dZYee   edp<   d?ZZe#edq<   dZ[eCedr<   dZ\e]eeCf   eds<   dZ^eedt<   d?Z_e#edu<   dvZ`edw   edx<   d!Zae	edy<   d?Zbe#edz<   d?Zce#ed{<   d?Zde#ed|<   d?Zee#ed}<   dZfe#ed~<   dZge#ed<   dZhee#   ed€<   dZiee#   ed�<   dZjee   ed‚<    eSdde¬f«      eTdƒeed   z  dgeed   z  fd„„«       «       Zk eSdddde¬f«      eTdƒedgefd…„«       «       Zl eSdde¬f«      eTdƒe	dge	fd†„«       «       Zm eSd"de¬f«      eTdƒe	dge	fd‡„«       «       Zn eSdBd\de¬f«      eTdƒedgefdˆ„«       «       Zo eSd‚de¬f«      eTdƒee   dgee   fd‰„«       «       Zp eSd:d<di¬f«      eTdƒedz  dgeCdz  fdŠ„«       «       Zq eSddi¬f«      eTdƒedz  dgeCdz  fd‹„«       «       Zry)�ÚTrainConfigaW  Training hyperparameters and auto-batching configuration.

    Notes:
        * ``auto_batch_target_effective`` is interpreted as the **per-device**
          effective batch size target, i.e. the number of images seen by a single process in one optimizer step after
          accounting for ``grad_accum_steps``. In multi-GPU / multi-node runs the global effective batch size is
          therefore:

            ``global_effective_batch = auto_batch_target_effective * devices * num_nodes``

          This avoids silently changing behavior when scaling from single-GPU to multi-GPU training.
    ÚignoreTr6   r9   g-Cëâ6?Úlrga2U0*©#?Ú
lr_encoderrš   ÚautoÚ
batch_sizeÚgrad_accum_stepsrà   Úauto_batch_target_effectiver  Ú auto_batch_max_targets_per_imagegffffffæ?Úauto_batch_ema_headroomÚepochsNÚresumeg-²�ï§Æï?Ú	ema_decayÚema_tauÚlr_dropé
   r   rv   Úcheckpoint_intervalr   Úskip_best_epochsru   Úsmooth_alphaÚwarmup_epochsgš™™™™™é?Úlr_vit_layer_decayÚlr_component_decayÚ	drop_pathr†   r‡   rŒ   r�   rŽ   rr   rt   r–   Úkeypoint_flip_pairsÚkeypoint_l1_loss_coefÚkeypoint_findable_loss_coefÚkeypoint_visible_loss_coefÚkeypoint_nll_loss_coefÚkeypoint_oks_sigmasÚroboflow)ÚcocoÚo365r3  ÚyoloÚdataset_fileÚsquare_resize_div_64Údataset_dirÚoutputÚ
output_dirÚmulti_scaleÚexpanded_scalesFÚdo_random_resize_via_paddingÚuse_emaÚema_update_intervalr¤   Únum_workersÚweight_decayzüMixed-precision autocast dtype. 'auto' selects bf16-mixed on Ampere+ CUDA, fp16 otherwise. 'bf16' forces bfloat16 (falls back to fp16 with a warning if unsupported). 'fp16' forces fp16. Has no effect when model_config.amp=False or when training on CPU.rŸ   ©r  Úbf16Úfp16Ú	amp_dtypeÚearly_stoppingÚearly_stopping_patiencegü©ñÒMbP?Úearly_stopping_min_deltaÚearly_stopping_use_ema)ÚtqdmÚrichÚprogress_barÚtensorboardÚwandbÚmlflowÚclearmlÚprojectÚrunÚclass_namesÚrun_testr�   iô  Úeval_max_detsÚeval_intervalÚlog_per_class_metricsÚ
aug_configr&   )r&   r  ÚgpuÚaugmentation_backendÚsave_dataset_gridsaB  User-defined provenance metadata embedded in best-model .pth checkpoints under checkpoint['args']['notes'] and in exported ONNX files under the 'rfdetr_notes' metadata property. Accepts any JSON-serialisable value (string, dict, list, int, float, bool). String values are stored verbatim; all other types are JSON-encoded.Únotesr¢   r;   r!   c                 ó|   — d}|D ]4  }|| j                   v sŒt        j                  d|› d|› d�t        d¬«       Œ6 | S )u²  Emit DeprecationWarning for fields whose ownership is moving to ModelConfig.

        The following fields are duplicated between ``ModelConfig`` and ``TrainConfig`` but ``ModelConfig`` is the
        authoritative source (Item #3, v1.7.0).  Setting them on ``TrainConfig`` is deprecated.  The fields will be
        removed in v1.9.0.

        - ``group_detr``: query group count is an architecture decision â†’ ``ModelConfig``
        - ``ia_bce_loss``: loss type is tied to architecture family â†’ ``ModelConfig``
        - ``segmentation_head``: architecture flag â†’ ``ModelConfig``
        - ``num_select``: postprocessor count is an architecture decision â†’ ``ModelConfig``
        )r‡   rŒ   r�   rt   zTrainConfig.z? is deprecated since v1.7.0 and will be removed in v1.9.0. Set z on ModelConfig instead.r¤   r¥   r§   )r\   Ú_deprecatedÚfields      r    Ú$_warn_deprecated_train_config_fieldsz0TrainConfig._warn_deprecated_train_config_fieldsÙ  s[   € ð WˆØ ò 		ˆEØ˜×-Ñ-Ò-ô —‘Ø" 5 'ð *Ø ˜'Ð!9ð;ä&Ø ö	ð			ð ˆr   r:   rU   c                 ó2   — t        |t        «      r|rdS dS |S )z¸Normalize legacy boolean progress_bar values to the new string/None representation.

        This preserves compatibility with older configs where ``progress_bar`` was a bool.
        rK  N)rE   rØ   ©rM   rU   s     r    Ú_coerce_legacy_progress_barz'TrainConfig._coerce_legacy_progress_baró  s    € ô �eœTÔ"Ù"�6Ð,¨Ð,Øˆr   c                 óP   — |dvr!t        j                  d|›d�t        d¬«       y|S )a  Fall back to ``'auto'`` (with a warning) for an unrecognised or wrong-typed ``amp_dtype``.

        Mixed precision is a best-effort speed/memory optimisation, so an invalid request degrades to the auto-selected
        dtype rather than failing the whole training run.
        rC  zUnknown amp_dtype=zA; expected one of 'auto', 'bf16', 'fp16'. Falling back to 'auto'.r¤   r¥   r  )r©   rª   ÚUserWarningrc  s     r    Ú_coerce_amp_dtypezTrainConfig._coerce_amp_dtypeþ  s6   € ð Ð0Ñ0ä�M‰MØ$ U IÐ-nÐoÜØõð
 Øˆr   r#   gš™™™™™¹?Úclip_max_normÚseedÚsync_bnÚstrategyÚdevicesÚ	num_nodesÚ	fp16_evalÚstep)ro  ÚcosineÚlr_schedulerÚlr_min_factorÚdont_save_weightsÚtrain_log_sync_distÚtrain_log_on_stepÚcompute_train_metricsÚcompute_val_lossÚcompute_test_lossÚ
pin_memoryÚpersistent_workersÚprefetch_factorrÊ   c                 ó4   — |dk(  r|S |dk  rt        d«      ‚|S )z@Validate batch_size is a positive integer or the literal 'auto'.r  r   z#batch_size must be >= 1, or 'auto'.©rL   ©rM   rÊ   s     r    Úvalidate_batch_sizezTrainConfig.validate_batch_size+  s(   € ð �Š;ØˆHØˆqŠ5ÜÐBÓCÐCØˆr   c                 ó&   — |dk  rt        d«      ‚|S )zHValidate accumulation, target-effective batch, and max targets are >= 1.r   zagrad_accum_steps, auto_batch_target_effective, and auto_batch_max_targets_per_image must be >= 1.r}  r~  s     r    Úvalidate_positive_train_stepsz)TrainConfig.validate_positive_train_steps5  s"   € ð ˆqŠ5ÜØsóð ð ˆr   c                 óJ   — d|cxk  rdk  st        d«      ‚ t        d«      ‚|S )z.Validate auto_batch_ema_headroom is in (0, 1].r   r�   z*auto_batch_ema_headroom must be in (0, 1].r}  r~  s     r    Úvalidate_ema_headroomz!TrainConfig.validate_ema_headroomA  s1   € ð �A”˜’ÜÐIÓJÐJð ÜÐIÓJÐJØˆr   c                 óJ   — d|cxk  rdk  st        d«      ‚ t        d«      ‚|S )z'Validate smooth_alpha is in [0.0, 1.0).ru   r�   z#smooth_alpha must be in [0.0, 1.0).r}  r~  s     r    Úvalidate_smooth_alphaz!TrainConfig.validate_smooth_alphaI  s1   € ð �q”˜3’ÜÐBÓCÐCð ÜÐBÓCÐCØˆr   c                 ó&   — |dk  rt        d«      ‚|S )z"Validate interval fields are >= 1.r   zInterval fields must be >= 1.r}  r~  s     r    Úvalidate_positive_intervalsz'TrainConfig.validate_positive_intervalsQ  s   € ð ˆqŠ5ÜÐ<Ó=Ð=Øˆr   c                 ó*   — |�|dk  rt        d«      ‚|S )z)Validate prefetch_factor is None or >= 1.r   z+prefetch_factor must be >= 1 when provided.r}  r~  s     r    Úvalidate_prefetch_factorz$TrainConfig.validate_prefetch_factorY  s    € ð ˆ=˜Q šUÜÐJÓKÐKØˆr   c                 ó¨   — |€|S t         j                  j                  t         j                  j                  t        j                  |«      «      «      S )uj   Expand and normalize dataset/output directory paths via ``os.fspath`` â†’ ``expanduser`` â†’ ``realpath``.)rÍ   rÎ   rÓ   rÏ   rÐ   r~  s     r    Úexpand_pathszTrainConfig.expand_pathsa  s:   € ð ˆ9ØˆHÜ�w‰w×Ñ¤§¡× 2Ñ 2´2·9±9¸Q³<Ó @ÓAÐAr   c                 ó4   — |€|S t        j                  |«      S )aÝ  Normalise the resume checkpoint value to ``str`` without resolving it.

        Unlike ``dataset_dir``/``output_dir``, ``resume`` is forwarded verbatim to PyTorch Lightning's
        ``trainer.fit(ckpt_path=...)``, which also accepts sentinel values such as ``"last"``. Running
        ``os.path.realpath`` would rewrite those sentinels into spurious absolute paths, so this validator only coerces
        the type (``Path`` -> ``str``) and leaves the value untouched.
        )rÍ   rÐ   r~  s     r    Ú_coerce_resume_pathzTrainConfig._coerce_resume_pathi  s   € ð ˆ9ØˆHÜ�y‰y˜‹|Ðr   )r!   r  )sr   r   r   r   r   r9   r   r^   r  rÙ   r  r  r®   r   r  r  r  r  r   r!  r
   r   r"  r#  r$  r   r&  r'  r(  r)  r*  r+  r,  r‡   rŒ   rØ   rŽ   rt   rÚ   r-  r   r.  r/  r0  r1  r2  r7  r8  r;  r<  r=  r>  r?  r@  rA  rB  rF  rG  rH  rI  rJ  rM  rN  rO  rP  rQ  rR  r-   rS  rT  rU  r�   rV  rW  rX  rY  r   r   r[  r\  r]  r   ra  r   r_   rd  rg  r#   rh  ri  rj  rk  rl  r   rm  rn  rq  rr  rs  rt  ru  rv  rw  rx  ry  rz  r{  r  r�  rƒ  r…  r‡  r‰  r‹  r�  r   r   r    r  r  w  sa  … ññ *4¸(ÐX\Ô)]€L�(˜:Ñ&Ó]à€BˆÓØ€J�ÓØ()€J��g˜f‘oÑ%Ó)ØÐ�cÓØ')Ð Ó)à,/Ð$ cÓ/Ø%(Ð˜UÓ(Ø€FˆCÓØ$(€FˆH�[Ñ!Ó(Ø€IˆuÓØ€GˆSÓØ€GˆSÓÙ$¨R°AÔ6Ð˜Ó6Ù!¨!°Ô2Ð�cÓ2Ø€L�%ÓØ€M�5ÓØ #Ð˜Ó#Ø #Ð˜Ó#Ø€IˆuÓØ€J�ÓØ€K�ÓØ€M�5ÓØ€J�ÓÙ%*¸4Ô%@Ð˜˜c™Ó@Ø#$Ð˜5Ó$Ø)*Ð Ó*Ø()Ð Ó)Ø$%Ð˜EÓ%Ø.2Ð˜˜e™ tÑ+Ó2Ø@J€L�'Ð<Ñ=ÓJØ!%Ð˜$Ó%Ø˜+Ñ&Ó&Ø&€J�Ó&Ø€K�ÓØ €O�TÓ Ø).Ð  $Ó.Ø€GˆTÓØ Ð˜Ó Ø€K�ÓØ€L�%ÓÙ16ØðQô	2€IˆwÐ-Ñ.ó 	ð !€N�DÓ Ø#%Ð˜SÓ%Ø&+Ð˜eÓ+Ø#(Ð˜DÓ(Ø6:€L�(˜7 >Ñ2Ñ3Ó:Ø€K�ÓØ€Eˆ4ÓØ€FˆDÓØ€GˆTÓØ!€GˆX�c‰]Ó!Ø€Cˆ�#‰ÓØ'+€K�˜$˜s™)Ñ$Ó+Ø€HˆdÓØ#Ð�tÓ#Ø€M�3ÓØ€M�3ÓØ"&Ð˜4Ó&Ø+/€J�˜˜c 3˜h™Ñ(Ó/Ø:?Ð˜'Ð"6Ñ7Ó?Ø$Ð˜Ó$Ù Øð0ô	€Eˆ8�C‰=ó 	ñ ˜'Ô"òó #ðñ2 �^¨(Ô3Øð°ð ¸ò ó ó 4ðñ �[ xÔ0Øð cð ¨cò ó ó 1ðð$ €K�ÓØ€M�5ÓØ€Dˆ(�3‰-ÓØ€GˆTÓð €HˆcÓØ €GˆU�3˜�8‰_Ó ð €IˆsÓØ€IˆtÓØ.4€L�'Ð*Ñ+Ó4Ø€M�5ÓØ#Ð�tÓ#à %Ð˜Ó%Ø#Ð�tÓ#Ø"'Ð˜4Ó'Ø!Ð�dÓ!Ø"Ð�tÓ"Ø!%€J�˜‘Ó%Ø)-Ð˜ ™Ó-Ø%)€O�X˜c‘]Ó)á�\¨Ô0Øð C¨'°&©/Ñ$9ð ¸cÀGÈFÁOÑ>Sò ó ó 1ðñ ØÐ9Ð;]Ðdkôð ð¨cð °cò ó óðñ Ð.°WÔ=Øð eð °ò ó ó >ðñ �^¨'Ô2Øð eð °ò ó ó 3ðñ Ð*¨OÀ'ÔJØð¨Cð °Cò ó ó Kðñ Ð&¨WÔ5Øð¨°#©ð ¸8ÀC¹=ò ó ó 6ðñ �] L°xÔ@ØðB˜[¨4Ñ/ð B°C¸$±Jò Bó ó AðBñ �X HÔ-Øð
 K°$Ñ$6ð 
¸3À¹:ò 
ó ó .ñ
r   r  c                   ól   — e Zd ZU dZdZee   ed<   dZeed<   dZ	e
ed<   dZe
ed<   d	Ze
ed
<   dZeed<   y)ÚSegmentationTrainConfigaÀ  Training configuration for instance segmentation models.

    Extends :class:`TrainConfig` with segmentation-specific loss coefficients.

    Attributes:
        num_select: Maximum number of predictions to keep per image. ``None`` uses
            the model default.
        mask_point_sample_ratio: Number of points sampled per mask for point-based
            mask loss computation.
        mask_ce_loss_coef: Cross-entropy loss weight for mask prediction.
        mask_dice_loss_coef: Dice loss weight for mask prediction.
        cls_loss_coef: Classification loss weight. Defaults to ``1.0`` to match the
            effective pre-v1.7 value (the v1.7 TrainConfig ownership migration
            silently activated a dormant ``5.0``; this field restores the correct
            weight). To reproduce pre-fix segmentation behaviour pass
            ``cls_loss_coef=5.0`` explicitly.
        segmentation_head: Whether to attach the segmentation head.
    Nrt   rà   Úmask_point_sample_ratiog      @Úmask_ce_loss_coefÚmask_dice_loss_coefr�   rŽ   Tr�   )r   r   r   r   rt   r
   r®   r^   r�  r‘  rÙ   r’  rŽ   r�   rØ   r   r   r    r�  r�  x  sM   … ñð& !%€J�˜‘Ó$Ø#%Ð˜SÓ%Ø"Ð�uÓ"Ø!$Ð˜Ó$Ø€M�5ÓØ"Ð�tÔ"r   r�  c                   ó„   — e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	eed<   dZ
eed	<   d
Zeed<    edd¬«      Zeed<   y)ÚKeypointTrainConfigaE  Training configuration for keypoint detection models.

    Extends :class:`TrainConfig` with keypoint-specific loss coefficients and
    metric-smoothing defaults tuned for the NLL-Cholesky keypoint head, which
    produces noisy per-epoch OKS metrics during early fine-tuning.

    Attributes:
        cls_loss_coef: Classification loss weight.
        keypoint_l1_loss_coef: L1 regression loss weight for keypoint coordinates.
        keypoint_findable_loss_coef: Loss weight for the keypoint visibility head.
        keypoint_visible_loss_coef: Loss weight for the keypoint visibility score.
        keypoint_nll_loss_coef: NLL-Cholesky loss weight. Restored to ``1.0`` to
            align with the other keypoint loss terms (``keypoint_l1_loss_coef``,
            ``keypoint_findable_loss_coef``, ``keypoint_visible_loss_coef``).
            Previously set to ``0.5`` to dampen OKS@75 oscillation; reverted as
            the under-weighting was not beneficial in practice.
        smooth_alpha: EMA smoothing factor for :class:`BestModelCallback` metric
            comparison. Overrides the :class:`TrainConfig` default of ``0.0``
            (disabled) to ``0.5``, which balances responsiveness and noise
            suppression for noisy keypoint mAP curves.
        skip_best_epochs: Number of epochs to skip before checkpoint selection begins.
            Overrides the :class:`TrainConfig` default of ``0`` to ``10`` because
            ``val/keypoint_map_50_95`` under the NLL-Cholesky loss is noisy in early
            fine-tuning and can lock checkpoint selection to a transient peak.
    g       @rŽ   r   r.  r/  r0  r�   r1  g      à?r(  r%  r   rv   r'  N)r   r   r   r   rŽ   rÙ   r^   r.  r/  r0  r1  r(  r   r'  r®   r   r   r    r”  r”  ”  s[   … ñð4 €M�5ÓØ#$Ð˜5Ó$Ø)*Ð Ó*Ø()Ð Ó)Ø$'Ð˜EÓ'Ø€L�%ÓÙ!¨"°Ô3Ð�cÔ3r   r”  )2rÍ   r©   Úpathlibr   Útypingr   r   r   r   r   r	   r
   r   r   r*   Úpydanticr   r   r   r   r   Úpydantic_corer   r   r^   r-   r   rf  r   r1   r2   r4   rb   rÜ   rå   rê   rð   ró   r÷   rú   rÿ   r  r  r	  r  r  r  r  r�  r”  r   r   r    ú<module>r™     sl  ðô 
Û Ý ß Z× ZÕ Zã ß SÕ SÝ +à Ð!sÑt€ˆYÓ tØ˜t™€ˆYÓ #ô¨+ô ð#˜ó #ñL Ó€ˆÓ ô:�ô :ôB{E�*ô {Eô|	'�{ô 'ô(	BÐ"2ô 	Bô	AÐ'ô 	Aô	BÐ(ô 	Bô	CÐ)ô 	Cô˜ô ô.Ð-ô ôÐ*ô ôÐ+ô ôÐ,ô ôÐ+ô ôÐ,ô ôÐ-ô ôÐ"2ô ô,~�*ô ~ôB#˜kô #ô8!4˜+õ !4r   