
    ^j-'                    8   d Z ddlmZ g dZddlmZ ddlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ  e       Z edd	d
       G d de             Z G d de      Z G d de      Z G d de      Z  G d de      Z! edd	d
       G d de             Z" G d de      Z# G d de      Z$ edd	d
       G d de$             Z% G d de$      Z& G d  d!e$      Z' G d" d#e$      Z( G d$ d%e$      Z) G d& d'e$      Z* G d( d)e$      Z+y)*aV  Concrete RF-DETR model variant classes.

All classes inherit from :class:`~rfdetr.detr.RFDETR` which remains defined in ``rfdetr.detr``. Backward-compatible
access from ``rfdetr.detr`` is provided via lazy ``__getattr__`` re-exports, so importing ``rfdetr.variants`` no longer
depends on a fragile eager ``detr -> variants`` import sequence.
    )annotations)
RFDETRBaseRFDETRKeypointPreview
RFDETRNanoRFDETRSmallRFDETRMediumRFDETRLargeRFDETRLargeDeprecated	RFDETRSegRFDETRSegPreviewRFDETRSegNanoRFDETRSegSmallRFDETRSegMediumRFDETRSegLargeRFDETRSegXLargeRFDETRSeg2XLarge)deprecated_class)KeypointTrainConfigModelConfigRFDETRBaseConfigRFDETRKeypointPreviewConfigRFDETRLargeConfigRFDETRLargeDeprecatedConfigRFDETRMediumConfigRFDETRNanoConfigRFDETRSeg2XLargeConfigRFDETRSegLargeConfigRFDETRSegMediumConfigRFDETRSegNanoConfigRFDETRSegPreviewConfigRFDETRSegSmallConfigRFDETRSegXLargeConfigRFDETRSmallConfigSegmentationTrainConfig)RFDETR)
get_loggerNz1.7.0z2.0.0)targetdeprecated_in	remove_inc                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Base model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``.
    zrfdetr-baseN)__name__
__module____qualname____doc__sizer   _model_config_class     Z/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/rfdetr/variants.pyr   r   <   s     D*r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Nano model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``.
    zrfdetr-nanoN)r+   r,   r-   r.   r/   r   r0   r1   r2   r3   r   r   L   s     D*r2   r   c                      e Zd ZdZdZeZeZy)r   zTrain or run inference with the RF-DETR keypoint preview model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``.
    zrfdetr-keypoint-previewN)	r+   r,   r-   r.   r/   r   r0   r   _train_config_classr1   r2   r3   r   r   W   s     %D5-r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Small model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``.
    zrfdetr-smallN)r+   r,   r-   r.   r/   r#   r0   r1   r2   r3   r   r   c   s     D+r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Medium model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``.
    zrfdetr-mediumN)r+   r,   r-   r.   r/   r   r0   r1   r2   r3   r   r   n   s     D,r2   r   c                      e Zd ZdZdZeZy)r
   zTrain an RF-DETR Large model using the legacy config.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``.
    rfdetr-largeN)r+   r,   r-   r.   r/   r   r0   r1   r2   r3   r
   r
   y   s     D5r2   r
   c                  @     e Zd ZdZdZedd       Z fdZddZ xZ	S )r	   zTrain an RF-DETR Large model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``.
    r:   c                    t        |       j                         dv ryt        | t              rdv S t        | t              rd}t        fd|D              S y)a  Return whether initialization should retry with deprecated Large config.

        The fallback is only for known checkpoint/config incompatibilities from deprecated Large weights. Runtime issues
        such as CUDA OOM must fail fast and must not trigger a second initialization attempt.

        Args:
            exc: Exception raised by initial ``RFDETR`` initialization.

        Returns:
            ``True`` when retrying with deprecated config is expected to help.
        zout of memoryF
patch_size)zerror(s) in loading state_dictzsize mismatchzmissing key(s) in state_dictzunexpected key(s) in state_dictc              3  &   K   | ]  }|v  
 y w)Nr1   ).0markermessages     r3   	<genexpr>zDRFDETRLarge._should_fallback_to_deprecated_config.<locals>.<genexpr>   s     WVv(Ws   )strlower
isinstance
ValueErrorRuntimeErrorany)excincompatible_state_dict_markersrA   s     @r3   %_should_fallback_to_deprecated_configz1RFDETRLarge._should_fallback_to_deprecated_config   s^     c(.."g%c:&7**c<(/+ W7VWWWr2   c                
   d | _         d| _        t        j                  d   j                  }d|v xr |j                  d      |k7  }	 t        |   d
i | y # t        t        f$ r}|s| j                  |      s || _         d| _        	 t        |   d
i | t        j                  dddz  z   dz          n@# t        $ r4}t        j                  d| j                   |	       | j                   |d }~ww xY wY d }~y d }~ww xY w)NF
resolutionTz
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=z
WARNING: Automatically switched to deprecated model configuration, due to using deprecated weights. This will be removed in v1.9.0.
 Please retrain your model with the new weights and configuration.
=d   
zRetry with deprecated RF-DETR Large configuration failed; re-raising the original initialization error for compatibility. Original error: %s)exc_infor1   )
init_erroris_deprecatedr   model_fieldsdefaultgetsuper__init__rF   rG   rK   loggerwarning	Exception	exception)selfkwargs_default_resolution_custom_resolutionrI   	retry_exc	__class__s         r3   rW   zRFDETRLarge.__init__   s$   " 0<<\JRR)V3g

<8PTg8g	5G&v&L) 	5!)S)STW)X!DO!%D5 *6*!
 ! !%%  5  ) OO& !  oo945	5s<   A D'"C=
-B87C=8	C5/C00C55C==Dc                F    | j                   st        di |S t        di |S )Nr1   )rR   r   r   )r\   r]   s     r3   get_model_configzRFDETRLarge.get_model_config   s'    !!$.v...888r2   )rI   rZ   returnbool)rd   r   )
r+   r,   r-   r.   r/   staticmethodrK   rW   rc   __classcell__)ra   s   @r3   r	   r	      s,     D 6%5N9r2   r	   c                      e Zd ZdZeZy)r   zBase class for all RF-DETR segmentation models.

    Training accepts custom square integer ``resolution`` values. Most segmentation variants use multiples of 24;
    ``RFDETRSegNano`` uses multiples of 12.
    N)r+   r,   r-   r.   r$   r6   r1   r2   r3   r   r      s     2r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Segmentation Preview model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``. Deprecated in v1.7.0, scheduled for removal in v2.0.0.
    zrfdetr-seg-previewN)r+   r,   r-   r.   r/   r    r0   r1   r2   r3   r   r      s      D0r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Segmentation Nano model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``; this variant uses multiples of 12.
    zrfdetr-seg-nanoN)r+   r,   r-   r.   r/   r   r0   r1   r2   r3   r   r      s     D-r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Segmentation Small model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``; this variant uses multiples of 24.
    zrfdetr-seg-smallN)r+   r,   r-   r.   r/   r!   r0   r1   r2   r3   r   r          D.r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Segmentation Medium model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``; this variant uses multiples of 24.
    zrfdetr-seg-mediumN)r+   r,   r-   r.   r/   r   r0   r1   r2   r3   r   r          D/r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Segmentation Large model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``; this variant uses multiples of 24.
    zrfdetr-seg-largeN)r+   r,   r-   r.   r/   r   r0   r1   r2   r3   r   r     rl   r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Segmentation XLarge model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``; this variant uses multiples of 24.
    zrfdetr-seg-xlargeN)r+   r,   r-   r.   r/   r"   r0   r1   r2   r3   r   r   "  rn   r2   r   c                      e Zd ZdZdZeZy)r   zTrain an RF-DETR Segmentation 2XLarge model.

    Training accepts custom square integer ``resolution`` values. The value must be divisible by ``patch_size *
    num_windows``; this variant uses multiples of 24.
    zrfdetr-seg-2xlargeN)r+   r,   r-   r.   r/   r   r0   r1   r2   r3   r   r   -  s      D0r2   r   ),r.   
__future__r   __all__	deprecater   rfdetr.configr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   rfdetr.detrr%   rfdetr.utilities.loggerr&   rX   r   r   r   r   r   r
   r	   r   r   r   r   r   r   r   r   r1   r2   r3   <module>rx      sQ   #$ '    &  .	 
+ +
++ +	.F 	.,& ,-6 - 
6F 6
6P9& P9f2 2 
1y 1
1.I ./Y /0i 0/Y /0i 01y 1r2   