
    ^j_                        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 erddlm	Z	 ddl
Z
ddlmZmZ ddlm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  e       Z G d de      Z G d de      Zy)zUBest-model checkpointing and early stopping callbacks for RF-DETR Lightning training.    )annotationsN)Path)TYPE_CHECKING)Any)LightningModuleTrainer)__version__)EarlyStoppingModelCheckpoint)
get_logger)get_version)_make_fit_loop_statestrip_checkpointc                      e Zd ZdZdZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZe	 	 d	 	 	 	 	 	 	 	 	 	 	 dd       Zedd       Ze	 	 	 	 	 	 dd       Z	e	 d	 	 	 	 	 dd       Z
edd       Zd fd	Zd fd
ZddZd fdZddZ xZS )BestModelCallbackaS  Track best validation mAP and save best checkpoints during training.

    Extends :class:`pytorch_lightning.callbacks.ModelCheckpoint` to save stripped ``{model, args, epoch}`` ``.pth``
    files (instead of full ``.ckpt`` files) and to track a separate EMA checkpoint in parallel.

    At the end of training the overall winner (regular vs EMA, strict ``>`` for EMA) is copied to
    ``checkpoint_best_total.pth`` and optimizer/scheduler state is stripped via
    :func:`rfdetr.util.misc.strip_checkpoint`.

    Checkpoints are only updated on validation epochs where the monitor metric is actually logged.  On non-eval epochs
    (when ``eval_interval > 1`` causes COCO evaluation to be skipped) the callback is a no-op.

    ``state_dict()`` and ``load_state_dict()`` are overridden to persist ``_best_ema`` in the Lightning callback state,
    ensuring that ``trainer.fit(ckpt_path=...)`` resumes EMA high-water-mark tracking from the correct value.

    Args:
        output_dir: Directory where checkpoint files are written.
        monitor_regular: Metric key for the regular model mAP.
        monitor_ema: Metric key for the EMA model mAP.  ``None`` disables EMA tracking.
        run_test: If ``True``, run ``trainer.test()`` on the best model at the end of training.
        skip_best_epochs: Ignore the first N epochs (0..N-1) when tracking
            best regular and EMA checkpoints.  Useful when fine-tuning from ``pretrain_weights``: the pretrained model's
            epoch-0 mAP can artificially dominate best-checkpoint selection before training adapts to the new dataset.
        smooth_alpha: Exponential-moving-average smoothing factor in ``[0.0, 1.0)`` applied to the regular monitor
            metric before checkpoint comparison.  ``0.0`` (default) disables smoothing and keeps legacy behaviour:
            ``trainer.callback_metrics[monitor_regular]`` is consumed as-is by the parent
            :class:`~pytorch_lightning.callbacks.ModelCheckpoint`.  ``smooth_alpha > 0`` maintains an internal EMA
            state ``self._smoothed_regular = alpha * self._smoothed_regular + (1 - alpha) * raw`` and temporarily
            substitutes the smoothed value into ``trainer.callback_metrics`` for the duration of the parent's
            improvement check; the original raw value is always restored before returning so what gets logged to
            ``metrics.csv`` is unaffected.  Useful for noisy metrics (e.g. keypoint mAP under NLL-Cholesky losses) where
            raw per-epoch swings can lock the best checkpoint to an early local peak.  The EMA accumulator is updated
            on every validation epoch including epochs within the ``skip_best_epochs`` window so the smoothed value
            is pre-warmed by the first eligible comparison.

    Examples:
        Skip the first 3 epochs so pretrained weights do not dominate:

        >>> import tempfile
        >>> from rfdetr.training.callbacks.best_model import BestModelCallback
        >>> with tempfile.TemporaryDirectory() as tmp:
        ...     cb = BestModelCallback(output_dir=tmp, skip_best_epochs=3)
        ...     cb._skip_best_epochs
        3
    z.pthc                   t         |   |d|dddddd	       || _        || _        d| _        t        |      | _        t        |t              st        |t              st        d      |dk  rt        d	      || _        t        |t              st        |t        t        f      st        d
      t        j                  |      r
|dk  s|dk\  rt        d      t        |      | _        d| _        d| _        d | _        y )Ncheckpoint_best_regularmax   F)	dirpathfilenamemonitormode
save_top_ksave_on_train_epoch_endverboseauto_insert_metric_nameenable_version_counter        /skip_best_epochs must be a non-negative integerr   3skip_best_epochs must be greater than or equal to 0z*smooth_alpha must be a float in [0.0, 1.0)      ?z"smooth_alpha must be in [0.0, 1.0))super__init___monitor_ema	_run_test	_best_emar   _output_dir
isinstanceboolint	TypeError
ValueError_skip_best_epochsfloatmathisfinite_smooth_alpha_smoothed_regular_best_raw_regular_current_pl_module)self
output_dirmonitor_regularmonitor_emarun_testskip_best_epochssmooth_alpha	__class__s          o/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/rfdetr/training/callbacks/best_model.pyr$   zBestModelCallback.__init__O   s	    	.#$)$)#( 	 
	
 (! #
+&-Z@PRU5VMNNaRSS!1lD)L3PU,1WHII}}\*lS.@LTWDWABB$),$7 ), ),:>    c           
        | ||j                   | j                         D ci c]  \  }}d| | c}}|j                  t        t	        |j                         di idi idg g d	}|||d<   |||d<   t               }|||d<   |S c c}}w )a~  Build a PTL-compatible RF-DETR checkpoint payload.

        Args:
            model_state_dict: Model weights with raw (non-prefixed) keys.
            args_dict: Serialized training args/config payload.
            trainer: Active Lightning trainer providing epoch/step counters.
            model_name: Name of the model class (e.g. ``"RFDETRLarge"``).
            model_config_dict: Serialized architecture config needed to reconstruct schema-dependent models.

        Returns:
            Checkpoint dictionary that supports ``Trainer.fit(ckpt_path=...)`` while intentionally omitting
            optimizer/scheduler states.
        zmodel.
state_dict)fit_loopvalidate_loop	test_loop)	modelargsepochrA   global_stepzpytorch-lightning_versionloopsoptimizer_stateslr_schedulers
model_namemodel_configrfdetr_version)current_epochitemsrH   ptl_versionr   r   )	model_state_dict	args_dicttrainerrL   model_config_dictkvpayloadversions	            r>   _build_checkpoint_payloadz+BestModelCallback._build_checkpoint_payload|   s    , &**7G7M7M7OPtq!VA3<?P"..)401F1FG #/!3*B/ !#'&
. !$.GL!(&7GN# -(/G$%9 Qs   Bc                    t        | j                  dd      }t        |t        j                  j
                        r|n| j                  }|j                         S )a	  Resolve live model weights from the active Lightning module.

        Args:
            pl_module: The ``RFDETRModelModule`` being trained.

        Returns:
            State dict from the live, non-EMA model, unwrapped from ``torch.compile`` when needed.
        	_orig_modN)getattrrE   r)   torchnnModulerA   )	pl_module_origraws      r>   _get_live_model_state_dictz,BestModelCallback._get_live_model_state_dict   s?     	d;!%9ey~~r?   c                N   | j                   D ])  }t        |dd      }t        |      s |       }||c S  n t        j	                  d       t        |j
                  dd      }t        |t        j                  j                        r|n|j
                  }|j                         S )a,  Resolve EMA model weights from the active EMA callback.

        Args:
            trainer: The Lightning Trainer instance.
            pl_module: The ``RFDETRModelModule`` being trained.

        Returns:
            EMA model state dict when available, otherwise the live model state dict.
        get_ema_model_state_dictNzhEMA metric improved but EMA callback weights were unavailable; saving current model weights as fallback.r\   )	callbacksr]   callableloggerwarningrE   r)   r^   r_   r`   rA   )rT   ra   callbackgetterrA   rb   rc   s          r>   _get_ema_model_state_dictz+BestModelCallback._get_ema_model_state_dict   s      )) 	HX'A4HF#X
)%%	 	v	
 	d;!%9ey~~r?   c                   t        | dd      }|yt        |t              r|S t        |dd      }t        |      sy |       }t        |t              sy|Yt        | j                  dd      }t        |t
        j                  j                        r|n| j                  }|j                         }|j                  d      }t        |t
        j                        rM|j                  dk(  r>d|v r:|j                  d	      j                         D cg c]  }t        |       c}|d<   |j                  d
      }	t        |	t
        j                        r(|	j                  dk(  rd|v r|	j                  d   dz
  |d<   |S c c}w )a  Serialize the model architecture config when the module exposes one.

        Schema-critical fields (``num_keypoints_per_class``, ``num_classes``) are synced from live model weights so the
        saved config reflects what the model actually learned, not a stale constructor default (e.g. COCO ``[0, 17]``
        when the model was fine-tuned on ``[0, 33]``).

        Args:
            pl_module: The Lightning module whose model config will be serialized.
            state_dict: Pre-computed model state dict. If ``None``, computed from the live model.
                Pass the already-retrieved checkpoint state dict to avoid a redundant copy.
        rM   N
model_dumpr\   _kp_active_mask   num_keypoints_per_classr   )dimzclass_embed.weightnum_classesr   )r]   r)   dictrh   rE   r^   r_   r`   rA   getTensorndimsumtolistr+   shape)
ra   rA   rM   ro   dumpedrb   rc   _kp_maskn
_ce_weights
             r>   _serialize_model_configz)BestModelCallback._serialize_model_config   sO    y.$?lD)\<>

#&$' IOO[$?E%eUXX__=%9??C)J>>"34h-(--12DIbflIlAIRSATA[A[A]0^AQ0^F,-^^$89
j%,,/JOOq4H]^dMd$.$4$4Q$7!$;F=! 1_s   E<c                `   t        | dd      }|t        |dd      nd}t        |t              r|j                         }|r|S |t	        |      j
                  nd}|j                  d      rt        d| d      |j                  d      r"|j                  d	      r|j                  d	      S y)
a  Resolve checkpoint model_name from model_config or config type.

        The CLI/PTL path does not call ``RFDETR.train()``, so ``model_config.model_name`` may be unset. In that case,
        infer the model class from concrete config names like ``RFDETRSmallConfig``.

        Note:
            The ``DeprecatedConfig`` ``RuntimeError`` guard is only reachable from the CLI/PTL path. ``RFDETR.train()``
            pre-populates ``model_config.model_name`` before saving any checkpoint, so the config type-name branch (and
            therefore the ``DeprecatedConfig`` guard) is never reached when training is started via ``RFDETR.train()``.
        rM   NrL    DeprecatedConfigzDeprecated model config 'zL' is no longer supported. Re-train your model using a current model variant.RFDETRConfig)
r]   r)   strstriptype__name__endswithRuntimeError
startswithremovesuffix)ra   rM   configured_namenormalized_nameconfig_type_names        r>   _resolve_model_namez%BestModelCallback._resolve_model_name	  s     y.$?GSG_',dCeios+-335O&&:F:R4-66XZ$$%78+,<+= >E E  &&x05E5N5Nx5X#00::r?   c                ~    t         |          }| j                  |d<   | j                  |d<   | j                  |d<   |S )aW  Return callback state including ``_best_ema``, ``_smoothed_regular``, and ``_best_raw_regular``.

        Extends the parent :class:`~pytorch_lightning.callbacks.ModelCheckpoint` state dict with three extra keys so
        that ``trainer.fit(ckpt_path=...)`` resumes the EMA high-water mark, the smoothed-metric accumulator, and the
        raw metric at the smoothed-best epoch from their correct values rather than resetting to ``0.0``.

        Returns:
            State dict with all parent fields plus ``"_best_ema"``, ``"_smoothed_regular"``,
            and ``"_best_raw_regular"``.
        r'   r3   r4   )r#   rA   r'   r3   r4   )r6   stater=   s     r>   rA   zBestModelCallback.state_dict'  sG     "$!^^k%)%;%;!"%)%;%;!"r?   c                   t        |      }t        |j                  dd            | _        t	        j
                  | j                        sd| _        t        |j                  dd            | _        t	        j
                  | j                        sd| _        t        |j                  dd            | _        t	        j
                  | j                        sd| _        t        | %  |       y)a  Restore callback state from a Lightning checkpoint.

        Pops ``"_best_ema"``, ``"_smoothed_regular"``, and ``"_best_raw_regular"`` from a shallow copy of *state_dict*
        before delegating to the parent so the parent does not receive unexpected keys.  Each key defaults to ``0.0``
        when absent (e.g. checkpoints saved before these fields were persisted) and is reset to ``0.0`` when the stored
        value is non-finite.

        Args:
            state_dict: Callback state dict as produced by :meth:`state_dict`.
        r'   r   r3   r4   N)
ru   r/   popr'   r0   r1   r3   r4   r#   load_state_dict)r6   rA   r   r=   s      r>   r   z!BestModelCallback.load_state_dict8  s     Z uyyc:;}}T^^, DN!&uyy1Dc'J!K}}T334%(D"!&uyy1Dc'J!K}}T334%(D"&r?   c           	        |j                   sy| j                  }|t        d|d|j                   d      t	        |      }|j
                  j                  dd       | j                  |      }|j                  }t        |j                  dd      }|-t        |d      r!t        |dd      |j                  d|i	      }t        |d
      r|j                         n|}| j                  |      }	| j                  ||      }
t!        j"                  | j%                  ||||	|
      |       |j&                  | _        |j*                  j-                  | j.                        }t!        j0                  |      r|j3                         d}n|t5        |      }nd}t6        j9                  d||j                  | j.                  |       y)um  Save stripped ``.pth`` format instead of a full ``.ckpt``.

        Skips on non-main processes.  Intentionally does NOT call ``trainer.save_checkpoint()`` — we only want ``{model,
        args, epoch}``.

        Args:
            trainer: The Lightning Trainer instance.
            filepath: Destination path (ends in ``.pth`` via ``FILE_EXTENSION``).
        Nz8BestModelCallback._save_checkpoint called with filepath=z
 at epoch=z but pl_module was not set.Tparentsexist_okclass_names
model_copyupdatero   rL   rU   z.6gunknownzDBest regular checkpoint saved to %s (epoch %d, monitor=%s, value=%s))is_global_zeror5   r   rO   r   parentmkdirrd   train_configr]   
datamodulehasattrr   ro   r   r   r^   saverZ   rH   _last_global_step_savedcallback_metricsrv   r   	is_tensoritemr   ri   info)r6   rT   filepathra   pth_pathrR   r   dataset_class_namesrS   rL   rU   monitor_valuemonitor_displays                r>   _save_checkpointz"BestModelCallback._save_checkpointP  s    %%++	J8, W#1122MO  >dT:  ::9E !--%g&8&8-N+l3mT:B'22=J]:^2_L18|1TL++-Zf	--i8
 88DTU

** %"3 +  		
 (/':':$0044T\\B??=)!.!3!3!5c :O&!-0O'OR!!LL	
r?   c           	     t   || _         d}| j                  dkD  rp| j                  |j                  v rX|j                  | j                     j	                         }| j                  | j
                  z  d| j                  z
  |z  z   | _        |j                  | j                  k  ry| j                  |j                  vry| j                  dkD  r,||n&|j                  | j                     j	                         }| j                  | j                  j	                         nt        d       }|j                  | j                     }t        j                  | j
                  |j                  |j                        |j                  | j                  <   	 t        | =  ||       ||j                  | j                  <   | j                  | j                  j	                         nt        d       }||kD  r|| _        nt        | =  ||       | j"                  |j$                  sy|j                  j'                  | j"                  t        j                  d            j	                         }|| j(                  kD  r"|| _        | j*                  j-                  dd       | j/                  ||      }	|j0                  }
t3        |j4                  dd      }|-t7        |
d	      r!t3        |
dd      |
j9                  d|i
      }
t7        |
d      r|
j;                         n|
}| j=                  |      }| j?                  ||	      }t        j@                  | jC                  |	||||      | j*                  dz         tD        jG                  d||j                         yy# ||j                  | j                  <   w xY w)a  Save best regular/EMA checkpoints when validation mAP improves.

        Delegates regular-model checkpoint management to the :class:`~pytorch_lightning.callbacks.ModelCheckpoint`
        parent (handles improvement detection, fast_dev_run/sanity guards, ``best_model_path`` and ``best_model_score``
        bookkeeping).  EMA is tracked independently.

        Args:
            trainer: The Lightning Trainer instance.
            pl_module: The ``RFDETRModelModule`` being trained.
        Nr   r"   inf)dtypedeviceTr   r   r   r   ro   r   checkpoint_best_ema.pthz(Best EMA mAP improved to %.4f (epoch %d))$r5   r2   r   r   r   r3   rO   r.   best_model_scorer/   r^   tensorr   r   r#   on_validation_endr4   r%   r   rv   r'   r(   r   rm   r   r]   r   r   r   ro   r   r   r   rZ   ri   r   )r6   rT   ra   rc   current_rawprev_best_scoreoriginalnew_best_scoreema_valema_state_dictema_train_configr   ema_args_dictema_model_nameema_model_config_dictr=   s                  r>   r   z#BestModelCallback.on_validation_end  sq    #, !#8P8P(P**4<<8==?C%)%7%7$:P:P%PTWZ^ZlZlTlpsSs%sD"  4#9#99 <<w777 # ),W=U=UVZVbVb=c=h=h=jK>B>S>S>_d3388:fklqfrerO//=H5:\\&&hnnX__6G$$T\\2B)'9=9A((6 >B=R=R=^T22779ejkpeqdqN/)4&G%gy9 $G,B,B**..t/@/@%,,sBSTYY[T^^#$DN""4$"?!;;GYON  )55")'*<*<mT"R#/,l;,mTBJ#3#>#>}ViFj#>#k 189I<1X ++-^n  "55i@N$($@$@N$[!JJ.."!-&; /    #<<	 KK:%%; $ :B((6s   N N7c                D   |j                   sy| j                  dkD  r| j                  }n(| j                  | j                  j	                         nd}| j
                  rt        | j
                        nd}| j                  dz  }| j                  dz  }| j                  |kD  }|r|j                         r|n|}|rW|j                         rGt        j                  ||       t        |       t        j                  d|rdnd|| j                         | j                  rt!        t#        |      dd      }	|	duxr |	t$        j&                  u}
|
r|j                         st        j)                  d	       yt+        j,                  |d
d      }t!        |j.                  dd      }t1        |t*        j2                  j4                        r|n|j.                  }|j7                  |d   d       t        j                  d|       |j9                  ||j:                  d       yyy)a  Select the overall best model and optionally run test evaluation.

        Copies the winner (regular vs EMA, strict ``>`` for EMA) to ``checkpoint_best_total.pth``, strips
        optimizer/scheduler state, then optionally runs ``trainer.test()``.

        Args:
            trainer: The Lightning Trainer instance.
            pl_module: The ``RFDETRModelModule`` being trained.
        Nr   r   zcheckpoint_best_total.pthz<Best total checkpoint saved from %s (regular=%.4f, ema=%.4f)EMAregular	test_stepzSkipping trainer.test() because no best checkpoint was produced. Ensure the monitored metric is logged on evaluation epochs, that evaluation runs often enough, and that skip_best_epochs is smaller than the number of training epochs.cpuF)map_locationweights_onlyr\   rE   T)strictz0Loaded best weights from %s for test evaluation.)r   r   )r   r2   r4   r   r   best_model_pathr   r(   r'   existsshutilcopy2r   ri   r   r&   r]   r   r   r   rj   r^   loadrE   r)   r_   r`   r   testr   )r6   rT   ra   best_regularregular_pathema_path
total_pathbest_is_ema	best_pathcls_test_stephas_test_stepckptrb   rc   s                 r>   
on_fit_endzBestModelCallback.on_fit_end  s    %% #11L;?;P;P;\400557beL595I5ItD001t##&??%%(CC
 nn|3!,1BH	))+LLJ/Z(KKN$)	 >>#DO[$GM)5h-OhOh:hM!((*NN+ zz*5uU  	dC)%Aey##DM$#?NPZ[Y73E3EuU# 	 r?   )val/mAP_50_95NTr   r   )r7   r   r8   r   r9   
str | Noner:   r*   r;   r+   r<   r/   returnNone)NN)rR   dict[str, torch.Tensor]rS   objectrT   r   rL   r   rU   zobject | Noner   zdict[str, object])ra   r   r   r   )rT   r   ra   r   r   r   )N)ra   r   rA   zdict[str, Any] | Noner   zdict[str, object] | None)ra   r   r   r   )r   dict[str, Any])rA   r   r   r   )rT   r   r   r   r   r   rT   r   ra   r   r   r   )r   
__module____qualname____doc__FILE_EXTENSIONr$   staticmethodrZ   rd   rm   r   r   rA   r   r   r   r   __classcell__r=   s   @r>   r   r      sd   ,\ N
  /"& !!+?+? +?  	+?
 +? +? +? 
+?Z 
 "&+/5155 5 	5
 )5 
5 5n       "  
!   6 HL("(0E(	!( (T  :"'0=
~Zx@Vr?   r   c                  n     e Zd ZU dZdZded<   	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZd	 fdZ xZS )
RFDETREarlyStoppinguM  Early stopping callback monitoring validation mAP for RF-DETR.

    Extends :class:`pytorch_lightning.callbacks.EarlyStopping` with dual-metric
    monitoring: by default it monitors ``max(regular_mAP, ema_mAP)`` (legacy
    behaviour); set ``use_ema=True`` to monitor the EMA metric exclusively.

    The effective metric is injected into ``trainer.callback_metrics`` under a synthetic key before delegating to the
    parent's stopping logic, so all parent features are available for free: ``state_dict``/``load_state_dict`` for
    checkpoint resumption, NaN/inf guard via ``check_finite``, and ``stopping_threshold``/``divergence_threshold``.

    Early stopping evaluates only on validation epochs where the monitored metrics are logged; non-eval epochs
    (``eval_interval > 1``) are skipped automatically.

    Args:
        patience: Number of epochs with no improvement before stopping.
        min_delta: Minimum mAP improvement to reset the patience counter.
        use_ema: When ``True`` and both regular and EMA metrics are available,
            monitor only the EMA metric.  When ``False``, monitor ``max(regular, ema)``.
        monitor_regular: Metric key for the regular model mAP.
        monitor_ema: Metric key for the EMA model mAP.
        verbose: If ``True``, log early stopping status each epoch.
        skip_best_epochs: Ignore the first N epochs (0..N-1) when evaluating
            patience and best-score baselines.  Set this when fine-tuning from ``pretrain_weights`` to avoid premature
            stopping before the model adapts to the new dataset.

    Examples:
        Fine-tuning from pretrained weights — skip first 3 epochs:

        >>> from rfdetr.training.callbacks.best_model import RFDETREarlyStopping
        >>> cb = RFDETREarlyStopping(patience=10, skip_best_epochs=3)
        >>> cb._skip_best_epochs
        3
    __rfdetr_effective_map__r   _SYNTHETIC_MONITORc                    t         |   | j                  d||d|ddd	       t        |t              st        |t
              st        d      |dk  rt        d      || _        || _	        || _
        || _        y )Nr   FT)	r   r   patience	min_deltacheck_on_train_epoch_endr   check_finiter   log_rank_zero_onlyr    r   r!   )r#   r$   r   r)   r*   r+   r,   r-   _monitor_regularr%   _use_emar.   )	r6   r   r   use_emar8   r9   r   r;   r=   s	           r>   r$   zRFDETREarlyStopping.__init__S  s     	++%*# 	 
	
 &-Z@PRU5VMNNaRSS /'!1r?   c                   |j                   | j                  k  ry|j                  }|j                  | j                        }|j                  | j
                        }||j                         nd}||j                         nd}||y| j                  r||}n||t        ||      }n||}n|}t        j                  |      |j                  | j                  <   t        	| 5  ||       y)a  Compute effective mAP and delegate to parent stopping logic.

        Computes ``ema_mAP`` or ``max(regular_mAP, ema_mAP)`` depending on ``use_ema``, injects the result under the
        synthetic monitor key, then calls :meth:`EarlyStopping.on_validation_end` which handles patience,
        ``trainer.should_stop``, logging, and ``state_dict`` persistence.

        Args:
            trainer: The Lightning Trainer instance.
            pl_module: The ``RFDETRModelModule`` being trained.
        N)rO   r.   r   rv   r   r%   r   r   r   r^   r   r   r#   r   )
r6   rT   ra   metricsregular_tensor
ema_tensorregular_valr   	effectiver=   s
            r>   r   z%RFDETREarlyStopping.on_validation_endr  s       4#9#99** T%:%:;[[!2!23
=K=WN$7$7$9]a5?5K
 1QU7?==W0I$)<K1I I#I<ALL<S  !8!89!'95r?   )
   gMbP?Fr   zval/ema_mAP_50_95Tr   )r   r+   r   r/   r   r*   r8   r   r9   r   r   r*   r;   r+   r   r   r   )	r   r   r   r   r   __annotations__r$   r   r   r   s   @r>   r   r   .  s     D 98  .. !22 2 	2
 2 2 2 2 
2>"6 "6r?   r   )r   
__future__r   r0   r   pathlibr   typingr   r   r^   pytorch_lightningr   r   r	   rQ   pytorch_lightning.callbacksr
   r   rfdetr.utilities.loggerr   rfdetr.utilities.packager   rfdetr.utilities.state_dictr   r   ri   r   r    r?   r>   <module>r
     s[    \ "       6 8 F . 0 N	MV MV`f6- f6r?   