Skip to content

Commit

Permalink
Document undocumented parameters (#3299)
Browse files Browse the repository at this point in the history
* Document undodcumented parameters

* remove setup.cfg changes

* Properly pass normalize down instead of deprecating it

* Fix flake8

* Add new CI check

* Fix type spec

* Leave normalize be part of kwargs

Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
  • Loading branch information
NicolasHug and datumbox authored Jan 29, 2021
1 parent 59df482 commit 6116812
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ jobs:
pip install --user --progress-bar off --editable .
mypy --config-file mypy.ini
docstring_parameters_sync:
docker:
- image: circleci/python:3.7
steps:
- checkout
- run:
command: |
pip install --user pydocstyle
pydocstyle
clang_format:
docker:
- image: circleci/python:3.7
Expand Down Expand Up @@ -1167,6 +1177,7 @@ workflows:
- build_docs
- python_lint
- python_type_check
- docstring_parameters_sync
- clang_format
- torchhub_test
- torch_onnx_test
Expand Down Expand Up @@ -1283,6 +1294,7 @@ workflows:
- circleci_consistency
- python_lint
- python_type_check
- docstring_parameters_sync
- clang_format
- torchhub_test
- torch_onnx_test
Expand Down
12 changes: 12 additions & 0 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ jobs:
pip install --user --progress-bar off --editable .
mypy --config-file mypy.ini

docstring_parameters_sync:
docker:
- image: circleci/python:3.7
steps:
- checkout
- run:
command: |
pip install --user pydocstyle
pydocstyle

clang_format:
docker:
- image: circleci/python:3.7
Expand Down Expand Up @@ -778,6 +788,7 @@ workflows:
{{ build_workflows(windows_latest_only=True) }}
- python_lint
- python_type_check
- docstring_parameters_sync
- clang_format
- torchhub_test
- torch_onnx_test
Expand All @@ -796,6 +807,7 @@ workflows:
- circleci_consistency
- python_lint
- python_type_check
- docstring_parameters_sync
- clang_format
- torchhub_test
- torch_onnx_test
Expand Down
1 change: 1 addition & 0 deletions references/detection/coco_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def loadRes(self, resFile):
"""
Load result file and return a result api object.
Args:
self (obj): coco object with ground truth annotations
resFile (str): file name of result file
Returns:
res (obj): result api object
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ max-line-length = 120
max-line-length = 120
ignore = F401,E402,F403,W503,W504,F821
exclude = venv

[pydocstyle]
select = D417 # Missing argument descriptions in the docstring
1 change: 1 addition & 0 deletions torchvision/datasets/video_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def compute_clips(self, num_frames, step, frame_rate=None):
Args:
num_frames (int): number of frames for the clip
step (int): distance between two clips
frame_rate (int, optional): The frame rate
"""
self.num_frames = num_frames
self.step = step
Expand Down
1 change: 1 addition & 0 deletions torchvision/models/detection/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def encode_boxes(reference_boxes, proposals, weights):
Args:
reference_boxes (Tensor): reference boxes
proposals (Tensor): boxes to be encoded
weights (Tensor[4]): the weights for ``(x, y, w, h)``
"""

# perform some unpacking to make it JIT-fusion friendly
Expand Down
9 changes: 8 additions & 1 deletion torchvision/models/detection/backbone_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,18 @@ def resnet_fpn_backbone(
Args:
backbone_name (string): resnet architecture. Possible values are 'ResNet', 'resnet18', 'resnet34', 'resnet50',
'resnet101', 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', 'wide_resnet50_2', 'wide_resnet101_2'
pretrained (bool): If True, returns a model with backbone pre-trained on Imagenet
norm_layer (torchvision.ops): it is recommended to use the default value. For details visit:
(https://github.com/facebookresearch/maskrcnn-benchmark/issues/267)
pretrained (bool): If True, returns a model with backbone pre-trained on Imagenet
trainable_layers (int): 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.
returned_layers (list of int): The layers of the network to return. Each entry must be in ``[1, 4]``.
By default all layers are returned.
extra_blocks (ExtraFPNBlock or None): if provided, extra operations will
be performed. It is expected to take the fpn features, the original
features and the names of the original features as input, and returns
a new list of feature maps and their corresponding names. By
default a ``LastLevelMaxPool`` is used.
"""
backbone = resnet.__dict__[backbone_name](
pretrained=pretrained,
Expand Down
1 change: 1 addition & 0 deletions torchvision/models/quantization/googlenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def googlenet(pretrained=False, progress=True, quantize=False, **kwargs):
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
aux_logits (bool): If True, adds two auxiliary branches that can improve training.
Default: *False* when pretrained is True otherwise *True*
transform_input (bool): If True, preprocesses the input according to the method with which it
Expand Down
1 change: 1 addition & 0 deletions torchvision/models/quantization/inception.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def inception_v3(pretrained=False, progress=True, quantize=False, **kwargs):
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
aux_logits (bool): If True, add an auxiliary branch that can improve training.
Default: *True*
transform_input (bool): If True, preprocesses the input according to the method with which it
Expand Down
3 changes: 3 additions & 0 deletions torchvision/models/quantization/resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def resnet18(pretrained=False, progress=True, quantize=False, **kwargs):
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
"""
return _resnet('resnet18', QuantizableBasicBlock, [2, 2, 2, 2], pretrained, progress,
quantize, **kwargs)
Expand All @@ -155,6 +156,7 @@ def resnet50(pretrained=False, progress=True, quantize=False, **kwargs):
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
"""
return _resnet('resnet50', QuantizableBottleneck, [3, 4, 6, 3], pretrained, progress,
quantize, **kwargs)
Expand All @@ -167,6 +169,7 @@ def resnext101_32x8d(pretrained=False, progress=True, quantize=False, **kwargs):
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
"""
kwargs['groups'] = 32
kwargs['width_per_group'] = 8
Expand Down
4 changes: 4 additions & 0 deletions torchvision/models/quantization/shufflenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def shufflenet_v2_x0_5(pretrained=False, progress=True, quantize=False, **kwargs
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
"""
return _shufflenetv2('shufflenetv2_x0.5', pretrained, progress, quantize,
[4, 8, 4], [24, 48, 96, 192, 1024], **kwargs)
Expand All @@ -121,6 +122,7 @@ def shufflenet_v2_x1_0(pretrained=False, progress=True, quantize=False, **kwargs
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
"""
return _shufflenetv2('shufflenetv2_x1.0', pretrained, progress, quantize,
[4, 8, 4], [24, 116, 232, 464, 1024], **kwargs)
Expand All @@ -135,6 +137,7 @@ def shufflenet_v2_x1_5(pretrained=False, progress=True, quantize=False, **kwargs
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
"""
return _shufflenetv2('shufflenetv2_x1.5', pretrained, progress, quantize,
[4, 8, 4], [24, 176, 352, 704, 1024], **kwargs)
Expand All @@ -149,6 +152,7 @@ def shufflenet_v2_x2_0(pretrained=False, progress=True, quantize=False, **kwargs
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
progress (bool): If True, displays a progress bar of the download to stderr
quantize (bool): If True, return a quantized version of the model
"""
return _shufflenetv2('shufflenetv2_x2.0', pretrained, progress, quantize,
[4, 8, 4], [24, 244, 488, 976, 2048], **kwargs)
4 changes: 2 additions & 2 deletions torchvision/models/segmentation/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def deeplabv3_resnet101(pretrained=False, progress=True,
pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
contains the same classes as Pascal VOC
progress (bool): If True, displays a progress bar of the download to stderr
num_classes (int): number of output classes of the model (including the background)
aux_loss (bool): If True, it uses an auxiliary loss
num_classes (int): The number of classes
aux_loss (bool): If True, include an auxiliary classifier
"""
return _load_model('deeplabv3', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion torchvision/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def draw_bounding_boxes(
Args:
image (Tensor): Tensor of shape (C x H x W)
bboxes (Tensor): Tensor of size (N, 4) containing bounding boxes in (xmin, ymin, xmax, ymax) format. Note that
boxes (Tensor): Tensor of size (N, 4) containing bounding boxes in (xmin, ymin, xmax, ymax) format. Note that
the boxes are absolute coordinates with respect to the image. In other words: `0 <= xmin < xmax < W` and
`0 <= ymin < ymax < H`.
labels (List[str]): List containing the labels of bounding boxes.
Expand Down

0 comments on commit 6116812

Please sign in to comment.