Skip to content

Commit 7dc5e5b

Browse files
authored
Fix typos and grammar errors (pytorch#7065)
* fix typos throughout the code base * fix grammar * revert formatting changes to gallery * revert 'an uXX' * remove 'number of the best'
1 parent ed2a0ad commit 7dc5e5b

File tree

103 files changed

+272
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+272
-275
lines changed

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ If you plan to modify the code or documentation, please follow the steps below:
6969
For more details about pull requests,
7070
please read [GitHub's guides](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
7171

72-
If you would like to contribute a new model, please see [here](#New-model).
72+
If you would like to contribute a new model, please see [here](#New-architecture-or-improved-model-weights).
7373

7474
If you would like to contribute a new dataset, please see [here](#New-dataset).
7575

@@ -198,7 +198,7 @@ it in an issue as, most likely, it will not be accepted.
198198
### Pull Request
199199

200200
If all previous checks (flake8, mypy, unit tests) are passing, please send a PR. Submitted PR will pass other tests on
201-
different operation systems, python versions and hardwares.
201+
different operating systems, python versions and hardware.
202202

203203
For more details about pull requests workflow,
204204
please read [GitHub's guides](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).

CONTRIBUTING_MODELS.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ So, before starting any work and submitting a PR there are a few critical things
2020

2121
### 1. Preparation work
2222

23-
- Start by looking into this [issue](https://github.com/pytorch/vision/issues/2707) in order to have an idea of the models that are being considered, express your willingness to add a new model and discuss with the community whether or not this model should be included in TorchVision. It is very important at this stage to make sure that there is an agreement on the value of having this model in TorchVision and there is no one else already working on it.
23+
- Start by looking into this [issue](https://github.com/pytorch/vision/issues/2707) in order to have an idea of the models that are being considered, express your willingness to add a new model and discuss with the community whether this model should be included in TorchVision. It is very important at this stage to make sure that there is an agreement on the value of having this model in TorchVision and there is no one else already working on it.
2424

2525
- If the decision is to include the new model, then please create a new ticket which will be used for all design and implementation discussions prior to the PR. One of the TorchVision maintainers will reach out at this stage and this will be your POC from this point onwards in order to provide support, guidance and regular feedback.
2626

2727
### 2. Implement the model
2828

29-
Please take a look at existing models in TorchVision to get familiar with the idioms. Also please look at recent contributions for new models. If in doubt about any design decisions you can ask for feedback on the issue created in step 1. Example of things to take into account:
29+
Please take a look at existing models in TorchVision to get familiar with the idioms. Also, please look at recent contributions for new models. If in doubt about any design decisions you can ask for feedback on the issue created in step 1. Example of things to take into account:
3030

3131
- The implementation should be as close as possible to the canonical implementation/paper
3232
- The PR must include the code implementation, documentation and tests
3333
- It should also extend the existing reference scripts used to train the model
3434
- The weights need to reproduce closely the results of the paper in terms of accuracy, even though the final weights to be deployed will be those trained by the TorchVision maintainers
3535
- The PR description should include commands/configuration used to train the model, so that the TorchVision maintainers can easily run them to verify the implementation and generate the final model to be released
3636
- Make sure we re-use existing components as much as possible (inheritance)
37-
- New primitives (transforms, losses, etc) can be added if necessary, but the final location will be determined after discussion with the dedicated maintainer
37+
- New primitives (transforms, losses, etc.) can be added if necessary, but the final location will be determined after discussion with the dedicated maintainer
3838
- Please take a look at the detailed [implementation and documentation guidelines](https://github.com/pytorch/vision/issues/5319) for a fine grain list of things not to be missed
3939

4040
### 3. Train the model with reference scripts

docs/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def inject_weight_metadata(app, what, name, obj, options, lines):
331331
]
332332

333333
if obj.__doc__ != "An enumeration.":
334-
# We only show the custom enum doc if it was overriden. The default one from Python is "An enumeration"
334+
# We only show the custom enum doc if it was overridden. The default one from Python is "An enumeration"
335335
lines.append("")
336336
lines.append(obj.__doc__)
337337

docs/source/models/alexnet.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ and is based on `One weird trick for parallelizing convolutional neural networks
1414
Model builders
1515
--------------
1616

17-
The following model builders can be used to instanciate an AlexNet model, with or
17+
The following model builders can be used to instantiate an AlexNet model, with or
1818
without pre-trained weights. All the model builders internally rely on the
1919
``torchvision.models.alexnet.AlexNet`` base class. Please refer to the `source
2020
code

docs/source/models/efficientnet.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ paper.
1010
Model builders
1111
--------------
1212

13-
The following model builders can be used to instanciate an EfficientNet model, with or
13+
The following model builders can be used to instantiate an EfficientNet model, with or
1414
without pre-trained weights. All the model builders internally rely on the
1515
``torchvision.models.efficientnet.EfficientNet`` base class. Please refer to the `source
1616
code

docs/source/models/efficientnetv2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ paper.
1010
Model builders
1111
--------------
1212

13-
The following model builders can be used to instanciate an EfficientNetV2 model, with or
13+
The following model builders can be used to instantiate an EfficientNetV2 model, with or
1414
without pre-trained weights. All the model builders internally rely on the
1515
``torchvision.models.efficientnet.EfficientNet`` base class. Please refer to the `source
1616
code

docs/source/models/googlenet.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ paper.
1010
Model builders
1111
--------------
1212

13-
The following model builders can be used to instanciate a GoogLeNet model, with or
13+
The following model builders can be used to instantiate a GoogLeNet model, with or
1414
without pre-trained weights. All the model builders internally rely on the
1515
``torchvision.models.googlenet.GoogLeNet`` base class. Please refer to the `source
1616
code

docs/source/models/googlenet_quant.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ paper.
1010
Model builders
1111
--------------
1212

13-
The following model builders can be used to instanciate a quantized GoogLeNet
13+
The following model builders can be used to instantiate a quantized GoogLeNet
1414
model, with or without pre-trained weights. All the model builders internally
1515
rely on the ``torchvision.models.quantization.googlenet.QuantizableGoogLeNet``
1616
base class. Please refer to the `source code

docs/source/models/inception.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Computer Vision <https://arxiv.org/abs/1512.00567>`__ paper.
1010
Model builders
1111
--------------
1212

13-
The following model builders can be used to instanciate an InceptionV3 model, with or
13+
The following model builders can be used to instantiate an InceptionV3 model, with or
1414
without pre-trained weights. All the model builders internally rely on the
1515
``torchvision.models.inception.Inception3`` base class. Please refer to the `source
1616
code <https://github.com/pytorch/vision/blob/main/torchvision/models/inception.py>`_ for

docs/source/models/inception_quant.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Computer Vision <https://arxiv.org/abs/1512.00567>`__ paper.
1010
Model builders
1111
--------------
1212

13-
The following model builders can be used to instanciate a quantized Inception
13+
The following model builders can be used to instantiate a quantized Inception
1414
model, with or without pre-trained weights. All the model builders internally
1515
rely on the ``torchvision.models.quantization.inception.QuantizableInception3``
1616
base class. Please refer to the `source code

docs/source/models/mnasnet.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Search for Mobile <https://arxiv.org/pdf/1807.11626.pdf>`__ paper.
1111
Model builders
1212
--------------
1313

14-
The following model builders can be used to instanciate an MNASNet model.
14+
The following model builders can be used to instantiate an MNASNet model.
1515
All the model builders internally rely on the
1616
``torchvision.models.mnasnet.MNASNet`` base class. Please refer to the `source
1717
code

docs/source/models/ssd.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The SSD model is based on the `SSD: Single Shot MultiBox Detector
1212
Model builders
1313
--------------
1414

15-
The following model builders can be used to instanciate a SSD model, with or
15+
The following model builders can be used to instantiate a SSD model, with or
1616
without pre-trained weights. All the model builders internally rely on the
1717
``torchvision.models.detection.SSD`` base class. Please refer to the `source
1818
code

docs/source/utils.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Utils
44
=====
55

66
The ``torchvision.utils`` module contains various utilities, mostly :ref:`for
7-
vizualization <sphx_glr_auto_examples_plot_visualization_utils.py>`.
7+
visualization <sphx_glr_auto_examples_plot_visualization_utils.py>`.
88

99
.. currentmodule:: torchvision.utils
1010

gallery/plot_scripted_tensor_transforms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Prior to v0.8.0, transforms in torchvision have traditionally been PIL-centric
1212
and presented multiple limitations due to that. Now, since v0.8.0, transforms
13-
implementations are Tensor and PIL compatible and we can achieve the following
13+
implementations are Tensor and PIL compatible, and we can achieve the following
1414
new features:
1515
1616
- transform multi-band torch tensor images (with more than 3-4 channels)

gallery/plot_visualization_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def show(imgs):
188188
# We can plot more than one mask per image! Remember that the model returned as
189189
# many masks as there are classes. Let's ask the same query as above, but this
190190
# time for *all* classes, not just the dog class: "For each pixel and each class
191-
# C, is class C the most most likely class?"
191+
# C, is class C the most likely class?"
192192
#
193193
# This one is a bit more involved, so we'll first show how to do it with a
194194
# single image, and then we'll generalize to the batch
@@ -317,7 +317,7 @@ def show(imgs):
317317

318318
#####################################
319319
# The model seems to have properly detected the dog, but it also confused trees
320-
# with people. Looking more closely at the scores will help us plotting more
320+
# with people. Looking more closely at the scores will help us plot more
321321
# relevant masks:
322322

323323
print(dog1_output['scores'])
@@ -343,7 +343,7 @@ def show(imgs):
343343

344344
#####################################
345345
# The two 'people' masks in the first image where not selected because they have
346-
# a lower score than the score threshold. Similarly in the second image, the
346+
# a lower score than the score threshold. Similarly, in the second image, the
347347
# instance with class 15 (which corresponds to 'bench') was not selected.
348348

349349
#####################################

references/classification/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ Here `$MODEL` is one of `googlenet`, `inception_v3`, `resnet18`, `resnet50`, `re
298298

299299
### Quantized ShuffleNet V2
300300

301-
Here are commands that we use to quantized the `shufflenet_v2_x1_5` and `shufflenet_v2_x2_0` models.
301+
Here are commands that we use to quantize the `shufflenet_v2_x1_5` and `shufflenet_v2_x2_0` models.
302302
```
303303
# For shufflenet_v2_x1_5
304304
python train_quantization.py --device='cpu' --post-training-quantize --backend='fbgemm' \

references/classification/train.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,11 @@ def collate_fn(batch):
314314

315315
model_ema = None
316316
if args.model_ema:
317-
# Decay adjustment that aims to keep the decay independent from other hyper-parameters originally proposed at:
317+
# Decay adjustment that aims to keep the decay independent of other hyper-parameters originally proposed at:
318318
# https://github.com/facebookresearch/pycls/blob/f8cd9627/pycls/core/net.py#L123
319319
#
320320
# total_ema_updates = (Dataset_size / n_GPUs) * epochs / (batch_size_per_gpu * EMA_steps)
321-
# We consider constant = Dataset_size for a given dataset/setup and ommit it. Thus:
321+
# We consider constant = Dataset_size for a given dataset/setup and omit it. Thus:
322322
# adjust = 1 / total_ema_updates ~= n_GPUs * batch_size_per_gpu * EMA_steps / epochs
323323
adjust = args.world_size * args.batch_size * args.model_ema_steps / args.epochs
324324
alpha = 1.0 - args.model_ema_decay

references/classification/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ def store_model_weights(model, checkpoint_path, checkpoint_key="model", strict=T
365365
checkpoint_path = os.path.abspath(checkpoint_path)
366366
output_dir = os.path.dirname(checkpoint_path)
367367

368-
# Deep copy to avoid side-effects on the model object.
368+
# Deep copy to avoid side effects on the model object.
369369
model = copy.deepcopy(model)
370370
checkpoint = torch.load(checkpoint_path, map_location="cpu")
371371

372372
# Load the weights to the model to validate that everything works
373-
# and remove unnecessary weights (such as auxiliaries, etc)
373+
# and remove unnecessary weights (such as auxiliaries, etc.)
374374
if checkpoint_key == "model_ema":
375375
del checkpoint[checkpoint_key]["n_averaged"]
376376
torch.nn.modules.utils.consume_prefix_in_state_dict_if_present(checkpoint[checkpoint_key], "module.")

references/depth/stereo/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ A ratio of **88-6-6** was used in order to train a baseline weight set. We provi
1212
Both used 8 A100 GPUs and a batch size of 2 (so effective batch size is 16). The
1313
rest of the hyper-parameters loosely follow the recipe from https://github.com/megvii-research/CREStereo.
1414
The original recipe trains for **300000** updates (or steps) on the dataset mixture. We modify the learning rate
15-
schedule to one that starts decaying the weight much sooner. Throughout experiments we found that this reduces overfitting
16-
during evaluation time and gradient clip help stabilize the loss during a pre-mature learning rate change.
15+
schedule to one that starts decaying the weight much sooner. Throughout the experiments we found that this reduces
16+
overfitting during evaluation time and gradient clip help stabilize the loss during a pre-mature learning rate change.
1717

1818
```
1919
torchrun --nproc_per_node 8 --nnodes 1 train.py \
@@ -31,7 +31,7 @@ torchrun --nproc_per_node 8 --nnodes 1 train.py \
3131
--clip-grad-norm 1.0 \
3232
```
3333

34-
We employ a multi-set fine-tuning stage where we uniformly sample from multiple datasets. Given hat some of these datasets have extremely large images (``2048x2048`` or more) we opt for a very aggresive scale-range ``[0.2 - 0.8]`` such that as much of the original frame composition is captured inside the ``384x512`` crop.
34+
We employ a multi-set fine-tuning stage where we uniformly sample from multiple datasets. Given hat some of these datasets have extremely large images (``2048x2048`` or more) we opt for a very aggressive scale-range ``[0.2 - 0.8]`` such that as much of the original frame composition is captured inside the ``384x512`` crop.
3535

3636
```
3737
torchrun --nproc_per_node 8 --nnodes 1 train.py \
@@ -59,7 +59,7 @@ Evaluating the base weights
5959
torchrun --nproc_per_node 1 --nnodes 1 cascade_evaluation.py --dataset middlebury2014-train --batch-size 1 --dataset-root $dataset_root --model crestereo_base --weights CREStereo_Base_Weights.CRESTEREO_ETH_MBL_V1
6060
```
6161

62-
This should give an **mae of about 1.416** on the train set of `Middlebury2014`. Results may vary slightly depending on the batch size and the number of GPUs. For the most accurate resuts use 1 GPU and `--batch-size 1`. The created log file should look like this, where the first key is the number of cascades and the nested key is the number of recursive iterations:
62+
This should give an **mae of about 1.416** on the train set of `Middlebury2014`. Results may vary slightly depending on the batch size and the number of GPUs. For the most accurate results use 1 GPU and `--batch-size 1`. The created log file should look like this, where the first key is the number of cascades and the nested key is the number of recursive iterations:
6363

6464
```
6565
Dataset: middlebury2014-train @size: [384, 512]:
@@ -135,7 +135,7 @@ Dataset: middlebury2014-train @size: [384, 512]:
135135

136136
# Concerns when training
137137

138-
We encourage users to be aware of the **aspect-ratio** and **disparity scale** they are targetting when doing any sort of training or fine-tuning. The model is highly sensitive to these two factors, as a consequence with naive multi-set fine-tuning one can achieve `0.2 mae` relatively fast. We recommend that users pay close attention to how they **balance dataset sizing** when training such networks.
138+
We encourage users to be aware of the **aspect-ratio** and **disparity scale** they are targeting when doing any sort of training or fine-tuning. The model is highly sensitive to these two factors, as a consequence of naive multi-set fine-tuning one can achieve `0.2 mae` relatively fast. We recommend that users pay close attention to how they **balance dataset sizing** when training such networks.
139139

140140
Ideally, dataset scaling should be trated at an individual level and a thorough **EDA** of the disparity distribution in random crops at the desired training / inference size should be performed prior to any large compute investments.
141141

@@ -146,14 +146,14 @@ We encourage users to be aware of the **aspect-ratio** and **disparity scale** t
146146

147147
![Disparity1](assets/disparity-domain-drift.jpg)
148148

149-
From left to right (`left_image`, `right_image`, `valid_mask`, `valid_mask & ground_truth`, `prediction`). **Darker is further away, lighter is closer**. In the case of `Sintel` which is more closely aligned to the original distribution of `CREStereo` we notice that the model accurately predicts the background scale whereas in the case of `Middlebury2014` it cannot correcly estimate the continous disparity. Notice that the frame composition is similar for both examples. The blue skybox in the `Sintel` scene behaves similarly to the `Middlebury` black background. However, because the `Middlebury` samples comes from an extremly large scene the crop size of `384x512` does not correctly capture the general training distribution.
149+
From left to right (`left_image`, `right_image`, `valid_mask`, `valid_mask & ground_truth`, `prediction`). **Darker is further away, lighter is closer**. In the case of `Sintel` which is more closely aligned to the original distribution of `CREStereo` we notice that the model accurately predicts the background scale whereas in the case of `Middlebury2014` it cannot correctly estimate the continuous disparity. Notice that the frame composition is similar for both examples. The blue skybox in the `Sintel` scene behaves similarly to the `Middlebury` black background. However, because the `Middlebury` samples comes from an extremely large scene the crop size of `384x512` does not correctly capture the general training distribution.
150150

151151

152152

153153

154154
##### Sample B
155155

156-
The top row contains a scene from `Sceneflow` using the `Monkaa` split whilst the bottom row is a scene from `Middlebury`. This sample exhibits the same issues when it comes to **background estimation**. Given the exagerated size of the `Middlebury` samples the model **colapses the smooth background** of the sample to what it considers to be a mean background disparity value.
156+
The top row contains a scene from `Sceneflow` using the `Monkaa` split whilst the bottom row is a scene from `Middlebury`. This sample exhibits the same issues when it comes to **background estimation**. Given the exaggerated size of the `Middlebury` samples the model **colapses the smooth background** of the sample to what it considers to be a mean background disparity value.
157157

158158
![Disparity2](assets/disparity-background-mode-collapse.jpg)
159159

0 commit comments

Comments
 (0)