a
    PSic@                  
   @   sp  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m	Z	m
Z
mZm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 dd
lmZ ddlmZ ddlm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%m&Z& ddl'm!Z( ddl!m)Z)m*Z* ddl+m,Z, ddl-m.Z.m/Z/ ddl0m1Z1 g dZ2e
e edddZ3dd Z4dd Z5G d d! d!ej6Z7G d"d# d#ej6Z8G d$d% d%ej6Z9G d&d' d'ej6Z:e d(d)Z;G d*d+ d+eZ<G d,d- d-eZ=e"d.e<j>fd/e%j?fd0dd1de%j?dd2ee< e@eeA ee% eeA ee:d3d4d5ZBdd1dddd2ee= e@eeA ee% eeA ee:d3d6d7ZCdd8l!mDZD eDd9e<j>jEiZFdS ):    N)OrderedDict)partial)AnyCallableDictListTupleOptional)nnTensor   )sigmoid_focal_loss)boxes)misc)LastLevelP6P7)ObjectDetection)_log_api_usage_once   )WeightsEnumWeights)_COCO_CATEGORIES)handle_legacy_interface_ovewrite_value_param)ResNet50_Weightsresnet50   )_utils)overwrite_eps	_box_loss)AnchorGenerator)_resnet_fpn_extractor_validate_trainable_layers)GeneralizedRCNNTransform)	RetinaNetRetinaNet_ResNet50_FPN_Weights!RetinaNet_ResNet50_FPN_V2_Weightsretinanet_resnet50_fpnretinanet_resnet50_fpn_v2)xreturnc                 C   s&   | d }| dd  D ]}|| }q|S )Nr   r    )r(   resir*   r*   b/var/www/html/django/DPS/env/lib/python3.9/site-packages/torchvision/models/detection/retinanet.py_sum$   s    
r.   c                 C   s^   t dD ]P}dD ]F}| dd|  d| }| d| d| }|| v r| || |< qqd S )N   )weightbiaszconv.r   .z.0.)rangepop)
state_dictprefixr,   typeold_keynew_keyr*   r*   r-   _v1_to_v2_weights+   s    r:   c                  C   s,   t dd dD } dt|  }t| |}|S )Nc                 s   s(   | ] }|t |d  t |d fV  qdS )gr(?g<n=e?N)int.0r(   r*   r*   r-   	<genexpr>5       z%_default_anchorgen.<locals>.<genexpr>)    @         i   ))      ?      ?g       @)tuplelenr   )anchor_sizesaspect_ratiosanchor_generatorr*   r*   r-   _default_anchorgen4   s    
rK   c                       sF   e Zd ZdZdeedejf  d fddZdd Z	d	d
 Z
  ZS )RetinaNetHeadau  
    A regression and classification head for use in RetinaNet.

    Args:
        in_channels (int): number of channels of the input feature
        num_anchors (int): number of anchors to be predicted
        num_classes (int): number of classes to be predicted
        norm_layer (callable, optional): Module specifying the normalization layer to use. Default: None
    N.
norm_layerc                    s0   t    t||||d| _t|||d| _d S )NrM   )super__init__RetinaNetClassificationHeadclassification_headRetinaNetRegressionHeadregression_head)selfin_channelsnum_anchorsnum_classesrN   	__class__r*   r-   rP   F   s
    
zRetinaNetHead.__init__c                 C   s$   | j |||| j||||dS )N)classificationbbox_regression)rR   compute_lossrT   )rU   targetshead_outputsanchorsmatched_idxsr*   r*   r-   r]   M   s    zRetinaNetHead.compute_lossc                 C   s   |  || |dS )N)
cls_logitsr\   )rR   rT   )rU   r(   r*   r*   r-   forwardT   s    zRetinaNetHead.forward)N)__name__
__module____qualname____doc__r	   r   r
   ModulerP   r]   rc   __classcell__r*   r*   rY   r-   rL   ;   s   
"rL   c                       sV   e Zd ZdZdZdeedejf  d fddZ	 fd	d
Z
dd Zdd Z  ZS )rQ   af  
    A classification head for use in RetinaNet.

    Args:
        in_channels (int): number of channels of the input feature
        num_anchors (int): number of anchors to be predicted
        num_classes (int): number of classes to be predicted
        norm_layer (callable, optional): Module specifying the normalization layer to use. Default: None
    r   {Gz?N.rM   c           	         s   t    g }tdD ]}|tj|||d qtj| | _| j	 D ]@}t
|tjrHtjjj|jdd |jd urHtjj|jd qHtj||| dddd| _tjjj| jjdd tjj| jjtd| |   || _|| _tjj| _d S )	Nr/   rM   rj   stdr   r   r   kernel_sizestridepadding)rO   rP   r3   appendmisc_nn_opsConv2dNormActivationr
   
Sequentialconvmodules
isinstanceConv2dtorchinitnormal_r0   r1   	constant_rb   mathlogrX   rW   	det_utilsMatcherBETWEEN_THRESHOLDS)	rU   rV   rW   rX   prior_probabilityrN   ru   _layerrY   r*   r-   rP   f   s     

$z$RetinaNetClassificationHead.__init__c           	   	      sB   | dd }|d u s|dk r&t|| t ||||||| d S Nversionr   getr:   rO   _load_from_state_dict	rU   r5   r6   local_metadatastrictmissing_keysunexpected_keys
error_msgsr   rY   r*   r-   r      s    

z1RetinaNetClassificationHead._load_from_state_dictc                 C   s   g }|d }t |||D ]l\}}}|dk}	|	 }
t|}d||	|d ||	  f< || jk}|t|| || ddtd|
  qt|t	| S )Nrb   r   rE   labelssum)	reductionr   )
zipr   ry   
zeros_liker   rq   r   maxr.   rG   )rU   r^   r_   ra   lossesrb   targets_per_imageZcls_logits_per_imagematched_idxs_per_imageforeground_idxs_per_imagenum_foregroundZgt_classes_targetZvalid_idxs_per_imager*   r*   r-   r]      s.    

	z(RetinaNetClassificationHead.compute_lossc           	      C   s~   g }|D ]f}|  |}| |}|j\}}}}||d| j||}|ddddd}||d| j}|| qtj	|ddS )Nr   r   r/   r   r   dim)
ru   rb   shapeviewrX   permutereshaperq   ry   cat)	rU   r(   all_cls_logitsfeaturesrb   Nr   HWr*   r*   r-   rc      s    

z#RetinaNetClassificationHead.forward)rj   N)rd   re   rf   rg   _versionr	   r   r
   rh   rP   r   r]   rc   ri   r*   r*   rY   r-   rQ   Y   s   
  !!rQ   c                       s`   e Zd ZdZdZdejiZdee	de
jf  d fddZ fd	d
Zdd Zdd Z  ZS )rS   a%  
    A regression head for use in RetinaNet.

    Args:
        in_channels (int): number of channels of the input feature
        num_anchors (int): number of anchors to be predicted
        norm_layer (callable, optional): Module specifying the normalization layer to use. Default: None
    r   	box_coderN.rM   c                    s   t    g }tdD ]}|tj|||d qtj| | _tj	||d dddd| _
tjjj| j
jdd tjj| j
j | j D ]>}t|tj	rtjjj|jdd |jd urtjj|j qtjdd	| _d
| _d S )Nr/   rM   r   r   rm   rj   rk   rE   rE   rE   rE   weightsl1)rO   rP   r3   rq   rr   rs   r
   rt   ru   rx   bbox_regry   rz   r{   r0   zeros_r1   rv   rw   r   BoxCoderr   
_loss_type)rU   rV   rW   rN   ru   r   r   rY   r*   r-   rP      s    

z RetinaNetRegressionHead.__init__c           	   	      sB   | dd }|d u s|dk r&t|| t ||||||| d S r   r   r   rY   r*   r-   r      s    

z-RetinaNetRegressionHead._load_from_state_dictc              	   C   s   g }|d }t ||||D ]z\}}}	}
t|
dkd }| }|d |
|  }||d d f }|	|d d f }	|t| j| j|	||td|  qt	|tdt
| S )Nr\   r   r   r   )r   ry   wherenumelrq   r   r   r   r   r.   rG   )rU   r^   r_   r`   ra   r   r\   r   bbox_regression_per_imageanchors_per_imager   r   r   matched_gt_boxes_per_imager*   r*   r-   r]     s,    z$RetinaNetRegressionHead.compute_lossc           	      C   sz   g }|D ]b}|  |}| |}|j\}}}}||dd||}|ddddd}||dd}|| qtj|ddS )Nr   r/   r   r   r   r   r   )	ru   r   r   r   r   r   rq   ry   r   )	rU   r(   all_bbox_regressionr   r\   r   r   r   r   r*   r*   r-   rc   2  s    

zRetinaNetRegressionHead.forward)N)rd   re   rf   rg   r   r   r   __annotations__r	   r   r
   rh   rP   r   r]   rc   ri   r*   r*   rY   r-   rS      s   	" rS   c                       sZ   e Zd ZdZejejdZd fdd	Ze	j
jdd Zdd Zdd ZdddZ  ZS )r#   aE  
    Implements RetinaNet.

    The input to the model is expected to be a list of tensors, each of shape [C, H, W], one for each
    image, and should be in 0-1 range. Different images can have different sizes.

    The behavior of the model changes depending if it is in training or evaluation mode.

    During training, the model expects both the input tensors, as well as a targets (list of dictionary),
    containing:
        - boxes (``FloatTensor[N, 4]``): the ground-truth boxes in ``[x1, y1, x2, y2]`` format, with
          ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.
        - labels (Int64Tensor[N]): the class label for each ground-truth box

    The model returns a Dict[Tensor] during training, containing the classification and regression
    losses.

    During inference, the model requires only the input tensors, and returns the post-processed
    predictions as a List[Dict[Tensor]], one for each input image. The fields of the Dict are as
    follows:
        - boxes (``FloatTensor[N, 4]``): the predicted boxes in ``[x1, y1, x2, y2]`` format, with
          ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.
        - labels (Int64Tensor[N]): the predicted labels for each image
        - scores (Tensor[N]): the scores for each prediction

    Args:
        backbone (nn.Module): the network used to compute the features for the model.
            It should contain an out_channels attribute, which indicates the number of output
            channels that each feature map has (and it should be the same for all feature maps).
            The backbone should return a single Tensor or an OrderedDict[Tensor].
        num_classes (int): number of output classes of the model (including the background).
        min_size (int): minimum size of the image to be rescaled before feeding it to the backbone
        max_size (int): maximum size of the image to be rescaled before feeding it to the backbone
        image_mean (Tuple[float, float, float]): mean values used for input normalization.
            They are generally the mean values of the dataset on which the backbone has been trained
            on
        image_std (Tuple[float, float, float]): std values used for input normalization.
            They are generally the std values of the dataset on which the backbone has been trained on
        anchor_generator (AnchorGenerator): module that generates the anchors for a set of feature
            maps.
        head (nn.Module): Module run on top of the feature pyramid.
            Defaults to a module containing a classification and regression module.
        score_thresh (float): Score threshold used for postprocessing the detections.
        nms_thresh (float): NMS threshold used for postprocessing the detections.
        detections_per_img (int): Number of best detections to keep after NMS.
        fg_iou_thresh (float): minimum IoU between the anchor and the GT box so that they can be
            considered as positive during training.
        bg_iou_thresh (float): maximum IoU between the anchor and the GT box so that they can be
            considered as negative during training.
        topk_candidates (int): Number of best detections to keep before NMS.

    Example:

        >>> import torch
        >>> import torchvision
        >>> from torchvision.models.detection import RetinaNet
        >>> from torchvision.models.detection.anchor_utils import AnchorGenerator
        >>> # load a pre-trained model for classification and return
        >>> # only the features
        >>> backbone = torchvision.models.mobilenet_v2(weights=MobileNet_V2_Weights.DEFAULT).features
        >>> # RetinaNet needs to know the number of
        >>> # output channels in a backbone. For mobilenet_v2, it's 1280
        >>> # so we need to add it here
        >>> backbone.out_channels = 1280
        >>>
        >>> # let's make the network generate 5 x 3 anchors per spatial
        >>> # location, with 5 different sizes and 3 different aspect
        >>> # ratios. We have a Tuple[Tuple[int]] because each feature
        >>> # map could potentially have different sizes and
        >>> # aspect ratios
        >>> anchor_generator = AnchorGenerator(
        >>>     sizes=((32, 64, 128, 256, 512),),
        >>>     aspect_ratios=((0.5, 1.0, 2.0),)
        >>> )
        >>>
        >>> # put the pieces together inside a RetinaNet model
        >>> model = RetinaNet(backbone,
        >>>                   num_classes=2,
        >>>                   anchor_generator=anchor_generator)
        >>> model.eval()
        >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)]
        >>> predictions = model(x)
    )r   proposal_matcher   5  N皙?rD   ,  皙?  c                    s  t    t|  t|ds$td|| _t|ttd fsNt	dt| |d u r\t
 }|| _|d u rt|j| d |}|| _|	d u rtj||dd}	|	| _tjdd| _|d u rg d	}|d u rg d
}t||||fi || _|
| _|| _|| _|| _d| _d S )Nout_channelszbackbone should contain an attribute out_channels specifying the number of output channels (assumed to be the same for all the levels)zFanchor_generator should be of type AnchorGenerator or None instead of r   T)allow_low_quality_matchesr   r   )g
ףp=
?gv/?gCl?)gZd;O?gy&1?g?F)rO   rP   r   hasattr
ValueErrorbackbonerw   r   r7   	TypeErrorrK   rJ   rL   r   num_anchors_per_locationheadr   r   r   r   r   r"   	transformscore_thresh
nms_threshdetections_per_imgtopk_candidates_has_warned)rU   r   rX   min_sizemax_size
image_mean	image_stdrJ   r   r   r   r   r   fg_iou_threshbg_iou_threshr   kwargsrY   r*   r-   rP     sF    

zRetinaNet.__init__c                 C   s   | j r
|S |S )N)training)rU   r   
detectionsr*   r*   r-   eager_outputs  s    zRetinaNet.eager_outputsc              	   C   s   g }t ||D ]^\}}|d  dkrL|tj|dfdtj|jd qt	|d |}|| 
| q| j||||S )Nr   r   r   )dtypedevice)r   r   rq   ry   fullsizeint64r   box_opsbox_iour   r   r]   )rU   r^   r_   r`   ra   r   r   match_quality_matrixr*   r*   r-   r]     s    zRetinaNet.compute_lossc                    s  |d }|d }t |}g }t|D ]|  fdd|D } fdd|D }	|  |   }
}g }g }g }t||	|
D ]\}}}|jd }t| }|| jk}|| }t|d }t	
|| jd}||\}}|| }tj||dd	}|| }| j|| || }t||}|| || || qxtj|dd
}tj|dd
}tj|dd
}t|||| j}|d | j }||| || || d q$|S )Nrb   r\   c                    s   g | ]}|  qS r*   r*   )r=   brindexr*   r-   
<listcomp>  r?   z4RetinaNet.postprocess_detections.<locals>.<listcomp>c                    s   g | ]}|  qS r*   r*   )r=   clr   r*   r-   r     r?   r   r   floor)rounding_moder   )r   scoresr   )rG   r3   r   r   ry   sigmoidflattenr   r   r   	_topk_minr   topkdivr   decode_singler   clip_boxes_to_imagerq   r   batched_nmsr   r   )rU   r_   r`   image_shapesclass_logitsbox_regression
num_imagesr   box_regression_per_imagelogits_per_imager   image_shapeimage_boxesimage_scoresimage_labelsbox_regression_per_levellogits_per_levelanchors_per_levelrX   scores_per_level	keep_idxs	topk_idxsnum_topkidxsanchor_idxslabels_per_levelboxes_per_levelkeepr*   r   r-   postprocess_detections  sV    



z RetinaNet.postprocess_detectionsc              	      s  | j rf|du rtdd nJ|D ]D}|d }tt|tjd tt|jdko^|jd dkd	 q g }|D ]L}|jd
d }tt|dkd|jd
d   ||d |d f qn| ||\}}|dur`t	|D ]\}}|d }|ddddf |ddddf k}	|	
 rt|	j
ddd d }
||
  }tdd| d| d q| |j}t|tjrtd|fg}t| }| |}| ||}i }g }| j r|du rtdd n| |||}ndd |D d}D ]}||7 }q|d d}||   fddD i }|D ] }t|| jdd||< q8fdd|D }| |||j}| j||j|}tj r| jstd d| _||fS | ||S )a  
        Args:
            images (list[Tensor]): images to be processed
            targets (list[Dict[Tensor]]): ground-truth boxes present in the image (optional)

        Returns:
            result (list[BoxList] or dict[Tensor]): the output from the model.
                During training, it returns a dict[Tensor] which contains the losses.
                During testing, it returns list[BoxList] contains additional fields
                like `scores`, `labels` and `mask` (for Mask R-CNN models).

        NFz0targets should not be none when in training moder   z+Expected target boxes to be of type Tensor.r   r   r/   z5Expected target boxes to be a tensor of shape [N, 4].zJexpecting the last two dimensions of the Tensor to be H and W instead got r   r   r   zLAll bounding boxes should have positive height and width. Found invalid box z for target at index r2   0c                 S   s    g | ]}| d | d qS )r   r   )r   r<   r*   r*   r-   r     r?   z%RetinaNet.forward.<locals>.<listcomp>rb   c                    s   g | ]}|  qS r*   r*   )r=   hw)Ar*   r-   r     r?   c                    s   g | ]}t | qS r*   )listsplit)r=   a)num_anchors_per_levelr*   r-   r     r?   zBRetinaNet always returns a (Losses, Detections) tuple in scriptingT) r   ry   _assertrw   r   rG   r   rq   r   	enumerateanyr   tolistr   tensorsr   r  valuesr   rJ   r]   r   r  r  image_sizespostprocessjitis_scriptingr   warningswarnr   )rU   imagesr^   targetr   original_image_sizesimgval
target_idxdegenerate_boxesbb_idxdegen_bbr   r_   r`   r   r   ZHWvZHWAsplit_head_outputsksplit_anchorsr*   )r
  r  r-   rc   ;  s    

(


zRetinaNet.forward)r   r   NNNNNr   rD   r   rD   r   r   )N)rd   re   rf   rg   r   r   r   r   rP   ry   r  unusedr   r]   r  rc   ri   r*   r*   rY   r-   r#   E  s.   U
             E
@r#   )r   r   )
categoriesr   c                	   @   s8   e Zd Zedei edddddiiddd	ZeZd
S )r$   zLhttps://download.pytorch.org/models/retinanet_resnet50_fpn_coco-eeacb38b.pthizJhttps://github.com/pytorch/vision/tree/main/references/detection#retinanetCOCO-val2017box_mapg333333B@zSThese weights were produced by following a similar training recipe as on the paper.
num_paramsrecipe_metrics_docsurl
transformsmetaNrd   re   rf   r   r   _COMMON_METACOCO_V1DEFAULTr*   r*   r*   r-   r$     s    r$   c                	   @   s8   e Zd Zedei edddddiiddd	ZeZd
S )r%   zOhttps://download.pytorch.org/models/retinanet_resnet50_fpn_v2_coco-5905b1c5.pthiFz+https://github.com/pytorch/vision/pull/5756r*  r+  g     D@zZThese weights were produced using an enhanced training recipe to boost the model accuracy.r,  r1  Nr5  r*   r*   r*   r-   r%     s    r%   
pretrainedpretrained_backbone)r   weights_backboneT)r   progressrX   r;  trainable_backbone_layers)r   r<  rX   r;  r=  r   r)   c           
      K   s   t | } t|}| dur6d}t|t| jd }n|du rBd}| dupP|du}t||dd}|rjtjnt	j
}t|||d}t||g dtddd	}t||fi |}	| dur|	| j|d
 | t jkrt|	d |	S )a  
    Constructs a RetinaNet model with a ResNet-50-FPN backbone.

    .. betastatus:: detection module

    Reference: `Focal Loss for Dense Object Detection <https://arxiv.org/abs/1708.02002>`_.

    The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each
    image, and should be in ``0-1`` range. Different images can have different sizes.

    The behavior of the model changes depending if it is in training or evaluation mode.

    During training, the model expects both the input tensors, as well as a targets (list of dictionary),
    containing:

        - boxes (``FloatTensor[N, 4]``): the ground-truth boxes in ``[x1, y1, x2, y2]`` format, with
          ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.
        - labels (``Int64Tensor[N]``): the class label for each ground-truth box

    The model returns a ``Dict[Tensor]`` during training, containing the classification and regression
    losses.

    During inference, the model requires only the input tensors, and returns the post-processed
    predictions as a ``List[Dict[Tensor]]``, one for each input image. The fields of the ``Dict`` are as
    follows, where ``N`` is the number of detections:

        - boxes (``FloatTensor[N, 4]``): the predicted boxes in ``[x1, y1, x2, y2]`` format, with
          ``0 <= x1 < x2 <= W`` and ``0 <= y1 < y2 <= H``.
        - labels (``Int64Tensor[N]``): the predicted labels for each detection
        - scores (``Tensor[N]``): the scores of each detection

    For more details on the output, you may refer to :ref:`instance_seg_output`.

    Example::

        >>> model = torchvision.models.detection.retinanet_resnet50_fpn(weights=RetinaNet_ResNet50_FPN_Weights.DEFAULT)
        >>> model.eval()
        >>> x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)]
        >>> predictions = model(x)

    Args:
        weights (:class:`~torchvision.models.detection.RetinaNet_ResNet50_FPN_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.detection.RetinaNet_ResNet50_FPN_Weights`
            below for more details, and possible values. By default, no
            pre-trained weights are used.
        progress (bool): If True, displays a progress bar of the download to stderr. Default is True.
        num_classes (int, optional): number of output classes of the model (including the background)
        weights_backbone (:class:`~torchvision.models.ResNet50_Weights`, optional): The pretrained weights for
            the backbone.
        trainable_backbone_layers (int, optional): number of trainable (not frozen) layers starting from final block.
            Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is
            passed (the default) this value is set to 3.
        **kwargs: parameters passed to the ``torchvision.models.detection.RetinaNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/detection/retinanet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.detection.RetinaNet_ResNet50_FPN_Weights
        :members:
    Nr)  [      r   )r   r<  rN   r   r   r/   rC   returned_layersextra_blocksr<  g        )r$   verifyr   r   rG   r4  r!   rr   FrozenBatchNorm2dr
   BatchNorm2dr   r    r   r#   load_state_dictget_state_dictr7  r   )
r   r<  rX   r;  r=  r   
is_trainedrN   r   modelr*   r*   r-   r&     s(    J



r&   c                 K   s   t | } t|}| dur6d}t|t| jd }n|du rBd}| dupP|du}t||dd}t||d}t||g dt	dd	d
}t
 }t|j| d |ttjdd}	d|	j_t||f||	d|}
| dur|
| j|d |
S )a  
    Constructs an improved RetinaNet model with a ResNet-50-FPN backbone.

    .. betastatus:: detection module

    Reference: `Bridging the Gap Between Anchor-based and Anchor-free Detection via Adaptive Training Sample Selection
    <https://arxiv.org/abs/1912.02424>`_.

    :func:`~torchvision.models.detection.retinanet_resnet50_fpn` for more details.

    Args:
        weights (:class:`~torchvision.models.detection.RetinaNet_ResNet50_FPN_V2_Weights`, optional): The
            pretrained weights to use. See
            :class:`~torchvision.models.detection.RetinaNet_ResNet50_FPN_V2_Weights`
            below for more details, and possible values. By default, no
            pre-trained weights are used.
        progress (bool): If True, displays a progress bar of the download to stderr. Default is True.
        num_classes (int, optional): number of output classes of the model (including the background)
        weights_backbone (:class:`~torchvision.models.ResNet50_Weights`, optional): The pretrained weights for
            the backbone.
        trainable_backbone_layers (int, optional): number of trainable (not frozen) layers starting from final block.
            Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is
            passed (the default) this value is set to 3.
        **kwargs: parameters passed to the ``torchvision.models.detection.RetinaNet``
            base class. Please refer to the `source code
            <https://github.com/pytorch/vision/blob/main/torchvision/models/detection/retinanet.py>`_
            for more details about this class.

    .. autoclass:: torchvision.models.detection.RetinaNet_ResNet50_FPN_V2_Weights
        :members:
    Nr)  r>  r?  r   )r   r<  r@  i   rC   rA  r   r@   rM   giou)rJ   r   rD  )r%   rE  r   r   rG   r4  r!   r   r    r   rK   rL   r   r   r   r
   	GroupNormrT   r   r#   rH  rI  )r   r<  rX   r;  r=  r   rJ  r   rJ   r   rK  r*   r*   r-   r'   6  s2    (



r'   )
_ModelURLsZretinanet_resnet50_fpn_coco)Gr}   r  collectionsr   	functoolsr   typingr   r   r   r   r   r	   ry   r
   r   opsr   r   r   r   rr   Zops.feature_pyramid_networkr   Ztransforms._presetsr   utilsr   _apir   r   _metar   r   r   r   resnetr   r    r   r   r   anchor_utilsr   backbone_utilsr    r!   r   r"   __all__r.   r:   rK   rh   rL   rQ   rS   r#   r6  r$   r%   r7  IMAGENET1K_V1boolr;   r&   r'   rN  r2  
model_urlsr*   r*   r*   r-   <module>   s    		{q  bdI