Unverified Commit f3a2be99 authored by Kai Chen's avatar Kai Chen Committed by GitHub
Browse files

lint markdown files (#592)

parent 9141d91d
...@@ -14,16 +14,12 @@ jobs: ...@@ -14,16 +14,12 @@ jobs:
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: 3.7 python-version: 3.7
- name: Install linting dependencies - name: Install pre-commit hook
run: | run: |
python -m pip install --upgrade pip pip install pre-commit
pip install flake8 yapf isort==4.3.21 pre-commit install
- name: Lint with flake8 - name: Linting
run: flake8 --max-complexity 20 . run: pre-commit run --all-files
- name: Lint with isort
run: isort --recursive --check-only --diff mmcv/ tests/ examples/
- name: Format python codes with yapf
run: yapf -r -d mmcv/ tests/ examples/
- name: Format c/cuda codes with clang-format - name: Format c/cuda codes with clang-format
uses: DoozyX/clang-format-lint-action@v0.6 uses: DoozyX/clang-format-lint-action@v0.6
with: with:
......
...@@ -29,16 +29,21 @@ repos: ...@@ -29,16 +29,21 @@ repos:
args: ["--remove"] args: ["--remove"]
- id: mixed-line-ending - id: mixed-line-ending
args: ["--fix=lf"] args: ["--fix=lf"]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4
hooks:
- id: markdownlint
args: ["-r", "~MD002,~MD013,~MD029,~MD033,~MD034"]
- repo: https://github.com/myint/docformatter - repo: https://github.com/myint/docformatter
rev: v1.3.1 rev: v1.3.1
hooks: hooks:
- id: docformatter - id: docformatter
args: ["--in-place", "--wrap-descriptions", "79"] args: ["--in-place", "--wrap-descriptions", "79"]
- repo: local # - repo: local
hooks: # hooks:
- id: clang-format # - id: clang-format
name: clang-format # name: clang-format
description: Format files with ClangFormat # description: Format files with ClangFormat
entry: clang-format -style=google -i # entry: clang-format -style=google -i
language: system # language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$ # files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$
...@@ -17,9 +17,11 @@ Note: If you plan to add some new features that involve large changes, it is enc ...@@ -17,9 +17,11 @@ Note: If you plan to add some new features that involve large changes, it is enc
## Code style ## Code style
### Python ### Python
We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style. We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style.
We use the following tools for linting and formatting: We use the following tools for linting and formatting:
- [flake8](http://flake8.pycqa.org/en/latest/): linter - [flake8](http://flake8.pycqa.org/en/latest/): linter
- [yapf](https://github.com/google/yapf): formatter - [yapf](https://github.com/google/yapf): formatter
- [isort](https://github.com/timothycrosley/isort): sort imports - [isort](https://github.com/timothycrosley/isort): sort imports
...@@ -32,19 +34,20 @@ The config for a pre-commit hook is stored in [.pre-commit-config](./.pre-commit ...@@ -32,19 +34,20 @@ The config for a pre-commit hook is stored in [.pre-commit-config](./.pre-commit
After you clone the repository, you will need to install initialize pre-commit hook. After you clone the repository, you will need to install initialize pre-commit hook.
``` ```shell
pip install -U pre-commit pip install -U pre-commit
``` ```
From the repository folder From the repository folder
```
```shell
pre-commit install pre-commit install
``` ```
After this on every commit check code linters and formatter will be enforced. After this on every commit check code linters and formatter will be enforced.
>Before you create a PR, make sure that your code lints and is formatted by yapf. >Before you create a PR, make sure that your code lints and is formatted by yapf.
### C++ and CUDA ### C++ and CUDA
We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
...@@ -148,7 +148,6 @@ Note: If you would like to use `opencv-python-headless` instead of `opencv-pytho ...@@ -148,7 +148,6 @@ Note: If you would like to use `opencv-python-headless` instead of `opencv-pytho
e.g., in a minimum container environment or servers without GUI, e.g., in a minimum container environment or servers without GUI,
you can first install it before installing MMCV to skip the installation of `opencv-python`. you can first install it before installing MMCV to skip the installation of `opencv-python`.
### TroubleShooting ### TroubleShooting
If you meet issues when running or compiling mmcv, we list some common issues in [TROUBLESHOOTING.md](docs/trouble_shooting.md). If you meet issues when running or compiling mmcv, we list some common issues in [TROUBLESHOOTING.md](docs/trouble_shooting.md).
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
This module provides some image processing methods, which requires `opencv` to be installed. This module provides some image processing methods, which requires `opencv` to be installed.
### Read/Write/Show ### Read/Write/Show
To read or write images files, use `imread` or `imwrite`. To read or write images files, use `imread` or `imwrite`.
```python ```python
...@@ -34,7 +35,9 @@ for i in range(10): ...@@ -34,7 +35,9 @@ for i in range(10):
``` ```
### Color space conversion ### Color space conversion
Supported conversion methods: Supported conversion methods:
- bgr2gray - bgr2gray
- gray2bgr - gray2bgr
- bgr2rgb - bgr2rgb
...@@ -50,6 +53,7 @@ img3 = mmcv.bgr2hsv(img) ...@@ -50,6 +53,7 @@ img3 = mmcv.bgr2hsv(img)
``` ```
### Resize ### Resize
There are three resize methods. All `imresize_*` methods have an argument `return_scale`, There are three resize methods. All `imresize_*` methods have an argument `return_scale`,
if this argument is `False`, then the return value is merely the resized image, otherwise if this argument is `False`, then the return value is merely the resized image, otherwise
is a tuple `(resized_img, scale)`. is a tuple `(resized_img, scale)`.
...@@ -70,6 +74,7 @@ mmcv.imrescale(img, (1000, 800)) ...@@ -70,6 +74,7 @@ mmcv.imrescale(img, (1000, 800))
``` ```
### Rotate ### Rotate
To rotate an image by some angle, use `imrotate`. The center can be specified, To rotate an image by some angle, use `imrotate`. The center can be specified,
which is the center of original image by default. There are two modes of rotating, which is the center of original image by default. There are two modes of rotating,
one is to keep the image size unchanged so that some parts of the image will be one is to keep the image size unchanged so that some parts of the image will be
...@@ -96,6 +101,7 @@ img_ = mmcv.imrotate(img, 30, auto_bound=True) ...@@ -96,6 +101,7 @@ img_ = mmcv.imrotate(img, 30, auto_bound=True)
``` ```
### Flip ### Flip
To flip an image, use `imflip`. To flip an image, use `imflip`.
```python ```python
...@@ -109,6 +115,7 @@ mmcv.imflip(img, direction='vertical') ...@@ -109,6 +115,7 @@ mmcv.imflip(img, direction='vertical')
``` ```
### Crop ### Crop
`imcrop` can crop the image with one or some regions, represented as (x1, y1, x2, y2). `imcrop` can crop the image with one or some regions, represented as (x1, y1, x2, y2).
```python ```python
...@@ -130,6 +137,7 @@ patches = mmcv.imcrop(img, bboxes, scale_ratio=1.2) ...@@ -130,6 +137,7 @@ patches = mmcv.imcrop(img, bboxes, scale_ratio=1.2)
``` ```
### Padding ### Padding
There are two methods `impad` and `impad_to_multiple` to pad an image to the There are two methods `impad` and `impad_to_multiple` to pad an image to the
specific size with given values. specific size with given values.
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
This module provides two universal API to load and dump files of different formats. This module provides two universal API to load and dump files of different formats.
### Load and dump data ### Load and dump data
`mmcv` provides a universal api for loading and dumping data, currently `mmcv` provides a universal api for loading and dumping data, currently
supported formats are json, yaml and pickle. supported formats are json, yaml and pickle.
...@@ -82,6 +83,7 @@ class PickleHandler(mmcv.BaseFileHandler): ...@@ -82,6 +83,7 @@ class PickleHandler(mmcv.BaseFileHandler):
### Load a text file as a list or dict ### Load a text file as a list or dict
For example `a.txt` is a text file with 5 lines. For example `a.txt` is a text file with 5 lines.
``` ```
a a
b b
...@@ -104,6 +106,7 @@ Then use `list_from_file` to load the list from a.txt. ...@@ -104,6 +106,7 @@ Then use `list_from_file` to load the list from a.txt.
``` ```
For example `b.txt` is a text file with 5 lines. For example `b.txt` is a text file with 5 lines.
``` ```
1 cat 1 cat
2 dog cow 2 dog cow
......
...@@ -38,7 +38,7 @@ Currently, it supports four predefined variables: ...@@ -38,7 +38,7 @@ Currently, it supports four predefined variables:
`{{ fileExtname }}` - the current opened file's extension, e.g. .ext `{{ fileExtname }}` - the current opened file's extension, e.g. .ext
These variable names are referred from https://code.visualstudio.com/docs/editor/variables-reference. These variable names are referred from [VS Code](https://code.visualstudio.com/docs/editor/variables-reference).
Here is one examples of config with predefined variables. Here is one examples of config with predefined variables.
...@@ -58,7 +58,6 @@ c = '{{ fileExtname }}' ...@@ -58,7 +58,6 @@ c = '{{ fileExtname }}'
... c='.py') ... c='.py')
``` ```
For all format configs, inheritance is supported. To reuse fields in other config files, For all format configs, inheritance is supported. To reuse fields in other config files,
specify `_base_='./config_a.py'` or a list of configs `_base_=['./config_a.py', './config_b.py']`. specify `_base_='./config_a.py'` or a list of configs `_base_=['./config_a.py', './config_b.py']`.
Here are 4 examples of config inheritance. Here are 4 examples of config inheritance.
...@@ -70,7 +69,7 @@ a = 1 ...@@ -70,7 +69,7 @@ a = 1
b = dict(b1=[0, 1, 2], b2=None) b = dict(b1=[0, 1, 2], b2=None)
``` ```
#### Inherit from base config without overlaped keys. #### Inherit from base config without overlaped keys
`config_b.py` `config_b.py`
...@@ -91,7 +90,7 @@ d = 'string' ...@@ -91,7 +90,7 @@ d = 'string'
New fields in `config_b.py` are combined with old fields in `config_a.py` 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 overlaped keys
`config_c.py` `config_c.py`
...@@ -111,7 +110,7 @@ c = (1, 2) ...@@ -111,7 +110,7 @@ c = (1, 2)
`b.b2=None` in `config_a` is replaced with `b.b2=1` in `config_c.py`. `b.b2=None` in `config_a` is replaced with `b.b2=1` in `config_c.py`.
#### Inherit from base config with ignored fields. #### Inherit from base config with ignored fields
`config_d.py` `config_d.py`
...@@ -131,7 +130,7 @@ c = (1, 2) ...@@ -131,7 +130,7 @@ c = (1, 2)
You may also set `_delete_=True` to ignore some fields in base configs. All old keys `b1, b2, b3` in `b` are replaced with new keys `b2, b3`. You may also set `_delete_=True` to ignore some fields in base configs. All old keys `b1, b2, b3` in `b` are replaced with new keys `b2, b3`.
#### Inherit from multiple base configs (the base configs should not contain the same keys). #### Inherit from multiple base configs (the base configs should not contain the same keys)
`config_e.py` `config_e.py`
......
...@@ -6,7 +6,6 @@ This module provides the following functionalities. ...@@ -6,7 +6,6 @@ This module provides the following functionalities.
- Some methods for editing (cut, concat, resize) videos. - Some methods for editing (cut, concat, resize) videos.
- Optical flow read/write/warp. - Optical flow read/write/warp.
### VideoReader ### VideoReader
The `VideoReader` class provides sequence like apis to access video frames. The `VideoReader` class provides sequence like apis to access video frames.
......
...@@ -8,11 +8,11 @@ from .registry import CONV_LAYERS ...@@ -8,11 +8,11 @@ from .registry import CONV_LAYERS
@CONV_LAYERS.register_module() @CONV_LAYERS.register_module()
class Conv2dAdaptivePadding(nn.Conv2d): class Conv2dAdaptivePadding(nn.Conv2d):
""" Implementation of 2D convolution in tensorflow with `padding` as """Implementation of 2D convolution in tensorflow with `padding` as "same",
"same", which applies padding to input (if needed) so that input image which applies padding to input (if needed) so that input image gets fully
gets fully covered by filter and stride you specified. For stride 1, this covered by filter and stride you specified. For stride 1, this will ensure
will ensure that output image size is same as input. For stride of 2, that output image size is same as input. For stride of 2, output dimensions
output dimensions will be half, for example. will be half, for example.
Args: Args:
in_channels (int): Number of channels in the input image in_channels (int): Number of channels in the input image
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment