Add code spell hook to pre-commit and fix typos (#1384)

* Add code-spell hook to pre-commit

* Add code-spell hook to pre-commit and fix typos

* fix setup.cfg
pull/1223/head
Zaida Zhou 2021-10-04 20:13:54 +08:00 committed by GitHub
parent c934605e83
commit f22c9eb4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 64 additions and 57 deletions

View File

@ -35,6 +35,10 @@ repos:
- id: markdownlint
args: ["-r", "~MD002,~MD013,~MD029,~MD033,~MD034",
"-t", "allow_different_nesting"]
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
- repo: https://github.com/myint/docformatter
rev: v1.3.1
hooks:

View File

@ -43,7 +43,7 @@ There are two versions of MMCV:
- **mmcv-full**: comprehensive, with full features and various CUDA ops out of box. It takes longer time to build.
- **mmcv**: lite, without CUDA ops but all other features, similar to mmcv<1.0.0. It is useful when you do not need those CUDA ops.
**Note**: Do not install both versions in the same environment, otherwise you may encounter errors like `ModuleNotFound`. You need to uninstall one before installing the other. `Installing the full verion is highly recommended if CUDA is avaliable`.
**Note**: Do not install both versions in the same environment, otherwise you may encounter errors like `ModuleNotFound`. You need to uninstall one before installing the other. `Installing the full version is highly recommended if CUDA is available`.
a. Install the full version.

View File

@ -73,7 +73,7 @@ pip install $TENSORRT_DIR/onnx_graphsurgeon/onnx_graphsurgeon-0.2.6-py2.py3-none
pip install $TENSORRT_DIR/graphsurgeon/graphsurgeon-0.4.5-py2.py3-none-any.whl
```
For more detailed infomation of installing TensorRT using tar, please refer to [Nvidia' website](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-721/install-guide/index.html#installing-tar).
For more detailed information of installing TensorRT using tar, please refer to [Nvidia' website](https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-721/install-guide/index.html#installing-tar).
#### Build on Linux

View File

@ -189,7 +189,7 @@ pip list
<... omit some lines ...>
```
This should already be done by CUDA installer. If not, or you have multiple version of CUDA tookit installed, set it with
This should already be done by CUDA installer. If not, or you have multiple version of CUDA toolkit installed, set it with
```shell
$env:CUDA_HOME = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2"
@ -202,7 +202,7 @@ pip list
```shell
# Suppose you are using GTX 1080, which is of capability 6.1
$env:TORCH_CUDA_ARCH_LIST="6.1"
# OR build all suppoted arch, will be slow
# OR build all supported arch, will be slow
$env:TORCH_CUDA_ARCH_LIST="3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5"
```

View File

@ -6,7 +6,7 @@ There are two versions of MMCV:
- **mmcv**: lite, without CUDA ops but all other features, similar to mmcv<1.0.0. It is useful when you do not need those CUDA ops.
```{warning}
Do not install both versions in the same environment, otherwise you may encounter errors like `ModuleNotFound`. You need to uninstall one before installing the other. `Installing the full verion is highly recommended if CUDA is avaliable`.
Do not install both versions in the same environment, otherwise you may encounter errors like `ModuleNotFound`. You need to uninstall one before installing the other. `Installing the full version is highly recommended if CUDA is avaliable`.
```
a. Install the full version.

View File

@ -140,7 +140,7 @@ We provide the following initialization methods.
- kaiming_init
Initialize module paramters with the valuse according to the method
Initialize module parameters with the values according to the method
described in [Delving deep into rectifiers: Surpassing human-level
performance on ImageNet classification - He, K. et al. (2015)](https://www.cv-foundation.org/openaccess/content_iccv_2015/papers/He_Delving_Deep_into_ICCV_2015_paper.pdf)
@ -430,7 +430,7 @@ Let us introduce the usage of `initialize` in detail.
# [2., 2., 2.],
# [2., 2., 2.]]]], requires_grad=True)
# inner init_cfg has highter priority
# inner init_cfg has higher priority
model1 = FooConv1d(init_cfg1)
model2 = FooConv2d(init_cfg2)
init_cfg = dict(type='Constant', layer=['Conv1d', 'Conv2d'], val=4., bias=5.)
@ -473,7 +473,7 @@ Let us introduce the usage of `initialize` in detail.
# [2., 2., 2.],
# [2., 2., 2.]]]], requires_grad=True)
# inner init_cfg has highter priority
# inner init_cfg has higher priority
model1 = FooConv1d(init_cfg1)
model2 = FooConv2d(init_cfg2)
init_cfg = dict(type='Constant', layer=['Conv1d', 'Conv2d'], val=4., bias=5.)

View File

@ -92,7 +92,7 @@ We will walk you through the usage of runner with a classification task. The fol
model=...
# initialize optimizer, typically, we set: cfg.optimizer = dict(type='SGD', lr=0.1, momentum=0.9, weight_decay=0.0001)
optimizer = build_optimizer(model, cfg.optimizer)
# intialize the dataloader corresponding to the workflow(train/val)
# initialize the dataloader corresponding to the workflow(train/val)
data_loaders = [
build_dataloader(
ds,
@ -119,7 +119,7 @@ runner = build_runner(
**(3) Register training hooks and customized hooks.**
```python
# register defalt hooks neccesary for traning
# register default hooks necessary for training
runner.register_training_hooks(
# configs of learning rate, it is typically set as:
# lr_config = dict(policy='step', step=[100, 150])

View File

@ -419,7 +419,7 @@ conv = ConvModule(
# [2., 2., 2.],
# [2., 2., 2.]]]], requires_grad=True)
# inner init_cfg has highter priority
# inner init_cfg has higher priority
model1 = FooConv1d(init_cfg1)
model2 = FooConv2d(init_cfg2)
init_cfg = dict(type='Constant', layer=['Conv1d', 'Conv2d'], val=4., bias=5.)
@ -462,7 +462,7 @@ conv = ConvModule(
# [2., 2., 2.],
# [2., 2., 2.]]]], requires_grad=True)
# inner init_cfg has highter priority
# inner init_cfg has higher priority
model1 = FooConv1d(init_cfg1)
model2 = FooConv2d(init_cfg2)
init_cfg = dict(type='Constant', layer=['Conv1d', 'Conv2d'], val=4., bias=5.)

View File

@ -383,7 +383,7 @@ class UniformInit(BaseInit):
@INITIALIZERS.register_module(name='Kaiming')
class KaimingInit(BaseInit):
r"""Initialize module paramters with the valuse according to the method
r"""Initialize module parameters with the values according to the method
described in `Delving deep into rectifiers: Surpassing human-level
performance on ImageNet classification - He, K. et al. (2015).
<https://www.cv-foundation.org/openaccess/content_iccv_2015/

View File

@ -4,7 +4,7 @@ def list_from_file(filename, prefix='', offset=0, max_num=0, encoding='utf-8'):
Args:
filename (str): Filename.
prefix (str): The prefix to be inserted to the begining of each item.
prefix (str): The prefix to be inserted to the beginning of each item.
offset (int): The offset of lines.
max_num (int): The maximum number of lines to be read,
zeros and negatives mean no limitation.

View File

@ -86,7 +86,7 @@ def _convert_input_type_range(img):
It converts the input image to np.float32 type and range of [0, 1].
It is mainly used for pre-processing the input image in colorspace
convertion functions such as rgb2ycbcr and ycbcr2rgb.
conversion functions such as rgb2ycbcr and ycbcr2rgb.
Args:
img (ndarray): The input image. It accepts:
@ -116,7 +116,7 @@ def _convert_output_type_range(img, dst_type):
images will be converted to np.uint8 type with range [0, 255]. If
`dst_type` is np.float32, it converts the image to np.float32 type with
range [0, 1].
It is mainly used for post-processing images in colorspace convertion
It is mainly used for post-processing images in colorspace conversion
functions such as rgb2ycbcr and ycbcr2rgb.
Args:

View File

@ -51,7 +51,7 @@ def _interpolate(name, dim, interpolate_mode):
'Resize',
input,
empty_tensor,
# roi only takes effect whith
# roi only takes effect with
# coordinate_transformation_mode="tf_crop_and_resize"
scales, # scales is not needed since we are sending out_size
output_size,

View File

@ -22,7 +22,7 @@ class BallQuery(Function):
center_xyz (Tensor): (B, npoint, 3) centers of the ball query.
Returns:
Tensor: (B, npoint, nsample) tensor with the indicies of
Tensor: (B, npoint, nsample) tensor with the indices of
the features that form the query balls.
"""
assert center_xyz.is_contiguous()

View File

@ -249,7 +249,7 @@ void GridSampleKernel::Compute(OrtKernelContext *context) {
int64_t ix_nearest = static_cast<int64_t>(std::nearbyint(ix));
int64_t iy_nearest = static_cast<int64_t>(std::nearbyint(iy));
// assign nearest neighor pixel value to output pixel
// assign nearest neighbor pixel value to output pixel
float *out_ptr_NCHW = out_ptr + n * out_sN + h * out_sH + w * out_sW;
const float *inp_ptr_NC = inp_ptr_N;
for (int64_t c = 0; c < C;
@ -284,7 +284,7 @@ void GridSampleKernel::Compute(OrtKernelContext *context) {
++c, out_ptr_NCHW += out_sC, inp_ptr_NC += inp_sC) {
float coefficients[4];
// Interpolate 4 values in the x directon
// Interpolate 4 values in the x direction
for (int64_t i = 0; i < 4; ++i) {
coefficients[i] = cubic_interp1d<float>(
get_value_bounded<float>(inp_ptr_NC, ix_nw - 1, iy_nw - 1 + i,

View File

@ -122,7 +122,7 @@ void CumMax_CumMin_CPU(const T1 *input, T1 *output, T2 *indices,
reversed_dim_cumprod[dim_i + 1] * out_dimensions.data()[dim_i];
}
// do cummax or cummin besed on `Operation` type
// do cummax or cummin based on `Operation` type
tensor_dim_apply3<float, int64_t>(
input, output, indices, dim, ndims, reversed_dim_cumprod,
cummax_cummin_helper<float, int64_t, Operation>);
@ -135,7 +135,7 @@ void MMCVCumMaxKernel::Compute(OrtKernelContext *context) {
const float *input_data =
reinterpret_cast<const float *>(ort_.GetTensorData<float>(input));
// get ouput
// get output
OrtTensorDimensions out_dimensions(ort_, input);
OrtValue *output = ort_.KernelContext_GetOutput(
context, 0, out_dimensions.data(), out_dimensions.size());
@ -164,7 +164,7 @@ void MMCVCumMinKernel::Compute(OrtKernelContext *context) {
const float *input_data =
reinterpret_cast<const float *>(ort_.GetTensorData<float>(input));
// get ouput
// get output
OrtTensorDimensions out_dimensions(ort_, input);
OrtValue *output = ort_.KernelContext_GetOutput(
context, 0, out_dimensions.data(), out_dimensions.size());

View File

@ -25,7 +25,7 @@ std::string get_compiling_cuda_version() {
printCudaStyleVersion(get_cudart_version());
return oss.str();
#else
return std::string("rocm not vailable");
return std::string("rocm not available");
#endif
#else
return std::string("not available");

View File

@ -99,10 +99,10 @@ void modulated_deform_conv_forward(
const int kernel_w_ = weight.size(3);
if (kernel_h_ != kernel_h || kernel_w_ != kernel_w)
AT_ERROR("Input shape and kernel shape wont match: (%d x %d vs %d x %d).",
AT_ERROR("Input shape and kernel shape won't match: (%d x %d vs %d x %d).",
kernel_h_, kernel_w, kernel_h_, kernel_w_);
if (channels != channels_kernel * group)
AT_ERROR("Input shape and kernel channels wont match: (%d vs %d).",
AT_ERROR("Input shape and kernel channels won't match: (%d vs %d).",
channels, channels_kernel * group);
const int height_out =
@ -220,10 +220,10 @@ void modulated_deform_conv_backward(
const int kernel_h_ = weight.size(2);
const int kernel_w_ = weight.size(3);
if (kernel_h_ != kernel_h || kernel_w_ != kernel_w)
AT_ERROR("Input shape and kernel shape wont match: (%d x %d vs %d x %d).",
AT_ERROR("Input shape and kernel shape won't match: (%d x %d vs %d x %d).",
kernel_h_, kernel_w, kernel_h_, kernel_w_);
if (channels != channels_kernel * group)
AT_ERROR("Input shape and kernel channels wont match: (%d vs %d).",
AT_ERROR("Input shape and kernel channels won't match: (%d vs %d).",
channels, channels_kernel * group);
const int height_out =

View File

@ -148,7 +148,7 @@ __global__ void grid_sampler_2d_kernel(
const int n = index / (out_H * out_W);
const int grid_offset = n * grid_sN + h * grid_sH + w * grid_sW;
// get the corresponding input x, y co-ordinates from grid
// get the corresponding input x, y coordinates from grid
scalar_t ix = grid[grid_offset];
scalar_t iy = grid[grid_offset + grid_sCoor];
@ -197,7 +197,7 @@ __global__ void grid_sampler_2d_kernel(
int ix_nearest = static_cast<int>(::round(ix));
int iy_nearest = static_cast<int>(::round(iy));
// assign nearest neighor pixel value to output pixel
// assign nearest neighbor pixel value to output pixel
auto inp_ptr_NC = input + n * inp_sN;
auto out_ptr_NCHW = output + n * out_sN + h * out_sH + w * out_sW;
for (int c = 0; c < C;
@ -249,7 +249,7 @@ __global__ void grid_sampler_3d_kernel(
const int grid_offset =
n * grid_sN + d * grid_sD + h * grid_sH + w * grid_sW;
// get the corresponding input x, y, z co-ordinates from grid
// get the corresponding input x, y, z coordinates from grid
scalar_t ix = grid[grid_offset];
scalar_t iy = grid[grid_offset + grid_sCoor];
scalar_t iz = grid[grid_offset + 2 * grid_sCoor];
@ -367,7 +367,7 @@ __global__ void grid_sampler_3d_kernel(
int iy_nearest = static_cast<int>(::round(iy));
int iz_nearest = static_cast<int>(::round(iz));
// assign nearest neighor pixel value to output pixel
// assign nearest neighbor pixel value to output pixel
auto inp_ptr_NC = input + n * inp_sN;
auto out_ptr_NCDHW =
output + n * out_sN + d * out_sD + h * out_sH + w * out_sW;

View File

@ -144,7 +144,7 @@ size_t get_onnxnms_workspace_size(size_t num_batches, size_t spatial_dimension,
* @param[in] score_threshold threshold of scores
* @param[in] offset box offset, only 0 or 1 is valid
* @param[out] output with shape [output_length, 3], each row contain index
* (batch_id, class_id, boxes_id), filling -1 if result is not vaild.
* (batch_id, class_id, boxes_id), filling -1 if result is not valid.
* @param[in] center_point_box 0 if boxes is [left, top, right, bottom] 1 if
* boxes is [center_x, center_y, width, height]
* @param[in] num_batches batch size of boxes and scores

View File

@ -30,7 +30,7 @@ class MMDataParallel(DataParallel):
def forward(self, *inputs, **kwargs):
"""Override the original forward function.
The main difference lies in the CPU inference where the datas in
The main difference lies in the CPU inference where the data in
:class:`DataContainers` will still be gathered.
"""
if not self.device_ids:

View File

@ -15,7 +15,7 @@ try:
# If PyTorch version >= 1.6.0, torch.cuda.amp.autocast would be imported
# and used; otherwise, auto fp16 will adopt mmcv's implementation.
# Note that when PyTorch >= 1.6.0, we still cast tensor types to fp16
# manually, so the behavior may not be consistant with real amp.
# manually, so the behavior may not be consistent with real amp.
from torch.cuda.amp import autocast
except ImportError:
pass

View File

@ -28,7 +28,7 @@ class MlflowLoggerHook(LoggerHook):
tags (dict of str: str, optional): Tags for the current run.
Default None.
If not None, set tags for the current run.
log_model (bool, optional): Wheter to log an MLflow artifact.
log_model (bool, optional): Whether to log an MLflow artifact.
Default True.
If True, log runner.model as an MLflow artifact
for the current run.

View File

@ -53,7 +53,7 @@ class DefaultOptimizerConstructor:
offset layer in deformable convs, set ``dcn_offset_lr_mult``
to the original ``dcn_offset_lr_mult`` * ``bias_lr_mult``.
2. If the option ``dcn_offset_lr_mult`` is used, the constructor will
apply it to all the DCN layers in the model. So be carefull when
apply it to all the DCN layers in the model. So be careful when
the model contains multiple DCN layers in places other than
backbone.

View File

@ -257,7 +257,7 @@ class Config:
f'Duplicate keys: {duplicate_keys}')
base_cfg_dict.update(c)
# Subtitute base variables from strings to their actual values
# Substitute base variables from strings to their actual values
cfg_dict = Config._substitute_base_vars(cfg_dict, base_var_dict,
base_cfg_dict)

View File

@ -47,7 +47,7 @@ def scandir(dir_path, suffix=None, recursive=False):
directory. Default: False.
Returns:
A generator for all the interested files with relative pathes.
A generator for all the interested files with relative paths.
"""
if isinstance(dir_path, (str, Path)):
dir_path = str(dir_path)

View File

@ -68,7 +68,7 @@ class Registry:
Please refer to
https://mmcv.readthedocs.io/en/latest/understand_mmcv/registry.html for
advanced useage.
advanced usage.
Args:
name (str): Registry name.

View File

@ -33,7 +33,7 @@ def _any(judge_result):
if _any(element):
return True
except TypeError:
# Maybe encouter the case: torch.tensor(True) | torch.tensor(False)
# Maybe encounter the case: torch.tensor(True) | torch.tensor(False)
if judge_result:
return True
return False

View File

@ -17,3 +17,6 @@ known_first_party = mmcv
known_third_party = addict,cv2,m2r,numpy,onnx,onnxruntime,packaging,pytest,pytorch_sphinx_theme,recommonmark,scipy,sphinx,tensorrt,torch,torchvision,yaml,yapf
no_lines_before = STDLIB,LOCALFOLDER
default_section = THIRDPARTY
[codespell]
ignore-words-list = inout,hist

View File

@ -88,7 +88,7 @@ class TestGeometric:
assert resized_img.shape == (
912, 810, 3) and h_scale == 912 / 300 and w_scale == 810 / 400
# one of size and scale_factor shuld be given
# one of size and scale_factor should be given
with pytest.raises(ValueError):
mmcv.imresize_to_multiple(
self.img, divisor=16, size=(1000, 600), scale_factor=2)

View File

@ -15,7 +15,7 @@ boxes_arr = [[[0, 0, 2, 1], [1, 0, 3, 1], [1, 0, 2, 1], [0, 0, 3, 1],
[0, 1, 1, 2], [0, 0, 3, 2], [1, 0, 3, 2], [2, 0, 3, 2]]]
output_dict = {
# [1,c,h*w,4] for each value,
# the ouput is manually checked for its correctness
# the output is manually checked for its correctness
# pool_size=1
1: [[[[3., 6., 1., 2.], [4., 7., -1., 1.], [3., 7., 1., 2.],

View File

@ -80,7 +80,7 @@ def test_roialign():
opset_version=11)
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'input': [list(input.shape),
list(input.shape),
@ -141,7 +141,7 @@ def test_nms():
opset_version=11)
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'boxes': [list(boxes.shape),
list(boxes.shape),
@ -220,7 +220,7 @@ def test_batched_nms():
output_names=output_names,
opset_version=11)
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'boxes': [list(boxes.shape),
list(boxes.shape),
@ -295,7 +295,7 @@ def test_scatternd():
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'input': [list(data.shape),
list(data.shape),
@ -372,7 +372,7 @@ def test_deform_conv():
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'input': [list(x.shape), list(x.shape),
list(x.shape)],
@ -443,7 +443,7 @@ def test_modulated_deform_conv(with_bias):
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'input': [list(x.shape), list(x.shape),
list(x.shape)],
@ -515,7 +515,7 @@ def test_grid_sample(mode, padding_mode, align_corners):
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'input': [list(input.shape),
list(input.shape),
@ -602,7 +602,7 @@ def test_cummin_cummax(func: Callable):
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'input':
[list(input.shape),
@ -688,7 +688,7 @@ def test_instance_norm(dynamic_export, fp16_mode):
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
if dynamic_export:
opt_shape_dict = {
'input':
@ -777,7 +777,7 @@ def test_corner_pool(mode):
opset_version=opset)
onnx_model = onnx.load(onnx_file)
# create trt engine and wraper
# create trt engine and wrapper
opt_shape_dict = {
'input': [list(input.shape),
list(input.shape),

View File

@ -29,7 +29,7 @@ def test_is_module_wrapper():
return self.conv(x)
# _verify_model_across_ranks is added in torch1.9.0 so we should check
# wether _verify_model_across_ranks is the member of torch.distributed
# whether _verify_model_across_ranks is the member of torch.distributed
# before mocking
if hasattr(torch.distributed, '_verify_model_across_ranks'):
torch.distributed._verify_model_across_ranks = mock

View File

@ -503,7 +503,7 @@ def test_sequential_model_weight_init():
torch.full(seq_model[1].conv2d.weight.shape, 2.))
assert torch.equal(seq_model[1].conv2d.bias,
torch.full(seq_model[1].conv2d.bias.shape, 3.))
# inner init_cfg has highter priority
# inner init_cfg has higher priority
layers = [build_from_cfg(cfg, COMPONENTS) for cfg in seq_model_cfg]
seq_model = Sequential(
*layers,
@ -540,7 +540,7 @@ def test_modulelist_weight_init():
torch.full(modellist[1].conv2d.weight.shape, 2.))
assert torch.equal(modellist[1].conv2d.bias,
torch.full(modellist[1].conv2d.bias.shape, 3.))
# inner init_cfg has highter priority
# inner init_cfg has higher priority
layers = [build_from_cfg(cfg, COMPONENTS) for cfg in models_cfg]
modellist = ModuleList(
layers,

View File

@ -236,7 +236,7 @@ def test_eval_hook():
assert osp.exists(ckpt_path)
assert runner.meta['hook_msgs']['best_score'] == -3
# Test the EvalHook when resume happend
# Test the EvalHook when resume happened
data_loader = DataLoader(EvalDataset())
eval_hook = EvalHook(data_loader, save_best='acc')
with tempfile.TemporaryDirectory() as tmpdir: