§
    ­¸jôÉ  ã                  ó  — U d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZ ddlZddlmZ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 ddlmZ 	 ddlmZ n# e$ r dZY nw xY wddl m!Z!m"Z"m#Z#m$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/  e/¦   «         Z0dNd„Z1dZ2de3d<   e� G d„ de¦  «        Z4e4Z2 G d„ de¦  «        Z5dOd„Z6dPd „Z7dQd"„Z8dRd%„Z9dRd&„Z:dSdTd,„Z;dUdVd.„Z<dWd3„Z=d4d5d6œZ>d7e3d8<   dXdC„Z? G dD„ dEe¦  «        Z@ddFdGœdYdM„ZAdS )ZuA   Trainer factory â€” assembles a PTL Trainer from RF-DETR configs.é    )ÚannotationsN)ÚSequence)ÚPath)ÚAnyÚLiteral)ÚCallbackÚLightningModuleÚTrainer)ÚModelCheckpoint)ÚRichProgressBarTheme)Ú	CSVLoggerÚMLFlowLoggerÚTensorBoardLoggerÚWandbLogger)ÚDDPStrategy)Ú_MultiProcessingLauncher)ÚKeypointTrainConfigÚModelConfigÚTrainConfigÚ_resolve_amp_dtype)ÚBestModelCallbackÚDropPathCallbackÚGPUMemoryRichProgressBarÚGPUMemoryTQDMProgressBarÚRFDETREarlyStoppingÚRFDETREMACallback)ÚCOCOEvalCallback)Ú
get_loggerÚreturnÚNonec                 ó   — ddl m}  dS )a¯  Probe the full tensorboard import chain to surface numpy/tensorflow incompatibilities early.

    When tensorboard is installed alongside a numpy-2.0-incompatible tensorflow, importing
    ``torch.utils.tensorboard`` raises ``AttributeError`` at module level (e.g. ``np.float_`` was
    removed in NumPy 2.0).  Calling this function inside the logger-construction try/except lets
    ``build_trainer`` degrade gracefully to CSV-only logging instead of crashing mid-training.

    Raises:
        ImportError: If the ``tensorboard`` package is absent.
        AttributeError: If ``torch.utils.tensorboard`` fails to import due to a NumPy 2.0 /
            tensorflow incompatibility.
    r   ©ÚSummaryWriterN)Útorch.utils.tensorboardr#   r"   s    úg/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/rfdetr/training/trainer.pyÚ&_try_import_tensorboard_summary_writerr&   .   s   € ð 6Ð5Ð5Ð5Ð5Ð5Ð5Ð5ó    ztype[Any] | NoneÚ_InteractiveSpawnLauncherc                  ó*   — e Zd ZdZedd„¦   «         ZdS )Ú_InteractiveSpawnLauncherImplz=Spawn launcher that reports itself as interactive-compatible.r   Úboolc                ó   — dS )NT© ©Úselfs    r%   Úis_interactive_compatiblez7_InteractiveSpawnLauncherImpl.is_interactive_compatibleX   s   € à�4r'   N)r   r+   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr0   r-   r'   r%   r*   r*   U   s8   € € € € € ØKÐKà	ð	ð 	ð 	ñ 
Œð	ð 	ð 	r'   r*   c                  ó   — e Zd ZdZdd„ZdS )Ú_NotebookSpawnDDPStrategyzFSpawn-based DDP strategy that works inside Jupyter / Kaggle notebooks.r   r    c                óÈ   — | j         €t          d¦  «        ‚t          €t          d¦  «        ‚| j        dk    rt          d¦  «        ‚t          | | j        ¬¦  «        | _        d S )Nzs_NotebookSpawnDDPStrategy requires a cluster environment; ensure the strategy is initialised through PTL's Trainer.zýNotebook spawn strategy requires pytorch_lightning.strategies.launchers.multiprocessing._MultiProcessingLauncher. Your installed PyTorch Lightning version changed this private API; pin/upgrade PTL to a compatible version in the supported >=2.6,<3 range.Úpopenz‡_NotebookSpawnDDPStrategy does not support start_method='popen'; it is always constructed with start_method='spawn' in build_trainer().)Ústart_method)Úcluster_environmentÚRuntimeErrorr(   Ú_start_methodÚ	_launcherr.   s    r%   Ú_configure_launcherz-_NotebookSpawnDDPStrategy._configure_launcherb   sˆ   € ØÔ#Ð+ÝðLñô ð õ %Ð,Ýð[ñô ð ð Ô Ò(Ð(ÝðYñô ð õ 3°4ÀdÔFXÐYÑYÔYˆŒˆˆr'   N©r   r    )r1   r2   r3   r4   r?   r-   r'   r%   r7   r7   _   s4   € € € € € ØPÐPðZð Zð Zð Zð Zð Zr'   r7   Ú	precisionÚstrú*Literal['32-true', '16-true', 'bf16-true']c                óX   — | dk    rdS | dk    rdS | dk    rdS t          d| ›d�¦  «        ‚)a  Normalize resolved precision strings to a valid XLAPrecision literal.

    Args:
        precision: Precision string produced by the local resolver, e.g. ``"16-mixed"``.

    Returns:
        One of ``"32-true"``, ``"16-true"``, or ``"bf16-true"`` suitable for XLA plugin creation.

    Raises:
        ValueError: If the resolved precision is not supported by ``XLAPrecision``.
    ú32-truez16-trueú	bf16-truez-Unexpected precision value for XLAPrecision: z0; expected '32-true', '16-true', or 'bf16-true'.)Ú
ValueError)rA   s    r%   Ú_normalize_xla_precisionrH   w   sT   € ð �IÒÐØˆyØ�IÒÐØˆyØ�KÒÐØˆ{Ý
Øu¸	ÐuÐuÐuñô ð r'   Ústrategyr+   c                ób   ‡— |                       ¦   «         Št          ˆfd„dD ¦   «         ¦  «        S )zLReturn whether a TrainConfig strategy string requests distributed execution.c              3  ó    •K  — | ]}|‰v V — Œ	d S ©Nr-   )Ú.0ÚtokenÚstrategy_names     €r%   ú	<genexpr>z5_is_distributed_strategy_requested.<locals>.<genexpr>‘   s(   øè è € ÐPÐP¨%ˆu˜Ð%ÐPÐPÐPÐPÐPÐPr'   )ÚddpÚfsdpÚ	deepspeed)ÚlowerÚany)rI   rO   s    @r%   Ú"_is_distributed_strategy_requestedrV   Ž   s6   ø€ à—N’NÑ$Ô$€MÝÐPÐPÐPÐPÐ3OÐPÑPÔPÑPÔPÐPr'   Úobjectc                ó  ‡ — t          ‰ t          ¦  «        rt          ˆ fd„dD ¦   «         ¦  «        S 	 ddlm}m}m} |||f}n# t          $ r d}Y nw xY w|rt          ‰ |¦  «        rdS t          ˆ fd„dD ¦   «         ¦  «        S )	aD  Return whether *strategy* is a sharded distributed strategy.

    Detects FSDP, FSDP2 (``ModelParallelStrategy``) and DeepSpeed given either a config
    string (e.g. ``"fsdp"``, ``"deepspeed"``) or an instantiated ``Strategy`` object. Object
    detection uses ``isinstance`` because ``str(ModelParallelStrategy())`` contains neither the
    ``"fsdp"`` nor ``"deepspeed"`` token, so a substring test alone would misclassify FSDP2 as
    non-sharded and let it reach the unvalidated manual-optimization path.

    Args:
        strategy: A strategy string or an instantiated PyTorch Lightning ``Strategy`` object.

    Returns:
        ``True`` if *strategy* requests a sharded strategy, ``False`` otherwise.

    Examples:
        >>> _is_sharded_strategy("fsdp")
        True
        >>> _is_sharded_strategy("ddp")
        False
    c              3  óD   •K  — | ]}|‰                      ¦   «         v V — Œd S rL   )rT   ©rM   rN   rI   s     €r%   rP   z'_is_sharded_strategy.<locals>.<genexpr>ª   s2   øè è € ÐPÐP°�5˜HŸNšNÑ,Ô,Ð,ÐPÐPÐPÐPÐPÐPr'   )rR   rS   r   )ÚDeepSpeedStrategyÚFSDPStrategyÚModelParallelStrategyr-   Tc              3  ó^   •K  — | ]'}|t          ‰¦  «                             ¦   «         v V — Œ(d S rL   )rB   rT   rZ   s     €r%   rP   z'_is_sharded_strategy.<locals>.<genexpr>·   s:   øè è € ÐbÐb°%ˆu�˜H™œ×+Ò+Ñ-Ô-Ð-ÐbÐbÐbÐbÐbÐbr'   )rR   rS   Úmodelparallel)Ú
isinstancerB   rU   Úpytorch_lightning.strategiesr[   r\   r]   ÚImportError)rI   r[   r\   r]   Úsharded_typess   `    r%   Ú_is_sharded_strategyrd   ”   sð   ø€ õ* �(�CÑ Ô ð QÝÐPÐPÐPÐPÐ:OÐPÑPÔPÑPÔPÐPð	Qð	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð &Ð'8Ð:OÐPˆˆøõ ð -ð -ð -Ø*,ˆˆˆð-øøøð ð � H¨mÑ<Ô<ð ØˆtÝÐbÐbÐbÐbÐ;aÐbÑbÔbÑbÔbÐbs   ³
A ÁAÁAÚacceleratorú
str | Nonec                óÞ   — | pd                      ¦   «                              ¦   «         }|dv r@t          j                             ¦   «         o!t          j                             ¦   «         dk    S dS )zJReturn whether PTL auto/all device resolution can select multiple devices.Úauto)rh   ÚcudaÚgpué   F)ÚstriprT   Útorchri   Úis_availableÚdevice_count)re   Úaccelerator_names     r%   Ú&_accelerator_has_multiple_auto_devicesrq   º   sb   € à#Ð- v×4Ò4Ñ6Ô6×<Ò<Ñ>Ô>ÐØÐ2Ð2Ð2ÝŒz×&Ò&Ñ(Ô(ÐJ­U¬Z×-DÒ-DÑ-FÔ-FÈÒ-JÐJØˆ5r'   c                ó”   — t          | ¦  «                             ¦   «         }|dv rdS |dk    rdS ddlm} |                     ¦   «         S )a�  Return whether *accelerator* names, or will resolve to, the XLA/TPU backend.

    ``build_trainer`` decides the strategy and precision plugin before ``Trainer`` performs its
    own accelerator resolution, so an explicit ``"xla"``/``"tpu"`` string is not the only case that
    matters: ``TrainConfig.accelerator`` defaults to ``"auto"``, and leaving it there is this
    repo's own documented default (see ``TrainConfig.accelerator``'s docstring). When left as
    ``"auto"``, this mirrors ``lightning_fabric.utilities.device_parser._select_auto_accelerator``'s
    resolution order, which checks XLA availability first -- otherwise a caller who never names an
    accelerator would still build a ``DDPStrategy`` here, then hit the exact
    ``XLAAccelerator``/``DDPStrategy`` mismatch this module works around, once Lightning's own
    ``Trainer(accelerator="auto")`` resolves to XLA a few lines later.
    )ÚxlaÚtpuTrh   Fr   ©ÚXLAAccelerator)rB   rT   Úpytorch_lightning.acceleratorsrv   rn   )re   rp   rv   s      r%   Ú_accelerator_resolves_to_xlarx   Â   sb   € õ ˜;Ñ'Ô'×-Ò-Ñ/Ô/ÐØ˜>Ð)Ð)ØˆtØ˜6Ò!Ð!ØˆuØ=Ð=Ð=Ð=Ð=Ð=à×&Ò&Ñ(Ô(Ð(r'   rk   Údevicesúint | str | Sequence[int]Ú	num_nodesÚintc                óp  — |dk    st          | t          t          f¦  «        sdS t          | t          ¦  «        r| dk    r| dk    S nS|                      ¦   «                              ¦   «         }|                     ¦   «         rt          |¦  «        dk    S |dvrdS ddlm} |                     ¦   «         dk    S )a“  Return whether an XLA/TPU run provably executes on exactly one device.

    :func:`_requests_multiple_devices` answers the neighbouring question for CUDA and cannot be
    reused here: its ``"auto"``/``-1`` branch delegates to
    :func:`_accelerator_has_multiple_auto_devices`, which only ever counts CUDA devices and reports
    ``False`` for ``"xla"``/``"tpu"``. An ``"auto"`` request on a multi-chip TPU host would then read
    as single-device, which is the one case the EMA guard must keep disabled.

    ``num_nodes > 1`` is never one device: a single device per host across several hosts is still a
    multi-replica run, and that topology has no runtime validation here.

    Any ``int | str`` value (the forms ``TrainConfig.devices`` takes) that cannot be proven to be
    exactly one device answers ``False``, so an unrecognised value keeps the conservative
    multi-device behaviour instead of enabling EMA on a host this has not been validated on. A
    device-index sequence such as the ``devices=[N]`` that ``RFDETR.train(device="xla:N")`` forwards
    is outside the count forms validated on one chip and answers ``False`` too, rather than raising.
    rk   Féÿÿÿÿ©rh   z-1r   ru   )	r`   r|   rB   rl   rT   Úisdigitrw   rv   Úauto_device_count)ry   r{   Údevices_namerv   s       r%   Ú_xla_resolves_to_single_devicerƒ   Ù   sÉ   € ð$ �1‚}€}�J wµµc°
Ñ;Ô;€}ØˆuÝ�'�3ÑÔð Ø�bŠ=ˆ=Ø˜a’<Ðð ð —}’}‘”×,Ò,Ñ.Ô.ˆØ×ÒÑ!Ô!ð 	*Ý�|Ñ$Ô$¨Ò)Ð)Ø˜~Ð-Ð-Ø�5à=Ð=Ð=Ð=Ð=Ð=à×+Ò+Ñ-Ô-°Ò2Ð2r'   ú	int | strc                óŽ  — t          | t          ¦  «        r| dk    rt          |¦  «        S | dk    S |                      ¦   «                              ¦   «         }|dv rt          |¦  «        S |                     ¦   «         rt          |¦  «        dk    S d|v r0t          d„ |                     d¦  «        D ¦   «         ¦  «        dk    S dS )zQReturn whether the configured devices value explicitly requests multiple devices.r~   rk   r   ú,c                ó:   — g | ]}|                      ¦   «         ¯|‘ŒS r-   )rl   )rM   Úentrys     r%   ú
<listcomp>z._requests_multiple_devices.<locals>.<listcomp>  s%   € ÐPÐPÐP˜eÀ%Ç+Â+Á-Ä-ÐP�EÐPÐPÐPr'   F)r`   r|   rq   rl   rT   r€   ÚlenÚsplit)ry   re   r‚   s      r%   Ú_requests_multiple_devicesrŒ   ü   sÏ   € å�'�3ÑÔð Ø�bŠ=ˆ=Ý9¸+ÑFÔFÐFØ˜Š{ÐØ—=’=‘?”?×(Ò(Ñ*Ô*€LØ�~Ð%Ð%Ý5°kÑBÔBÐBØ×ÒÑÔð %Ý�<Ñ Ô  1Ò$Ð$Ø
ˆlÐÐÝÐPÐP |×'9Ò'9¸#Ñ'>Ô'>ÐPÑPÔPÑQÔQÐTUÒUÐUØˆ5r'   Ú
csv_loggerr   Ú
output_dirú
str | Pathc                ó>  — t          |¦  «        dz  }|                     ¦   «         sdS |                     d¬¦  «        5 }t          j        |¦  «        }t          |j        pg ¦  «        }t          |¦  «        }ddd¦  «         n# 1 swxY w Y   |sdS | j        }|                     dd¬¦  «        5 }t          j        ||¬¦  «        }| 	                    ¦   «          | 
                    |¦  «         ddd¦  «         n# 1 swxY w Y   t          |¦  «        |_        dS )u   Stop CSVLogger from silently deleting metrics.csv history when a run resumes.

    ``build_trainer`` constructs a brand-new ``CSVLogger(version="")`` every time training starts or
    resumes, always pointed at the same ``output_dir``. The first access to ``CSVLogger.experiment``
    triggers PTL's ``_ExperimentWriter._check_log_dir_exists``, which deletes any pre-existing
    ``metrics.csv`` in that directory (see ``lightning.fabric.loggers.csv_logs``). On a fresh run there
    is nothing to delete, but on a resumed run this wipes every row logged before the resume. Snapshot
    the file before that deletion happens, restore it immediately after, and seed the writer's column
    cache to match so the next ``save()`` call appends rather than starting over.

    Only call this for a resumed run (a truthy tc.resume). This matches the
    public Trainer.fit(..., ckpt_path=config.resume or None) normalization.
    Reusing output_dir for a fresh run, including an empty resume value, must
    still let CSVLogger reset metrics.csv â€” appending fresh-run history onto
    unrelated prior-run history would silently corrupt the log.

    Args:
        csv_logger: The just-constructed ``CSVLogger`` for this run, not yet attached to a ``Trainer``.
        output_dir: The training run's output directory; must match ``csv_logger``'s log location
            (``name=""``, ``version=""``).

    Regression fix for :issue:`1321`.
    zmetrics.csvNÚ )ÚnewlineÚw)Ú
fieldnames)r   Úis_fileÚopenÚcsvÚ
DictReaderÚlistr”   Ú
experimentÚ
DictWriterÚwriteheaderÚ	writerowsÚsortedÚmetrics_keys)	r�   rŽ   Úmetrics_pathÚfÚreaderr”   Úrowsrš   Úwriters	            r%   Ú#_preserve_csv_history_across_resumer¥     s›  € õ0 ˜
Ñ#Ô# mÑ3€LØ×ÒÑ!Ô!ð ØˆØ	×	Ò	 2Ð	Ñ	&Ô	&ð ¨!Ý” Ñ"Ô"ˆÝ˜&Ô+Ð1¨rÑ2Ô2ˆ
Ý�F‰|Œ|ˆðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð ð ØˆàÔ&€JØ	×	Ò	˜3¨Ð	Ñ	+Ô	+ð ¨qÝ” ¨jÐ9Ñ9Ô9ˆØ×ÒÑÔÐØ×Ò˜ÑÔÐðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð õ % ZÑ0Ô0€JÔÐÐs$   ¿:BÂB	ÂB	Â2A C>Ã>DÄD)Úkeypoint_map_50_95Úsegm_mAP_50_95Ú	mAP_50_95)Úkeypoint_mARÚmARrª   )ÚmapÚmarzdict[str, tuple[str, str, str]]Ú_BEST_MODEL_MONITOR_KEYSÚ	callbacksúlist[Callback]Úloggersú	list[Any]Útcr   Úmodel_configr   Ú
enable_emaÚhas_keypointsc               óú  — |r4|                       t          |j        |j        |j        ¬¦  «        ¦  «         |j        dk    r(|                       t          |j        ¬¦  «        ¦  «         |j        dk    r/|                       t          |j	        ddddddd¬¦  «        ¦  «         |                       t          |j	        d	|j        d
dddd¬¦  «        ¦  «         t          |j                 \  }}}|rd|› �}	d|› �}
n|j        rd|› �}	d|› �}
n
d|› �}	d|› �}
|r|
nd}|j        p| }|j        }|                       t          t!          |j	        ¦  «        |	|||j        |j        |¬¦  «        ¦  «         |j        r<|                       t)          |j        |j        |j        |	|
|j        ¬¦  «        ¦  «         t1          |j	        dd¬¦  «        }|j        rt5          ||j	        ¦  «         |                      |¦  «         |j        rs	 t9          ¦   «          |                      t;          |j	        dd¬¦  «        ¦  «         n9# t<          t>          f$ r%}t@           !                    d|¦  «         Y d}~nd}~ww xY w|j"        rh	 |                      tG          |j$        |j%        |j	        ¬¦  «        ¦  «         n2# tL          $ r%}t@           !                    d|¦  «         Y d}~nd}~ww xY w|j'        rw	 |                      tQ          |j%        pd|j$        t!          |j	        ¦  «        ¬¦  «        ¦  «         n2# tL          $ r%}t@           !                    d|¦  «         Y d}~nd}~ww xY w|j)        rtU          d¦  «        ‚dS )aÃ  Append the training-only callbacks and loggers to *callbacks* / *loggers* in place.

    Called by :func:`build_trainer` only when ``include_training_callbacks=True``: EMA, drop-path, checkpointing,
    best-model selection, early stopping, and the configured loggers (CSVLogger always; TensorBoard/WandB/MLflow
    optionally). Extracted from ``build_trainer`` to keep the training-vs-eval mode split to a single call site
    rather than a re-indented function body.

    Args:
        callbacks: The trainer's callback list, appended to in place.
        loggers: The trainer's logger list, appended to in place.
        tc: Training hyperparameter configuration.
        model_config: Architecture configuration (used to select the best-model monitor metric).
        enable_ema: Whether EMA is active (already resolved against sharded-strategy compatibility).
        has_keypoints: Whether the model uses the keypoint head (selects the monitor metric).
    )ÚdecayÚtauÚupdate_interval_stepsg        )Ú	drop_pathrk   ÚlastTF)ÚdirpathÚfilenameÚevery_n_epochsÚ
save_top_kÚsave_on_train_epoch_endÚenable_version_counterÚauto_insert_metric_nameÚverbosezcheckpoint_{epoch}r~   zval/zval/ema_N)rŽ   Úmonitor_regularÚmonitor_emaÚevaluates_base_modelÚrun_testÚskip_best_epochsÚsmooth_alpha)ÚpatienceÚ	min_deltaÚuse_emarÄ   rÅ   rÈ   r‘   )Úsave_dirÚnameÚversionzéTensorBoard logging disabled: %s. If using NumPy 2.x, ensure your TensorBoard installation is NumPy 2.0 compatible (the failure can originate from tensorboard.compat.tensorflow_stub). Install TensorBoard with: pip install tensorboard)rÎ   ÚprojectrÍ   z;WandB logging disabled: %s. Install with: pip install wandbÚrfdetr)Úexperiment_nameÚrun_namerÍ   z=MLflow logging disabled: %s. Install with: pip install mlflowzKClearML logging is not yet supported. Remove clearml=True from TrainConfig.)+Úappendr   Ú	ema_decayÚema_tauÚema_update_intervalrº   r   Úcheckpoint_intervalr   rŽ   r­   Úbest_model_metricÚsegmentation_headÚeval_base_modelrÉ   r   rB   rÇ   rÈ   Úearly_stoppingr   Úearly_stopping_patienceÚearly_stopping_min_deltaÚearly_stopping_use_emar   Úresumer¥   Útensorboardr&   r   rb   ÚAttributeErrorÚ_loggerÚwarningÚwandbr   ÚrunrÐ   ÚModuleNotFoundErrorÚmlflowr   ÚclearmlÚNotImplementedError)r®   r°   r²   r³   r´   rµ   Úkp_keyÚsegm_keyÚdet_keyrÄ   Úearly_stopping_monitor_emarÅ   rÆ   Úbest_model_smooth_alphar�   Úexcs                   r%   Ú_append_training_callbacksrñ   ?  sÂ  € ð0 ð 
Ø×ÒÝØ”lØ”JØ&(Ô&<ðñ ô ñ	
ô 	
ð 	
ð 
„|�cÒÐØ×ÒÕ)°B´LÐAÑAÔAÑBÔBÐBð 
Ô Ò"Ð"Ø×ÒÝØœØØ ØØ(,Ø',Ø(-Øð	ñ 	ô 	ñ	
ô 	
ð 	
ð ×ÒÝØ”MØ)ØÔ1ØØ$(Ø#(Ø$)Øð		
ñ 		
ô 		
ñô ð õ  !9¸Ô9MÔ NÑ€FˆH�gØð :Ø) ˜/˜/ˆØ%8°Ð%8Ð%8Ð"Ð"Ø	Ô	'ð :Ø+ Ð+Ð+ˆØ%:°Ð%:Ð%:Ð"Ð"à* Ð*Ð*ˆØ%9°Ð%9Ð%9Ð"Ø0:ÐDÐ,Ð,À€Kð Ô-Ð?°Z°Ðà œoÐð ×ÒÝÝ˜2œ=Ñ)Ô)Ø+Ø#Ø!5Ø”[ØÔ0Ø0ð	
ñ 	
ô 	
ñ
ô 
ð 
ð 
Ôð 

Ø×ÒÝØÔ3ØÔ5ØÔ1Ø /Ø6Ø!#Ô!4ðñ ô ñ		
ô 		
ð 		
õ"  B¤M¸ÀBÐGÑGÔG€JØ	„yð GÝ+¨J¸¼ÑFÔFÐFØ‡N‚N�:ÑÔÐà	„~ð ð	Ý2Ñ4Ô4Ð4Ø�NŠNÝ!Øœ]ØØðñ ô ñô ð ð øõ �^Ð,ð 	ð 	ð 	Ý�OŠOðDð ñô ð ð ð ð ð ð øøøøð	øøøð 
„xð 
`ð		`Ø�NŠNÝØœØœJØœ]ðñ ô ñô ð ð øõ #ð 	`ð 	`ð 	`Ý�OŠOÐYÐ[^Ñ_Ô_Ð_Ð_Ð_Ð_Ð_Ð_øøøøð	`øøøð 
„yð 
bð		bØ�NŠNÝØ$&¤JÐ$:°(ØœVÝ  ¤Ñ/Ô/ðñ ô ñô ð ð øõ #ð 	bð 	bð 	bÝ�OŠOÐ[Ð]`ÑaÔaÐaÐaÐaÐaÐaÐaøøøøð	bøøøð 
„zð qÝ!Ð"oÑpÔpÐpðqð qsI   È8H? È?I5ÉI0É0I5Ê 4J5 Ê5
K$Ê?KËK$Ë/AL3 Ì3
M"Ì=MÍM"c                  ó   — e Zd ZdZd
d„Zd	S )Ú!_ForceLastEpochValidationCallbackaQ  Force a validation run on the final training epoch when ``eval_interval`` would skip it.

    ``check_val_every_n_epoch=N`` makes Lightning skip the whole validation loop on non-eval epochs (the compute saving
    behind ``eval_interval``), but Lightning has no "always validate the last epoch" switch while RF-DETR guarantees
    last-epoch metrics (``COCOEvalCallback`` treats the final epoch as an eval epoch). The fit loop reads
    ``trainer.check_val_every_n_epoch`` live on every epoch, so resetting it to 1 at the start of the final epoch re-
    enables validation exactly there.
    Útrainerr
   Ú	pl_moduleú'LightningModule'r   r    c                ó€   — |j         }t          |t          ¦  «        r|dk    r|j        |dz
  k    rd|_        dS dS dS dS )zÊReset ``check_val_every_n_epoch`` to 1 once the final epoch starts.

        Args:
            trainer: The Lightning Trainer instance.
            pl_module: The module being trained (unused).
        r   rk   N)Ú
max_epochsr`   r|   Úcurrent_epochÚcheck_val_every_n_epoch)r/   rô   rõ   rø   s       r%   Úon_train_epoch_startz6_ForceLastEpochValidationCallback.on_train_epoch_startÿ  s\   € ð Ô'ˆ
Ý�j¥#Ñ&Ô&ð 	0¨:¸ª>¨>¸gÔ>SÐWaÐdeÑWeÒ>eÐ>eØ./ˆGÔ+Ð+Ð+ð	0ð 	0¨>¨>Ð>eÐ>er'   N)rô   r
   rõ   rö   r   r    )r1   r2   r3   r4   rû   r-   r'   r%   ró   ró   õ  s2   € € € € € ðð ð	0ð 	0ð 	0ð 	0ð 	0ð 	0r'   ró   T)re   Úinclude_training_callbacksÚtrain_configrü   Útrainer_kwargsr   r
   c               óš  ‡‡#‡$— | }‰€|j         Št          ‰¦  «        }t          ‰¦  «                             ¦   «         }|dk    p|dk    o|Š$	 t	          j        d¦  «         n,# t          $ r t                               dd¬¦  «         Y nw xY wt          ||¦  «        Š#‰#dk    r|s‰d	vrt          d
¦  «        ‚dUˆˆ#ˆ$fd„}|                     d|j        ¦  «        }	|                     d|j        ¦  «        }
|                     d|j        ¦  «        }t          |j        ¦  «        }‰#dk    rt#          |	¦  «        rt          d¦  «        ‚|rS|sQt%          |	t          ¦  «        r<|	                     ¦   «                              ¦   «         dk    rt)          |
‰¦  «        rd}	t%          |	t          ¦  «        r&|	                     ¦   «                              ¦   «         nd}t%          |t*          ¦  «        |k    r.t          dt%          |t*          ¦  «        › d|j        › d�¦  «        ‚t-          t          |	¦  «        ¦  «        p|dk    pt)          |
‰¦  «        }|rŒ|rŠt#          |	¦  «        rt/          d|	›d�¦  «        ‚t%          |	t0          ¦  «        r6t3          |	di ¦  «        }|                     dd¦  «        st          d¦  «        ‚t                               d|	|
|¦  «         |                     d|j        ¦  «        }| o|dk    }|dv r0t9          d d||¬!¦  «        }	t                               d"||¦  «         n]|d#k    s|dk    rQ|rOt1          d||¬$¦  «        }	|dk    rt                               d%|¦  «         nt                               d&|¦  «         t#          |	¦  «        }|ot;          |
|¦  «         }t          |j        ¦  «        o| o| }|j        r#|r!t?          j         d'|	›d(�tB          d)¬*¦  «         n'|r%|j        r|rt?          j         d+tB          d)¬*¦  «         g }|j"        d,k    r4| #                    tI          d-dtK          d.¬/¦  «        ¬0¦  «        ¦  «         n.|j"        d1k    r#| #                    tM          d-¬2¦  «        ¦  «         g }|rtO          ||||||¬3¦  «         | #                    tQ          |j)        |j*        |j+        |j,        |j-        |j.        |j/        ¬4¦  «        ¦  «         |j+        dk    r!| #                    ta          ¦   «         ¦  «         |j1        }|j2        }|}|rd}d}n	|j        }|}i d5|j3        “d6‰“d|j        “d|j        “d|	“d|“d7|“d8|“d9|“d:|r|nd“d;|“d<|j"        du“d=|j4        “d>d?“d@d“dA|j+        “dB|j5        “}|s |¦   «         |dC<   | 6                    |¦  «         |r—dDdEl7m8} | 9                    dFg ¦  «        }|€g }nt%          |tt          tv          f¦  «        s|g}| 9                    dCd¦  «         ‰$sdGn*ty           |¦   «          =                    dHdI¦  «        ¦  «        }g |¢ ||¦  «        ‘|dF<   |	|d<   |rYdJD ]L} | |v rF| dk    rdKndL}!| dk    rdMndN}"t?          j         dO| ›dP||          ›dQ| › dR|!› dS|"› dT�tB          d)¬*¦  «         ŒMd|d<   d|d7<   t}          dVi |¤ŽS )Wuþ  Assemble a PTL ``Trainer`` with the full RF-DETR callback and logger stack.

    Resolves training precision from ``train_config.amp_dtype`` and device capability, guards EMA against sharded
    strategies, wires conditional loggers, and applies promoted training knobs (sync_batchnorm, strategy).

    Args:
        train_config: Training hyperparameter configuration. ``amp_dtype`` is the authority for
            precision resolution.
        model_config: Architecture configuration. Read for the deprecated ``amp`` toggle (a fallback
            only when ``amp_dtype`` is left at its default) and to guard against unsupported
            distributed configurations for keypoint models.
        accelerator: PTL accelerator string (e.g. ``"auto"``, ``"cpu"``, ``"gpu"``).
            Defaults to ``None`` which reads from ``train_config.accelerator`` (itself defaulting to ``"auto"``). Pass
            ``"cpu"`` to override auto-detection (e.g. when the caller explicitly requests CPU training via
            ``device="cpu"``).
        include_training_callbacks: When ``True`` (default) the full training stack is wired (EMA, drop-path,
            checkpointing, best-model selection, early stopping) along with the configured loggers. When ``False`` an
            evaluation-only trainer is built that keeps just the metric callback (and the progress bar): no
            checkpoints or logs are written. Used by :meth:`rfdetr.detr.RFDETR.evaluate`.
        **trainer_kwargs: Extra keyword arguments forwarded to ``pytorch_lightning.Trainer``. Use this to pass
            PTL-native flags that are not exposed through ``TrainConfig``, for example::

                build_trainer(tc, mc, fast_dev_run=2)

            Most keys present in both ``trainer_kwargs`` and the built config dict are overridden by the value in
            ``trainer_kwargs``. Detection and segmentation models forward ``accumulate_grad_batches`` from
            ``train_config.grad_accum_steps`` and ``gradient_clip_val`` from ``train_config.clip_max_norm`` to the
            Trainer normally. Keypoint models force ``accumulate_grad_batches=1`` and ``gradient_clip_val=None``
            because ``RFDETRModelModule`` owns both operations under manual optimization; passing those keys for a
            keypoint config raises a ``UserWarning`` to make the override explicit.

    Note:
        Two process-wide side effects: (1) unconditionally calls
        ``torch.set_float32_matmul_precision("high")``, which persists after this function
        returns and overrides any caller-set precision (e.g. ``"highest"``) with no opt-out â€”
        mirrors the import-time guard in ``rfdetr.detr`` so the Lightning CLI path
        (``rfdetr fit``) gets the same TF32 behavior as the python API path. (2) sets
        ``check_val_every_n_epoch=tc.eval_interval``, so ``eval_interval`` now gates the whole
        validation loop (forward pass, metric compute, EMA forward), not just result logging;
        a ``_ForceLastEpochValidationCallback`` still guarantees the final epoch always
        validates even when ``epochs`` is not a multiple of ``eval_interval``.

        When ``accelerator`` resolves to ``"xla"`` or ``"tpu"``, the resolved precision is
        set via an ``XLAPrecision`` plugin instead of a ``precision`` argument â€” PTL's
        ``XLAStrategy`` only accepts the plugin and raises ``TypeError`` for standard precision
        strings. The XLA plugin is appended to caller-supplied plugins.

    Returns:
        A configured ``pytorch_lightning.Trainer`` instance.
    Nrt   rh   Úhighz1torch.set_float32_matmul_precision('high') failedT)Úexc_infoÚfp8>   rj   rh   ri   úIFP8 training requires an NVIDIA CUDA GPU supported by Transformer Engine.r   rB   c                 ó~  •‡— ‰€dS ‰r‰dv rdS ‰dk    rdS t           j                             ¦   «         rý‰dk    rodŠˆfd„t          t           j                             ¦   «         ¦  «        D ¦   «         } | r2d                     d	„ | D ¦   «         ¦  «        }t          d
|› d�¦  «        ‚dS ‰dk    rdS ‰dk    rXt           j                             ¦   «         rdS t           	                    d¦  «         t          j        dt          d¬¦  «         dS t           j                             ¦   «         rdndS t           j        j                             ¦   «         rS‰dk    rt          d¦  «        ‚‰dk    r6t           	                    d¦  «         t          j        dt          d¬¦  «         dS ‰dk    rt          d¦  «        ‚dS )NrE   >   rh   Úbf16rF   Úcpur  )é   é	   c                óZ   •— g | ]'}t           j                             |¦  «        ‰k     ¯%|‘Œ(S r-   )rm   ri   Úget_device_capability)rM   ÚindexÚ_min_fp8_capabilitys     €r%   r‰   z=build_trainer.<locals>._resolve_precision.<locals>.<listcomp>‘  s?   ø€ ð 'ð 'ð 'àÝ”z×7Ò7¸Ñ>Ô>ÐATÒTÐTð àTÐTÐTr'   z, c              3  ób   K  — | ]*}d |› dt           j                             |¦  «        › d�V — Œ+dS )zcuda:z (ú)N)rm   ri   Úget_device_name)rM   r  s     r%   rP   z<build_trainer.<locals>._resolve_precision.<locals>.<genexpr>—  sW   è è € ð &ð &ØRWÐM ÐMÐM­¬×)CÒ)CÀEÑ)JÔ)JÐMÐMÐMð&ð &ð &ð &ð &ð &r'   z–amp_dtype='fp8' requires a Transformer Engine-supported NVIDIA GPU (Ada, Hopper, or newer; compute capability >= 8.9). Unsupported visible device(s): ú.ztransformer-engineÚfp16z16-mixedr  z
bf16-mixedzqamp_dtype='bf16' was requested but this CUDA device does not support bfloat16; falling back to fp16 ('16-mixed').é   ©Ú
stacklevelr  zXamp_dtype='bf16' is not applied on MPS; RF-DETR uses fp16 ('16-mixed') for MPS autocast.)rm   ri   rn   Úrangero   ÚjoinrG   Úis_bf16_supportedrã   rä   ÚwarningsÚwarnÚUserWarningÚbackendsÚmps)Úunsupported_devicesÚnamesr  re   Ú	amp_dtypeÚtpu_accelerators     @€€€r%   Ú_resolve_precisionz)build_trainer.<locals>._resolve_precisiong  sR  øø€ ØÐØ�9Øð 	˜yÐ,<Ð<Ð<ð �;ð ˜%ÒÐØ�9õ, Œ:×"Ò"Ñ$Ô$ð '	RØ˜EÒ!Ð!ð
 '-Ð#ð'ð 'ð 'ð 'å!&¥u¤z×'>Ò'>Ñ'@Ô'@Ñ!AÔ!Að'ñ 'ô 'Ð#ð
 'ð Ø ŸIšIð &ð &Ø[nð&ñ &ô &ñ ô �Eõ %ðCà:?ðCð Cð Cñô ð ð
 ,Ð+Ø˜FÒ"Ð"Ø!�zØ˜FÒ"Ð"Ý”:×/Ò/Ñ1Ô1ð (Ø'˜<Ý—’ð9ñô ð õ ”ð9åØ ð	ñ ô ð ð "�zå#(¤:×#?Ò#?Ñ#AÔ#AÐQ�<�<ÀzÐQÝŒ>Ô×*Ò*Ñ,Ô,ð 	Ø˜EÒ!Ð!Ý Ð!lÑmÔmÐmØ˜FÒ"Ð"Ý—’Ønñô ð õ ”ØnÝØ ðñ ô ð ð
 �:Ø˜ÒÐÝÐhÑiÔiÐiØˆyr'   rI   ry   r{   zùamp_dtype='fp8' is not compatible with FSDP or DeepSpeed strategies because Lightning's Transformer Engine precision plugin cannot replace their strategy-owned precision plugin. Use strategy='ddp' or 'auto', or select bf16/fp16 for sharded training.rs   z;Config/model mismatch: isinstance(tc, KeypointTrainConfig)=z* but model_config.use_grouppose_keypoints=zT. Pass KeypointTrainConfig for keypoint models and TrainConfig for detection models.rk   zLKeypoint training does not support sharded distributed strategies (strategy=zˆ). Use DistributedDataParallel instead, e.g. strategy='ddp' (or strategy='auto' with devices>1), which is supported for keypoint models.Ú_ddp_kwargsÚfind_unused_parametersFzâKeypoint training under a supplied DDPStrategy requires find_unused_parameters=True; construct it as DDPStrategy(find_unused_parameters=True). Keypoint models can leave parameters unused on some steps, which plain DDP rejects.u±   Keypoint model + distributed execution (strategy=%r, devices=%r, num_nodes=%r) â†’ DDP with manual optimization. Accumulated gradients synchronize only when the optimizer steps.Úaccumulate_grad_batches)Úddp_notebookÚ	ddp_spawnÚspawn)r:   r#  Ústatic_graphÚgradient_as_bucket_viewu[   %s â†’ spawn-based DDP to avoid OpenMP thread pool corruption after fork (static_graph=%s).rQ   )r#  r(  r)  ui   strategy='auto' with distributed execution â†’ DDPStrategy(find_unused_parameters=True, static_graph=%s).uM   strategy='ddp' â†’ DDPStrategy(find_unused_parameters=True, static_graph=%s).zTEMA disabled: RFDETREMACallback is not compatible with sharded strategies (strategy=z.). Set use_ema=False to suppress this warning.r  r  zèEMA disabled on multi-device XLA because per-step weight reads can corrupt subsequent optimizer updates there. One-device XLA keeps EMA. Training will continue with the live model weights. Set use_ema=False to suppress this warning.Úriché   z.3e)Úmetrics_format)Úrefresh_rateÚleaveÚthemeÚtqdm)r-  )r´   rµ   )Úmax_detsÚsegmentationÚeval_intervalÚlog_per_class_metricsÚeval_backendÚkeypoint_oks_sigmasrÛ   rø   re   Úgradient_clip_valÚsync_batchnormr®   ÚloggerÚenable_checkpointingÚenable_progress_barÚdefault_root_dirÚlog_every_n_stepsé2   Údeterministicrú   Únum_sanity_val_stepsrA   r   )ÚXLAPrecisionÚpluginsrE   z-mixedz-true)r$  r7  Ú1r    Úgrad_accum_stepsÚclip_max_normz'build_trainer() ignored trainer_kwargs[z]=z1 for a keypoint model. The model will train with ú=z± regardless of the value passed here because RFDETRModelModule owns gradient accumulation and clipping under manual optimization. To change the effective value, set TrainConfig.z	 instead.)r   rB   r-   )?re   rx   rB   rT   rm   Úset_float32_matmul_precisionÚ	Exceptionrã   Údebugr   rG   ÚgetrI   ry   r{   r+   Úuse_grouppose_keypointsrd   r`   rl   rŒ   r   rV   rê   Ú_DDPStrategyÚgetattrÚinforD  r7   rƒ   rÌ   r  r  r  Úprogress_barrÔ   r   r   r   rñ   r   Úeval_max_detsrÚ   r3  r4  r5  r6  rÛ   ró   rE  Úsync_bnÚepochsrŽ   r@  ÚupdateÚpytorch_lightning.pluginsrA  Úpopr™   ÚtuplerH   Úreplacer
   )%rý   r³   re   rü   rþ   r²   Úxla_acceleratorrp   r!  rI   ry   r{   rµ   rO   Údistributed_requestedÚ
ddp_kwargsÚ_effective_grad_accum_stepsÚ_static_graph_eligibleÚshardedÚxla_multi_devicer´   r®   r°   rE  rQ  Úmanual_optimizationr$  r7  Útrainer_configrA  rB  Úxla_precisionÚkeyÚ	effectiveÚaltr  r   s%     `                                @@r%   Úbuild_trainerre    sü	  øøø€ ðt 
€BØÐØ”nˆõ 3°;Ñ?Ô?€OÝ˜;Ñ'Ô'×-Ò-Ñ/Ô/Ðð '¨%Ò/ÐcÐ4DÈÒ4NÐ4bÐSb€Oð
ZÝÔ*¨6Ñ2Ô2Ð2Ð2øÝð Zð Zð ZÝ�ŠÐIÐTXˆÑYÔYÐYÐYÐYðZøøøõ # <°Ñ4Ô4€IØ�EÒÐ˜Ð°+ÐE\Ð2\Ð2\õ ÐdÑeÔeÐeðZð Zð Zð Zð Zð Zð Zð Zðz ×!Ò! *¨b¬kÑ:Ô:€HØ× Ò  ¨B¬JÑ7Ô7€GØ×"Ò" ;°´Ñ=Ô=€IÝ˜Ô=Ñ>Ô>€MØ�EÒÐÕ2°8Ñ<Ô<ÐÝðVñ
ô 
ð 	
ð 	ðàðõ �x¥Ñ%Ô%ðð �NŠNÑÔ×"Ò"Ñ$Ô$¨Ò.Ð.Ý& w°Ñ<Ô<ð /ð ˆÝ0:¸8ÅSÑ0IÔ0IÐS�H—N’NÑ$Ô$×*Ò*Ñ,Ô,Ð,Èt€MÝ�"Õ)Ñ*Ô*¨mÒ;Ð;ÝðaÍ*ÐUWÕYlÑJmÔJmð að aØ8DÔ8\ðað að añ
ô 
ð 	
õ 	+­3¨x©=¬=Ñ9Ô9ð 	<Ø�qŠ=ð	<å% g¨{Ñ;Ô;ð ð
 ð #
Ð.ð #
õ   Ñ)Ô)ð 	Ý%ð_Ø%ð_ð _ð _ñô ð õ
 �h¥Ñ-Ô-ð 	õ
 ! ¨=¸"Ñ=Ô=ˆJØ—>’>Ð":¸EÑBÔBð Ý ðPñô ð õ 	�ŠðmàØØñ	
ô 	
ð 	
ð: #1×"4Ò"4Ð5NÐPRÔPcÑ"dÔ"dÐØ!.Ð.ÐSÐ3NÐRSÒ3SÐð Ð5Ð5Ð5Ý,Ø Ø#'Ø/Ø$:ð	
ñ 
ô 
ˆõ 	�ŠØiØØ"ñ	
ô 	
ð 	
ð 	
ð
 
˜%Ò	Ð	 M°VÒ$;Ð$;Ð@UÐ$;õ  Ø#'Ø/Ø$:ð
ñ 
ô 
ˆð
 ˜FÒ"Ð"Ý�LŠLðMà&ñô ð ð õ �LŠLØ_Ø&ñô ð õ # 8Ñ,Ô,€GØ&ÐaÕ/MÈgÐW`Ñ/aÔ/aÐ+aÐÝ�b”jÑ!Ô!ÐJ¨' kÐJÐ:JÐ6J€JØ	„zð 
�gð 
ÝŒðTØ!ðTð Tð TåØð		
ñ 	
ô 	
ð 	
ð 	
ð 
$ð 
¨¬
ð 
Ð7Gð 
ÝŒðIõ Øð	
ñ 	
ô 	
ð 	
ð !#€Ià	„˜&Ò Ð Ø×ÒÝ$ØØÝ*¸%Ð@Ñ@Ô@ðñ ô ñ	
ô 	
ð 	
ð 	
ð 
Œ˜FÒ	"Ð	"Ø×ÒÕ1¸qÐAÑAÔAÑBÔBÐBð €GØ!ð 
Ý"Ø�w  L¸ZÐWdð	
ñ 	
ô 	
ð 	
ð
 ×ÒÝØÔ%Ø%Ô7ØÔ*Ø"$Ô":ØœØ "Ô 6ØÔ.ð	
ñ 	
ô 	
ñ
ô 
ð 
ð" 
Ô˜!ÒÐØ×ÒÕ:Ñ<Ô<Ñ=Ô=Ð=ð Ô+€MØ”J€Gð (ÐØð *Ø'(ÐØ*.ÐÐà"$Ô"5ÐØ)Ðð&Ø�b”ið&à�{ð&ð 	�2”:ð&ð 	�R”\ð	&ð
 	�Hð&ð 	"Ð#:ð&ð 	Ð.ð&ð 	˜'ð&ð 	�Yð&ð 	˜WÐ/�'�'¨%ð&ð 	Ð :ð&ð 	˜rœ°dÐ:ð&ð 	˜BœMð&ð 	˜Rð&ð  	˜ð!&ð" 	" 2Ô#3ð#&ð$ 	 Ô 7ð%&€Nð( ð ;Ø&8Ð&8Ñ&:Ô&:ˆ�{Ñ#Ø×Ò˜.Ñ)Ô)Ð)Øð LØ:Ð:Ð:Ð:Ð:Ð:ð !×$Ò$ Y°Ñ3Ô3ˆØˆ?ØˆGˆGÝ˜G¥d­E ]Ñ3Ô3ð 	 Ø�iˆGØ×Ò˜;¨Ñ-Ô-Ð-ð
 #ð[ˆIˆIå)Ð*<Ð*<Ñ*>Ô*>×*FÒ*FÀxÐQXÑ*YÔ*YÑZÔZð 	ð
 %L gÐ$K¨|¨|¸MÑ/JÔ/JÐ$Kˆ�yÑ!Ø!)€N�:ÑØð 3ð
 Dð 	ð 	ˆCØ�nÐ$Ð$Ø#&Ð*CÒ#CÐ#C˜C˜CÈ�	Ø,/Ð3LÒ,LÐ,LÐ(Ð(ÐRa�Ý”ðc¸cð cð cÀ~ÐVYÔGZð cð cØ8;ðcð cØ>Gðcð cð UXðcð cð cõ  Ø ðñ ô ð øð 56ˆÐ0Ñ1ð /3ˆÐ*Ñ+ÝÐ$Ð$�^Ð$Ð$Ð$s   ÁA# Á#&BÂBr@   )rA   rB   r   rC   )rI   rB   r   r+   )rI   rW   r   r+   )re   rf   r   r+   )rk   )ry   rz   r{   r|   r   r+   rL   )ry   r„   re   rf   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   re   rf   rü   r+   rþ   r   r   r
   )Br4   Ú
__future__r   r—   r  Úcollections.abcr   Úpathlibr   Útypingr   r   rm   Úpytorch_lightningr   r	   r
   Úpytorch_lightning.callbacksr   Ú2pytorch_lightning.callbacks.progress.rich_progressr   Úpytorch_lightning.loggersr   r   r   r   ra   r   rL  Ú6pytorch_lightning.strategies.launchers.multiprocessingr   rb   Úrfdetr.configr   r   r   r   Úrfdetr.training.callbacksr   r   r   r   r   r   Ú#rfdetr.training.callbacks.coco_evalr   Úrfdetr.utilities.loggerr   rã   r&   r(   Ú__annotations__r*   r7   rH   rV   rd   rq   rx   rƒ   rŒ   r¥   r­   rñ   ró   re  r-   r'   r%   ú<module>rt     sÎ  ðð HÐ GÐ Gà "Ð "Ð "Ð "Ð "Ð "à 
€
€
€
Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð à €€€Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø SÐ SÐ SÐ SÐ SÐ SØ ]Ð ]Ð ]Ð ]Ð ]Ð ]Ð ]Ð ]Ð ]Ð ]Ð ]Ð ]Ø DÐ DÐ DÐ DÐ DÐ Dð
$Ø_Ð_Ð_Ð_Ð_Ð_Ð_øØð $ð $ð $Ø#ÐÐÐð$øøøð \Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [Ð [ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð AÐ @Ð @Ð @Ð @Ð @Ø .Ð .Ð .Ð .Ð .Ð .à
ˆ*‰,Œ,€ð6ð 6ð 6ð 6ðF /3Ð Ð 2Ð 2Ð 2Ñ 2àÐ'ðð ð ð ð Ð(@ñ ô ð ð !>ÐðZð Zð Zð Zð Z ñ Zô Zð Zð0ð ð ð ð.Qð Qð Qð Qð#cð #cð #cð #cðLð ð ð ð)ð )ð )ð )ð. 3ð  3ð  3ð  3ð  3ðFð ð ð ð ð '1ð '1ð '1ð '1ð\ AØ)ð=ð =Ð ð ð ð ñ ðsqð sqð sqð sqðl0ð 0ð 0ð 0ð 0¨ñ 0ô 0ð 0ð4 #Ø'+ðY%ð Y%ð Y%ð Y%ð Y%ð Y%ð Y%ð Y%s   ÁA ÁA$Á#A$