
    h#                        S SK Jr  S SKJrJr  S SKJr  SSKJr  SSK	J
r
JrJr  SSKJr  SS	KJrJrJr  SS
KJrJrJrJrJr  SSKJr  / SQr " S S\5      r " S S\R8                  5      r\SSS.r " S S\5      r " S S\5      r S\S\!S\\"   S\4S jr#\
" 5       \" S\RH                  4S\RJ                  4S 9S!S"S!S!\RJ                  S#.S$\\   S%\"S\\!   S&\\"   S'\\   S(\S\4S) jj5       5       r&\
" 5       \" S\ RH                  4S\RJ                  4S 9S!S"S!S!\RJ                  S#.S$\\    S%\"S\\!   S&\\"   S'\\   S(\S\4S* jj5       5       r'g!)+    )partial)AnyOptional)nn   )SemanticSegmentation   )register_modelWeightsWeightsEnum)_VOC_CATEGORIES)_ovewrite_value_paramhandle_legacy_interfaceIntermediateLayerGetter)ResNet	resnet101ResNet101_Weightsresnet50ResNet50_Weights   )_SimpleSegmentationModel)FCNFCN_ResNet50_WeightsFCN_ResNet101_Weightsfcn_resnet50fcn_resnet101c                       \ rS rSrSrSrg)r      a[  
Implements FCN model from
`"Fully Convolutional Networks for Semantic Segmentation"
<https://arxiv.org/abs/1411.4038>`_.

Args:
    backbone (nn.Module): the network used to compute the features for the model.
        The backbone should return an OrderedDict[Tensor], with the key being
        "out" for the last feature map used, and "aux" if an auxiliary classifier
        is used.
    classifier (nn.Module): module that takes the "out" element returned from
        the backbone and returns a dense prediction.
    aux_classifier (nn.Module, optional): auxiliary classifier used during training
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       [/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/models/segmentation/fcn.pyr   r      s     	r&   r   c                   8   ^  \ rS rSrS\S\SS4U 4S jjrSrU =r$ )FCNHead$   in_channelschannelsreturnNc           	        > US-  n[         R                  " XSSSS9[         R                  " U5      [         R                  " 5       [         R                  " S5      [         R                  " X2S5      /n[
        TU ]  " U6   g )N   r   r   F)paddingbiasg?)r   Conv2dBatchNorm2dReLUDropoutsuper__init__)selfr+   r,   inter_channelslayers	__class__s        r'   r7   FCNHead.__init__%   sc    $)IIk1aeLNN>*GGIJJsOIIn2
 	&!r&   r   )r    r!   r"   r#   intr7   r%   __classcell__)r;   s   @r'   r)   r)   $   s"    
"C 
"3 
"4 
" 
"r&   r)   )r   r   z
        These weights were trained on a subset of COCO, using only the 20 categories that are present in the Pascal VOC
        dataset.
    )
categoriesmin_size_docsc                   P    \ rS rSr\" S\" \SS90 \ESSSSS	S
.0SSS.ES9r\r	Sr
g)r   <   zBhttps://download.pytorch.org/models/fcn_resnet50_coco-1167a1af.pth  resize_sizeijzPhttps://github.com/pytorch/vision/tree/main/references/segmentation#fcn_resnet50COCO-val2017-VOC-labelsg     @N@gV@miou	pixel_accgmc@g?5^I`@
num_paramsrecipe_metrics_ops
_file_sizeurl
transformsmetar   Nr    r!   r"   r#   r   r   r   _COMMON_METACOCO_WITH_VOC_LABELS_V1DEFAULTr%   r   r&   r'   r   r   <   sU    %P/SA

"h) !%, !
" &Gr&   r   c                   P    \ rS rSr\" S\" \SS90 \ESSSSS	S
.0SSS.ES9r\r	Sr
g)r   Q   zChttps://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pthrD   rE   ij<zWhttps://github.com/pytorch/vision/tree/main/references/segmentation#deeplabv3_resnet101rG   gO@gV@rH   gV-m@gni@rK   rQ   r   NrU   r   r&   r'   r   r   Q   sU    %Q/SA

"o) !%, !
" &Gr&   r   backbonenum_classesauxr-   c                     SS0nU(       a  SUS'   [        XS9n U(       a  [        SU5      OS n[        SU5      n[        XU5      $ )Nlayer4outr]   layer3)return_layersi   i   )r   r)   r   )r[   r\   r]   rb   aux_classifier
classifiers         r'   _fcn_resnetre   f   sN    
 u%M
"'h&xMH36WT;/DN{+Jx^44r&   
pretrainedpretrained_backbone)weightsweights_backboneNT)rh   progressr\   aux_lossri   rh   rj   rk   ri   kwargsc                 F   [         R                  U 5      n [        R                  " U5      nU b3  Sn[        SU[	        U R
                  S   5      5      n[        SUS5      nOUc  Sn[        U/ SQS9n[        XbU5      nU b  UR                  U R                  USS	95        U$ )
a  Fully-Convolutional Network model with a ResNet-50 backbone from the `Fully Convolutional
Networks for Semantic Segmentation <https://arxiv.org/abs/1411.4038>`_ paper.

.. betastatus:: segmentation module

Args:
    weights (:class:`~torchvision.models.segmentation.FCN_ResNet50_Weights`, optional): The
        pretrained weights to use. See
        :class:`~torchvision.models.segmentation.FCN_ResNet50_Weights` below for
        more details, and possible values. By default, no pre-trained
        weights are used.
    progress (bool, optional): 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).
    aux_loss (bool, optional): If True, it uses an auxiliary loss.
    weights_backbone (:class:`~torchvision.models.ResNet50_Weights`, optional): The pretrained
        weights for the backbone.
    **kwargs: parameters passed to the ``torchvision.models.segmentation.fcn.FCN``
        base class. Please refer to the `source code
        <https://github.com/pytorch/vision/blob/main/torchvision/models/segmentation/fcn.py>`_
        for more details about this class.

.. autoclass:: torchvision.models.segmentation.FCN_ResNet50_Weights
    :members:
Nr\   r?   rk   T   FTTrh   replace_stride_with_dilationrj   
check_hash)
r   verifyr   r   lenrT   r   re   load_state_dictget_state_dictrh   rj   r\   rk   ri   rl   r[   models           r'   r   r   u   s    P #))'2G'../?@+M;GLLYeLfHgh(XtD		 0ObcHx8Eg44hSW4XYLr&   c                 F   [         R                  U 5      n [        R                  " U5      nU b3  Sn[        SU[	        U R
                  S   5      5      n[        SUS5      nOUc  Sn[        U/ SQS9n[        XbU5      nU b  UR                  U R                  USS	95        U$ )
a  Fully-Convolutional Network model with a ResNet-101 backbone from the `Fully Convolutional
Networks for Semantic Segmentation <https://arxiv.org/abs/1411.4038>`_ paper.

.. betastatus:: segmentation module

Args:
    weights (:class:`~torchvision.models.segmentation.FCN_ResNet101_Weights`, optional): The
        pretrained weights to use. See
        :class:`~torchvision.models.segmentation.FCN_ResNet101_Weights` below for
        more details, and possible values. By default, no pre-trained
        weights are used.
    progress (bool, optional): 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).
    aux_loss (bool, optional): If True, it uses an auxiliary loss.
    weights_backbone (:class:`~torchvision.models.ResNet101_Weights`, optional): The pretrained
        weights for the backbone.
    **kwargs: parameters passed to the ``torchvision.models.segmentation.fcn.FCN``
        base class. Please refer to the `source code
        <https://github.com/pytorch/vision/blob/main/torchvision/models/segmentation/fcn.py>`_
        for more details about this class.

.. autoclass:: torchvision.models.segmentation.FCN_ResNet101_Weights
    :members:
Nr\   r?   rk   Trn   ro   rp   rr   )
r   rt   r   r   ru   rT   r   re   rv   rw   rx   s           r'   r   r      s    P $**73G(//0@A+M;GLLYeLfHgh(XtD		!1PcdHx8Eg44hSW4XYLr&   )(	functoolsr   typingr   r   torchr   transforms._presetsr   _apir
   r   r   _metar   _utilsr   r   r   resnetr   r   r   r   r   r   __all__r   
Sequentialr)   rV   r   r   r=   boolre   rW   IMAGENET1K_V1r   r   r   r&   r'   <module>r      s
       7 7 7 # \ \ U U , d	
" 	&"bmm " "&; &*&K &*555 
$5 		5 /GGH+-=-K-KL /3!%#3C3Q3Q3*+3 3 #	3
 tn3 /03 3 	3	 
3l 0HHI+->-L-LM 04!%#4E4S4S3+,3 3 #	3
 tn3 013 3 	3	 
3r&   