Repository: pytorch/vision

Issue:
 Revamping our semantic segmentation and object detection models docs #5833 
Sister issue (for classification models): https://github.com/pytorch/vision/issues/5833

We're re-writing our models docs to make them clearer, simpler, and to properly document the [upcoming multi-weight API](https://pytorch.org/blog/introducing-torchvision-new-multi-weight-support-api/). This issue is about adding docs for the detection and segmentation models.

Our latest new docs are currently [here](https://output.circle-artifacts.com/output/job/69c86c41-3a9e-4b76-aec0-1fc50c36f5f0/artifacts/0/docs/models_new.html) (this link is likely outdated by the time you look at it, but it doesn't matter; the skeleton is there). We created a separate section that will eventually be merged into the main one. We have documented a few models, but most of them are still missing. The list of models that still need docs is listed below. If you'd like to participate, please comment below with a message saying "I'm working on XYZ" where XYZ is a model, so that others don't pick the same as you do. To keep things simple, please submit one PR per model, but feel free to contribute more than one model.

### How to write docs for a model

Note: below are detailed instructions. This makes it look more complicated than it actually is. Don't be scared!

A great place to start is to look a the changes in [this PR that documents SqueezeNet](https://github.com/pytorch/vision/pull/5832/files). You'll need to do exactly the same for your model:

- Create a new `.rst` file in https://github.com/pytorch/vision/tree/main/docs/source/models. The file should [look like this](https://raw.githubusercontent.com/pytorch/vision/main/docs/source/models/squeezenet.rst), with a link to the original paper, and a list of the corresponding model builders. It should also mention the base model class and link to the `.py` file where it is defined.
- Update the models list in https://github.com/pytorch/vision/blame/main/docs/source/models_new.rst to link to this new file (without the `.rst` suffix). Please keep the list alphabetically sorted
- Update the docstring of each new model builder, similarly to [this one](https://github.com/pytorch/vision/blob/e8cb0bacd86c49e67a7e1a5f83c6da866bc451cf/torchvision/models/squeezenet.py#L162-L182).
    - there is a 1:1 mapping between a model builder and a Weight enum. For example, the docstring of [squeezenet1_0](https://github.com/pytorch/vision/blob/e8cb0bacd86c49e67a7e1a5f83c6da866bc451cf/torchvision/models/squeezenet.py#L159) makes direct references to [SqueezeNet1_0_Weights](https://github.com/pytorch/vision/blob/e8cb0bacd86c49e67a7e1a5f83c6da866bc451cf/torchvision/models/squeezenet.py#L128).
    - don't forget the [autoclass](https://github.com/pytorch/vision/blob/e8cb0bacd86c49e67a7e1a5f83c6da866bc451cf/torchvision/models/squeezenet.py#L181-L182) directive in the docstring. This will auto-generate documentation for the Weight enums. You don't need to understand how this is done, but if you're curious, it's done [here](https://github.com/pytorch/vision/blob/e8cb0bacd86c49e67a7e1a5f83c6da866bc451cf/docs/source/conf.py#L299).
    - don't forget to document the `**kwargs` parameter. Usually these are passed to the base class, but if they don't do anything, just document them as `**kwargs: unsued.`

To build the docs locally, please look at our [contributing guide](https://github.com/pytorch/vision/blob/main/CONTRIBUTING.md#documentation). You won't need to worry about the gallery example, **so always use `make html-noplot`** instead of `make html` to save time.

Please don't hesitate to ping us if you need any help / guidance or if you have any question!


------

Semantic segmentation:

- [X] FCN with Resnet (101 and 50) -  #5915
- [X] LRASPP - https://github.com/pytorch/vision/pull/5923

Object Detection:

- [X] FCOS -  #5901
- [X] FasterRCNN - https://github.com/pytorch/vision/pull/5918
- [X] MaskRCNN - https://github.com/pytorch/vision/pull/5900
- [X] SSD300 - https://github.com/pytorch/vision/pull/5934
- [X] SSDLite320 - https://github.com/pytorch/vision/pull/5917


Discussion:
I can work on `FasterRCNN`
Happy to take care of `MaskRCNN` 👍 
I can work on FCOS
I can take SSD300
I will take LRASPP 
I'll take FCN & SSDLite to finish this then :)
Thanks a lot everyone! ~`SSD300` is still up for grabs if anyone would like to do it~
@NicolasHug Hi I am doing with SSD. Could you wail till today:)
Oops sorry @puhuk I missed your comment above! Please take your time, no rush :)

Resolving patch:
diff --git a/torchvision/models/detection/ssd.py b/torchvision/models/detection/ssd.py
--- a/torchvision/models/detection/ssd.py
+++ b/torchvision/models/detection/ssd.py
@@ -578,9 +578,8 @@ def ssd300_vgg16(
     trainable_backbone_layers: Optional[int] = None,
     **kwargs: Any,
 ) -> SSD:
-    """Constructs an SSD model with input size 300x300 and a VGG16 backbone.
-
-    Reference: `"SSD: Single Shot MultiBox Detector" <https://arxiv.org/abs/1512.02325>`_.
+    """The SSD300 model is based on the `SSD: Single Shot MultiBox Detector
+    <https://arxiv.org/abs/1512.02325>`_ paper.
 
     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 but they will be resized
@@ -615,13 +614,26 @@ def ssd300_vgg16(
         >>> predictions = model(x)
 
     Args:
-        weights (SSD300_VGG16_Weights, optional): The pretrained weights for the model
-        progress (bool): If True, displays a progress bar of the download to stderr
+        weights (:class:`~torchvision.models.detection.SSD300_VGG16_Weights`, optional): The pretrained
+                weights to use. See
+                :class:`~torchvision.models.detection.SSD300_VGG16_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)
-        weights_backbone (VGG16_Weights, optional): The pretrained weights for the backbone
+        weights_backbone (:class:`~torchvision.models.VGG16_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 4.
+        **kwargs: parameters passed to the ``torchvision.models.detection.SSD``
+            base class. Please refer to the `source code
+            <https://github.com/pytorch/vision/blob/main/torchvision/models/detection/ssd.py>`_
+            for more details about this class.
+
+    .. autoclass:: torchvision.models.detection.SSD300_VGG16_Weights
+        :members:
     """
     weights = SSD300_VGG16_Weights.verify(weights)
     weights_backbone = VGG16_Weights.verify(weights_backbone)


Test patch: