Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos #1041

Merged
merged 3 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/cnn.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ Let us introduce the usage of `initialize` in detail.

`BaseModule` is inherited from `torch.nn.Module`, and the only different between them is that `BaseModule` implements `init_weight`.

`Sequential` is inhertied from `BaseModule` and `torch.nn.Sequential`.
`Sequential` is inherited from `BaseModule` and `torch.nn.Sequential`.

`ModuleList` is inhertied from `BaseModule` and `torch.nn.ModuleList`.
`ModuleList` is inherited from `BaseModule` and `torch.nn.ModuleList`.

`````python
import torch.nn as nn
Expand Down Expand Up @@ -534,5 +534,5 @@ The following types are supported for `filename` argument of `mmcv.load_checkpoi

- filepath: The filepath of the checkpoint.
- `http://xxx` and `https://xxx`: The link to download the checkpoint. The `SHA256` postfix should be contained in the filename.
- `torchvison://xxx`: The model links in `torchvision.models`.Please refer to [torchvision](https://pytorch.org/docs/stable/torchvision/models.html) for details.
- `torchvision://xxx`: The model links in `torchvision.models`.Please refer to [torchvision](https://pytorch.org/docs/stable/torchvision/models.html) for details.
- `open-mmlab://xxx`: The model links or filepath provided in default and additional json files.
6 changes: 3 additions & 3 deletions docs/tensorrt_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Here is an example.
import torch
import onnx

from mmcv.tensorrt import (TRTWraper, onnx2trt, save_trt_engine,
from mmcv.tensorrt import (TRTWrapper, onnx2trt, save_trt_engine,
is_tensorrt_plugin_loaded)

assert is_tensorrt_plugin_loaded(), 'Requires to complie TensorRT plugins in mmcv'
Expand Down Expand Up @@ -115,7 +115,7 @@ trt_engine = onnx2trt(
save_trt_engine(trt_engine, trt_file)

# Run inference with TensorRT
trt_model = TRTWraper(trt_file, ['input'], ['output'])
trt_model = TRTWrapper(trt_file, ['input'], ['output'])

with torch.no_grad():
trt_outputs = trt_model({'input': inputs})
Expand Down Expand Up @@ -159,7 +159,7 @@ Below are the main steps:

### Reminders

- Some of the [custom ops](https://mmcv.readthedocs.io/en/latest/ops.html) in `mmcv` have their cuda implementations, which could be refered.
- Some of the [custom ops](https://mmcv.readthedocs.io/en/latest/ops.html) in `mmcv` have their cuda implementations, which could be referred.

## Known Issues

Expand Down
6 changes: 3 additions & 3 deletions docs/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ a = 1
b = dict(b1=[0, 1, 2], b2=None)
```

#### Inherit from base config without overlaped keys
#### Inherit from base config without overlapped keys

`config_b.py`

Expand All @@ -90,7 +90,7 @@ d = 'string'

New fields in `config_b.py` are combined with old fields in `config_a.py`

#### Inherit from base config with overlaped keys
#### Inherit from base config with overlapped keys

`config_c.py`

Expand Down Expand Up @@ -203,7 +203,7 @@ for i, task in enumerate(mmcv.track_iter_progress(tasks)):

### Timer

It is convinient to compute the runtime of a code block with `Timer`.
It is convenient to compute the runtime of a code block with `Timer`.

```python
import time
Expand Down
2 changes: 1 addition & 1 deletion mmcv/cnn/utils/flops_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def print_model_with_flops(model,

>>> model = ExampleModel()
>>> x = (3, 16, 16)
to print the complexity inforamtion state for each layer, you can use
to print the complexity information state for each layer, you can use
>>> get_model_complexity_info(model, x)
or directly use
>>> print_model_with_flops(model, 4579784.0, 37361)
Expand Down
2 changes: 1 addition & 1 deletion mmcv/cnn/utils/weight_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BaseInit(object):
def __init__(self, *, bias=0, bias_prob=None, layer=None):
self.wholemodule = False
if not isinstance(bias, (int, float)):
raise TypeError(f'bias must be a numbel, but got a {type(bias)}')
raise TypeError(f'bias must be a number, but got a {type(bias)}')

if bias_prob is not None:
if not isinstance(bias_prob, float):
Expand Down
4 changes: 2 additions & 2 deletions mmcv/fileio/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def list_from_file(filename, prefix='', offset=0, max_num=0):
def dict_from_file(filename, key_type=str):
"""Load a text file and parse the content as a dict.

Each line of the text file will be two or more columns splited by
Each line of the text file will be two or more columns split by
whitespaces or tabs. The first column will be parsed as dict keys, and
the following columns will be parsed as dict values.

Args:
filename(str): Filename.
key_type(type): Type of the dict's keys. str is user by default and
key_type(type): Type of the dict keys. str is user by default and
type conversion will be performed if specified.

Returns:
Expand Down
4 changes: 2 additions & 2 deletions mmcv/image/geometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def _get_shear_matrix(magnitude, direction='horizontal'):

Args:
magnitude (int | float): The magnitude used for shear.
direction (str): Thie flip direction, either "horizontal"
direction (str): The flip direction, either "horizontal"
or "vertical".

Returns:
Expand All @@ -552,7 +552,7 @@ def imshear(img,
img (ndarray): Image to be sheared with format (h, w)
or (h, w, c).
magnitude (int | float): The magnitude used for shear.
direction (str): Thie flip direction, either "horizontal"
direction (str): The flip direction, either "horizontal"
or "vertical".
border_value (int | tuple[int]): Value used in case of a
constant border.
Expand Down
4 changes: 2 additions & 2 deletions mmcv/image/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def imread(img_or_path, flag='color', channel_order='bgr', backend=None):
it will be returned as is.
flag (str): Flags specifying the color type of a loaded image,
candidates are `color`, `grayscale` and `unchanged`.
Note that the `turbojpeg` backened does not support `unchanged`.
Note that the `turbojpeg` backend does not support `unchanged`.
channel_order (str): Order of channel, candidates are `bgr` and `rgb`.
backend (str | None): The image decoding backend type. Options are
`cv2`, `pillow`, `turbojpeg`, `tifffile`, `None`.
Expand Down Expand Up @@ -234,7 +234,7 @@ def imwrite(img, file_path, params=None, auto_mkdir=True):
Args:
img (ndarray): Image array to be written.
file_path (str): Image file path.
params (None or list): Same as opencv's :func:`imwrite` interface.
params (None or list): Same as opencv :func:`imwrite` interface.
auto_mkdir (bool): If the parent folder of `file_path` does not exist,
whether to create it automatically.

Expand Down
10 changes: 5 additions & 5 deletions mmcv/image/photometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def adjust_color(img, alpha=1, beta=None, gamma=0):
beta = 1 - alpha
colored_img = cv2.addWeighted(img, alpha, gray_img, beta, gamma)
if not colored_img.dtype == np.uint8:
# Note when the dtype of `img` is not defaultly `np.uint8`
# Note when the dtype of `img` is not the default `np.uint8`
# (e.g. np.float32), the value in `colored_img` got from cv2
# is not guaranteed to be in range [0, 255], so here clip
# is needed.
Expand Down Expand Up @@ -320,9 +320,9 @@ def adjust_sharpness(img, factor=1., kernel=None):
# adopted from PIL.ImageFilter.SMOOTH
kernel = np.array([[1., 1., 1.], [1., 5., 1.], [1., 1., 1.]]) / 13
assert isinstance(kernel, np.ndarray), \
f'kernel must be of type np.ndarrray, but got {type(kernel)} instead.'
f'kernel must be of type np.ndarray, but got {type(kernel)} instead.'
assert kernel.ndim == 2, \
f'kernel must have a dimention of 2, but got {kernel.ndim} instead.'
f'kernel must have a dimension of 2, but got {kernel.ndim} instead.'

degenerated = cv2.filter2D(img, -1, kernel)
sharpened_img = cv2.addWeighted(
Expand All @@ -340,13 +340,13 @@ def adjust_lighting(img, eigval, eigvec, alphastd=0.1, to_rgb=True):
<https://dl.acm.org/doi/pdf/10.1145/3065386>`_.

Args:
img (ndarray): Image to be ajusted lighting. BGR order.
img (ndarray): Image to be adjusted lighting. BGR order.
eigval (ndarray): the eigenvalue of the convariance matrix of pixel
values, respectively.
eigvec (ndarray): the eigenvector of the convariance matrix of pixel
values, respectively.
alphastd (float): The standard deviation for distribution of alpha.
Dafaults to 0.1
Defaults to 0.1
to_rgb (bool): Whether to convert img to rgb.

Returns:
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def bbox_overlaps(bboxes1, bboxes2, mode='iou', aligned=False, offset=0):
mode_dict = {'iou': 0, 'iof': 1}
assert mode in mode_dict.keys()
mode_flag = mode_dict[mode]
# Either the boxes are empty or the length of boxes's last dimenstion is 4
# Either the boxes are empty or the length of boxes' last dimension is 4
assert (bboxes1.size(-1) == 4 or bboxes1.size(0) == 0)
assert (bboxes2.size(-1) == 4 or bboxes2.size(0) == 0)
assert offset == 1 or offset == 0
Expand Down
10 changes: 5 additions & 5 deletions mmcv/ops/fused_bias_leakyrelu.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ class FusedBiasLeakyReLU(nn.Module):

The bias term comes from the convolution operation. In addition, to keep
the variance of the feature map or gradients unchanged, they also adopt a
scale similarly with Kaiming initalization. However, since the
scale similarly with Kaiming initialization. However, since the
:math:`1 + \alpha^2` : is too small, we can just ignore it. Therefore, the
final sacle is just :math:`\sqrt{2}`:. Of course, you may change it with # noqa: W605, E501
final scale is just :math:`\sqrt{2}`:. Of course, you may change it with # noqa: W605, E501
your own scale.

TODO: Implement the CPU version.

Args:
channel (int): The channnel number of the feature map.
channel (int): The channel number of the feature map.
negative_slope (float, optional): Same as nn.LeakyRelu.
Defaults to 0.2.
scale (float, optional): A scalar to adjust the variance of the feature
Expand All @@ -230,9 +230,9 @@ def fused_bias_leakyrelu(input, bias, negative_slope=0.2, scale=2**0.5):

The bias term comes from the convolution operation. In addition, to keep
the variance of the feature map or gradients unchanged, they also adopt a
scale similarly with Kaiming initalization. However, since the
scale similarly with Kaiming initialization. However, since the
:math:`1 + \alpha^2` : is too small, we can just ignore it. Therefore, the
final sacle is just :math:`\sqrt{2}`:. Of course, you may change it with # noqa: W605, E501
final scale is just :math:`\sqrt{2}`:. Of course, you may change it with # noqa: W605, E501
your own scale.

Args:
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/merge_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class BaseMergeCell(nn.Module):
"""The basic class for cells used in NAS-FPN and NAS-FCOS.

BaseMergeCell takes 2 inputs. After applying concolution
BaseMergeCell takes 2 inputs. After applying convolution
on them, they are resized to the target size. Then,
they go through binary_op, which depends on the type of cell.
If with_out_conv is True, the result of output will go through
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def nms_rotated(dets, scores, iou_threshold, labels=None):
be in (x_ctr, y_ctr, width, height, angle_radian) format.
scores (Tensor): scores in shape (N, ).
iou_threshold (float): IoU thresh for NMS.
labels (Tensor): boxes's label in shape (N,).
labels (Tensor): boxes' label in shape (N,).

Returns:
tuple: kept dets(boxes and scores) and indice, which is always the \
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/pixel_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def pixel_group(score, mask, embedding, kernel_label, kernel_contour,
Arguments:
score (np.array or Tensor): The foreground score with size hxw.
mask (np.array or Tensor): The foreground mask with size hxw.
embedding (np.array or Tensor): The emdedding with size hxwxc to
embedding (np.array or Tensor): The embedding with size hxwxc to
distinguish instances.
kernel_label (np.array or Tensor): The instance kernel index with
size hxw.
Expand Down
2 changes: 1 addition & 1 deletion mmcv/parallel/_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def scatter(input, devices, streams=None):
with torch.cuda.device(devices[0]), torch.cuda.stream(stream):
output = output.cuda(devices[0], non_blocking=True)
else:
# unsquzee the first dimension thus the tensor's shape is the
# unsqueeze the first dimension thus the tensor's shape is the
# same as those scattered with GPU.
output = output.unsqueeze(0)
return output
Expand Down
2 changes: 1 addition & 1 deletion mmcv/runner/base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, init_cfg=None):

super(BaseModule, self).__init__()
# define default value of init_cfg instead of hard code
# in init_weigt() function
# in init_weight() function
self._is_init = False
self.init_cfg = init_cfg

Expand Down
2 changes: 1 addition & 1 deletion mmcv/runner/hooks/lr_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class CyclicLrUpdaterHook(LrUpdaterHook):
Implement the cyclical learning rate policy (CLR) described in
https://arxiv.org/pdf/1506.01186.pdf

Different from the original paper, we use cosine anealing rather than
Different from the original paper, we use cosine annealing rather than
triangular policy inside a cycle. This improves the performance in the
3D detection area.

Expand Down
2 changes: 1 addition & 1 deletion mmcv/runner/hooks/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Fp16OptimizerHook(OptimizerHook):
It can also be a dict containing arguments of GradScalar.
Defaults to 512. For Pytorch >= 1.6, mmcv uses official
implementation of GradScaler. If you use a dict version of
loss_scale to create GradScaler, plese refer to:
loss_scale to create GradScaler, please refer to:
https://pytorch.org/docs/stable/amp.html#torch.cuda.amp.GradScaler
for the parameters.

Expand Down
8 changes: 4 additions & 4 deletions mmcv/runner/hooks/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@HOOKS.register_module()
class ProfilerHook(Hook):
"""Profiler to analyze perfromance during training.
"""Profiler to analyze performance during training.

PyTorch Profiler is a tool that allows the collection of the performance
metrics during the training. More details on Profiler can be found at
Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(self,
from torch import profiler # torch version >= 1.8.1
except ImportError:
raise ImportError('profiler is the new feature of torch1.8.1, '
f'but your verison is {torch.__version__}')
f'but your version is {torch.__version__}')

assert isinstance(by_epoch, bool), '``by_epoch`` should be a boolean.'
self.by_epoch = by_epoch
Expand Down Expand Up @@ -120,10 +120,10 @@ def before_run(self, runner):
trace_type = trace_cfg.pop('type') # log_trace handler
if trace_type == 'log_trace':

def _log_hanlder(prof):
def _log_handler(prof):
print(prof.key_averages().table(**trace_cfg))

_on_trace_ready = _log_hanlder
_on_trace_ready = _log_handler
elif trace_type == 'tb_trace': # tensorboard_trace handler
try:
import torch_tb_profiler # noqa: F401
Expand Down
2 changes: 1 addition & 1 deletion mmcv/runner/optimizer/default_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DefaultOptimizerConstructor:
``dcn_offset_lr_mult``. If you wish to apply both of them to the
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 construtor will
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
the model contains multiple DCN layers in places other than
backbone.
Expand Down
4 changes: 2 additions & 2 deletions mmcv/tensorrt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# flake8: noqa
from .init_plugins import is_tensorrt_plugin_loaded, load_tensorrt_plugin
from .tensorrt_utils import (TRTWraper, load_trt_engine, onnx2trt,
from .tensorrt_utils import (TRTWrapper, load_trt_engine, onnx2trt,
save_trt_engine)

# load tensorrt plugin lib
load_tensorrt_plugin()

__all__ = [
'onnx2trt', 'save_trt_engine', 'load_trt_engine', 'TRTWraper',
'onnx2trt', 'save_trt_engine', 'load_trt_engine', 'TRTWrapper',
'is_tensorrt_plugin_loaded'
]
10 changes: 5 additions & 5 deletions mmcv/tensorrt/tensorrt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse_data(name, typ):
elif name in init_dict:
raw_data = init_dict[name].raw_data
else:
raise ValueError(f'{name} not found in node or initilizer.')
raise ValueError(f'{name} not found in node or initializer.')
return np.frombuffer(raw_data, typ).item()

nrof_node = len(nodes)
Expand Down Expand Up @@ -225,8 +225,8 @@ def torch_device_from_trt(device):
return TypeError('%s is not supported by torch' % device)


class TRTWraper(torch.nn.Module):
"""TensorRT engine Wraper.
class TRTWrapper(torch.nn.Module):
"""TensorRT engine Wrapper.

Arguments:
engine (tensorrt.ICudaEngine): TensorRT engine to wrap
Expand All @@ -239,15 +239,15 @@ class TRTWraper(torch.nn.Module):
"""

def __init__(self, engine, input_names, output_names):
super(TRTWraper, self).__init__()
super(TRTWrapper, self).__init__()
self.engine = engine
if isinstance(self.engine, str):
self.engine = load_trt_engine(engine)

if not isinstance(self.engine, trt.ICudaEngine):
raise TypeError('engine should be str or trt.ICudaEngine')

self._register_state_dict_hook(TRTWraper._on_state_dict)
self._register_state_dict_hook(TRTWrapper._on_state_dict)
self.context = self.engine.create_execution_context()

self.input_names = input_names
Expand Down
2 changes: 1 addition & 1 deletion mmcv/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def requires_executable(prerequisites):


def deprecated_api_warning(name_dict, cls_name=None):
"""A decorator to check if some argments are deprecate and try to replace
"""A decorator to check if some arguments are deprecate and try to replace
deprecate src_arg_name to dst_arg_name.

Args:
Expand Down
2 changes: 1 addition & 1 deletion mmcv/visualization/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def imshow(img, win_name='', wait_time=0):
wait_time (int): Value of waitKey param.
"""
cv2.imshow(win_name, imread(img))
if wait_time == 0: # prevent from hangning if windows was closed
if wait_time == 0: # prevent from hanging if windows was closed
while True:
ret = cv2.waitKey(1)

Expand Down