From 5d9079cdcd0a091c5af58e8e5b9a4f78cbdb51f5 Mon Sep 17 00:00:00 2001 From: Yassine Alouini Date: Fri, 22 Apr 2022 17:48:36 +0200 Subject: [PATCH 1/3] [FEAT] Add efficientnetv2 doc. --- docs/source/models/efficientnetv2.rst | 26 +++++++++++++++ docs/source/models_new.rst | 1 + torchvision/models/efficientnet.py | 47 +++++++++++++++++++++++---- 3 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 docs/source/models/efficientnetv2.rst diff --git a/docs/source/models/efficientnetv2.rst b/docs/source/models/efficientnetv2.rst new file mode 100644 index 00000000000..a4fe80d538f --- /dev/null +++ b/docs/source/models/efficientnetv2.rst @@ -0,0 +1,26 @@ +EfficientNetV2 +============ + +.. currentmodule:: torchvision.models + +The EfficientNetV2 model is based on the `EfficientNetV2: Smaller Models and Faster Training `__ +paper. + + +Model builders +-------------- + +The following model builders can be used to instanciate an EfficientNetV2 model, with or +without pre-trained weights. All the model builders internally rely on the +``torchvision.models.efficientnet.EfficientNet`` base class. Please refer to the `source +code +`_ for +more details about this class. + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + efficientnet_v2_s + efficientnet_v2_m + efficientnet_v2_l \ No newline at end of file diff --git a/docs/source/models_new.rst b/docs/source/models_new.rst index d512d917d65..17a0741150a 100644 --- a/docs/source/models_new.rst +++ b/docs/source/models_new.rst @@ -36,6 +36,7 @@ weights: .. toctree:: :maxdepth: 1 + models/efficientnetv2 models/regnet models/resnet models/squeezenet diff --git a/torchvision/models/efficientnet.py b/torchvision/models/efficientnet.py index ef7e0c323a4..76c704da071 100644 --- a/torchvision/models/efficientnet.py +++ b/torchvision/models/efficientnet.py @@ -824,8 +824,19 @@ def efficientnet_v2_s( `"EfficientNetV2: Smaller Models and Faster Training" `_. Args: - weights (EfficientNet_V2_S_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.EfficientNet_V2_S_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.EfficientNet_V2_S_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.efficientnet.EfficientNet`` + base class. Please refer to the `source code + `_ + for more details about this class. + .. autoclass:: torchvision.models.EfficientNet_V2_S_Weights + :members: """ weights = EfficientNet_V2_S_Weights.verify(weights) @@ -850,8 +861,19 @@ def efficientnet_v2_m( `"EfficientNetV2: Smaller Models and Faster Training" `_. Args: - weights (EfficientNet_V2_M_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.EfficientNet_V2_M_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.EfficientNet_V2_M_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.efficientnet.EfficientNet`` + base class. Please refer to the `source code + `_ + for more details about this class. + .. autoclass:: torchvision.models.EfficientNet_V2_M_Weights + :members: """ weights = EfficientNet_V2_M_Weights.verify(weights) @@ -873,11 +895,22 @@ def efficientnet_v2_l( ) -> EfficientNet: """ Constructs an EfficientNetV2-L architecture from - `"EfficientNetV2: Smaller Models and Faster Training" `_. + `EfficientNetV2: Smaller Models and Faster Training `_. Args: - weights (EfficientNet_V2_L_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.EfficientNet_V2_L_Weights`, optional): The + pretrained weights to use. See + :class:`~torchvision.models.EfficientNet_V2_L_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.efficientnet.EfficientNet`` + base class. Please refer to the `source code + `_ + for more details about this class. + .. autoclass:: torchvision.models.EfficientNet_V2_L_Weights + :members: """ weights = EfficientNet_V2_L_Weights.verify(weights) From 6ee66c89de8cffb48d39bd92d4e27644b44383ad Mon Sep 17 00:00:00 2001 From: Yassine Alouini Date: Fri, 22 Apr 2022 17:49:31 +0200 Subject: [PATCH 2/3] [FIX] Precommits fix. --- docs/source/models/efficientnetv2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/models/efficientnetv2.rst b/docs/source/models/efficientnetv2.rst index a4fe80d538f..6a545b6e765 100644 --- a/docs/source/models/efficientnetv2.rst +++ b/docs/source/models/efficientnetv2.rst @@ -23,4 +23,4 @@ more details about this class. efficientnet_v2_s efficientnet_v2_m - efficientnet_v2_l \ No newline at end of file + efficientnet_v2_l From 1a8a55a41adf9e74f913b352e7d6fc126733dea1 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Mon, 25 Apr 2022 10:02:50 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- docs/source/models/efficientnetv2.rst | 2 +- torchvision/models/efficientnet.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/models/efficientnetv2.rst b/docs/source/models/efficientnetv2.rst index 6a545b6e765..023b9f58f9b 100644 --- a/docs/source/models/efficientnetv2.rst +++ b/docs/source/models/efficientnetv2.rst @@ -3,7 +3,7 @@ EfficientNetV2 .. currentmodule:: torchvision.models -The EfficientNetV2 model is based on the `EfficientNetV2: Smaller Models and Faster Training `__ +The EfficientNetV2 model is based on the `EfficientNetV2: Smaller Models and Faster Training `__ paper. diff --git a/torchvision/models/efficientnet.py b/torchvision/models/efficientnet.py index 3ae34def8e3..a5ef068fac6 100644 --- a/torchvision/models/efficientnet.py +++ b/torchvision/models/efficientnet.py @@ -845,7 +845,7 @@ def efficientnet_v2_s( ) -> EfficientNet: """ Constructs an EfficientNetV2-S architecture from - `"EfficientNetV2: Smaller Models and Faster Training" `_. + `EfficientNetV2: Smaller Models and Faster Training `_. Args: weights (:class:`~torchvision.models.EfficientNet_V2_S_Weights`, optional): The @@ -882,7 +882,7 @@ def efficientnet_v2_m( ) -> EfficientNet: """ Constructs an EfficientNetV2-M architecture from - `"EfficientNetV2: Smaller Models and Faster Training" `_. + `EfficientNetV2: Smaller Models and Faster Training `_. Args: weights (:class:`~torchvision.models.EfficientNet_V2_M_Weights`, optional): The