mirror of https://github.com/open-mmlab/mmcv.git
lint markdown files (#592)
parent
9141d91ddc
commit
f3a2be99b9
|
@ -14,16 +14,12 @@ jobs:
|
|||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Install linting dependencies
|
||||
- name: Install pre-commit hook
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flake8 yapf isort==4.3.21
|
||||
- name: Lint with flake8
|
||||
run: flake8 --max-complexity 20 .
|
||||
- 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/
|
||||
pip install pre-commit
|
||||
pre-commit install
|
||||
- name: Linting
|
||||
run: pre-commit run --all-files
|
||||
- name: Format c/cuda codes with clang-format
|
||||
uses: DoozyX/clang-format-lint-action@v0.6
|
||||
with:
|
||||
|
|
|
@ -29,16 +29,21 @@ repos:
|
|||
args: ["--remove"]
|
||||
- id: mixed-line-ending
|
||||
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
|
||||
rev: v1.3.1
|
||||
hooks:
|
||||
- id: docformatter
|
||||
args: ["--in-place", "--wrap-descriptions", "79"]
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: clang-format
|
||||
name: clang-format
|
||||
description: Format files with ClangFormat
|
||||
entry: clang-format -style=google -i
|
||||
language: system
|
||||
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$
|
||||
# - repo: local
|
||||
# hooks:
|
||||
# - id: clang-format
|
||||
# name: clang-format
|
||||
# description: Format files with ClangFormat
|
||||
# entry: clang-format -style=google -i
|
||||
# language: system
|
||||
# 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
|
|||
## Code style
|
||||
|
||||
### Python
|
||||
|
||||
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:
|
||||
|
||||
- [flake8](http://flake8.pycqa.org/en/latest/): linter
|
||||
- [yapf](https://github.com/google/yapf): formatter
|
||||
- [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
|
|||
|
||||
After you clone the repository, you will need to install initialize pre-commit hook.
|
||||
|
||||
```
|
||||
```shell
|
||||
pip install -U pre-commit
|
||||
```
|
||||
|
||||
From the repository folder
|
||||
```
|
||||
|
||||
```shell
|
||||
pre-commit install
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
### C++ and CUDA
|
||||
|
||||
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
|
|||
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`.
|
||||
|
||||
|
||||
### TroubleShooting
|
||||
|
||||
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 @@
|
|||
This module provides some image processing methods, which requires `opencv` to be installed.
|
||||
|
||||
### Read/Write/Show
|
||||
|
||||
To read or write images files, use `imread` or `imwrite`.
|
||||
|
||||
```python
|
||||
|
@ -34,7 +35,9 @@ for i in range(10):
|
|||
```
|
||||
|
||||
### Color space conversion
|
||||
|
||||
Supported conversion methods:
|
||||
|
||||
- bgr2gray
|
||||
- gray2bgr
|
||||
- bgr2rgb
|
||||
|
@ -50,6 +53,7 @@ img3 = mmcv.bgr2hsv(img)
|
|||
```
|
||||
|
||||
### Resize
|
||||
|
||||
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
|
||||
is a tuple `(resized_img, scale)`.
|
||||
|
@ -70,6 +74,7 @@ mmcv.imrescale(img, (1000, 800))
|
|||
```
|
||||
|
||||
### Rotate
|
||||
|
||||
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,
|
||||
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)
|
|||
```
|
||||
|
||||
### Flip
|
||||
|
||||
To flip an image, use `imflip`.
|
||||
|
||||
```python
|
||||
|
@ -109,6 +115,7 @@ mmcv.imflip(img, direction='vertical')
|
|||
```
|
||||
|
||||
### Crop
|
||||
|
||||
`imcrop` can crop the image with one or some regions, represented as (x1, y1, x2, y2).
|
||||
|
||||
```python
|
||||
|
@ -130,6 +137,7 @@ patches = mmcv.imcrop(img, bboxes, scale_ratio=1.2)
|
|||
```
|
||||
|
||||
### Padding
|
||||
|
||||
There are two methods `impad` and `impad_to_multiple` to pad an image to the
|
||||
specific size with given values.
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
This module provides two universal API to load and dump files of different formats.
|
||||
|
||||
### Load and dump data
|
||||
|
||||
`mmcv` provides a universal api for loading and dumping data, currently
|
||||
supported formats are json, yaml and pickle.
|
||||
|
||||
|
@ -82,6 +83,7 @@ class PickleHandler(mmcv.BaseFileHandler):
|
|||
### Load a text file as a list or dict
|
||||
|
||||
For example `a.txt` is a text file with 5 lines.
|
||||
|
||||
```
|
||||
a
|
||||
b
|
||||
|
@ -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.
|
||||
|
||||
```
|
||||
1 cat
|
||||
2 dog cow
|
||||
|
|
|
@ -38,7 +38,7 @@ Currently, it supports four predefined variables:
|
|||
|
||||
`{{ 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.
|
||||
|
||||
|
@ -58,7 +58,6 @@ c = '{{ fileExtname }}'
|
|||
... c='.py')
|
||||
```
|
||||
|
||||
|
||||
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']`.
|
||||
Here are 4 examples of config inheritance.
|
||||
|
@ -70,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 overlaped keys
|
||||
|
||||
`config_b.py`
|
||||
|
||||
|
@ -91,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 overlaped keys
|
||||
|
||||
`config_c.py`
|
||||
|
||||
|
@ -111,7 +110,7 @@ c = (1, 2)
|
|||
|
||||
`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`
|
||||
|
||||
|
@ -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`.
|
||||
|
||||
#### 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`
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ This module provides the following functionalities.
|
|||
- Some methods for editing (cut, concat, resize) videos.
|
||||
- Optical flow read/write/warp.
|
||||
|
||||
|
||||
### VideoReader
|
||||
|
||||
The `VideoReader` class provides sequence like apis to access video frames.
|
||||
|
|
|
@ -8,11 +8,11 @@ from .registry import CONV_LAYERS
|
|||
|
||||
@CONV_LAYERS.register_module()
|
||||
class Conv2dAdaptivePadding(nn.Conv2d):
|
||||
""" Implementation of 2D convolution in tensorflow with `padding` as
|
||||
"same", which applies padding to input (if needed) so that input image
|
||||
gets fully covered by filter and stride you specified. For stride 1, this
|
||||
will ensure that output image size is same as input. For stride of 2,
|
||||
output dimensions will be half, for example.
|
||||
"""Implementation of 2D convolution in tensorflow with `padding` as "same",
|
||||
which applies padding to input (if needed) so that input image gets fully
|
||||
covered by filter and stride you specified. For stride 1, this will ensure
|
||||
that output image size is same as input. For stride of 2, output dimensions
|
||||
will be half, for example.
|
||||
|
||||
Args:
|
||||
in_channels (int): Number of channels in the input image
|
||||
|
|
Loading…
Reference in New Issue