From 0e2dee0ac98da20bb07907b20aa61a94cc9fc5a2 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Thu, 28 Oct 2021 16:54:48 +0100 Subject: [PATCH 01/13] Put each transform into its own page --- docs/Makefile | 1 + docs/source/_templates/class.rst | 11 ++ docs/source/_templates/function.rst | 10 ++ docs/source/conf.py | 3 + docs/source/transforms.rst | 221 ++++++++++++++-------------- 5 files changed, 137 insertions(+), 109 deletions(-) create mode 100644 docs/source/_templates/class.rst create mode 100644 docs/source/_templates/function.rst diff --git a/docs/Makefile b/docs/Makefile index 0488c3db88f..fb66cb8c58e 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -32,6 +32,7 @@ clean: rm -rf $(BUILDDIR)/* rm -rf $(SOURCEDIR)/auto_examples/ # sphinx-gallery rm -rf $(SOURCEDIR)/gen_modules/ # sphinx-gallery + rm -rf $(SOURCEDIR)/generated/ # autosummary .PHONY: help Makefile docset diff --git a/docs/source/_templates/class.rst b/docs/source/_templates/class.rst new file mode 100644 index 00000000000..3f9d4f4d062 --- /dev/null +++ b/docs/source/_templates/class.rst @@ -0,0 +1,11 @@ +:mod:`{{module}}`.{{objname}} +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + :members: + +.. raw:: html + +
diff --git a/docs/source/_templates/function.rst b/docs/source/_templates/function.rst new file mode 100644 index 00000000000..e8de75a96ee --- /dev/null +++ b/docs/source/_templates/function.rst @@ -0,0 +1,10 @@ +:mod:`{{module}}`.{{objname}} +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. currentmodule:: {{ module }} + +.. autofunction:: {{ objname }} + +.. raw:: html + +
diff --git a/docs/source/conf.py b/docs/source/conf.py index 4c2f3faec75..70fd85b64c1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -145,6 +145,9 @@ htmlhelp_basename = "PyTorchdoc" +autosummary_generate = True + + # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst index 3d4ba9542ec..dcc31a3c172 100644 --- a/docs/source/transforms.rst +++ b/docs/source/transforms.rst @@ -90,131 +90,101 @@ For any custom transformations to be used with ``torch.jit.script``, they should Compositions of transforms -------------------------- -.. autoclass:: Compose +.. autosummary:: + :nosignatures: + :toctree: generated/ + :template: class.rst + + Compose Transforms on PIL Image and torch.\*Tensor ------------------------------------------ -.. autoclass:: CenterCrop - :members: - -.. autoclass:: ColorJitter - :members: - -.. autoclass:: FiveCrop - :members: - -.. autoclass:: Grayscale - :members: - -.. autoclass:: Pad - :members: - -.. autoclass:: RandomAffine - :members: - -.. autoclass:: RandomApply - -.. autoclass:: RandomCrop - :members: - -.. autoclass:: RandomGrayscale - :members: - -.. autoclass:: RandomHorizontalFlip - :members: - -.. autoclass:: RandomPerspective - :members: - -.. autoclass:: RandomResizedCrop - :members: - -.. autoclass:: RandomRotation - :members: - -.. autoclass:: RandomSizedCrop - :members: - -.. autoclass:: RandomVerticalFlip - :members: - -.. autoclass:: Resize - :members: - -.. autoclass:: Scale - :members: +.. autosummary:: + :nosignatures: + :toctree: generated/ + :template: class.rst + + CenterCrop + ColorJitter + FiveCrop + Grayscale + Pad + RandomAffine + RandomApply + RandomCrop + RandomGrayscale + RandomHorizontalFlip + RandomPerspective + RandomResizedCrop + RandomRotation + RandomSizedCrop + RandomVerticalFlip + Resize + Scale + TenCrop + GaussianBlur + RandomInvert + RandomPosterize + RandomSolarize + RandomAdjustSharpness + RandomAutocontrast + RandomEqualize -.. autoclass:: TenCrop - :members: - -.. autoclass:: GaussianBlur - :members: - -.. autoclass:: RandomInvert - :members: - -.. autoclass:: RandomPosterize - :members: - -.. autoclass:: RandomSolarize - :members: - -.. autoclass:: RandomAdjustSharpness - :members: - -.. autoclass:: RandomAutocontrast - :members: - -.. autoclass:: RandomEqualize - :members: .. _transforms_pil_only: Transforms on PIL Image only ---------------------------- -.. autoclass:: RandomChoice +.. autosummary:: + :nosignatures: + :toctree: generated/ + :template: class.rst -.. autoclass:: RandomOrder + RandomChoice + RandomOrder .. _transforms_tensor_only: Transforms on torch.\*Tensor only --------------------------------- -.. autoclass:: LinearTransformation - :members: - -.. autoclass:: Normalize - :members: +.. autosummary:: + :nosignatures: + :toctree: generated/ + :template: class.rst -.. autoclass:: RandomErasing - :members: - -.. autoclass:: ConvertImageDtype + LinearTransformation + Normalize + RandomErasing + ConvertImageDtype .. _conversion_transforms: Conversion Transforms --------------------- -.. autoclass:: ToPILImage - :members: - -.. autoclass:: ToTensor - :members: +.. autosummary:: + :nosignatures: + :toctree: generated/ + :template: class.rst -.. autoclass:: PILToTensor - :members: + ToPILImage + ToTensor + PILToTensor Generic Transforms ------------------ -.. autoclass:: Lambda - :members: +.. autosummary:: + :nosignatures: + :toctree: generated/ + :template: class.rst + + Lambda Automatic Augmentation Transforms @@ -226,27 +196,23 @@ ImageNet policies provide significant improvements when applied to other dataset In TorchVision we implemented 3 policies learned on the following datasets: ImageNet, CIFAR10 and SVHN. The new transform can be used standalone or mixed-and-matched with existing transforms: -.. autoclass:: AutoAugmentPolicy - :members: - -.. autoclass:: AutoAugment - :members: +.. autosummary:: + :nosignatures: + :toctree: generated/ + :template: class.rst -`RandAugment `_ is a simple high-performing Data Augmentation technique which improves the accuracy of Image Classification models. - -.. autoclass:: RandAugment - :members: - -`TrivialAugmentWide `_ is a dataset-independent data-augmentation technique which improves the accuracy of Image Classification models. - -.. autoclass:: TrivialAugmentWide - :members: + AutoAugmentPolicy + AutoAugment + RandAugment + TrivialAugmentWide .. _functional_transforms: Functional Transforms --------------------- +.. currentmodule:: torchvision.transforms.functional + Functional transforms give you fine-grained control of the transformation pipeline. As opposed to the transformations above, functional transforms don't contain a random number generator for their parameters. @@ -291,5 +257,42 @@ you can use a functional transform to build transform classes with custom behavi rotation_transform = MyRotationTransform(angles=[-30, -15, 0, 15, 30]) -.. automodule:: torchvision.transforms.functional - :members: +.. autosummary:: + :nosignatures: + :toctree: generated/ + :template: function.rst + + adjust_brightness + adjust_contrast + adjust_gamma + adjust_hue + adjust_saturation + adjust_sharpness + affine + autocontrast + center_crop + convert_image_dtype + crop + equalize + erase + five_crop + gaussian_blur + get_image_num_channels + get_image_size + hflip + invert + normalize + pad + perspective + pil_to_tensor + posterize + resize + resized_crop + rgb_to_grayscale + rotate + solarize + ten_crop + to_grayscale + to_pil_image + to_tensor + vflip From f9d1548a60d603f6327d4e342b3bfcea9f37207b Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 17:23:27 +0100 Subject: [PATCH 02/13] Fix rendering issue --- .gitignore | 1 + docs/source/_templates/class.rst | 12 +++++------- docs/source/_templates/function.rst | 10 ++++------ docs/source/docutils.conf | 2 ++ docs/source/transforms.rst | 9 --------- 5 files changed, 12 insertions(+), 22 deletions(-) create mode 100644 docs/source/docutils.conf diff --git a/.gitignore b/.gitignore index 0f82f69402b..d3ba0e7a8f9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ docs/build # sphinx-gallery docs/source/auto_examples/ docs/source/gen_modules/ +docs/source/generated/ # pytorch-sphinx-theme gets installed here docs/src diff --git a/docs/source/_templates/class.rst b/docs/source/_templates/class.rst index 3f9d4f4d062..eeb823a961f 100644 --- a/docs/source/_templates/class.rst +++ b/docs/source/_templates/class.rst @@ -1,11 +1,9 @@ -:mod:`{{module}}`.{{objname}} -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - +.. role:: hidden + :class: hidden-section .. currentmodule:: {{ module }} -.. autoclass:: {{ objname }} - :members: -.. raw:: html +{{ name | underline}} -
+.. autoclass:: {{ name }} + :members: diff --git a/docs/source/_templates/function.rst b/docs/source/_templates/function.rst index e8de75a96ee..72abc4f50fe 100644 --- a/docs/source/_templates/function.rst +++ b/docs/source/_templates/function.rst @@ -1,10 +1,8 @@ -:mod:`{{module}}`.{{objname}} -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - +.. role:: hidden + :class: hidden-section .. currentmodule:: {{ module }} -.. autofunction:: {{ objname }} -.. raw:: html +{{ name | underline}} -
+.. autofunction:: {{ name }} diff --git a/docs/source/docutils.conf b/docs/source/docutils.conf new file mode 100644 index 00000000000..00b6db82694 --- /dev/null +++ b/docs/source/docutils.conf @@ -0,0 +1,2 @@ +[html writers] +table_style: colwidths-auto # Necessary for the table generated by autosummary to look decent diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst index dcc31a3c172..143e02dfe6e 100644 --- a/docs/source/transforms.rst +++ b/docs/source/transforms.rst @@ -91,7 +91,6 @@ Compositions of transforms -------------------------- .. autosummary:: - :nosignatures: :toctree: generated/ :template: class.rst @@ -102,7 +101,6 @@ Transforms on PIL Image and torch.\*Tensor ------------------------------------------ .. autosummary:: - :nosignatures: :toctree: generated/ :template: class.rst @@ -122,7 +120,6 @@ Transforms on PIL Image and torch.\*Tensor RandomSizedCrop RandomVerticalFlip Resize - Scale TenCrop GaussianBlur RandomInvert @@ -139,7 +136,6 @@ Transforms on PIL Image only ---------------------------- .. autosummary:: - :nosignatures: :toctree: generated/ :template: class.rst @@ -152,7 +148,6 @@ Transforms on torch.\*Tensor only --------------------------------- .. autosummary:: - :nosignatures: :toctree: generated/ :template: class.rst @@ -167,7 +162,6 @@ Conversion Transforms --------------------- .. autosummary:: - :nosignatures: :toctree: generated/ :template: class.rst @@ -180,7 +174,6 @@ Generic Transforms ------------------ .. autosummary:: - :nosignatures: :toctree: generated/ :template: class.rst @@ -197,7 +190,6 @@ In TorchVision we implemented 3 policies learned on the following datasets: Imag The new transform can be used standalone or mixed-and-matched with existing transforms: .. autosummary:: - :nosignatures: :toctree: generated/ :template: class.rst @@ -258,7 +250,6 @@ you can use a functional transform to build transform classes with custom behavi .. autosummary:: - :nosignatures: :toctree: generated/ :template: function.rst From e0b31d09778d9bf1ceac606ce3bb5f4d559fc36d Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 18:13:02 +0100 Subject: [PATCH 03/13] Do that for datasets too --- docs/source/_templates/class_dataset.rst | 10 + docs/source/datasets.rst | 309 +++++------------------ torchvision/datasets/coco.py | 4 + 3 files changed, 73 insertions(+), 250 deletions(-) create mode 100644 docs/source/_templates/class_dataset.rst diff --git a/docs/source/_templates/class_dataset.rst b/docs/source/_templates/class_dataset.rst new file mode 100644 index 00000000000..2ced8d94337 --- /dev/null +++ b/docs/source/_templates/class_dataset.rst @@ -0,0 +1,10 @@ +.. role:: hidden + :class: hidden-section +.. currentmodule:: {{ module }} + + +{{ name | underline}} + +.. autoclass:: {{ name }} + :members: __getitem__, category_name + :special-members: diff --git a/docs/source/datasets.rst b/docs/source/datasets.rst index 050622625ec..9643fc3e771 100644 --- a/docs/source/datasets.rst +++ b/docs/source/datasets.rst @@ -19,263 +19,72 @@ All the datasets have almost similar API. They all have two common arguments: ``transform`` and ``target_transform`` to transform the input and target respectively. You can also create your own datasets using the provided :ref:`base classes `. -Caltech -~~~~~~~ - -.. autoclass:: Caltech101 - :members: __getitem__ - :special-members: - -.. autoclass:: Caltech256 - :members: __getitem__ - :special-members: - -CelebA -~~~~~~ - -.. autoclass:: CelebA - :members: __getitem__ - :special-members: - -CIFAR -~~~~~ - -.. autoclass:: CIFAR10 - :members: __getitem__ - :special-members: - -.. autoclass:: CIFAR100 - -Cityscapes -~~~~~~~~~~ - -.. note :: - Requires Cityscape to be downloaded. - -.. autoclass:: Cityscapes - :members: __getitem__ - :special-members: - -COCO -~~~~ - -.. note :: - These require the `COCO API to be installed`_ - -.. _COCO API to be installed: https://github.com/pdollar/coco/tree/master/PythonAPI - - -Captions -^^^^^^^^ - -.. autoclass:: CocoCaptions - :members: __getitem__ - :special-members: - - -Detection -^^^^^^^^^ - -.. autoclass:: CocoDetection - :members: __getitem__ - :special-members: - - -EMNIST -~~~~~~ - -.. autoclass:: EMNIST - -FakeData -~~~~~~~~ - -.. autoclass:: FakeData - -Fashion-MNIST -~~~~~~~~~~~~~ - -.. autoclass:: FashionMNIST - -Flickr -~~~~~~ - -.. autoclass:: Flickr8k - :members: __getitem__ - :special-members: - -.. autoclass:: Flickr30k - :members: __getitem__ - :special-members: - -HMDB51 -~~~~~~~ - -.. autoclass:: HMDB51 - :members: __getitem__ - :special-members: - -ImageNet -~~~~~~~~~~~ - -.. autoclass:: ImageNet - -.. note :: - This requires `scipy` to be installed - -iNaturalist -~~~~~~~~~~~ - -.. autoclass:: INaturalist - :members: __getitem__, category_name - -Kinetics-400 -~~~~~~~~~~~~ - -.. autoclass:: Kinetics400 - :members: __getitem__ - :special-members: - -KITTI -~~~~~~~~~ - -.. autoclass:: Kitti - :members: __getitem__ - :special-members: - -KMNIST -~~~~~~~~~~~~~ - -.. autoclass:: KMNIST - -LFW -~~~~~ - -.. autoclass:: LFWPeople - :members: __getitem__ - :special-members: - -.. autoclass:: LFWPairs - :members: __getitem__ - :special-members: - -LSUN -~~~~ - -.. autoclass:: LSUN - :members: __getitem__ - :special-members: - -MNIST -~~~~~ - -.. autoclass:: MNIST - -Omniglot -~~~~~~~~ - -.. autoclass:: Omniglot - -PhotoTour -~~~~~~~~~ - -.. autoclass:: PhotoTour - :members: __getitem__ - :special-members: - -Places365 -~~~~~~~~~ - -.. autoclass:: Places365 - :members: __getitem__ - :special-members: - -QMNIST -~~~~~~ - -.. autoclass:: QMNIST - -SBD -~~~~~~ - -.. autoclass:: SBDataset - :members: __getitem__ - :special-members: - -SBU -~~~ - -.. autoclass:: SBU - :members: __getitem__ - :special-members: - -SEMEION -~~~~~~~ - -.. autoclass:: SEMEION - :members: __getitem__ - :special-members: - -STL10 -~~~~~ - -.. autoclass:: STL10 - :members: __getitem__ - :special-members: - -SVHN -~~~~~ - -.. autoclass:: SVHN - :members: __getitem__ - :special-members: - -UCF101 -~~~~~~~ - -.. autoclass:: UCF101 - :members: __getitem__ - :special-members: - -USPS -~~~~~ - -.. autoclass:: USPS - :members: __getitem__ - :special-members: - -VOC -~~~~~~ - -.. autoclass:: VOCSegmentation - :members: __getitem__ - :special-members: - -.. autoclass:: VOCDetection - :members: __getitem__ - :special-members: - -WIDERFace -~~~~~~~~~ - -.. autoclass:: WIDERFace - :members: __getitem__ - :special-members: +.. autosummary:: + :toctree: generated/ + :template: class_dataset.rst + + Caltech101 + Caltech256 + CelebA + CIFAR10 + CIFAR100 + Cityscapes + CocoCaptions + CocoDetection + EMNIST + FakeData + FashionMNIST + Flickr8k + Flickr30k + HMDB51 + ImageNet + INaturalist + Kinetics400 + Kitti + KMNIST + LFWPeople + LFWPairs + LSUN + MNIST + Omniglot + PhotoTour + Places365 + QMNIST + SBDataset + SBU + SEMEION + STL10 + SVHN + UCF101 + USPS + VOCSegmentation + VOCDetection + WIDERFace .. _base_classes_datasets: Base classes for custom datasets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autoclass:: DatasetFolder - :members: __getitem__, find_classes, make_dataset - :special-members: +.. autosummary:: + :toctree: generated/ + :template: class.rst + + DatasetFolder + ImageFolder + VisionDataset + + +.. .. autoclass:: DatasetFolder +.. :members: __getitem__, find_classes, make_dataset +.. :special-members: -.. autoclass:: ImageFolder - :members: __getitem__ - :special-members: +.. .. autoclass:: ImageFolder +.. :members: __getitem__ +.. :special-members: -.. autoclass:: VisionDataset - :members: __getitem__ - :special-members: +.. .. autoclass:: VisionDataset +.. :members: __getitem__ +.. :special-members: diff --git a/torchvision/datasets/coco.py b/torchvision/datasets/coco.py index d65aa4dc862..8025cdf67f9 100644 --- a/torchvision/datasets/coco.py +++ b/torchvision/datasets/coco.py @@ -10,6 +10,8 @@ class CocoDetection(VisionDataset): """`MS Coco Detection `_ Dataset. + It requires the `COCO API to be installed `_. + Args: root (string): Root directory where images are downloaded to. annFile (string): Path to json annotation file. @@ -59,6 +61,8 @@ def __len__(self) -> int: class CocoCaptions(CocoDetection): """`MS Coco Captions `_ Dataset. + It requires the `COCO API to be installed `_. + Args: root (string): Root directory where images are downloaded to. annFile (string): Path to json annotation file. From 37a847d12df5c1b5eab68e9251506e8a826e4ebd Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 18:39:36 +0100 Subject: [PATCH 04/13] Fix warning? --- docs/source/_templates/class_dataset.rst | 4 +++- docs/source/datasets.rst | 24 ++++++++---------------- docs/source/transforms.rst | 8 +++++--- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/docs/source/_templates/class_dataset.rst b/docs/source/_templates/class_dataset.rst index 2ced8d94337..96ec6051d7b 100644 --- a/docs/source/_templates/class_dataset.rst +++ b/docs/source/_templates/class_dataset.rst @@ -6,5 +6,7 @@ {{ name | underline}} .. autoclass:: {{ name }} - :members: __getitem__, category_name + :members: + __getitem__ + {% if "category_name" in methods %} , category_name {% endif %} :special-members: diff --git a/docs/source/datasets.rst b/docs/source/datasets.rst index 9643fc3e771..fdf01eb8ffa 100644 --- a/docs/source/datasets.rst +++ b/docs/source/datasets.rst @@ -1,5 +1,11 @@ -torchvision.datasets -==================== +Datasets +======== + +Torchvision provides many built-in datasets in the ``torchvision.datasets`` +module, as well as utility classes for building your own datasets. + +Built-in datasets +~~~~~~~~~~~~~~~~~ All datasets are subclasses of :class:`torch.utils.data.Dataset` i.e, they have ``__getitem__`` and ``__len__`` methods implemented. @@ -74,17 +80,3 @@ Base classes for custom datasets DatasetFolder ImageFolder VisionDataset - - -.. .. autoclass:: DatasetFolder -.. :members: __getitem__, find_classes, make_dataset -.. :special-members: - - -.. .. autoclass:: ImageFolder -.. :members: __getitem__ -.. :special-members: - -.. .. autoclass:: VisionDataset -.. :members: __getitem__ -.. :special-members: diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst index 143e02dfe6e..235f3949f93 100644 --- a/docs/source/transforms.rst +++ b/docs/source/transforms.rst @@ -1,11 +1,13 @@ .. _transforms: -torchvision.transforms -====================== +Transforms +========== .. currentmodule:: torchvision.transforms -Transforms are common image transformations. They can be chained together using :class:`Compose`. +Transforms are common image transformations available in the +``torchvision.transforms`` module. They can be chained together using +:class:`Compose`. Most transform classes have a function equivalent: :ref:`functional transforms ` give fine-grained control over the transformations. From 2137b8aad7f52500ef2497b06bc53365fbc8ac6e Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 23:23:28 +0100 Subject: [PATCH 05/13] Done feature extraction --- docs/source/feature_extraction.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/source/feature_extraction.rst b/docs/source/feature_extraction.rst index f41b5c6127d..e83bc2fe4bc 100644 --- a/docs/source/feature_extraction.rst +++ b/docs/source/feature_extraction.rst @@ -1,9 +1,10 @@ -torchvision.models.feature_extraction -===================================== +Feature extraction for model inspection +======================================= .. currentmodule:: torchvision.models.feature_extraction -Feature extraction utilities let us tap into our models to access intermediate +The ``torchvision.models.feature_extraction`` package contains +feature extraction utilities that let us tap into our models to access intermediate transformations of our inputs. This could be useful for a variety of applications in computer vision. Just a few examples are: @@ -157,6 +158,9 @@ Here is an example of how we might extract features for MaskRCNN: API Reference ------------- -.. autofunction:: create_feature_extractor +.. autosummary:: + :toctree: generated/ + :template: function.rst -.. autofunction:: get_graph_node_names + create_feature_extractor + get_graph_node_names From 6af38ffbd6950db4fa19ae985d53833d3d0793d7 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 23:23:47 +0100 Subject: [PATCH 06/13] Done IO --- docs/source/io.rst | 62 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/docs/source/io.rst b/docs/source/io.rst index 2e416469d17..c62b519efe6 100644 --- a/docs/source/io.rst +++ b/docs/source/io.rst @@ -1,5 +1,5 @@ -torchvision.io -============== +Reading/Writing images and videos +================================= .. currentmodule:: torchvision.io @@ -10,11 +10,13 @@ images. Video ----- -.. autofunction:: read_video +.. autosummary:: + :toctree: generated/ + :template: function.rst -.. autofunction:: read_video_timestamps - -.. autofunction:: write_video + read_video + read_video_timestamps + write_video Fine-grained video API @@ -24,8 +26,11 @@ In addition to the :mod:`read_video` function, we provide a high-performance lower-level API for more fine-grained control compared to the :mod:`read_video` function. It does all this whilst fully supporting torchscript. -.. autoclass:: VideoReader - :members: __next__, get_metadata, set_current_stream, seek +.. autosummary:: + :toctree: generated/ + :template: class.rst + + VideoReader Example of inspecting a video: @@ -59,24 +64,23 @@ Example of inspecting a video: Image ----- -.. autoclass:: ImageReadMode - -.. autofunction:: read_image - -.. autofunction:: decode_image - -.. autofunction:: encode_jpeg - -.. autofunction:: decode_jpeg - -.. autofunction:: write_jpeg - -.. autofunction:: encode_png - -.. autofunction:: decode_png - -.. autofunction:: write_png - -.. autofunction:: read_file - -.. autofunction:: write_file +.. autosummary:: + :toctree: generated/ + :template: class.rst + + ImageReadMode + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + read_image + decode_image + encode_jpeg + decode_jpeg + write_jpeg + encode_png + decode_png + write_png + read_file + write_file From 9a32f15dbbb8fcdbf9d2cb98ce49fd960bae5567 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 23:24:05 +0100 Subject: [PATCH 07/13] done ops --- docs/source/ops.rst | 61 +++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/docs/source/ops.rst b/docs/source/ops.rst index f4f03bdb298..6b215572900 100644 --- a/docs/source/ops.rst +++ b/docs/source/ops.rst @@ -1,7 +1,7 @@ .. _ops: -torchvision.ops -=============== +Operators +========= .. currentmodule:: torchvision.ops @@ -10,29 +10,36 @@ torchvision.ops .. note:: All operators have native support for TorchScript. +.. autosummary:: + :toctree: generated/ + :template: function.rst -.. autofunction:: batched_nms -.. autofunction:: box_area -.. autofunction:: box_convert -.. autofunction:: box_iou -.. autofunction:: clip_boxes_to_image -.. autofunction:: deform_conv2d -.. autofunction:: generalized_box_iou -.. autofunction:: masks_to_boxes -.. autofunction:: nms -.. autofunction:: ps_roi_align -.. autofunction:: ps_roi_pool -.. autofunction:: remove_small_boxes -.. autofunction:: roi_align -.. autofunction:: roi_pool -.. autofunction:: sigmoid_focal_loss -.. autofunction:: stochastic_depth - -.. autoclass:: RoIAlign -.. autoclass:: PSRoIAlign -.. autoclass:: RoIPool -.. autoclass:: PSRoIPool -.. autoclass:: DeformConv2d -.. autoclass:: MultiScaleRoIAlign -.. autoclass:: FeaturePyramidNetwork -.. autoclass:: StochasticDepth + batched_nms + box_area + box_convert + box_iou + clip_boxes_to_image + deform_conv2d + generalized_box_iou + masks_to_boxes + nms + ps_roi_align + ps_roi_pool + remove_small_boxes + roi_align + roi_pool + sigmoid_focal_loss + stochastic_depth + +.. autosummary:: + :toctree: generated/ + :template: class.rst + + RoIAlign + PSRoIAlign + RoIPool + PSRoIPool + DeformConv2d + MultiScaleRoIAlign + FeaturePyramidNetwork + StochasticDepth From 2c764ae9ccfaab5de0077ca546f54b1f04bce190 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 23:24:18 +0100 Subject: [PATCH 08/13] more transforms --- docs/source/transforms.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst index 235f3949f93..cdb35ddc69a 100644 --- a/docs/source/transforms.rst +++ b/docs/source/transforms.rst @@ -1,7 +1,7 @@ .. _transforms: -Transforms -========== +Transforming and augmenting images +================================== .. currentmodule:: torchvision.transforms From 545c8c531e9b63109bd24b44a5b2b2ad08aacd88 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 23:24:31 +0100 Subject: [PATCH 09/13] done utils --- docs/source/utils.rst | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/source/utils.rst b/docs/source/utils.rst index b0a2d743d4e..651dc49a59a 100644 --- a/docs/source/utils.rst +++ b/docs/source/utils.rst @@ -1,14 +1,18 @@ .. _utils: -torchvision.utils -================= +Utils +===== -.. currentmodule:: torchvision.utils - -.. autofunction:: make_grid +The ``torchvision.utils`` module contains various utilities, mostly :ref:`for +vizualization `. -.. autofunction:: save_image +.. currentmodule:: torchvision.utils -.. autofunction:: draw_bounding_boxes +.. autosummary:: + :toctree: generated/ + :template: function.rst -.. autofunction:: draw_segmentation_masks + draw_bounding_boxes + draw_segmentation_masks + make_grid + save_image From 550c4f1ba46e8c02a305a5653a7d488c85af9724 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 23:24:39 +0100 Subject: [PATCH 10/13] done models --- docs/source/models.rst | 266 +++++++++++++++++++++++++++++------------ 1 file changed, 187 insertions(+), 79 deletions(-) diff --git a/docs/source/models.rst b/docs/source/models.rst index 9d05b509899..0aa9c47a061 100644 --- a/docs/source/models.rst +++ b/docs/source/models.rst @@ -1,10 +1,10 @@ .. _models: -torchvision.models -################## +Models and pre-trained weights +############################## -The models subpackage contains definitions of models for addressing +The ``torchvision.models`` subpackage contains definitions of models for addressing different tasks, including: image classification, pixelwise semantic segmentation, object detection, instance segmentation, person keypoint detection and video classification. @@ -256,48 +256,72 @@ regnet_y_32gf 80.878 95.340 Alexnet ------- -.. autofunction:: alexnet +.. autosummary:: + :toctree: generated/ + :template: function.rst + + alexnet VGG --- -.. autofunction:: vgg11 -.. autofunction:: vgg11_bn -.. autofunction:: vgg13 -.. autofunction:: vgg13_bn -.. autofunction:: vgg16 -.. autofunction:: vgg16_bn -.. autofunction:: vgg19 -.. autofunction:: vgg19_bn +.. autosummary:: + :toctree: generated/ + :template: function.rst + + vgg11 + vgg11_bn + vgg13 + vgg13_bn + vgg16 + vgg16_bn + vgg19 + vgg19_bn ResNet ------ -.. autofunction:: resnet18 -.. autofunction:: resnet34 -.. autofunction:: resnet50 -.. autofunction:: resnet101 -.. autofunction:: resnet152 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + resnet18 + resnet34 + resnet50 + resnet101 + resnet152 SqueezeNet ---------- -.. autofunction:: squeezenet1_0 -.. autofunction:: squeezenet1_1 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + squeezenet1_0 + squeezenet1_1 DenseNet --------- -.. autofunction:: densenet121 -.. autofunction:: densenet169 -.. autofunction:: densenet161 -.. autofunction:: densenet201 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + densenet121 + densenet169 + densenet161 + densenet201 Inception v3 ------------ -.. autofunction:: inception_v3 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + inception_v3 .. note :: This requires `scipy` to be installed @@ -306,7 +330,11 @@ Inception v3 GoogLeNet ------------ -.. autofunction:: googlenet +.. autosummary:: + :toctree: generated/ + :template: function.rst + + googlenet .. note :: This requires `scipy` to be installed @@ -315,71 +343,103 @@ GoogLeNet ShuffleNet v2 ------------- -.. autofunction:: shufflenet_v2_x0_5 -.. autofunction:: shufflenet_v2_x1_0 -.. autofunction:: shufflenet_v2_x1_5 -.. autofunction:: shufflenet_v2_x2_0 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + shufflenet_v2_x0_5 + shufflenet_v2_x1_0 + shufflenet_v2_x1_5 + shufflenet_v2_x2_0 MobileNet v2 ------------- -.. autofunction:: mobilenet_v2 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + mobilenet_v2 MobileNet v3 ------------- -.. autofunction:: mobilenet_v3_large -.. autofunction:: mobilenet_v3_small +.. autosummary:: + :toctree: generated/ + :template: function.rst + + mobilenet_v3_large + mobilenet_v3_small ResNext ------- -.. autofunction:: resnext50_32x4d -.. autofunction:: resnext101_32x8d +.. autosummary:: + :toctree: generated/ + :template: function.rst + + resnext50_32x4d + resnext101_32x8d Wide ResNet ----------- -.. autofunction:: wide_resnet50_2 -.. autofunction:: wide_resnet101_2 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + wide_resnet50_2 + wide_resnet101_2 MNASNet -------- -.. autofunction:: mnasnet0_5 -.. autofunction:: mnasnet0_75 -.. autofunction:: mnasnet1_0 -.. autofunction:: mnasnet1_3 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + mnasnet0_5 + mnasnet0_75 + mnasnet1_0 + mnasnet1_3 EfficientNet ------------ -.. autofunction:: efficientnet_b0 -.. autofunction:: efficientnet_b1 -.. autofunction:: efficientnet_b2 -.. autofunction:: efficientnet_b3 -.. autofunction:: efficientnet_b4 -.. autofunction:: efficientnet_b5 -.. autofunction:: efficientnet_b6 -.. autofunction:: efficientnet_b7 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + efficientnet_b0 + efficientnet_b1 + efficientnet_b2 + efficientnet_b3 + efficientnet_b4 + efficientnet_b5 + efficientnet_b6 + efficientnet_b7 RegNet ------------ -.. autofunction:: regnet_y_400mf -.. autofunction:: regnet_y_800mf -.. autofunction:: regnet_y_1_6gf -.. autofunction:: regnet_y_3_2gf -.. autofunction:: regnet_y_8gf -.. autofunction:: regnet_y_16gf -.. autofunction:: regnet_y_32gf -.. autofunction:: regnet_x_400mf -.. autofunction:: regnet_x_800mf -.. autofunction:: regnet_x_1_6gf -.. autofunction:: regnet_x_3_2gf -.. autofunction:: regnet_x_8gf -.. autofunction:: regnet_x_16gf -.. autofunction:: regnet_x_32gf +.. autosummary:: + :toctree: generated/ + :template: function.rst + + regnet_y_400mf + regnet_y_800mf + regnet_y_1_6gf + regnet_y_3_2gf + regnet_y_8gf + regnet_y_16gf + regnet_y_32gf + regnet_x_400mf + regnet_x_800mf + regnet_x_1_6gf + regnet_x_3_2gf + regnet_x_8gf + regnet_x_16gf + regnet_x_32gf Quantized Models ---------------- @@ -473,22 +533,34 @@ LR-ASPP MobileNetV3-Large 57.9 91.2 Fully Convolutional Networks ---------------------------- -.. autofunction:: torchvision.models.segmentation.fcn_resnet50 -.. autofunction:: torchvision.models.segmentation.fcn_resnet101 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.segmentation.fcn_resnet50 + torchvision.models.segmentation.fcn_resnet101 DeepLabV3 --------- -.. autofunction:: torchvision.models.segmentation.deeplabv3_resnet50 -.. autofunction:: torchvision.models.segmentation.deeplabv3_resnet101 -.. autofunction:: torchvision.models.segmentation.deeplabv3_mobilenet_v3_large +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.segmentation.deeplabv3_resnet50 + torchvision.models.segmentation.deeplabv3_resnet101 + torchvision.models.segmentation.deeplabv3_mobilenet_v3_large LR-ASPP ------- -.. autofunction:: torchvision.models.segmentation.lraspp_mobilenet_v3_large +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.segmentation.lraspp_mobilenet_v3_large .. _object_det_inst_seg_pers_keypoint_det: @@ -615,39 +687,63 @@ Keypoint R-CNN ResNet-50 FPN 0.3789 0.1242 Faster R-CNN ------------ -.. autofunction:: torchvision.models.detection.fasterrcnn_resnet50_fpn -.. autofunction:: torchvision.models.detection.fasterrcnn_mobilenet_v3_large_fpn -.. autofunction:: torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.detection.fasterrcnn_resnet50_fpn + torchvision.models.detection.fasterrcnn_mobilenet_v3_large_fpn + torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn RetinaNet --------- -.. autofunction:: torchvision.models.detection.retinanet_resnet50_fpn +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.detection.retinanet_resnet50_fpn SSD --- -.. autofunction:: torchvision.models.detection.ssd300_vgg16 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.detection.ssd300_vgg16 SSDlite ------- -.. autofunction:: torchvision.models.detection.ssdlite320_mobilenet_v3_large +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.detection.ssdlite320_mobilenet_v3_large Mask R-CNN ---------- -.. autofunction:: torchvision.models.detection.maskrcnn_resnet50_fpn +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.detection.maskrcnn_resnet50_fpn Keypoint R-CNN -------------- -.. autofunction:: torchvision.models.detection.keypointrcnn_resnet50_fpn +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.detection.keypointrcnn_resnet50_fpn Video classification @@ -686,14 +782,26 @@ ResNet (2+1)D 57.50 78.81 ResNet 3D ---------- -.. autofunction:: torchvision.models.video.r3d_18 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.video.r3d_18 ResNet Mixed Convolution ------------------------ -.. autofunction:: torchvision.models.video.mc3_18 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.video.mc3_18 ResNet (2+1)D ------------- -.. autofunction:: torchvision.models.video.r2plus1d_18 +.. autosummary:: + :toctree: generated/ + :template: function.rst + + torchvision.models.video.r2plus1d_18 From 372921949e701a6f4959f80949661379d15c9791 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 23:25:28 +0100 Subject: [PATCH 11/13] Fix some bad docstring --- torchvision/ops/deform_conv.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/torchvision/ops/deform_conv.py b/torchvision/ops/deform_conv.py index f898f66f702..278fb83b397 100644 --- a/torchvision/ops/deform_conv.py +++ b/torchvision/ops/deform_conv.py @@ -160,12 +160,10 @@ def forward(self, input: Tensor, offset: Tensor, mask: Optional[Tensor] = None) """ Args: input (Tensor[batch_size, in_channels, in_height, in_width]): input tensor - offset (Tensor[batch_size, 2 * offset_groups * kernel_height * kernel_width, - out_height, out_width]): offsets to be applied for each position in the - convolution kernel. - mask (Tensor[batch_size, offset_groups * kernel_height * kernel_width, - out_height, out_width]): masks to be applied for each position in the - convolution kernel. + offset (Tensor[batch_size, 2 * offset_groups * kernel_height * kernel_width, out_height, out_width]): + offsets to be applied for each position in the convolution kernel. + mask (Tensor[batch_size, offset_groups * kernel_height * kernel_width, out_height, out_width]): + masks to be applied for each position in the convolution kernel. """ return deform_conv2d( input, From 0c10cedf2b202b5bcd897a6c6c9fdde651fcc43c Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Fri, 29 Oct 2021 23:26:03 +0100 Subject: [PATCH 12/13] Change order of sections in TOC --- docs/source/_templates/class_dataset.rst | 4 ++-- docs/source/index.rst | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/_templates/class_dataset.rst b/docs/source/_templates/class_dataset.rst index 96ec6051d7b..c559c6dc9b0 100644 --- a/docs/source/_templates/class_dataset.rst +++ b/docs/source/_templates/class_dataset.rst @@ -7,6 +7,6 @@ .. autoclass:: {{ name }} :members: - __getitem__ - {% if "category_name" in methods %} , category_name {% endif %} + __getitem__, + {% if "category_name" in methods %} category_name {% endif %} :special-members: diff --git a/docs/source/index.rst b/docs/source/index.rst index d96086704c3..e9f4fdb7a28 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -31,12 +31,12 @@ architectures, and common image transformations for computer vision. :maxdepth: 2 :caption: Package Reference + models + transforms datasets + ops io - models feature_extraction - ops - transforms utils .. toctree:: From bc210dcaf547ebee1ee4eff810a9c56a92705898 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Sun, 31 Oct 2021 11:12:32 +0000 Subject: [PATCH 13/13] Update order --- docs/source/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index e9f4fdb7a28..91b44c155eb 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -31,12 +31,12 @@ architectures, and common image transformations for computer vision. :maxdepth: 2 :caption: Package Reference - models - transforms datasets + transforms + models + feature_extraction ops io - feature_extraction utils .. toctree::