Skip to content

Commit

Permalink
revamp FCOS doc (#5901)
Browse files Browse the repository at this point in the history
* refactor doc

* refactor code

* add fcos.rst

* add fcos

Co-authored-by: Nicolas Hug <[email protected]>
  • Loading branch information
xiaohu2015 and NicolasHug authored Apr 27, 2022
1 parent 557c5da commit 2214acb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
22 changes: 22 additions & 0 deletions docs/source/models/fcos.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FCOS
=========

.. currentmodule:: torchvision.models.detection

The RetinaNet model is based on the `FCOS: Fully Convolutional One-Stage Object Detection
<https://arxiv.org/abs/1904.01355>`__ paper.

Model builders
--------------

The following model builders can be used to instantiate a FCOS model, with or
without pre-trained weights. All the model buidlers internally rely on the
``torchvision.models.detection.fcos.FCOS`` base class. Please refer to the `source code
<https://github.com/pytorch/vision/blob/main/torchvision/models/detection/fcos.py>`_ for
more details about this class.

.. autosummary::
:toctree: generated/
:template: function.rst

fcos_resnet50_fpn
3 changes: 2 additions & 1 deletion docs/source/models_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ weights:
.. toctree::
:maxdepth: 1

models/retinanet
models/fcos
models/mask_rcnn
models/retinanet

Table of all available detection weights
----------------------------------------
Expand Down
18 changes: 15 additions & 3 deletions torchvision/models/detection/fcos.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def fcos_resnet50_fpn(
"""
Constructs a FCOS model with a ResNet-50-FPN backbone.
Reference: `"FCOS: Fully Convolutional One-Stage Object Detection" <https://arxiv.org/abs/1904.01355>`_.
Reference: `FCOS: Fully Convolutional One-Stage Object Detection <https://arxiv.org/abs/1904.01355>`_.
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.
Expand Down Expand Up @@ -715,13 +715,25 @@ def fcos_resnet50_fpn(
>>> predictions = model(x)
Args:
weights (FCOS_ResNet50_FPN_Weights, optional): The pretrained weights for the model
weights (:class:`~torchvision.models.detection.FCOS_ResNet50_FPN_Weights`, optional): The
pretrained weights to use. See
:class:`~torchvision.models.detection.FCOS_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
num_classes (int, optional): number of output classes of the model (including the background)
weights_backbone (ResNet50_Weights, optional): The pretrained weights for the backbone
weights_backbone (:class:`~torchvision.models.ResNet50_Weights`, optional): The pretrained weights for
the backbone.
trainable_backbone_layers (int, optional): number of trainable (not frozen) resnet 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. Default: None
**kwargs: parameters passed to the ``torchvision.models.detection.FCOS``
base class. Please refer to the `source code
<https://github.com/pytorch/vision/blob/main/torchvision/models/detection/fcos.py>`_
for more details about this class.
.. autoclass:: torchvision.models.detection.FCOS_ResNet50_FPN_Weights
:members:
"""
weights = FCOS_ResNet50_FPN_Weights.verify(weights)
weights_backbone = ResNet50_Weights.verify(weights_backbone)
Expand Down

0 comments on commit 2214acb

Please sign in to comment.