From b1e25208a8cb89599659e86f5c83cf71236a262f Mon Sep 17 00:00:00 2001 From: FG Fernandez <–26927750+frgfm@users.noreply.github.com> Date: Thu, 28 Apr 2022 14:40:30 +0200 Subject: [PATCH 1/5] docs: Added FCN to new doc --- docs/source/models/fcn.rst | 26 ++++++++++++++++++++++++++ docs/source/models_new.rst | 1 + 2 files changed, 27 insertions(+) create mode 100644 docs/source/models/fcn.rst diff --git a/docs/source/models/fcn.rst b/docs/source/models/fcn.rst new file mode 100644 index 00000000000..276ca30aed5 --- /dev/null +++ b/docs/source/models/fcn.rst @@ -0,0 +1,26 @@ +FCN +=== + +.. currentmodule:: torchvision.models.segmentation + +The FCN model is based on the `Fully Convolutional Networks for Semantic +Segmentation `__ +paper. + + +Model builders +-------------- + +The following model builders can be used to instantiate a FCN model, with or +without pre-trained weights. All the model builders internally rely on the +``torchvision.models.segmentation.fcn.FCN`` base class. Please refer to the `source +code +`_ for +more details about this class. + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + fcn_resnet50 + fcn_resnet101 diff --git a/docs/source/models_new.rst b/docs/source/models_new.rst index b4945938824..23b758c891d 100644 --- a/docs/source/models_new.rst +++ b/docs/source/models_new.rst @@ -73,6 +73,7 @@ pre-trained weights: :maxdepth: 1 models/deeplabv3 + models/fcn Table of all available semantic segmentation weights From 918343876144922714bf7b9bd846a08328a3e952 Mon Sep 17 00:00:00 2001 From: FG Fernandez <–26927750+frgfm@users.noreply.github.com> Date: Thu, 28 Apr 2022 14:40:41 +0200 Subject: [PATCH 2/5] docs: Updated docstring --- torchvision/models/segmentation/fcn.py | 46 +++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/torchvision/models/segmentation/fcn.py b/torchvision/models/segmentation/fcn.py index dddd50ae4b8..628770116c0 100644 --- a/torchvision/models/segmentation/fcn.py +++ b/torchvision/models/segmentation/fcn.py @@ -115,15 +115,26 @@ def fcn_resnet50( weights_backbone: Optional[ResNet50_Weights] = ResNet50_Weights.IMAGENET1K_V1, **kwargs: Any, ) -> FCN: - """Constructs a Fully-Convolutional Network model with a ResNet-50 backbone. + """Fully-Convolutional Network model with a ResNet-50 backbone from the `Fully Convolutional + Networks for Semantic Segmentation `_ paper. Args: - weights (FCN_ResNet50_Weights, optional): The pretrained weights for the model - progress (bool): If True, displays a progress bar of the download to stderr - 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 (ResNet50_Weights, optional): The pretrained weights for the backbone + 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. + **kwargs: parameters passed to the ``torchvision.models.segmentation.fcn.FCN`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.segmentation.FCN_ResNet50_Weights + :members: """ + weights = FCN_ResNet50_Weights.verify(weights) weights_backbone = ResNet50_Weights.verify(weights_backbone) @@ -156,15 +167,26 @@ def fcn_resnet101( weights_backbone: Optional[ResNet101_Weights] = ResNet101_Weights.IMAGENET1K_V1, **kwargs: Any, ) -> FCN: - """Constructs a Fully-Convolutional Network model with a ResNet-101 backbone. + """Fully-Convolutional Network model with a ResNet-101 backbone from the `Fully Convolutional + Networks for Semantic Segmentation `_ paper. Args: - weights (FCN_ResNet101_Weights, optional): The pretrained weights for the model - progress (bool): If True, displays a progress bar of the download to stderr - 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 (ResNet101_Weights, optional): The pretrained weights for the backbone + 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. + **kwargs: parameters passed to the ``torchvision.models.segmentation.fcn.FCN`` + base class. Please refer to the `source code + `_ + for more details about this class. + + .. autoclass:: torchvision.models.segmentation.FCN_ResNet101_Weights + :members: """ + weights = FCN_ResNet101_Weights.verify(weights) weights_backbone = ResNet101_Weights.verify(weights_backbone) From 0dcbed451daae26b6414e2c25972dca990485774 Mon Sep 17 00:00:00 2001 From: FG Fernandez <–26927750+frgfm@users.noreply.github.com> Date: Thu, 28 Apr 2022 18:15:47 +0200 Subject: [PATCH 3/5] docs: Fixed docstring --- torchvision/models/segmentation/fcn.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/torchvision/models/segmentation/fcn.py b/torchvision/models/segmentation/fcn.py index 628770116c0..dee78573654 100644 --- a/torchvision/models/segmentation/fcn.py +++ b/torchvision/models/segmentation/fcn.py @@ -126,6 +126,10 @@ def fcn_resnet50( 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 `_ @@ -178,6 +182,10 @@ def fcn_resnet101( 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 `_ From d328f7c1a61b9bd1b74a0c70418fa90de1c19f8e Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 3 May 2022 10:29:17 +0100 Subject: [PATCH 4/5] Update docs/source/models/fcn.rst Co-authored-by: Aditya Oke <47158509+oke-aditya@users.noreply.github.com> --- docs/source/models/fcn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/models/fcn.rst b/docs/source/models/fcn.rst index 276ca30aed5..ae76c50ff1b 100644 --- a/docs/source/models/fcn.rst +++ b/docs/source/models/fcn.rst @@ -13,7 +13,7 @@ Model builders The following model builders can be used to instantiate a FCN model, with or without pre-trained weights. All the model builders internally rely on the -``torchvision.models.segmentation.fcn.FCN`` base class. Please refer to the `source +``torchvision.models.segmentation.FCN`` base class. Please refer to the `source code `_ for more details about this class. From 9934e2d6ade88009689cfae32d10c07572169e00 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 3 May 2022 10:31:14 +0100 Subject: [PATCH 5/5] Apply suggestions from code review --- torchvision/models/segmentation/fcn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torchvision/models/segmentation/fcn.py b/torchvision/models/segmentation/fcn.py index dee78573654..55b60f312d9 100644 --- a/torchvision/models/segmentation/fcn.py +++ b/torchvision/models/segmentation/fcn.py @@ -128,7 +128,7 @@ def fcn_resnet50( 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_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 @@ -184,7 +184,7 @@ def fcn_resnet101( 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_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