§
    ­¸jäO ã            	       óæ  — U d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZ d dl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mZ d dlmZ d dlmZ d d	lm Z m!Z! ed
         Z"ee#d<   ed         Z$ee#d<   e%ez  Z&ee#d<   ed         dz  Z'ee#d<   ed         Z(ee#d<   dZ)e'e#d<   g d¢Z*ddddœZ+ee%e%f         e#d<   ddddœZ,ee%e%f         e#d<    e j-        d¬¦  «        d e%d!e.fd"„¦   «         Z/ G d#„ d$e%e	¦  «        Z0 G d%„ d&e%e	¦  «        Z1 G d'„ d(e2¦  «        Z3d!e%fd)„Z4 e4¦   «         Z5e%e#d*<   h d+£Z6d,e%d!e7e         fd-„Z8d.e9d!e.fd/„Z:d.ed0ef         d!e;e%dz  e<e%ef         dz  e%dz  f         fd1„Z=d2d3hZ>d4d5d6œZ?e<e%e@eAz  f         e#d7<    eBe?¦  «        ZCe e!z  ZDee#d8<   d9e9d!e.fd:„ZEd9ed0eDf         d!e;e%dz  e<e%ef         dz  e%dz  f         fd;„ZF G d<„ d=e¦  «        ZG G d>„ d?eG¦  «        ZH G d@„ dAeH¦  «        ZI G dB„ dCeI¦  «        ZJ G dD„ dEeI¦  «        ZK G dF„ dGeI¦  «        ZL G dH„ dIeI¦  «        ZM G dJ„ dKeH¦  «        ZN G dL„ dMeI¦  «        ZO G dN„ dOeI¦  «        ZP G dP„ dQeI¦  «        ZQ G dR„ dSeI¦  «        ZR G dT„ dUeI¦  «        ZS G dV„ dWeI¦  «        ZT G dX„ dYeI¦  «        ZU G dZ„ d[eI¦  «        ZV G d\„ d]eG¦  «        ZW G d^„ d_eW¦  «        ZX G d`„ daeW¦  «        ZYdbdcœddeHdeeWdfe.d!e'fdg„ZZdS )hé    N)ÚCallableÚMapping)ÚEnum)ÚPath)ÚAnyÚClassVarÚDictÚLiteralÚOptionalÚ	TypeAlias)Ú	BaseModelÚ
ConfigDictÚFieldÚfield_serializerÚfield_validatorÚmodel_validator)ÚPydanticUndefined)Ú	Optimizer)ÚLRSchedulerÚReduceLROnPlateau)Údinov2_windowed_smallÚdinov2_windowed_baseÚdinov2_registers_windowed_smallÚEncoderName)ÚcocoÚo365ÚroboflowÚyoloÚ
webdatasetÚDatasetFileÚPathLikeStr)ÚautoÚbf16Úfp16Úfp8ÚAmpDtype)ÚhotcocoÚfaster_coco_evalÚufcocoÚvernierÚCocoEvalBackendr"   Ú_AMP_DTYPE_DEFAULT)r&   ÚAugmentationBackendr+   r    ÚModelConfigÚ
MultiScaleÚRFDETRBaseConfigÚRFDETRLargeDeprecatedConfigÚRFDETRNanoConfigÚRFDETRSmallConfigÚRFDETRMediumConfigÚRFDETRLargeConfigÚRFDETRSegPreviewConfigÚRFDETRSegNanoConfigÚRFDETRSegSmallConfigÚRFDETRSegMediumConfigÚRFDETRSegLargeConfigÚRFDETRSegXLargeConfigÚRFDETRSeg2XLargeConfigÚRFDETRKeypointPreviewConfigÚTrainConfigÚSegmentationTrainConfigÚKeypointTrainConfigÚkorniaÚtorchvisionÚalbumentations)ÚgpuÚtvÚalbuÚ$_LEGACY_AUGMENTATION_BACKEND_ALIASESzkornia.augmentationztorchvision.transforms.v2)rC   rA   rB   Ú#_AUGMENTATION_BACKEND_PROBE_MODULES)ÚmaxsizeÚmodule_nameÚreturnc                 óR   — 	 t          j        | ¦  «         dS # t          $ r Y dS w xY w)uK  Return ``True`` when *module_name* can be imported.

    Cached for the process lifetime â€” package installation state does not change at runtime.

    Args:
        module_name: Dotted module path to probe (e.g. ``"kornia.augmentation"``).

    Returns:
        ``True`` if the import succeeds, ``False`` on ``ImportError``.
    TF)Ú	importlibÚimport_moduleÚImportError)rJ   s    ú]/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/rfdetr/config.pyÚ_package_importablerQ   P   s?   € ðÝÔ Ñ,Ô,Ð,ØˆtøÝð ð ð Øˆuˆuðøøøs   ‚ ˜
&¥&c                   ó6   — e Zd ZdZdZdZdZed
d„¦   «         Zd	S )r/   au  Multi-scale training mode for ``TrainConfig.multi_scale``.

    ``PER_BATCH`` draws one random scale per batch and applies it in ``RFDETRLightningModule.on_train_batch_start`` by
    interpolating the already collated batch (the dataset resizes every sample to the largest scale). ``PER_SAMPLE``
    draws a scale per sample inside the dataset transforms and collate pads to the batch maximum. ``OFF`` trains at the
    fixed ``ModelConfig.resolution``. Booleans are accepted as input (``True`` is ``PER_BATCH``, the behaviour the old
    ``multi_scale=True`` default had; ``False`` is ``OFF``) but are never stored as such.
    Úoffz	per-batchz
per-sampleÚvalueúMultiScale | str | boolrK   c                 óD   — |du r| j         S |du r| j        S  | |¦  «        S )au  Normalize a member, its string value, or a legacy boolean to a member.

        Examples:
            >>> MultiScale.from_value(True)
            <MultiScale.PER_BATCH: 'per-batch'>
            >>> MultiScale.from_value(False)
            <MultiScale.OFF: 'off'>
            >>> MultiScale.from_value("per-sample")
            <MultiScale.PER_SAMPLE: 'per-sample'>
        TF)Ú	PER_BATCHÚOFF©ÚclsrT   s     rP   Ú
from_valuezMultiScale.from_valueq   s3   € ð �Dˆ=ˆ=Ø”=Ð Ø�Eˆ>ˆ>Ø”7ˆNØˆs�5‰zŒzÐó    N)rT   rU   rK   r/   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__rX   rW   Ú
PER_SAMPLEÚclassmethodr[   © r\   rP   r/   r/   c   sM   € € € € € ðð ð €CØ€IØ€Jàðð ð ñ „[ðð ð r\   r/   c                   óX   — e Zd ZdZdZdZdZdZeddœde	de
d	d fd
„¦   «         Zd	e
fd„ZdS )r-   uÅ  Concrete augmentation backend selector for ``TrainConfig.augmentation_backend``.

    Only holds directly-usable, concrete backends â€” ``TV`` (torchvision), ``ALBU`` (Albumentations), and ``KORNIA``.
    ``GPU`` is a Python enum alias for ``KORNIA`` (same value ``"kornia"``): Kornia augmentation always runs on-device
    (GPU), so the two names refer to the same backend; ``GPU`` exists only so legacy ``augmentation_backend="gpu"``
    strings keep resolving correctly.

    ``"cpu"`` and ``"auto"`` are accepted as *input* strings (on ``TrainConfig.augmentation_backend`` and by
    :meth:`from_str`) but are never stored or returned as a member of this enum â€” they are auto-pick sentinels resolved
    to a concrete member at :meth:`from_str` call time. Resolution stays late (re-checked at dataset-build time against
    whatever is installed in the current environment) rather than baked into ``TrainConfig`` at construction time, so a
    saved config using ``"cpu"``/``"auto"`` remains portable across environments with different optional packages
    installed. Pass a concrete value (``"torchvision"``, ``"albumentations"``, or ``"kornia"``) explicitly to pin the
    backend regardless of environment.
    rB   rC   rA   F)Úhas_cudarT   re   rK   c                óz  — t                                ||¦  «        }|dv ro|dk    r"|r | j                             ¦   «         r| j        S | j                             ¦   «         r| j        S | j                             ¦   «         r| j        S | j        S 	  | |¦  «        S # t          $ r t          d|›d�¦  «        d‚w xY w)uÃ  Resolve a string to a concrete backend, auto-picking the best installed one.

        Legacy string aliases (``"gpu"``, ``"tv"``, ``"albu"``) are mapped to their current form
        first. ``"cpu"`` auto-picks the best *installed* CPU backend: Albumentations > Kornia
        (CPU) > torchvision. ``"auto"`` additionally prefers Kornia first when ``has_cuda=True``
        and Kornia is installed, then falls back to the same CPU priority. The concrete backend
        ``"cpu"``/``"auto"`` resolve to can therefore vary across environments â€” pass
        ``"torchvision"`` explicitly to force torchvision regardless of what's installed.

        Args:
            value: Backend name string.
            has_cuda: Whether a CUDA device is available. Only consulted for ``"auto"`` â€” callers
                that care about CUDA-gated GPU selection (e.g. dataset builders) compute this via
                their own fork-safe CUDA check and pass it in; this function does not probe CUDA
                itself to avoid importing device-detection code from other modules.

        Returns:
            Concrete ``AugmentationBackend`` member.

        Raises:
            ValueError: When *value* is not a recognised backend name.

        Examples:
            >>> AugmentationBackend.from_str("torchvision")
            <AugmentationBackend.TV: 'torchvision'>
            >>> AugmentationBackend.from_str("gpu")
            <AugmentationBackend.KORNIA: 'kornia'>
        ©Úcpur"   r"   zUnknown augmentation_backend zK; expected one of 'cpu', 'auto', 'torchvision', 'albumentations', 'kornia'.N)rG   ÚgetÚKORNIAÚ_is_availableÚALBUÚTVÚ
ValueError)rZ   rT   re   s      rP   Úfrom_strzAugmentationBackend.from_strš   sè   € õ< 5×8Ò8¸ÀÑFÔFˆØ�OÐ#Ð#Ø˜Šˆ 8ˆ°´
×0HÒ0HÑ0JÔ0JˆØ”zÐ!ØŒx×%Ò%Ñ'Ô'ð  Ø”x�ØŒz×'Ò'Ñ)Ô)ð "Ø”zÐ!Ø”6ˆMð	Ø�3�u‘:”:ÐøÝð 	ð 	ð 	Ýð.°ð .ð .ð .ñô ð ðð	øøøs   Â
B ÂB:c                 ó@   — t          t          | j                 ¦  «        S )um  Return ``True`` when this backend's package is importable.

        Every backend is probed lazily, on first call rather than at ``import rfdetr`` time. ``ALBU`` and ``KORNIA``
        are optional extras (``pip install 'rfdetr[augment]'``); ``TV`` is a required RF-DETR dependency. Probing all
        three keeps the availability contract consistent and verifies the ``torchvision.transforms.v2`` API RF-DETR
        uses is importable.

        The underlying probe is cached for the process lifetime (see :func:`_package_importable`). Tests that
        need to simulate "not installed" must patch **this method**, never ``_package_importable`` or the import
        machinery beneath it â€” a real probe result is cached process-wide and would leak into later tests. Patch
        with a plain function so it still binds and receives the member, which is what makes per-backend
        simulation possible::

            patch.object(AugmentationBackend, "_is_available", lambda self: self is not AugmentationBackend.KORNIA)

        Returns:
            ``True`` if this backend can be used in the current environment.
        )rQ   rH   rT   ©Úselfs    rP   rk   z!AugmentationBackend._is_availableÉ   s   € õ& #Õ#FÀtÄzÔ#RÑSÔSÐSr\   N)r]   r^   r_   r`   rm   rl   rj   ÚGPUrb   ÚstrÚboolro   rk   rc   r\   rP   r-   r-   „   s˜   € € € € € ðð ð  
€BØ€DØ€FØ
€CàØ6;ð ,ð ,ð ,˜Sð ,¨tð ,Ð@Uð ,ð ,ð ,ñ „[ð,ð\T˜tð Tð Tð Tð Tð Tð Tr\   r-   c                   ó   — e Zd ZdZdS )Ú#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)r]   r^   r_   r`   rc   r\   rP   rw   rw   ß   s   € € € € € ðð ð ð r\   rw   c                  ó°  — t          t          dd¦  «        } t          | dd¦  «        }|�g	 	  |d¬¦  «        }n4# t          $ r'  |¦   «         }|�| �|                      ¦   «         sd}Y nw xY w|�t	          |¦  «        S dS # t
          $ r Y dS w xY wt          j                             ¦   «         rdS t          j        j                             ¦   «         rdS dS )	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_availablerh   ÚcudaÚmps)	ÚgetattrÚtorchÚ	TypeErrorÚis_availablert   ÚRuntimeErrorr|   Úbackendsr}   )ry   rz   Úaccels      rP   Ú_detect_devicer…   å   s  € õ �% °Ñ5Ô5€KÝ! +Ð/DÀdÑKÔKÐØÐ&ð	ð!Ø+Ð+¸DÐAÑAÔA��øÝð !ð !ð !Ø+Ð+Ñ-Ô-�ØÐ$¨Ð)@È×IaÒIaÑIcÔIcÐ)@Ø �Eøøð!øøøð Ð Ý˜5‘z”zÐ!Ø�5øÝð 	ð 	ð 	Ø�5�5ð	øøøõ „z×ÒÑ Ô ð ØˆvÝ„~Ô×&Ò&Ñ(Ô(ð ØˆuØˆ5s,   ¬9 ¸B  ¹.A*Á'B  Á)A*Á*B  Â 
BÂBÚDEVICE>   ÚlrÚfusedÚparamsÚweight_decayÚnamec                 ól  — |                       ¦   «                              ¦   «         }t          t          j        ¦  «        D ]b}t          t          j        |¦  «        }t          |t          ¦  «        r1t          |t          ¦  «        r|                     ¦   «         |k    r|c S Œct          d| ›d�¦  «        ‚)u�  Resolve a bare optimizer short name to a ``torch.optim`` optimizer class.

    Only native ``torch.optim`` optimizers may be selected by short name; the match
    is case-insensitive (``"adamw"`` â†’ ``torch.optim.AdamW``, ``"sgd"`` â†’ ``torch.optim.SGD``).
    Any other optimizer must be given as a full dotted import path or a callable.

    Args:
        name: A bare optimizer name (no dotted import path).

    Returns:
        The matching ``torch.optim`` optimizer class.

    Raises:
        ValueError: If ``name`` is not a native ``torch.optim`` optimizer.

    Examples:
        >>> _resolve_native_optimizer("adamw") is torch.optim.AdamW
        True
    zUnknown native optimizer z�. Short names must name a torch.optim optimizer (e.g. 'adamw', 'sgd', 'adam'); use a full dotted import path or a callable for anything else.)ÚstripÚlowerÚdirr   Úoptimr~   Ú
isinstanceÚtypeÚ
issubclassr   rn   )r‹   ÚtargetÚ	attributeÚ	candidates       rP   Ú_resolve_native_optimizerr—     s»   € ð( �ZŠZ‰\Œ\×ÒÑ!Ô!€FÝ�œÑ%Ô%ð ð ˆ	Ý�EœK¨Ñ3Ô3ˆ	Ý�i¥Ñ&Ô&ð 	­:°iÅÑ+KÔ+Kð 	ÐPY×P_ÒP_ÑPaÔPaÐekÒPkÐPkØÐÐÐøÝ
ð	h Dð 	hð 	hð 	hñô ð r\   Ú	optimizerc                 ó4   — t          | t          ¦  «        od| vS )aØ  Return whether an optimizer config selects RF-DETR's managed construction.

    Managed mode covers bare ``torch.optim`` short names (e.g. ``"adamw"``, ``"sgd"``);
    RF-DETR injects ``lr`` and a signature-aware ``weight_decay`` there. A dotted import
    path or a callable selects explicit mode, where the optimizer is built only from
    ``optimizer_kwargs`` (or the callable's own bound arguments).

    Args:
        optimizer: The ``TrainConfig.optimizer`` value.

    Returns:
        ``True`` for managed short-name strings, ``False`` for dotted paths and callables.

    Examples:
        >>> _is_managed_optimizer_name("sgd")
        True
        >>> _is_managed_optimizer_name("torch.optim.AdamW")
        False
    ú.)r‘   rt   )r˜   s    rP   Ú_is_managed_optimizer_namer›   .  s   € õ( �i¥Ñ%Ô%Ð>¨#°YÐ*>Ð>r\   .c                 óR  — | }i }t          | t          j        ¦  «        r&| j        rdS | j        }t          | j        pi ¦  «        }t          |dd¦  «        }t          |dd¦  «        }|�|�d|v rdS 	 t          j	        |¦  «         n# t          t          f$ r Y dS w xY w|› d|› �|dfS )	u¡  Decompose a callable optimizer into a serializable ``(dotted_path, kwargs)`` form.

    Reconstructable callables â€” an importable top-level class or function, optionally
    wrapped in ``functools.partial`` with JSON-serializable keyword arguments and no
    positional arguments â€” desugar to a dotted import path plus keyword arguments that
    round-trip through ``training_config.json``.

    Args:
        optimizer: A callable or ``functools.partial`` given as ``TrainConfig.optimizer``.

    Returns:
        ``(dotted_path, kwargs, None)`` when reconstructable, otherwise
        ``(None, None, reason)`` where ``reason`` explains how to make it compatible.
    ©NNzDpass every functools.partial argument as a keyword, not positionallyr^   Nr_   ú<)NNzbdefine the optimizer as an importable top-level class or function (no lambda or nested definition)©NNzbuse only JSON-serializable functools.partial keyword arguments (no tensors, modules, or callables)rš   ©r‘   Ú	functoolsÚpartialÚargsÚfuncÚdictÚkeywordsr~   ÚjsonÚdumpsr€   rn   )r˜   r¤   Úextracted_kwargsÚmoduleÚqualnames        rP   Ú_desugar_optimizer_callabler¬   E  sö   € ð" €DØ')ÐÝ�)�YÔ.Ñ/Ô/ð :ØŒ>ð 	fØeÐeØŒ~ˆÝ 	Ô 2Ð 8°bÑ9Ô9Ðå�T˜<¨Ñ.Ô.€FÝ�t˜^¨TÑ2Ô2€HØ€~˜Ð)¨S°H¨_¨_ð
ð 
ð
ÝŒ
Ð#Ñ$Ô$Ð$Ð$øÝ•zÐ"ð 
ð 
ð 
ð
ð 
ð 
ð
øøøð Ð!Ð!�xÐ!Ð!Ð#3°TÐ9Ð9ó   Á2B ÂBÂBÚstepÚcosineéd   ç        )Úlr_dropÚ
min_factorÚ_MANAGED_SCHEDULER_DEFAULTSÚSchedulerTypeÚlr_schedulerc                 ó†   — t          | t          ¦  «        o,|                      ¦   «                              ¦   «         t          v S )a¶  Return whether an lr_scheduler config selects an RF-DETR managed preset.

    Managed presets are the built-in ``"step"`` and ``"cosine"`` schedules, which own warmup
    and total-step sizing. A dotted import path or a callable instead selects an explicit
    scheduler built from ``lr_scheduler_kwargs`` (or the callable's own bound arguments).

    Args:
        lr_scheduler: The ``TrainConfig.lr_scheduler`` value.

    Returns:
        ``True`` for managed preset short names, ``False`` for dotted paths and callables.

    Examples:
        >>> _is_managed_scheduler_name("cosine")
        True
        >>> _is_managed_scheduler_name("torch.optim.lr_scheduler.StepLR")
        False
    )r‘   rt   r�   rŽ   Ú_MANAGED_SCHEDULER_PRESETS)r¶   s    rP   Ú_is_managed_scheduler_namer¹   }  s7   € õ& �l¥CÑ(Ô(Ðg¨\×-?Ò-?Ñ-AÔ-A×-GÒ-GÑ-IÔ-IÕMgÐ-gÐgr\   c                 óR  — | }i }t          | t          j        ¦  «        r&| j        rdS | j        }t          | j        pi ¦  «        }t          |dd¦  «        }t          |dd¦  «        }|�|�d|v rdS 	 t          j	        |¦  «         n# t          t          f$ r Y dS w xY w|› d|› �|dfS )	uò  Decompose a callable lr_scheduler into a serializable ``(dotted_path, kwargs)`` form.

    Reconstructable callables â€” an importable top-level class or function, optionally wrapped in
    ``functools.partial`` with JSON-serializable keyword arguments and no positional arguments â€”
    desugar to a dotted import path plus keyword arguments that round-trip through
    ``training_config.json``. The optimizer is supplied at build time, never baked into the callable.

    Args:
        lr_scheduler: A callable or ``functools.partial`` given as ``TrainConfig.lr_scheduler``.

    Returns:
        ``(dotted_path, kwargs, None)`` when reconstructable, otherwise
        ``(None, None, reason)`` where ``reason`` explains how to make it compatible.
    r�   r^   Nr_   rž   )NNzedefine the lr_scheduler as an importable top-level class or function (no lambda or nested definition)rŸ   rš   r    )r¶   r¤   r©   rª   r«   s        rP   Ú_desugar_scheduler_callabler»   “  sø   € ð" €DØ')ÐÝ�,¥	Ô 1Ñ2Ô2ð =ØÔð 	fØeÐeØÔ ˆÝ Ô 5Ð ;¸Ñ<Ô<Ðå�T˜<¨Ñ.Ô.€FÝ�t˜^¨TÑ2Ô2€HØ€~˜Ð)¨S°H¨_¨_ð
ð 
ð
ÝŒ
Ð#Ñ$Ô$Ð$Ð$øÝ•zÐ"ð 
ð 
ð 
ð
ð 
ð 
ð
øøøð Ð!Ð!�xÐ!Ð!Ð#3°TÐ9Ð9r­   c                   ó¦   ‡ — 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ÚvaluesrK   c                 ó´  — t          |t          ¦  «        s|S | j                             d¦  «        dk    r|S t	          | j                             ¦   «         ¦  «        }t	          |¦  «        }||z
  }|rdd                     d„ t          |¦  «        D ¦   «         ¦  «        }d                     t          |¦  «        ¦  «        }t          d|› d|› d�¦  «        ‚|S )NrÀ   r¾   ú, c              3   ó"   K  — | ]
}d |› d �V — ŒdS )ú'Nrc   )Ú.0Úparams     rP   ú	<genexpr>z/BaseConfig.catch_typo_kwargs.<locals>.<genexpr>Ô  s*   è è € Ð+]Ð+]¸U¨L°¨L¨L¨LÐ+]Ð+]Ð+]Ð+]Ð+]Ð+]r\   zUnknown parameter(s): z. Available parameter(s): rš   )
r‘   r   rÂ   ri   ÚsetÚmodel_fieldsÚkeysÚjoinÚsortedrn   )rZ   rÆ   Úallowed_paramsÚprovided_paramsÚunknown_paramsÚunknown_params_listÚallowed_params_lists          rP   Úcatch_typo_kwargszBaseConfig.catch_typo_kwargsÉ  sé   € õ ˜&¥'Ñ*Ô*ð 	ØˆMØÔ×Ò Ñ(Ô(¨HÒ4Ð4ØˆMÝ˜SÔ-×2Ò2Ñ4Ô4Ñ5Ô5ˆÝ˜f™+œ+ˆØ(¨>Ñ9ˆØð 	Ø"&§)¢)Ð+]Ð+]ÅfÈ^ÑF\ÔF\Ð+]Ñ+]Ô+]Ñ"]Ô"]ÐØ"&§)¢)­F°>Ñ,BÔ,BÑ"CÔ"CÐÝØnÐ)<ÐnÐnÐXkÐnÐnÐnñô ð ð ˆr\   r‹   rT   Nc                 óÈ   •— |                      d¦  «        s|t          | ¦  «        j        v r$t          ¦   «                              ||¦  «         d S t          d|› d�¦  «        ‚)NÚ_zUnknown attribute: 'z'.)Ú
startswithr’   rÏ   ÚsuperÚ__setattr__rn   )rr   r‹   rT   Ú	__class__s      €rP   rÝ   zBaseConfig.__setattr__Û  sc   ø€ Ø�?Š?˜3ÑÔð 	 4­4°©:¬:Ô+BÐ#BÐ#BÝ‰GŒG×Ò  eÑ,Ô,Ð,ØˆFÝÐ8°Ð8Ð8Ð8Ñ9Ô9Ð9r\   )r]   r^   r_   r`   r   rÂ   r   Ú__annotations__r   rb   r   rØ   rt   rÝ   Ú__classcell__)rÞ   s   @rP   r½   r½   Á  sÉ   ø€ € € € € € ðð ð
 *4¨¸(ÐX\Ð)]Ñ)]Ô)]€L�(˜:Ô&Ð]Ð]Ñ]à€_˜(Ð#Ñ#Ô#Øð sð ¨sð ð ð ñ „[ñ $Ô#ðð : ð :¨Cð :°Dð :ð :ð :ð :ð :ð :ð :ð :ð :ð :r\   r½   c                   óÎ  — e Zd ZU dZ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dz  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(<   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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dz  ed?<    e/d@¬A¦  «        dIdC„¦   «         Z0 e/d@¬A¦  «        dIdD„¦   «         Z1 e2d dE¬A¦  «        e3dFedz  dBedz  fdG„¦   «         ¦   «         Z4 e2d!dE¬A¦  «        e3dFe5dBefdH„¦   «         ¦   «         Z6dS )Jr.   ah  Core architecture configuration for RF-DETR models.

    Concrete subclasses (e.g. ``RFDETRBaseConfig``, ``RFDETRLargeConfig``) must supply every field
    that has no default; direct instantiation of ``ModelConfig`` is unsupported.

    Attributes:
        encoder: Vision-transformer backbone identifier. Must be provided by concrete subclass.
        out_feature_indexes: Encoder layer indices whose feature maps are forwarded to the decoder.
            Must be provided by concrete subclass.
        dec_layers: Number of transformer decoder layers. Must be provided by concrete subclass.
        projector_scale: Feature-pyramid levels fed to the decoder cross-attention (subset of
            ``["P3", "P4", "P5"]``). Must be provided by concrete subclass.
        hidden_dim: Width of the decoder hidden state. Must be provided by concrete subclass.
        patch_size: ViT patch size used by the backbone. Must be provided by concrete subclass.
        num_windows: Number of windowed-attention windows in the backbone. Must be provided by
            concrete subclass.
        sa_nheads: Number of heads in decoder self-attention. Must be provided by concrete
            subclass.
        ca_nheads: Number of heads in decoder cross-attention. Must be provided by concrete
            subclass.
        dec_n_points: Deformable attention points per head per level in the decoder. Must be
            provided by concrete subclass.
        resolution: Square input resolution (pixels). Must be provided by concrete subclass.
        positional_encoding_size: Side length (in patches) of the sinusoidal positional grid.
            Must be provided by concrete subclass.
        num_queries: Number of object queries used during inference (and per group during
            training). Defaults to ``300``.
        num_classes: Number of output classes (background-free). Defaults to ``90`` (COCO).
        group_detr: Number of duplicate query groups used during training for GroupPose-style
            convergence acceleration. ``num_queries * group_detr`` predictions are produced in
            training mode; ``num_queries`` in eval mode. ``num_queries`` must be divisible by
            ``group_detr``. Defaults to ``13``.
        amp: Deprecated, removal in v1.14: use ``TrainConfig.amp_dtype=None`` instead. Enable
            automatic mixed precision (bfloat16/float16). Defaults to ``True``. An explicit
            ``TrainConfig.amp_dtype`` always overrides this field; it is only consulted when
            ``amp_dtype`` is left at its default and this field is set to ``False``.
        compile: Compile the model and matcher L1 box cost with ``torch.compile`` on CUDA.
            Under BF16/FP16 AMP the compiled cost serves the decoder (and auxiliary) layers;
            encoder-stage matching stays on the eager ``torch.cdist`` path because its predicted
            boxes are emitted in the reduced precision while targets stay float32. For detection
            models with ``TrainConfig.multi_scale=False`` (and the defaults
            ``TrainConfig.square_resize_div_64=True`` and ``cuda_graphs=False``) the model is compiled
            for the fixed training batch shape (a validation batch of another shape, such as a partial
            final batch or a different ``TrainConfig.eval_batch_size``, recompiles once) and the default
            IA-BCE detection losses run layer-batched in one compiled function. Target packing and
            assignment stay eager, and every other configuration, including segmentation and keypoint
            models, keeps its dynamic model compile and eager per-layer losses. Defaults to ``False``.
        cuda_graphs: Capture and replay the single-GPU detection training forward with CUDA
            graphs. Removes kernel-launch gaps, so it pays at small batch sizes; at large batch
            sizes it matches eager and ``compile`` is the better lever. Combined with
            ``compile=True`` the replay is delegated to Inductor's CUDA graph trees, which
            stacks both gains at small batch sizes and matches plain compilation at large
            ones. With ``amp_dtype="fp8"`` and ``compile=False``, uses Transformer Engine's
            FP8-aware capture instead, requiring fixed resolution and no gradient accumulation.
            Combining FP8 with both flags stays compile-only. Defaults to ``False``.
        pretrain_weights: Path or URL to pretrained checkpoint. ``None`` trains from scratch.
        device: Target device string (e.g. ``"cuda"``, ``"cpu"``). Auto-detected if not set.
        gradient_checkpointing: Trade compute for memory by checkpointing activations. Defaults
            to ``False``.
    Ú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š™™™™™É?r±   ©Ú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Úcuda_graphsÚfused_optimizerÚpositional_encoding_sizeÚia_bce_lossÚ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``.©rõ   ÚdescriptionÚ
model_nameÚafterrÄ   rK   c                 ót  — 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
  rì   )	Úmodel_fields_setr’   rÏ   rõ   r‘   Úintr  rì   r
  )rr   rZ   Údefault_resolutionÚ
default_peÚdefault_patch_sizes        rP   Ú_sync_pe_with_resolutionz$ModelConfig._sync_pe_with_resolutionX  sÑ   € ð ˜tÔ4Ð4Ð4Ð8RÐVZÔVkÐ8kÐ8kØˆKå�4‰jŒjˆØ Ô-¨lÔ;ÔCÐØÔ%Ð&@ÔAÔIˆ
Ø Ô-¨lÔ;ÔCÐõ Ð-­sÑ3Ô3ð	å˜j­#Ñ.Ô.ð	õ Ð0µ#Ñ6Ô6ð	ð
 ˆKð Ð+Ð/AÑAÒAÐAØ,0¬O¸t¼Ñ,NˆDÔ)àˆr\   c                 óŽ  — t          | ¦  «        }| j        }d|v }|rM| j        €F|j        d         j        }|t
          ur)|�'t          j        |j        › d|›d�t          d¬¦  «         | S |rI| j        �B|j        d         j        }|�,|t
          ur#| 
                    |¦  «        }| j        |k    r| S n| S |j        d         j        }|�	|t
          u r| S g }d}	d}
|	D ]w}||vrŒ|j                             |¦  «        }|�|                     ¦   «         rŒ8|j        }|t
          u rŒIt          | |¦  «        }||k    r|                     |||f¦  «         Œx|
D ]¡}||vrŒ|j                             |¦  «        }|�|                     ¦   «         rŒ8|j        }|t
          u st          |t           ¦  «        sŒ^t          | |¦  «        }t          |t           ¦  «        r||k    r|                     |||f¦  «         Œ¢d	|v rl| j        re|j                             d	¦  «        }|�I|                     ¦   «         s5|j        }|t
          ur%| j        }||k    r|                     d	||f¦  «         |r[|j        d         j        }d
                     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  Nz² 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).é   ©Ú
stacklevel)râ   rë   rä   rí   rî   rï   rð   rã   rê   rø   rù   rú   rå   rì   r  rþ   )rò   r  r  ú
c              3   ó6   K  — | ]\  }}}d |› d|›d|›d�V — ŒdS )z  z: z (variant default: ú)Nrc   )rË   r‹   Úcurrentrõ   s       rP   rÍ   z;ModelConfig._warn_pretrain_compatibility.<locals>.<genexpr>  sW   è è € ð ð ÙLbÈDÐRYÐ[bÐG�TÐGÐG˜WÐGÐG¸7ÐGÐGÐGðð ð ð ð ð r\   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.)r’   r!  r  rÏ   rõ   r   ÚwarningsÚwarnr]   rw   Úexpand_pathri   Úis_requiredr~   Úappendr‘   r"  r  r  rÑ   )rr   rZ   Ú
fields_setÚpretrain_user_setÚdefault_pretrainÚ_default_pretrainÚ_expanded_defaultÚ_class_default_pretrainÚ	overridesÚbreaking_fieldsÚbreaking_on_increaser‹   Ú
field_inforõ   r.  Ú	_mdr_infoÚ_mdr_defaultÚ_mdr_currentÚliness                      rP   Ú_warn_pretrain_compatibilityz(ModelConfig._warn_pretrain_compatibility|  sÉ  € õ( �4‰jŒjˆØÔ*ˆ
Ø.°*Ð<Ðàð 	 Ô!6Ð!>Ø"Ô/Ð0BÔCÔKÐØÕ'8Ð8Ð8Ð=MÐ=YÝ”Ø”|ð :ð :ð $4ð:ð :ð :õ 8Ø ðñ ô ð ð ˆKàð 	 Ô!6Ð!Bð !$Ô 0Ð1CÔ DÔ LÐØ Ð,Ð1BÕJ[Ð1[Ð1[Ø$'§O¢OÐ4EÑ$FÔ$FÐ!ØÔ(Ð,=Ò=Ð=Ø�Kð >ð �ð #&Ô"2Ð3EÔ"FÔ"NÐØ"Ð*Ð.EÕIZÐ.ZÐ.ZØˆKà02ˆ	ð,
ˆð(1
Ðð
 $ð 	;ð 	;ˆDØ˜:Ð%Ð%ØØÔ)×-Ò-¨dÑ3Ô3ˆJØÐ! Z×%;Ò%;Ñ%=Ô%=Ð!ØØ Ô(ˆGØÕ+Ð+Ð+ØÝ˜d DÑ)Ô)ˆGØ˜'Ò!Ð!Ø× Ò  $¨°Ð!9Ñ:Ô:Ð:øà(ð 	;ð 	;ˆDØ˜:Ð%Ð%ØØÔ)×-Ò-¨dÑ3Ô3ˆJØÐ! Z×%;Ò%;Ñ%=Ô%=Ð!ØØ Ô(ˆGØÕ+Ð+Ð+µ:¸gÅsÑ3KÔ3KÐ+ØÝ˜d DÑ)Ô)ˆGÝ˜'¥3Ñ'Ô'ð ;¨G°gÒ,=Ð,=Ø× Ò  $¨°Ð!9Ñ:Ô:Ð:øð # jÐ0Ð0°TÔ5KÐ0ØÔ(×,Ò,Ð-DÑEÔEˆIØÐ$¨Y×-BÒ-BÑ-DÔ-DÐ$Ø(Ô0�ØÕ'8Ð8Ð8Ø#'Ô#=�LØ# |Ò3Ð3Ø!×(Ò(Ð*AÀ<ÐQ]Ð)^Ñ_Ô_Ð_àð 	Ø"Ô/Ð0BÔCÔKÐØ—I’Ið ð Øfoðñ ô ñ ô ˆEõ ŒMØ”<ð  ð  à$ð ð  ð ð ð  ð  õ 4Øðñ ô ð ð ˆr\   rÃ   Úvc                 óD  — |€|S t           j                             t          j        |¦  «        ¦  «        }t           j                             |¦  «        s.ddlm} t           j                              |¦   «         |¦  «        S t           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.
        Nr   )Úget_model_cache_dir)	ÚosÚpathÚ
expanduserÚfspathÚdirnameÚrfdetr.assets.model_weightsrE  rÑ   Úrealpath)rZ   rC  ÚexpandedrE  s       rP   r1  zModelConfig.expand_path  sŠ   € ð ˆ9ØˆHÝ”7×%Ò%¥b¤i°¡l¤lÑ3Ô3ˆÝŒw�Š˜xÑ(Ô(ð 	AàGÐGÐGÐGÐGÐGå”7—<’<Ð 3Ð 3Ñ 5Ô 5°xÑ@Ô@Ð@ÝŒw×Ò Ñ)Ô)Ð)r\   c                 óF  — t          |t          j        ¦  «        rt          |¦  «        S t          |t          ¦  «        rU	 t          t          j        |¦  «        ¦  «        S # t          t
          t          f$ r}t          d|›d�¦  «        |‚d}~ww xY wt          d¦  «        ‚)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: rš   Nz(device must be a string or torch.device.)r‘   r   r  rt   r€   rn   r‚   )rZ   rC  Úexcs      rP   Ú_normalize_devicezModelConfig._normalize_device.  s§   € õ  �a�œÑ&Ô&ð 	Ý�q‘6”6ˆMÝ�a�ÑÔð 	OðOÝ�5œ<¨™?œ?Ñ+Ô+Ð+øÝ�z­<Ð8ð Oð Oð OÝ Ð!D¸aÐ!DÐ!DÐ!DÑEÔEÈ3ÐNøøøøðOøøøåÐCÑDÔDÐDs   Á  A! Á!BÁ8BÂB)rK   r.   )7r]   r^   r_   r`   r   rß   Úlistr"  rå   ru   r
   rò   ró   r   r÷   Úfloatrø   rù   rú   rû   rþ   r   r  r!   r†   r  rt   r  r  r  r  r	  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r&  rB  r   rb   r1  r   rP  rc   r\   rP   r.   r.   â  s  € € € € € € ð;ð ;ðz ÐÐÑØ˜cœÐ"Ð"Ñ"Ø€O€O�OØ€IˆtÐÐÑØ˜'Ð"2Ô3Ô4Ð4Ð4Ñ4Ø€O€O�OØ€O€O�OØÐÐÑØ€N€N�NØ€N€N�NØÐÐÑØ€K�ÐÐÑà€J�ÐÐÑØ%* U°3¸3Ð%?Ñ%?Ô%?Ð˜UÐ?Ð?Ñ?Ø€L�$ÐÐÑØ!%Ð˜$Ð%Ð%Ñ%Ø€J�ÐÐÑà€CˆÐÐÑØ˜ a¨AÐ.Ñ.Ô.€L�#Ð.Ð.Ñ.Ø€K�ÐÐÑØ+/Ð�k DÑ(Ð/Ð/Ñ/à€FˆCÐÐÑØ€O€O�OØ€J�ÐÐÑØ#(Ð˜DÐ(Ð(Ñ(Ø€GˆTÐÐÑØ€K�ÐÐÑØ €O�TÐ Ð Ñ Ø!Ð!Ð!Ñ!Ø€K�ÐÐÑØ#Ð�tÐ#Ð#Ñ#Ø$)Ð˜TÐ)Ð)Ñ)Ø $Ð˜Ð$Ð$Ñ$Ø#(Ð˜DÐ(Ð(Ñ(Ø,-Ð$ cÐ-Ð-Ñ-Ø €N�DÐ Ð Ñ Ø#(Ð˜DÐ(Ð(Ñ(Ø).¨¸tÐ)DÑ)DÔ)DÐ˜T #œYÐDÐDÑDØ!"Ð˜3Ð"Ð"Ñ"Ø!"Ð˜3Ð"Ð"Ñ"Ø€M�4ÐÐÑØ €N�DÐ Ð Ñ Ø€GˆSÐÐÑØ"˜UØð7ðñ ô €J��d‘
ð ð ñ ð €_˜'Ð"Ñ"Ô"ð!ð !ð !ñ #Ô"ð!ðF €_˜'Ð"Ñ"Ô"ðYð Yð Yñ #Ô"ðYðv €_Ð'¨hÐ7Ñ7Ô7Øð*˜K¨$Ñ.ð *°3¸±:ð *ð *ð *ñ „[ñ 8Ô7ð*ð( €_�X HÐ-Ñ-Ô-ØðE #ð E¨#ð Eð Eð Eñ „[ñ .Ô-ðEð Eð E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<   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dz  ed<   dZeed<   dZeed <   dS )!r0   z,The configuration for an RF-DETR Base model.r   râ   é   rë   é   rì   r  rí   rü   rä   é   rî   é   rï   r(  rð   rñ   rò   ró   rè   ræ   rê   )r(  é   rV  é   rã   zrf-detr-base.pthNr  i0  r  é%   r
  )r]   r^   r_   r`   râ   r   rß   rë   r"  rì   rí   rä   rî   rï   rð   rò   ró   rê   rQ  r
   rã   r  r!   r  r
  rc   r\   rP   r0   r0   H  s%  € € € € € € Ø6Ð6à2€Gˆ[Ð2Ð2Ñ2Ø€J�ÐÐÑØ€J�ÐÐÑØ€K�ÐÐÑØ€J�ÐÐÑØ€IˆsÐÐÑØ€IˆsÐÐÑØ€L�#ÐÐÑØ€K�ÐÐÑØ€J�ÐÐÑØ8<°v€O�T˜'Ð"2Ô3Ô4Ð=Ð=Ñ=Ø%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø+=Ð�k DÑ(Ð=Ð=Ñ=Ø€J�ÐÐÑØ$&Ð˜cÐ&Ð&Ñ&Ð&Ð&r\   r0   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dz  ed<   dS )r1   z-The configuration for an RF-DETR Large model.r   râ   é€  rë   é   rî   é   rï   r  rð   rç   ré   ræ   rê   zrf-detr-large.pthNr  )r]   r^   r_   r`   râ   r   rß   rë   r"  rî   rï   rð   rê   rQ  r
   r  r!   rc   r\   rP   r1   r1   \  s�   € € € € € € Ø7Ð7à1€Gˆ[Ð1Ð1Ñ1Ø€J�ÐÐÑØ€IˆsÐÐÑØ€IˆsÐÐÑØ€L�#ÐÐÑØ8<¸d°|€O�T˜'Ð"2Ô3Ô4ÐCÐCÑCØ+>Ð�k DÑ(Ð>Ð>Ñ>Ð>Ð>r\   r1   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dz  ed<   dS )r2   z,The configuration for an RF-DETR Nano model.©rü   é   é	   r]  rã   r(  rí   rä   rW  rì   r\  r  r^  r
  zrf-detr-nano.pthNr  ©r]   r^   r_   r`   rã   rQ  r"  rß   rí   rä   rì   r  r
  r  r!   rc   r\   rP   r2   r2   h  s˜   € € € € € € Ø6Ð6à%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$&Ð˜cÐ&Ð&Ñ&Ø+=Ð�k DÑ(Ð=Ð=Ñ=Ð=Ð=r\   r2   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dz  ed<   dS )r3   z-The configuration for an RF-DETR Small model.r`  rã   r(  rí   rü   rä   rW  rì   i   r  é    r
  zrf-detr-small.pthNr  rc  rc   r\   rP   r3   r3   t  s˜   € € € € € € Ø7Ð7à%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$&Ð˜cÐ&Ð&Ñ&Ø+>Ð�k DÑ(Ð>Ð>Ñ>Ð>Ð>r\   r3   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dz  ed<   dS )r4   z.The configuration for an RF-DETR Medium model.r`  rã   r(  rí   r  rä   rW  rì   é@  r  é$   r
  zrf-detr-medium.pthNr  rc  rc   r\   rP   r4   r4   €  s˜   € € € € € € Ø8Ð8à%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$&Ð˜cÐ&Ð&Ñ&Ø+?Ð�k DÑ(Ð?Ð?Ñ?Ð?Ð?r\   r4   c                   ó0  — e Zd ZU dZ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dz  ed<   dZeed<   dZeed<   dZeed <   dS )!r5   z2Configuration for the RF-DETR Large model variant.r   râ   rT  rë   r  rä   rV  rî   rW  rï   r(  rð   rí   rì   rè   ræ   rê   r`  rã   rÿ   r   é,   r
  zrf-detr-large-2026.pthNr  iÀ  r  rñ   rò   ró   )r]   r^   r_   r`   râ   r
   rß   rë   r"  rä   rî   rï   rð   rí   rì   rê   rQ  rã   r   r
  r  r!   r  rò   ró   rc   r\   rP   r5   r5   �  s=  € € € € € € Ø<Ð<à0G€GˆWÐ,Ô-ÐGÐGÑGØ€J�ÐÐÑØ€J�ÐÐÑØ€IˆsÐÐÑØ€IˆsÐÐÑØ€L�#ÐÐÑØ€K�ÐÐÑØ€J�ÐÐÑØ8<°v€O�T˜'Ð"2Ô3Ô4Ð=Ð=Ñ=Ø%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ$-Ð˜cÐ-Ð-Ñ-Ø+CÐ�k DÑ(ÐCÐCÑCØ€J�ÐÐÑð
 €K�ÐÐÑØ€J�ÐÐÑÐÐr\   r5   c                   óÄ   — e Zd ZU dZ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dz  ed<   dZe	ed<   dS )r6   z9Configuration for the RF-DETR Segmentation Preview model.Tr  r`  rã   r(  rí   r  rä   r]  rì   é°  r  rh  r
  éÈ   rò   ró   zrf-detr-seg-preview.ptNr  rÿ   r   ©r]   r^   r_   r`   r  ru   rß   rã   rQ  r"  rí   rä   rì   r  r
  rò   ró   r  r!   r   rc   r\   rP   r6   r6   ¦  sÙ   € € € € € € ØCÐCà"Ð�tÐ"Ð"Ñ"Ø%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$&Ð˜cÐ&Ð&Ñ&Ø€K�ÐÐÑØ€J�ÐÐÑØ+CÐ�k DÑ(ÐCÐCÑCØ€K�ÐÐÑÐÐr\   r6   c                   óÄ   — e Zd ZU dZ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dz  ed<   dZe	ed<   dS )r7   z>Configuration for the RF-DETR Segmentation Nano model variant.Tr  r`  rã   rý   rí   r  rä   r]  rì   i8  r  é   r
  r°   rò   ró   zrf-detr-seg-nano.ptNr  rÿ   r   rn  rc   r\   rP   r7   r7   ¶  sÙ   € € € € € € ØHÐHà"Ð�tÐ"Ð"Ñ"Ø%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$-Ð˜cÐ-Ð-Ñ-Ø€K�ÐÐÑØ€J�ÐÐÑØ+@Ð�k DÑ(Ð@Ð@Ñ@Ø€K�ÐÐÑÐÐr\   r7   c                   óÄ   — e Zd ZU dZ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dz  ed<   dZe	ed<   dS )r8   z?Configuration for the RF-DETR Segmentation Small model variant.Tr  r`  rã   r(  rí   r  rä   r]  rì   r\  r  re  r
  r°   rò   ró   zrf-detr-seg-small.ptNr  rÿ   r   rn  rc   r\   rP   r8   r8   Æ  óÙ   € € € € € € ØIÐIà"Ð�tÐ"Ð"Ñ"Ø%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$-Ð˜cÐ-Ð-Ñ-Ø€K�ÐÐÑØ€J�ÐÐÑØ+AÐ�k DÑ(ÐAÐAÑAØ€K�ÐÐÑÐÐr\   r8   c                   óÄ   — e Zd ZU dZ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dz  ed<   dZe	ed<   dS )r9   z@Configuration for the RF-DETR Segmentation Medium model variant.Tr  r`  rã   r(  rí   rX  rä   r]  rì   rl  r  rh  r
  rm  rò   ró   zrf-detr-seg-medium.ptNr  rÿ   r   rn  rc   r\   rP   r9   r9   Ö  óÙ   € € € € € € ØJÐJà"Ð�tÐ"Ð"Ñ"Ø%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$-Ð˜cÐ-Ð-Ñ-Ø€K�ÐÐÑØ€J�ÐÐÑØ+BÐ�k DÑ(ÐBÐBÑBØ€K�ÐÐÑÐÐr\   r9   c                   óÄ   — e Zd ZU dZ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dz  ed<   dZe	ed<   dS )r:   z?Configuration for the RF-DETR Segmentation Large model variant.Tr  r`  rã   r(  rí   rX  rä   r]  rì   iø  r  é*   r
  rm  rò   ró   zrf-detr-seg-large.ptNr  rÿ   r   rn  rc   r\   rP   r:   r:   æ  rr  r\   r:   c                   óÄ   — e Zd ZU dZ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dz  ed<   dZe	ed<   dS )r;   z@Configuration for the RF-DETR Segmentation XLarge model variant.Tr  r`  rã   r(  rí   ra  rä   r]  rì   ip  r  é4   r
  rñ   rò   ró   zrf-detr-seg-xlarge.ptNr  rÿ   r   rn  rc   r\   rP   r;   r;   ö  rt  r\   r;   c                   óÄ   — e Zd ZU dZ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dz  ed<   dZe	ed<   dS )r<   zAConfiguration for the RF-DETR Segmentation 2XLarge model variant.Tr  r`  rã   r(  rí   ra  rä   r]  rì   i   r  é@   r
  rñ   rò   ró   zrf-detr-seg-xxlarge.ptNr  rÿ   r   rn  rc   r\   rP   r<   r<     sÙ   € € € € € € ØKÐKà"Ð�tÐ"Ð"Ñ"Ø%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$-Ð˜cÐ-Ð-Ñ-Ø€K�ÐÐÑØ€J�ÐÐÑØ+CÐ�k DÑ(ÐCÐCÑCØ€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dz  ed<   dZeed <   dS )!r=   z-Configuration for the preview keypoint model.Tr  r  r  é   r  r  Fr  rý   r  r`  rã   r(  rí   r  rä   r]  rì   rg  r  é0   r
  r°   rò   ró   z#rf-detr-keypoint-preview-xlarge.pthNr  rÿ   r   )r]   r^   r_   r`   r  ru   rß   r  r  r  rQ  r"  r  r  r  rã   rí   rä   rì   r  r
  rò   ró   r  r!   r   rc   r\   rP   r=   r=     sD  € € € € € € Ø7Ð7à$(Ð˜TÐ(Ð(Ñ(Ø€N�DÐÐÑØ#'Ð˜DÐ'Ð'Ñ'Ø*,¨Ð˜T #œYÐ-Ð-Ñ-Ø $Ð˜Ð$Ð$Ñ$Ø#(Ð˜DÐ(Ð(Ñ(Ø,-Ð$ cÐ-Ð-Ñ-Ø%2 ] ]Ð˜˜cœÐ2Ð2Ñ2Ø€K�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ€J�ÐÐÑØ$-Ð˜cÐ-Ð-Ñ-Ø€K�ÐÐÑØ€J�ÐÐÑØ+PÐ�k DÑ(ÐPÐPÑPØ€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dz  ed<   dZ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dz  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*<    ee"¬+¦  «        Z#e"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	         dz  ed1<   d2Z)e*ed3<   dZ+e,ed4<   edz  ed5<   d6Z-eed7<   e.j/        Z0e.ed8<   dZ1e,ed9<   dZ2e,ed:<   dZ3eed;<   d<Z4e,ed=<   d<Z5e,ed><   d?Z6eed@<   dZ7e	edA<    ee8dB¬C¦  «        Z9e:edD<    edEdF¬C¦  «        Z;edG         edH<   d<Z<e,edI<   dZ=eedJ<   dKZ>e	edL<   d<Z?e,edM<   dZ@edN         dz  edO<   dZAe,edP<   d<ZBe,edQ<   d<ZCe,edR<   d<ZDe,edS<   dZEeFdz  edT<   dZGeFdz  edU<   dZHe"eF         dz  edV<   d<ZIe,edW<   dXZJeedY<   dZKeedZ<   d<ZLe,ed[<    ed\d]¬C¦  «        ZMeNed^<   d<ZOe,ed_<   dZPeQeReFeSf                  ed`<   dZTe,eda<   dbZUeVedc         z  edd<   d<ZWe,ede<    eXd8df¬g¦  «        eYdheSdieSfdj„¦   «         ¦   «         ZZ e[d8¦  «        dke.dieFfdl„¦   «         Z\ eXdddf¬g¦  «        eYdheSdieSfdm„¦   «         ¦   «         Z] e[dd¦  «        dkeVeFz  dieFfdn„¦   «         Z^ eddo¬C¦  «        Z_eQeS         edp<    eXdOdf¬g¦  «        eYdkeSdieSfdq„¦   «         ¦   «         Z` eXdDdf¬g¦  «        eYdkeSdieSfdr„¦   «         ¦   «         ZadZbeFeds<   dtZce	edu<   dZdedz  edv<   d<Zee,edw<   dZfeFedx<   dZgeeFz  edy<   dZheedz<   d<Zie,ed{<   d|ZjeFekd}elf         z  ed~<    eem¬+¦  «        ZnemeFeSf         ed<   d|Zoed€         ed�<   d‚ZpeFedƒ<   d„ZqeFekd}erf         z  ed…<    eem¬+¦  «        ZsemeFeSf         ed†<   d<Zte,ed‡<   d<Zue,edˆ<   d<Zve,ed‰<   dZwe,edŠ<   d<Zxe,ed‹<   d ZyeedŒ<   dZze,ed         z  ed�<   dZ{e,edŽ<   dZ|e,dz  ed�<   dZ}e,dz  ed�<   dZ~edz  ed‘<   dZe,ed’<    eXdd“¬g¦  «        eYdheed         z  dieed         z  fd”„¦   «         ¦   «         Z€ eXdd“¬g¦  «        eYdhedz  diedz  fd•„¦   «         ¦   «         Z� eXdd“¬g¦  «        eYdhedz  diedz  fd–„¦   «         ¦   «         Z‚ eXdddd“¬g¦  «        eYdhediefd—„¦   «         ¦   «         Zƒ eXdd“¬g¦  «        eYdhe	die	fd˜„¦   «         ¦   «         Z„ eXd#d“¬g¦  «        eYdhe	die	fd™„¦   «         ¦   «         Z… eXd;dZd“¬g¦  «        eYdhediefdš„¦   «         ¦   «         Z† e‡df¬g¦  «        eYd›eSdieSfdœ„¦   «         ¦   «         Zˆ eXd…d“¬g¦  «        eYdheFekd}erf         z  dieFekd}erf         z  fd�„¦   «         ¦   «         Z‰ e‡d“¬g¦  «        dªdž„¦   «         ZŠ e‡d“¬g¦  «        dªdŸ„¦   «         Z‹ e‡df¬g¦  «        eYd›eSdieSfd „¦   «         ¦   «         ZŒ e‡df¬g¦  «        eYd›eSdieSfd¡„¦   «         ¦   «         Z� e‡d“¬g¦  «        dªd¢„¦   «         ZŽ e‡d“¬g¦  «        dªd£„¦   «         Z� e‡d“¬g¦  «        dªd¤„¦   «         Z� e‡df¬g¦  «        eYd›eSdieSfd¥„¦   «         ¦   «         Z‘ eXd~d“¬g¦  «        eYdheFekd}elf         z  dieFekd}elf         z  fd¦„¦   «         ¦   «         Z’ eXd‘d“¬g¦  «        eYdhedz  diedz  fd§„¦   «         ¦   «         Z“ eXd5d7df¬g¦  «        eYdhedz  dieFdz  fd¨„¦   «         ¦   «         Z” eXddf¬g¦  «        eYdhedz  dieFdz  fd©„¦   «         ¦   «         Z•dS )«r>   av  Training hyperparameters and auto-batching configuration.

    Notes:
        * ``auto_batch_target_effective`` is interpreted as the **global**
          effective batch size target. In multi-GPU / multi-node runs the auto-batch resolver derives a per-device
          target by dividing this value across ``devices * num_nodes`` before selecting ``grad_accum_steps``.
    r¾   Tr¿   rÂ   g-Cëâ6?r‡   ga2U0*©#?Ú
lr_encoderr  r"   Ú
batch_sizerý   Úgrad_accum_stepsNÚeval_batch_sizeÚpad_targets_torW  Úauto_batch_target_effectiver°   Ú auto_batch_max_targets_per_imagegffffffæ?Úauto_batch_ema_headroomÚepochsÚresumeg-²�ï§Æï?Ú	ema_decayÚema_taué
   rô   Úcheckpoint_intervalr   Úskip_best_epochsr±   Úsmooth_alphaÚwarmup_epochsgš™™™™™é?Úlr_vit_layer_decayÚlr_component_decayÚ	drop_pathç      ð?Úcls_loss_coefr  Úkeypoint_flip_pairsÚkeypoint_l1_loss_coefÚkeypoint_findable_loss_coefÚkeypoint_visible_loss_coefÚkeypoint_nll_loss_coefÚkeypoint_oks_sigmasr   Údataset_fileÚsquare_resize_div_64Údataset_dirÚoutputÚ
output_dirÚmulti_scaleÚexpanded_scalesÚuse_emaÚema_update_intervalFÚeval_base_modelÚeval_ema_onlyr(  Únum_workersrŠ   a*  Mixed-precision training precision. Sole live authority for AMP enable+dtype; see _resolve_amp_dtype for the deprecated ModelConfig.amp fold-in. None disables autocast (full fp32). On TPU, 'auto' and 'bf16' select XLA's bf16-true precision. Elsewhere, 'auto' selects bf16-mixed on Ampere+ CUDA, fp16 otherwise. 'bf16' selects bfloat16 (falls back to fp16 with a warning if unsupported). 'fp16' selects fp16 on supported CUDA/MPS backends. Explicit XLA uses full fp32 until CPU/GPU PJRT BF16 execution is verified. 'fp8' uses Lightning's Transformer Engine precision plugin and requires a supported NVIDIA GPU; an explicit 'fp8' is honored even if the deprecated ModelConfig.amp=False. Any non-default value here always wins over the deprecated ModelConfig.amp. The direct CPU accelerator always uses full fp32.r  Ú	amp_dtypeÚmapa°  Validation metric that selects the best checkpoint, and (when early_stopping=True) that early stopping monitors. 'map' (default) uses the task's mAP@50:95 (keypoint OKS AP, segmentation mask AP, or box AP). 'mar' uses box mAR at the configured eval_max_dets for detection and segmentation, and keypoint mAR (OKS-based) at fixed COCO maxDets=20. Segmentation mAR is box-level because torchmetrics does not expose a separate mask mAR.)r¨  ÚmarÚbest_model_metricÚ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_testiô  Úeval_max_detsÚeval_intervalÚlog_per_class_metricsr*   a  COCO evaluation backend used for validation and test mAP. All four ship with 'rfdetr[train]' and produce identical metrics; 'vernier' is the default and computes fastest, both several times faster than 'faster_coco_eval', the previous evaluator. 'ufcoco' selects ultrafast-pycocotools.Úeval_backendÚeval_masks_head_resolutionÚ
aug_configÚscale_jitterrh   rg   Úaugmentation_backendÚsave_dataset_gridsrÃ   rÄ   rC  rK   c                 ód   — t          |t          ¦  «        rt                               |¦  «        n|S )ztMap the boolean spellings to members: ``True`` is ``"per-batch"`` (the old default), ``False`` is
        ``"off"``.)r‘   ru   r/   r[   ©rZ   rC  s     rP   Ú_coerce_multi_scalezTrainConfig._coerce_multi_scaleØ  s,   € õ
 ,6°a½Ñ+>Ô+>ÐE�z×$Ò$ QÑ'Ô'Ð'ÀAÐEr\   rT   c                 ó   — |j         S )zOSerialize the mode to its plain string value so ``model_dump`` stays JSON-safe.)rT   ©rr   rT   s     rP   Ú_serialize_multi_scalez"TrainConfig._serialize_multi_scaleß  s   € ð Œ{Ðr\   c                 óf   — t          |t          ¦  «        rt                               ||¦  «        S |S )u¦  Map legacy backend name strings (``"gpu"``, ``"tv"``, ``"albu"``) to their current form.

        ``"cpu"``/``"auto"`` pass through unchanged â€” they are auto-pick sentinels resolved lazily by
        :meth:`AugmentationBackend.from_str` at dataset-build time, not at config construction time, so a saved config
        stays portable across environments. See :class:`AugmentationBackend` for the full rationale.
        )r‘   rt   rG   ri   rÄ  s     rP   Ú_coerce_augmentation_backendz(TrainConfig._coerce_augmentation_backendä  s2   € õ �a�ÑÔð 	BÝ7×;Ò;¸A¸qÑAÔAÐAØˆr\   c                 óX   — t          |t          ¦  «        rt          |j        ¦  «        S |S )u-  Serialize the backend selector to its plain string form.

        Returns the enum's ``.value`` for :class:`AugmentationBackend` members and passes the
        ``"cpu"``/``"auto"`` sentinel strings through unchanged. This lets checkpoint writers call
        plain :meth:`model_dump` and still get a JSON-safe ``str`` for this one field, instead of a
        blanket ``model_dump(mode="json")`` that would also coerce every *other* field's serialized
        shape (e.g. the ``int`` keypoint loss coefficients to ``float``). Applies in both python and
        json ``model_dump`` modes, so the two checkpoint writers stay consistent.

        Args:
            value: Stored backend selector â€” an :class:`AugmentationBackend` member or a
                ``"cpu"``/``"auto"`` sentinel string.

        Returns:
            The plain string form of the backend selector.

        Examples:
            >>> cfg = TrainConfig(dataset_dir="ds", augmentation_backend="torchvision")
            >>> cfg.model_dump()["augmentation_backend"]
            'torchvision'
        )r‘   r-   rt   rT   rÇ  s     rP   Ú_serialize_augmentation_backendz+TrainConfig._serialize_augmentation_backendñ  s,   € õ. �eÕ0Ñ1Ô1ð 	$Ý�u”{Ñ#Ô#Ð#Øˆr\   aB  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.Únotesc                 ó<   — t          |t          ¦  «        r|rdn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.
        r¯  N)r‘   ru   rY   s     rP   Ú_coerce_legacy_progress_barz'TrainConfig._coerce_legacy_progress_bar  s*   € õ �e�TÑ"Ô"ð 	-Ø"Ð,�6�6¨Ð,Øˆr\   c                 óR   — |dvr"t          j        d|›d�t          d¬¦  «         dS |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.
        )Nr"   r#   r$   r%   zUnknown amp_dtype=zP; expected None or one of 'auto', 'bf16', 'fp16', 'fp8'. Falling back to 'auto'.r(  r)  r"   )r/  r0  ÚUserWarningrY   s     rP   Ú_coerce_amp_dtypezTrainConfig._coerce_amp_dtype"  sQ   € ð Ð=Ð=Ð=åŒMð* Uð *ð *ð *åØð	ñ ô ð ð �6Øˆr\   ry   gš™™™™™¹?Úclip_max_normÚseedÚsync_bnÚstrategyÚdevicesÚ	num_nodesÚ	fp16_evalr®   .r¶   Úlr_scheduler_kwargs)r®   ÚepochÚlr_scheduler_intervalúval/lossÚlr_scheduler_monitorÚadamwr˜   Úoptimizer_kwargsÚdont_save_weightsÚtrain_log_sync_distÚtrain_log_on_stepÚcompact_train_metricsÚcompute_train_metricsÚnum_sanity_val_stepsÚcompute_val_lossÚcompute_test_lossÚ
pin_memoryÚpersistent_workersÚprefetch_factorÚpack_targetsr  c                 ó@   — |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'.©rn   rÄ  s     rP   Úvalidate_batch_sizezTrainConfig.validate_batch_sizeb  s/   € ð �Š;ˆ;ØˆHØˆqŠ5ˆ5ÝÐBÑCÔCÐCØˆr\   c                 ó4   — |�|dk     rt          d¦  «        ‚|S )zHValidate eval_batch_size is None (inherit the train batch size) or >= 1.Nrý   z+eval_batch_size must be >= 1 when provided.rî  rÄ  s     rP   Úvalidate_eval_batch_sizez$TrainConfig.validate_eval_batch_sizel  ó%   € ð ˆ=˜Q šU˜UÝÐJÑKÔKÐKØˆr\   c                 ó4   — |�|dk     rt          d¦  «        ‚|S )zâValidate pad_targets_to is None (keep the variable-length path) or >= 1.

        Catches a non-positive value at construction instead of at the first DataLoader collate, which can run inside a
        worker process.
        Nrý   z8pad_targets_to must be a positive integer when provided.rî  rÄ  s     rP   Úvalidate_pad_targets_toz#TrainConfig.validate_pad_targets_tot  s%   € ð ˆ=˜Q šU˜UÝÐWÑXÔXÐXØˆr\   c                 ó0   — |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     rP   Úvalidate_positive_train_stepsz)TrainConfig.validate_positive_train_steps€  s)   € ð ˆqŠ5ˆ5ÝØsñô ð ð ˆr\   c                 óB   — d|cxk     rdk    sn 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     rP   Úvalidate_ema_headroomz!TrainConfig.validate_ema_headroomŒ  s/   € ð �A��’�˜’���ÝÐIÑJÔJÐJØˆr\   c                 óB   — d|cxk    rdk     sn t          d¦  «        ‚|S )z'Validate smooth_alpha is in [0.0, 1.0).r±   r“  z#smooth_alpha must be in [0.0, 1.0).rî  rÄ  s     rP   Úvalidate_smooth_alphaz!TrainConfig.validate_smooth_alpha”  s/   € ð �q��’�˜3’���ÝÐBÑCÔCÐCØˆr\   c                 ó0   — |dk     rt          d¦  «        ‚|S )z"Validate interval fields are >= 1.rý   zInterval fields must be >= 1.rî  rÄ  s     rP   Úvalidate_positive_intervalsz'TrainConfig.validate_positive_intervalsœ  s!   € ð ˆqŠ5ˆ5ÝÐ<Ñ=Ô=Ð=Øˆr\   Údatac                 óÈ  — t          |t          ¦  «        s|S |                     d¦  «        }|�$t          |t          ¦  «        st	          |¦  «        s|S |                     d¦  «        rt          j        dd¬¦  «         t          |¦  «        \  }}}|€||d<   ||d<   nBi |d<   t          |dd¦  «        pt          |¦  «        }t          j        d|›d	|› d
�d¬¦  «         |S )aý  Desugar a reconstructable callable optimizer into its serializable string form.

        A callable ``optimizer`` (a class or ``functools.partial``) that can be imported is rewritten to a dotted import
        path plus ``optimizer_kwargs`` so the config round-trips through ``training_config.json``. User-supplied
        ``optimizer_kwargs`` are ignored for callable optimizers (bake arguments into the callable instead). Non-
        reconstructable callables are kept as-is and only warned about.
        r˜   Nrà  zˆoptimizer_kwargs is ignored when optimizer is a callable; bake arguments into the callable (for example with functools.partial) instead.r(  r)  r_   zoptimizer callable ú7 cannot be saved to training_config.json and restored: ú_. Training proceeds with the in-memory callable; only saved-config reproducibility is affected.)
r‘   r¥   ri   rt   Úcallabler/  r0  r¬   r~   Úrepr)rZ   rý  r˜   rG  ÚkwargsÚreasonÚlabels          rP   Ú_desugar_callable_optimizerz'TrainConfig._desugar_callable_optimizer¤  s,  € õ ˜$¥Ñ%Ô%ð 	ØˆKØ—H’H˜[Ñ)Ô)ˆ	ØÐ¥
¨9µcÑ :Ô :ÐÅ(È9ÑBUÔBUÐØˆKà�8Š8Ð&Ñ'Ô'ð 	ÝŒMðIàðñ ô ð õ  ;¸9ÑEÔEÑˆˆf�fØˆ>Ø $ˆD�ÑØ'-ˆDÐ#Ñ$Ð$à')ˆDÐ#Ñ$Ý˜I ~°tÑ<Ô<ÐOÅÀYÁÄˆEÝŒMð/ eð /ð /Øð/ð /ð /ð ð	ñ ô ð ð ˆr\   c                 ó¤   — t          |t          ¦  «        s|S |                     ¦   «         }|st          d¦  «        ‚d|vrt	          |¦  «         |S )zPValidate a string optimizer: a bare name must be a native torch.optim optimizer.z%optimizer must be a non-empty string.rš   )r‘   rt   r�   rn   r—   )rZ   rC  r˜   s      rP   Úvalidate_optimizer_namez#TrainConfig.validate_optimizer_nameÊ  sa   € õ ˜!�SÑ!Ô!ð 	ØˆHØ—G’G‘I”Iˆ	Øð 	FÝÐDÑEÔEÐEð �iÐÐÝ% iÑ0Ô0Ð0ØÐr\   c                 óP   — | j         dk    r| j        dk    rt          d¦  «        ‚| S )zNRequire an explicit FP8 micro-batch until auto-sizing probes converted layers.r%   r"   z±FP8 training requires an explicit integer batch_size: automatic batch sizing does not probe Transformer Engine layers. Choose batch_size manually or use amp_dtype='bf16'/'fp16'.)r§  r€  rn   rq   s    rP   Úvalidate_fp8_batch_sizez#TrainConfig.validate_fp8_batch_sizeÙ  s<   € ð Œ>˜UÒ"Ð" t¤¸&Ò'@Ð'@Ýðnñô ð ð ˆr\   c                 óz   — | j         r| j        st          d¦  «        ‚| j         r| j        rt          d¦  «        ‚| S )aM  ``eval_ema_only`` has no EMA model to evaluate without ``use_ema=True``, and contradicts ``eval_base_model``.

        The flag is deprecated (see ``_warn_deprecated_eval_ema_only``) but still validated: absorbing a contradictory
        pair into the no-op alias would leave one of the two settings silently without effect.
        z)eval_ema_only=True requires use_ema=True.zŽeval_ema_only=True contradicts eval_base_model=True. Drop the deprecated eval_ema_only: evaluating only the selected model is now the default.)r¥  r¢  rn   r¤  rq   s    rP   Úvalidate_eval_ema_onlyz"TrainConfig.validate_eval_ema_onlyã  s]   € ð Ôð 	J d¤lð 	JÝÐHÑIÔIÐIØÔð 	 $Ô"6ð 	ÝðIñô ð ð ˆr\   c                 ó  — t          |t          ¦  «        s|S d|vr|S d|v r
|d         s|S t          |¦  «        }d|vrt          |d         ¦  «         |d<   |                     d¦  «        �t	          j        dt          d¬¦  «         |S )aJ  Warn that ``eval_ema_only`` is superseded by the default single-model evaluation policy.

        Legacy input that contains ``eval_ema_only`` without the new ``eval_base_model`` field is migrated to the
        equivalent old base-plus-EMA policy and warns. New dumps contain both fields, so reloading them stays silent.
        r¥  r¤  Nzáeval_ema_only is deprecated. New configurations evaluate only the selected model (EMA when use_ema=True) by default; legacy configurations are migrated from this flag. Set eval_base_model=True to also evaluate the base model.r(  r)  )r‘   r¥   ru   ri   r/  r0  ÚFutureWarning©rZ   rý  s     rP   Ú_warn_deprecated_eval_ema_onlyz*TrainConfig._warn_deprecated_eval_ema_onlyó  s·   € õ ˜$¥Ñ%Ô%ð 	ØˆKØ $Ð&Ð&ØˆKØ Ð$Ð$¨TÐ2CÔ-DÐ$ØˆKÝ�D‰zŒzˆØ DÐ(Ð(Ý*.¨t°OÔ/DÑ*EÔ*EÐ&EˆDÐ"Ñ#Ø�8Š8�OÑ$Ô$Ð0ÝŒMðLõ Øðñ ô ð ð ˆr\   c                 ó–   — t          |t          ¦  «        s|S |                     d¦  «        rt          j        dt
          d¬¦  «         |S )až  Warn that ``fp16_eval`` is inert and superseded by ``amp_dtype``.

        The flag has had no runtime consumer since the PTL migration, so it is warned about rather than migrated: a
        config carrying it already trains and evaluates at the precision ``amp_dtype`` resolves to. A default ``False``
        is skipped silently so reloading a dumped config (which always carries the field) never warns.
        rÙ  z|fp16_eval is deprecated and has no effect; evaluation precision follows amp_dtype. Set amp_dtype='fp16' to evaluate in fp16.r(  r)  )r‘   r¥   ri   r/  r0  r  r  s     rP   Ú_warn_deprecated_fp16_evalz&TrainConfig._warn_deprecated_fp16_eval  sZ   € õ ˜$¥Ñ%Ô%ð 	ØˆKØ�8Š8�KÑ Ô ð 	ÝŒMð<åØð	ñ ô ð ð ˆr\   c                 ób   — | j         du r%| j        dk    r| j        dk    rt          d¦  «        ‚| S )a4  Reject disabling validation loss for a configured plateau loss monitor.

        Reconstructable scheduler callables are normalized to their dotted path before this validator runs. Non-
        reconstructable callables are checked after their concrete scheduler is created by ``RFDETRModelModule``.
        Fz*torch.optim.lr_scheduler.ReduceLROnPlateaurÝ  zƒcompute_val_loss=False requires a non-val/loss monitor when lr_scheduler is ReduceLROnPlateau. Set compute_val_loss=True or 'auto'.)rç  r¶   rÞ  rn   rq   s    rP   Ú"validate_explicit_val_loss_disablez.TrainConfig.validate_explicit_val_loss_disable"  sN   € ð Ô! UÐ*Ð*ØÔ!Ð%QÒQÐQØÔ)¨ZÒ7Ð7åðZñô ð ð ˆr\   c                 óÚ   — t          | j        ¦  «        rVt                               | j        ¦  «        }|r5d                     t          |¦  «        ¦  «        }t          d|› d�¦  «        ‚| S )zPReserved optimizer kwargs are only rejected for managed (short-name) optimizers.rÈ   z8optimizer_kwargs cannot include RF-DETR-managed key(s): rš   )r›   r˜   Ú_OPTIMIZER_MANAGED_KWARGSÚintersectionrà  rÑ   rÒ   rn   )rr   Úreserved_presentÚreserveds      rP   Úvalidate_optimizer_kwargsz%TrainConfig.validate_optimizer_kwargs4  sq   € õ & d¤nÑ5Ô5ð 	iÝ8×EÒEÀdÔF[Ñ\Ô\ÐØð iØŸ9š9¥VÐ,<Ñ%=Ô%=Ñ>Ô>�Ý Ð!gÐ\dÐ!gÐ!gÐ!gÑhÔhÐhØˆr\   c           	      ó8  — t          | j        ¦  «        r…t          | j        ¦  «        t          z
  }|rgd                     t          t          ¦  «        ¦  «        }d                     t          |¦  «        ¦  «        }t          d| j        ›d|› d|› d�¦  «        ‚| S )a�  Reject unknown ``lr_scheduler_kwargs`` keys for the managed ``"step"`` / ``"cosine"`` presets.

        Managed presets consume only ``min_factor`` and ``lr_drop``; any other key would be silently ignored, so surface
        it as an error (mirroring ``validate_optimizer_kwargs``). Explicit schedulers forward their kwargs verbatim to
        the constructor and are left unchecked here.
        rÈ   z*lr_scheduler_kwargs for a managed preset (z) accepts only {z}; unknown key(s): rš   )r¹   r¶   rÎ   rÚ  Ú_MANAGED_SCHEDULER_KWARGSrÑ   rÒ   rn   )rr   ÚunknownÚallowedÚunknown_keyss       rP   Úvalidate_lr_scheduler_kwargsz(TrainConfig.validate_lr_scheduler_kwargs>  sº   € õ & dÔ&7Ñ8Ô8ð 	Ý˜$Ô2Ñ3Ô3Õ6OÑOˆGØð ØŸ)š)¥FÕ+DÑ$EÔ$EÑFÔF�Ø#Ÿyšy­°©¬Ñ9Ô9�Ý ðFÀÔARð Fð FØ ðFð FØ6BðFð Fð Fñô ð ð ˆr\   c                 óÈ  — t          |t          ¦  «        s|S |                     d¦  «        }|�$t          |t          ¦  «        st	          |¦  «        s|S |                     d¦  «        rt          j        dd¬¦  «         t          |¦  «        \  }}}|€||d<   ||d<   nBi |d<   t          |dd¦  «        pt          |¦  «        }t          j        d|›d	|› d
�d¬¦  «         |S )a	  Desugar a reconstructable callable lr_scheduler into its serializable string form.

        A callable ``lr_scheduler`` (a class or ``functools.partial``) that can be imported is rewritten to a dotted
        import path plus ``lr_scheduler_kwargs`` so the config round-trips through ``training_config.json``. User-
        supplied ``lr_scheduler_kwargs`` are ignored for callable schedulers (bake arguments into the callable instead).
        Non-reconstructable callables are kept as-is and only warned about.
        r¶   NrÚ  zŽlr_scheduler_kwargs is ignored when lr_scheduler is a callable; bake arguments into the callable (for example with functools.partial) instead.r(  r)  r_   zlr_scheduler callable rÿ  r   )
r‘   r¥   ri   rt   r  r/  r0  r»   r~   r  )rZ   rý  r¶   rG  r  r  r  s          rP   Ú_desugar_callable_lr_schedulerz*TrainConfig._desugar_callable_lr_schedulerQ  s/  € õ ˜$¥Ñ%Ô%ð 	ØˆKØ—x’x Ñ/Ô/ˆØÐ¥:¨l½CÑ#@Ô#@ÐÍÐQ]ÑH^ÔH^ÐØˆKà�8Š8Ð)Ñ*Ô*ð 	ÝŒMðIàðñ ô ð õ  ;¸<ÑHÔHÑˆˆf�fØˆ>Ø#'ˆD�Ñ Ø*0ˆDÐ&Ñ'Ð'à*,ˆDÐ&Ñ'Ý˜L¨.¸$Ñ?Ô?ÐUÅ4ÈÑCUÔCUˆEÝŒMð/¨ð /ð /Øð/ð /ð /ð ð	ñ ô ð ð ˆr\   c                 ó  — t          |t          ¦  «        s|S |                     ¦   «         }|st          d¦  «        ‚d|vrLt	          |¦  «        s=d                     t          t          ¦  «        ¦  «        }t          d|›d|› d�¦  «        ‚|S )z]Validate a string lr_scheduler: a bare name must be a managed preset, else use a dotted path.z(lr_scheduler must be a non-empty string.rš   rÈ   zUnknown lr_scheduler z'. Bare names must be a managed preset (zj); use a full dotted import path (e.g. 'torch.optim.lr_scheduler.StepLR') or a callable for anything else.)r‘   rt   r�   rn   r¹   rÑ   rÒ   r¸   )rZ   rC  r¶   Úpresetss       rP   Úvalidate_lr_scheduler_namez&TrainConfig.validate_lr_scheduler_namew  s°   € õ ˜!�SÑ!Ô!ð 	ØˆHØ—w’w‘y”yˆØð 	IÝÐGÑHÔHÐHà�lÐ"Ð"Õ+EÀlÑ+SÔ+SÐ"Ø—i’i¥Õ'AÑ BÔ BÑCÔCˆGÝð%¨ð %ð %ÐT[ð %ð %ð %ñô ð ð
 Ðr\   c                 ó4   — |�|dk     rt          d¦  «        ‚|S )z)Validate prefetch_factor is None or >= 1.Nrý   z+prefetch_factor must be >= 1 when provided.rî  rÄ  s     rP   Úvalidate_prefetch_factorz$TrainConfig.validate_prefetch_factorŠ  rò  r\   c                 ó¦   — |€|S t           j                             t           j                             t          j        |¦  «        ¦  «        ¦  «        S )uj   Expand and normalize dataset/output directory paths via ``os.fspath`` â†’ ``expanduser`` â†’ ``realpath``.)rF  rG  rL  rH  rI  rÄ  s     rP   Úexpand_pathszTrainConfig.expand_paths’  s<   € ð ˆ9ØˆHÝŒw×Ò¥¤× 2Ò 2µ2´9¸Q±<´<Ñ @Ô @ÑAÔAÐAr\   c                 ó2   — |€|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.
        )rF  rI  rÄ  s     rP   Ú_coerce_resume_pathzTrainConfig._coerce_resume_pathš  s   € ð ˆ9ØˆHÝŒy˜‰|Œ|Ðr\   )rK   r>   )–r]   r^   r_   r`   r   rÂ   r   rß   r‡   rR  r  r€  r"  r
   r�  r‚  rƒ  r„  r…  r†  r‡  rˆ  r!   r‰  rŠ  r   rŒ  r�  rŽ  r�  r�  r‘  r’  r”  rQ  r•  r–  r—  r˜  r™  rš  r›  r    rœ  ru   rŸ  r/   rW   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»  r¼  r½  r+   r¾  r¿  r   r	   r   rÀ  rÁ  r-   rÂ  r   rb   rÅ  r   rÈ  rÊ  rÌ  rÍ  rÏ  rÒ  ry   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ñ  rô  rö  rø  rú  rü  r   r  r  r
  r  r  r  r  r  r   r"  r%  r'  r)  r+  rc   r\   rP   r>   r>   ,  sL  € € € € € € ðð ð *4¨¸(ÐX\Ð)]Ñ)]Ô)]€L�(˜:Ô&Ð]Ð]Ñ]à€BˆÐÐÑØ€J�ÐÐÑØ()€J��g˜f”oÑ%Ð)Ð)Ñ)ð
 Ð�cÐÐÑð #'€O�S˜4‘ZÐ&Ð&Ñ&ð "&€N�C˜$‘JÐ%Ð%Ñ%ð (*Ð Ð)Ð)Ñ)à,/Ð$ cÐ/Ð/Ñ/Ø%(Ð˜UÐ(Ð(Ñ(Ø€FˆCÐÐÑØ!%€FˆK˜$ÑÐ%Ð%Ñ%Ø€IˆuÐÐÑØ€GˆSÐÐÑØ$˜u¨R°AÐ6Ñ6Ô6Ð˜Ð6Ð6Ñ6Ø!˜E¨!°Ð2Ñ2Ô2Ð�cÐ2Ð2Ñ2Ø€L�%ÐÐÑØ€M�5ÐÐÑØ #Ð˜Ð#Ð#Ñ#Ø #Ð˜Ð#Ð#Ñ#Ø€IˆuÐÐÑØ€M�5ÐÐÑð &+ U¸4Ð%@Ñ%@Ô%@Ð˜˜cœÐ@Ð@Ñ@Ø#$Ð˜5Ð$Ð$Ñ$Ø)*Ð Ð*Ð*Ñ*Ø()Ð Ð)Ð)Ñ)Ø$%Ð˜EÐ%Ð%Ñ%Ø.2Ð˜˜eœ tÑ+Ð2Ð2Ñ2ð !+€L�+Ð*Ð*Ñ*Ø!%Ð˜$Ð%Ð%Ñ%Ø˜tÑ#Ð#Ð#Ñ#Ø&€J�Ð&Ð&Ñ&ð )Ô2€K�Ð2Ð2Ñ2Ø €O�TÐ Ð Ñ Ø€GˆTÐÐÑØ Ð˜Ð Ð Ñ ð& "€O�TÐ!Ð!Ñ!ð  €M�4ÐÐÑØ€K�ÐÐÑØ€L�%ÐÐÑØ˜%Ø"ð@ðñ ô €Iˆxð ð ñ ð" 05¨uØðfð	0ñ 	0ô 	0Ð�w˜|Ô,ð 	ð 	ñ 	ð !€N�DÐ Ð Ñ Ø#%Ð˜SÐ%Ð%Ñ%Ø&+Ð˜eÐ+Ð+Ñ+Ø#(Ð˜DÐ(Ð(Ñ(Ø37€L�'˜.Ô)¨DÑ0Ð7Ð7Ñ7Ø€K�ÐÐÑØ€Eˆ4ÐÐÑØ€FˆDÐÐÑØ€GˆTÐÐÑØ€GˆS�4‰ZÐÐÑØ€Cˆˆt‰ÐÐÑØ$(€K��c”˜TÑ!Ð(Ð(Ñ(Ø€HˆdÐÐÑØ€M�3ÐÐÑØ€M�3ÐÐÑØ"'Ð˜4Ð'Ð'Ñ'Ø$) EØðnð%ñ %ô %€L�/ð ð ñ ð" (-Ð Ð,Ð,Ñ,Ø+/€J�˜˜c 3˜hœÔ(Ð/Ð/Ñ/Ø€L�$ÐÐÑØINÐÐ-°¸Ô0FÑFÐNÐNÑNØ$Ð˜Ð$Ð$Ñ$à€_�]¨Ð2Ñ2Ô2ØðF Cð F¨Cð Fð Fð Fñ „[ñ 3Ô2ðFð
 Ð�mÑ$Ô$ð¨Jð ¸3ð ð ð ñ %Ô$ðð €_Ð+°(Ð;Ñ;Ô;Øð	¨Sð 	°Sð 	ð 	ð 	ñ „[ñ <Ô;ð	ð ÐÐ,Ñ-Ô-ðÐ5HÈ3Ñ5Nð ÐSVð ð ð ñ .Ô-ðð4 !˜5Øð0ð	ñ 	ô 	€Eˆ8�CŒ=ð 	ð 	ñ 	ð €_�^¨(Ð3Ñ3Ô3Øð°ð ¸ð ð ð ñ „[ñ 4Ô3ðð €_�[ xÐ0Ñ0Ô0Øð cð ¨cð ð ð ñ „[ñ 1Ô0ðð& €K�ÐÐÑØ€M�5ÐÐÑØ€Dˆ#�‰*ÐÐÑØ€GˆTÐÐÑð €HˆcÐÐÑØ€GˆS�3‰YÐÐÑð €IˆsÐÐÑð €IˆtÐÐÑØ7=€L�#˜  mÐ!3Ô4Ñ4Ð=Ð=Ñ=Ø*/¨%ÀÐ*EÑ*EÔ*EÐ˜˜c 3˜hœÐEÐEÑEØ6<Ð˜7 ?Ô3Ð<Ð<Ñ<Ø *Ð˜#Ð*Ð*Ñ*Ø07€Iˆs�X˜c 9˜nÔ-Ñ-Ð7Ð7Ñ7Ø', u¸TÐ'BÑ'BÔ'BÐ�d˜3 ˜8”nÐBÐBÑBØ#Ð�tÐ#Ð#Ñ#à %Ð˜Ð%Ð%Ñ%ð $Ð�tÐ#Ð#Ñ#ð #'Ð˜4Ð&Ð&Ñ&Ø"'Ð˜4Ð'Ð'Ñ'ð !"Ð˜#Ð!Ð!Ñ!Ø/5Ð�d˜W Vœ_Ñ,Ð5Ð5Ñ5ð #Ð�tÐ"Ð"Ñ"Ø"€J��t‘Ð"Ð"Ñ"Ø&*Ð˜˜t™Ð*Ð*Ñ*Ø"&€O�S˜4‘ZÐ&Ð&Ñ&Ø€L�$ÐÐÑà€_�\¨Ð0Ñ0Ô0Øð C¨'°&¬/Ñ$9ð ¸cÀGÈFÄOÑ>Sð ð ð ñ „[ñ 1Ô0ðð €_Ð&¨WÐ5Ñ5Ô5Øð¨¨t©ð ¸¸d¹
ð ð ð ñ „[ñ 6Ô5ðð €_Ð%¨GÐ4Ñ4Ô4Øð¨¨d©
ð °s¸T±zð ð ð ñ „[ñ 5Ô4ðð €_ØÐ9Ð;]Ðdkðñ ô ð ð¨cð °cð ð ð ñ „[ñô ðð €_Ð.°WÐ=Ñ=Ô=Øð eð °ð ð ð ñ „[ñ >Ô=ðð €_�^¨'Ð2Ñ2Ô2Øð eð °ð ð ð ñ „[ñ 3Ô2ðð €_Ð*¨OÀ'ÐJÑJÔJØð¨Cð °Cð ð ð ñ „[ñ KÔJðð €_˜(Ð#Ñ#Ô#Øð"¨sð "°sð "ð "ð "ñ „[ñ $Ô#ð"ðH €_�[ wÐ/Ñ/Ô/Øð¨¨h°s¸I°~Ô.FÑ(Fð È3ÐQYÐZ]Ð_hÐZhÔQiÑKið ð ð ñ „[ñ 0Ô/ðð €_˜'Ð"Ñ"Ô"ðð ð ñ #Ô"ðð €_˜'Ð"Ñ"Ô"ðð ð ñ #Ô"ðð €_˜(Ð#Ñ#Ô#Øð°#ð ¸#ð ð ð ñ „[ñ $Ô#ðð2 €_˜(Ð#Ñ#Ô#Øð¨cð °cð ð ð ñ „[ñ $Ô#ðð$ €_˜'Ð"Ñ"Ô"ðð ð ñ #Ô"ðð" €_˜'Ð"Ñ"Ô"ðð ð ñ #Ô"ðð €_˜'Ð"Ñ"Ô"ðð ð ñ #Ô"ðð$ €_˜(Ð#Ñ#Ô#Øð"°#ð "¸#ð "ð "ð "ñ „[ñ $Ô#ð"ðH €_�^¨'Ð2Ñ2Ô2Øð¨3°¸#¸}Ð:LÔ1MÑ+Mð ÐRUÐX`ÐadÐfsÐasÔXtÑRtð ð ð ñ „[ñ 3Ô2ðð" €_Ð&¨WÐ5Ñ5Ô5Øð¨¨t©ð ¸¸d¹
ð ð ð ñ „[ñ 6Ô5ðð €_�] L°xÐ@Ñ@Ô@ØðB˜[¨4Ñ/ð B°C¸$±Jð Bð Bð Bñ „[ñ AÔ@ðBð €_�X HÐ-Ñ-Ô-Øð
 K°$Ñ$6ð 
¸3À¹:ð 
ð 
ð 
ñ „[ñ .Ô-ð
ð 
ð 
r\   r>   c                   óL   — 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	S )
r?   a
  Training configuration for instance segmentation models.

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

    Attributes:
        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.
    rW  Úmask_point_sample_ratiog      @Úmask_ce_loss_coefÚmask_dice_loss_coefr“  r”  N)r]   r^   r_   r`   r-  r"  rß   r.  rR  r/  r”  rc   r\   rP   r?   r?   ©  sa   € € € € € € ðð ð  $&Ð˜SÐ%Ð%Ñ%Ø"Ð�uÐ"Ð"Ñ"Ø!$Ð˜Ð$Ð$Ñ$Ø€M�5ÐÐÑÐÐ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<   dS )r@   aE  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—  r˜  r“  r™  g      à?rŽ  r‹  r   rô   r�  N)r]   r^   r_   r`   r”  rR  rß   r–  r—  r˜  r™  rŽ  r   r�  r"  rc   r\   rP   r@   r@   À  s¢   € € € € € € ðð ð4 €M�5ÐÐÑØ#$Ð˜5Ð$Ð$Ñ$Ø)*Ð Ð*Ð*Ñ*Ø()Ð Ð)Ð)Ñ)Ø$'Ð˜EÐ'Ð'Ñ'Ø€L�%ÐÐÑØ!˜E¨"°Ð3Ñ3Ô3Ð�cÐ3Ð3Ñ3Ð3Ð3r\   r@   T)Úwarn_legacyrÂ   Útrain_configr1  c                óŒ   — |j         t          k    r|j         S | j        s |rt          j        dt
          d¬¦  «         dS |j         S )a  Resolve the effective mixed-precision mode from the training and (deprecated) model settings.

    ``TrainConfig.amp_dtype`` is the live authority. The deprecated ``ModelConfig.amp`` toggle is consulted only as a
    fallback, so a caller that sets ``amp_dtype`` never has it silently overridden by a stale ``amp=False`` carried in
    a model config.

    "Set" means holding a non-default value, not ``model_fields_set`` membership: a config reloaded from
    ``training_config.json`` carries every field explicitly, which would otherwise make the legacy toggle inert after a
    single save/load round-trip.

    Args:
        model_config: Architecture configuration, read only for the deprecated ``amp`` toggle.
        train_config: Training configuration holding the authoritative ``amp_dtype``.
        warn_legacy: Emit the deprecation warning when the legacy toggle supplies the result.

    Returns:
        The effective ``amp_dtype``; ``None`` means run in full fp32.

    Examples:
        >>> from rfdetr.config import RFDETRNanoConfig, TrainConfig, _resolve_amp_dtype
        >>> _resolve_amp_dtype(RFDETRNanoConfig(), TrainConfig(dataset_dir="data"))
        'auto'
        >>> _resolve_amp_dtype(RFDETRNanoConfig(), TrainConfig(dataset_dir="data", amp_dtype="bf16"))
        'bf16'
        >>> import warnings
        >>> with warnings.catch_warnings():
        ...     warnings.simplefilter("ignore", FutureWarning)
        ...     _resolve_amp_dtype(RFDETRNanoConfig(amp=False), TrainConfig(dataset_dir="data")) is None
        True
    zRModelConfig.amp is deprecated; pass amp_dtype=None to the training config instead.r(  r)  N)r§  r,   rû   r/  r0  r  )rÂ   r2  r1  s      rP   Ú_resolve_amp_dtyper4  ä  sb   € ðH ÔÕ!3Ò3Ð3ØÔ%Ð%ØÔð Øð 	ÝŒMØdÝØðñ ô ð ð
 ˆtØÔ!Ð!r\   )[r¡   rM   r§   rF  r/  Úcollections.abcr   r   Úenumr   Úpathlibr   Útypingr   r   r	   r
   r   r   r   Úpydanticr   r   r   r   r   r   Úpydantic_corer   Útorch.optimr   Útorch.optim.lr_schedulerr   r   r   rß   r    rt   r!   r&   r+   r,   Ú__all__rG   rH   Ú	lru_cacheru   rQ   r/   r-   rÑ  rw   r…   r†   r  r’   r—   Úobjectr›   Útupler¥   r¬   r¸   r´   r"  rR  Ú	frozensetr  rµ   r¹   r»   r½   r.   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   r4  rc   r\   rP   ú<module>rB     s:  ðð Ð Ð Ð Ð Ø Ð Ð Ð Ø €€€Ø 	€	€	€	Ø €€€Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ Dà €€€Ø eÐ eÐ eÐ eÐ eÐ eÐ eÐ eÐ eÐ eÐ eÐ eÐ eÐ eÐ eÐ eØ +Ð +Ð +Ð +Ð +Ð +Ø !Ð !Ð !Ð !Ð !Ð !Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cà Ð!sÔt€ˆYÐ tÐ tÑ tð !Ð!QÔR€ˆYÐ RÐ RÑ RØ˜t™€ˆYÐ #Ð #Ñ #àÐ;Ô<¸tÑC€ˆ)Ð CÐ CÑ Cð %Ð%WÔX€�Ð XÐ XÑ Xð  &Ð �HÐ %Ð %Ñ %ðð ð €ð8 Ø
Øð8ð 8Ð $ d¨3°¨8¤nð ð ñ ð 'Ø#Ø.ð7ð 7Ð # T¨#¨s¨(¤^ð ð ñ ð €Ô˜TÐ"Ñ"Ô"ð Sð ¨Tð ð ð ñ #Ô"ðð$ð ð ð ð ��dñ ô ð ðBXTð XTð XTð XTð XT˜#˜tñ XTô XTð XTðvð ð ð ð ¨+ñ ô ð ð#˜ð #ð #ð #ð #ðL ˆnÑÔ€ˆÐ Ð Ñ ØEÐEÐEÐ ð Cð ¨D°¬Oð ð ð ð ð>?¨&ð ?°Tð ?ð ?ð ?ð ?ð.+:Ø˜˜Y˜Ô'ð+:à
ˆ3�‰:�t˜C ˜H”~¨Ñ,¨c°D©jÐ8Ô9ð+:ð +:ð +:ð +:ð\ % hÐ/Ð àBEÐUXÐ6YÐ6YÐ ˜T # s¨U¡{Ð"2Ô3Ð YÐ YÑ Yà%˜IÐ&AÑBÔBÐ ð 'Ð):Ñ:€ˆyÐ :Ð :Ñ :ðh¨Vð h¸ð hð hð hð hð,+:Ø˜3 Ð-Ô.ð+:à
ˆ3�‰:�t˜C ˜H”~¨Ñ,¨c°D©jÐ8Ô9ð+:ð +:ð +:ð +:ð\:ð :ð :ð :ð :�ñ :ô :ð :ðBcEð cEð cEð cEð cE�*ñ cEô cEð cEðL'ð 'ð 'ð 'ð '�{ñ 'ô 'ð 'ð(	?ð 	?ð 	?ð 	?ð 	?Ð"2ñ 	?ô 	?ð 	?ð	>ð 	>ð 	>ð 	>ð 	>Ð'ñ 	>ô 	>ð 	>ð	?ð 	?ð 	?ð 	?ð 	?Ð(ñ 	?ô 	?ð 	?ð	@ð 	@ð 	@ð 	@ð 	@Ð)ñ 	@ô 	@ð 	@ðð ð ð ð ˜ñ ô ð ð2ð ð ð ð Ð-ñ ô ð ð ð ð ð ð Ð*ñ ô ð ð ð ð ð ð Ð+ñ ô ð ð ð ð ð ð Ð,ñ ô ð ð ð ð ð ð Ð+ñ ô ð ð ð ð ð ð Ð,ñ ô ð ð ð ð ð ð Ð-ñ ô ð ð ð ð ð ð Ð"2ñ ô ð ð,z	ð z	ð z	ð z	ð z	�*ñ z	ô z	ð z	ðzð ð ð ð ˜kñ ô ð ð.!4ð !4ð !4ð !4ð !4˜+ñ !4ô !4ð !4ðP ð	."ð ."ð ."Øð."àð."ð ð	."ð
 ð."ð ."ð ."ð ."ð ."ð ."r\   