Skip to content

Commit 54bd4bd

Browse files
authored
[Enhancement] Add codespell pre-commit hook and fix typos (open-mmlab#920)
* add codespell pre-commit hook and fix typos * Update mmseg/models/decode_heads/dpt_head.py * Update mmseg/models/backbones/vit.py * Update mmseg/models/backbones/vit.py * fix typos * skip formating typo * deprecate formating * skip ipynb * unstage ipynb changes * unstage ipynb changes * fix typos in ipynb * unstage ipynb changes
1 parent d4d64eb commit 54bd4bd

File tree

23 files changed

+352
-333
lines changed

23 files changed

+352
-333
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ blank_issues_enabled: false
33
contact_links:
44
- name: MMSegmentation Documentation
55
url: https://mmsegmentation.readthedocs.io
6-
about: Check the docs and FAQ to see if you question is already anwsered.
6+
about: Check the docs and FAQ to see if you question is already answered.

.github/ISSUE_TEMPLATE/error-report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ A clear and concise description of what the bug is.
3030
3131
**Environment**
3232
33-
1. Please run `python mmseg/utils/collect_env.py` to collect necessary environment infomation and paste it here.
33+
1. Please run `python mmseg/utils/collect_env.py` to collect necessary environment information and paste it here.
3434
2. You may add addition that may be helpful for locating the problem, such as
3535
- How you installed PyTorch [e.g., pip, conda, source]
3636
- Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ repos:
3434
hooks:
3535
- id: markdownlint
3636
args: ["-r", "~MD002,~MD013,~MD029,~MD033,~MD034,~MD036"]
37+
- repo: https://github.com/codespell-project/codespell
38+
rev: v2.1.0
39+
hooks:
40+
- id: codespell
3741
- repo: https://github.com/myint/docformatter
3842
rev: v1.3.1
3943
hooks:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Please refer to [get_started.md](docs/get_started.md#installation) for installat
124124

125125
Please see [train.md](docs/train.md) and [inference.md](docs/inference.md) for the basic usage of MMSegmentation.
126126
There are also tutorials for [customizing dataset](docs/tutorials/customize_datasets.md), [designing data pipeline](docs/tutorials/data_pipeline.md), [customizing modules](docs/tutorials/customize_models.md), and [customizing runtime](docs/tutorials/customize_runtime.md).
127-
We also provide many [training tricks](docs/tutorials/training_tricks.md) for better training and [usefule tools](docs/useful_tools.md) for deployment.
127+
We also provide many [training tricks](docs/tutorials/training_tricks.md) for better training and [useful tools](docs/useful_tools.md) for deployment.
128128

129129
A Colab tutorial is also provided. You may preview the notebook [here](demo/MMSegmentation_Tutorial.ipynb) or directly [run](https://colab.research.google.com/github/open-mmlab/mmsegmentation/blob/master/demo/MMSegmentation_Tutorial.ipynb) on Colab.
130130

docs/tutorials/config.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ model = dict(
6767
channels=512, # The intermediate channels of decode head.
6868
pool_scales=(1, 2, 3, 6), # The avg pooling scales of PSPHead. Please refer to paper for details.
6969
dropout_ratio=0.1, # The dropout ratio before final classification layer.
70-
num_classes=19, # Number of segmentation classs. Usually 19 for cityscapes, 21 for VOC, 150 for ADE20k.
70+
num_classes=19, # Number of segmentation class. Usually 19 for cityscapes, 21 for VOC, 150 for ADE20k.
7171
norm_cfg=dict(type='SyncBN', requires_grad=True), # The configuration of norm layer.
7272
align_corners=False, # The align_corners argument for resize in decoding.
7373
loss_decode=dict( # Config of loss function for the decode_head.
@@ -82,7 +82,7 @@ model = dict(
8282
num_convs=1, # Number of convs in FCNHead. It is usually 1 in auxiliary head.
8383
concat_input=False, # Whether concat output of convs with input before classification layer.
8484
dropout_ratio=0.1, # The dropout ratio before final classification layer.
85-
num_classes=19, # Number of segmentation classs. Usually 19 for cityscapes, 21 for VOC, 150 for ADE20k.
85+
num_classes=19, # Number of segmentation class. Usually 19 for cityscapes, 21 for VOC, 150 for ADE20k.
8686
norm_cfg=dict(type='SyncBN', requires_grad=True), # The configuration of norm layer.
8787
align_corners=False, # The align_corners argument for resize in decoding.
8888
loss_decode=dict( # Config of loss function for the decode_head.
@@ -132,7 +132,7 @@ test_pipeline = [
132132
flip=False, # Whether to flip images during testing
133133
transforms=[
134134
dict(type='Resize', # Use resize augmentation
135-
keep_ratio=True), # Whether to keep the ratio between height and width, the img_scale set here will be supressed by the img_scale set above.
135+
keep_ratio=True), # Whether to keep the ratio between height and width, the img_scale set here will be suppressed by the img_scale set above.
136136
dict(type='RandomFlip'), # Thought RandomFlip is added in pipeline, it is not used when flip=False
137137
dict(
138138
type='Normalize', # Normalization config, the values are from img_norm_cfg
@@ -245,7 +245,7 @@ runner = dict(
245245
checkpoint_config = dict( # Config to set the checkpoint hook, Refer to https://github.com/open-mmlab/mmcv/blob/master/mmcv/runner/hooks/checkpoint.py for implementation.
246246
by_epoch=False, # Whether count by epoch or not.
247247
interval=4000) # The save interval.
248-
evaluation = dict( # The config to build the evaluation hook. Please refer to mmseg/core/evaulation/eval_hook.py for details.
248+
evaluation = dict( # The config to build the evaluation hook. Please refer to mmseg/core/evaluation/eval_hook.py for details.
249249
interval=4000, # The interval of evaluation.
250250
metric='mIoU') # The evaluation metric.
251251

docs/tutorials/customize_runtime.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Tricks not implemented by the optimizer should be implemented through optimizer
113113
_delete_=True, grad_clip=dict(max_norm=35, norm_type=2))
114114
```
115115

116-
If your config inherits the base config which already sets the `optimizer_config`, you might need `_delete_=True` to overide the unnecessary settings. See the [config documenetation](https://mmsegmentation.readthedocs.io/en/latest/config.html) for more details.
116+
If your config inherits the base config which already sets the `optimizer_config`, you might need `_delete_=True` to override the unnecessary settings. See the [config documentation](https://mmsegmentation.readthedocs.io/en/latest/config.html) for more details.
117117

118118
- __Use momentum schedule to accelerate model convergence__:
119119
We support momentum scheduler to modify model's momentum according to learning rate, which could make the model converge in a faster way.
@@ -198,7 +198,7 @@ custom_hooks = [
198198

199199
### Modify default runtime hooks
200200

201-
There are some common hooks that are not registerd through `custom_hooks`, they are
201+
There are some common hooks that are not registered through `custom_hooks`, they are
202202

203203
- log_config
204204
- checkpoint_config

docs_zh-CN/tutorials/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ runner = dict(
241241
checkpoint_config = dict( # 设置检查点钩子 (checkpoint hook) 的配置文件。执行时请参考 https://github.com/open-mmlab/mmcv/blob/master/mmcv/runner/hooks/checkpoint.py。
242242
by_epoch=False, # 是否按照每个 epoch 去算 runner。
243243
interval=4000) # 保存的间隔
244-
evaluation = dict( # 构建评估钩 (evaluation hook) 的配置文件。细节请参考 mmseg/core/evaulation/eval_hook.py。
244+
evaluation = dict( # 构建评估钩 (evaluation hook) 的配置文件。细节请参考 mmseg/core/evaluation/eval_hook.py。
245245
interval=4000, # 评估的间歇点
246246
metric='mIoU') # 评估的指标
247247

mmseg/core/evaluation/metrics.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def f_score(precision, recall, beta=1):
10-
"""calcuate the f-score value.
10+
"""calculate the f-score value.
1111
1212
Args:
1313
precision (float | torch.Tensor): The precision value.
@@ -40,7 +40,7 @@ def intersect_and_union(pred_label,
4040
ignore_index (int): Index that will be ignored in evaluation.
4141
label_map (dict): Mapping old labels to new labels. The parameter will
4242
work only when label is str. Default: dict().
43-
reduce_zero_label (bool): Wether ignore zero label. The parameter will
43+
reduce_zero_label (bool): Whether ignore zero label. The parameter will
4444
work only when label is str. Default: False.
4545
4646
Returns:
@@ -102,7 +102,7 @@ def total_intersect_and_union(results,
102102
num_classes (int): Number of categories.
103103
ignore_index (int): Index that will be ignored in evaluation.
104104
label_map (dict): Mapping old labels to new labels. Default: dict().
105-
reduce_zero_label (bool): Wether ignore zero label. Default: False.
105+
reduce_zero_label (bool): Whether ignore zero label. Default: False.
106106
107107
Returns:
108108
ndarray: The intersection of prediction and ground truth histogram
@@ -148,7 +148,7 @@ def mean_iou(results,
148148
nan_to_num (int, optional): If specified, NaN values will be replaced
149149
by the numbers defined by the user. Default: None.
150150
label_map (dict): Mapping old labels to new labels. Default: dict().
151-
reduce_zero_label (bool): Wether ignore zero label. Default: False.
151+
reduce_zero_label (bool): Whether ignore zero label. Default: False.
152152
153153
Returns:
154154
dict[str, float | ndarray]:
@@ -187,7 +187,7 @@ def mean_dice(results,
187187
nan_to_num (int, optional): If specified, NaN values will be replaced
188188
by the numbers defined by the user. Default: None.
189189
label_map (dict): Mapping old labels to new labels. Default: dict().
190-
reduce_zero_label (bool): Wether ignore zero label. Default: False.
190+
reduce_zero_label (bool): Whether ignore zero label. Default: False.
191191
192192
Returns:
193193
dict[str, float | ndarray]: Default metrics.
@@ -228,7 +228,7 @@ def mean_fscore(results,
228228
nan_to_num (int, optional): If specified, NaN values will be replaced
229229
by the numbers defined by the user. Default: None.
230230
label_map (dict): Mapping old labels to new labels. Default: dict().
231-
reduce_zero_label (bool): Wether ignore zero label. Default: False.
231+
reduce_zero_label (bool): Whether ignore zero label. Default: False.
232232
beta (int): Determines the weight of recall in the combined score.
233233
Default: False.
234234
@@ -274,7 +274,7 @@ def eval_metrics(results,
274274
nan_to_num (int, optional): If specified, NaN values will be replaced
275275
by the numbers defined by the user. Default: None.
276276
label_map (dict): Mapping old labels to new labels. Default: dict().
277-
reduce_zero_label (bool): Wether ignore zero label. Default: False.
277+
reduce_zero_label (bool): Whether ignore zero label. Default: False.
278278
Returns:
279279
float: Overall accuracy on all images.
280280
ndarray: Per category accuracy, shape (num_classes, ).

mmseg/datasets/pipelines/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
from .compose import Compose
3-
from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor,
4-
Transpose, to_tensor)
3+
from .formatting import (Collect, ImageToTensor, ToDataContainer, ToTensor,
4+
Transpose, to_tensor)
55
from .loading import LoadAnnotations, LoadImageFromFile
66
from .test_time_aug import MultiScaleFlipAug
77
from .transforms import (CLAHE, AdjustGamma, Normalize, Pad,

0 commit comments

Comments
 (0)