Skip to content

Commit

Permalink
Update pre-commit yaml and md2yml.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xiexinch committed Jul 5, 2022
1 parent 89d6f89 commit 28a3d89
Show file tree
Hide file tree
Showing 80 changed files with 1,532 additions and 1,452 deletions.
15 changes: 8 additions & 7 deletions .dev/log_collector/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ markdown_file ='markdowns/lr_in_trans.json.md'
json_file = 'jsons/trans_in_cnn.json'
```

The structure of the work-dir directory should be like:
The structure of the work-dir directory should be like:

```text
├── work-dir
Expand All @@ -69,14 +69,15 @@ python log_collector.py ./example_config.py

The output markdown file is like:

|exp_num|method|mIoU best|best index|mIoU last|last index|last iter num|
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|1|segformer_mit-b5_512x512_160k_ade20k_cnn_lr_with_warmup|0.2776|10|0.2776|10|160000|
|2|segformer_mit-b5_512x512_160k_ade20k_cnn_no_warmup_lr|0.2802|10|0.2802|10|160000|
|3|segformer_mit-b5_512x512_160k_ade20k_mit_trans_lr|0.4943|11|0.4943|11|160000|
|4|segformer_mit-b5_512x512_160k_ade20k_swin_trans_lr|0.4883|11|0.4883|11|160000|
| exp_num | method | mIoU best | best index | mIoU last | last index | last iter num |
| :-----: | :-----------------------------------------------------: | :-------: | :--------: | :-------: | :--------: | :-----------: |
| 1 | segformer_mit-b5_512x512_160k_ade20k_cnn_lr_with_warmup | 0.2776 | 10 | 0.2776 | 10 | 160000 |
| 2 | segformer_mit-b5_512x512_160k_ade20k_cnn_no_warmup_lr | 0.2802 | 10 | 0.2802 | 10 | 160000 |
| 3 | segformer_mit-b5_512x512_160k_ade20k_mit_trans_lr | 0.4943 | 11 | 0.4943 | 11 | 160000 |
| 4 | segformer_mit-b5_512x512_160k_ade20k_swin_trans_lr | 0.4883 | 11 | 0.4883 | 11 | 160000 |

The output json file is like:

```json
[
{
Expand Down
42 changes: 34 additions & 8 deletions .dev/md2yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@
import re
import sys

import mmcv
from lxml import etree
from mmcv.fileio import dump

MMSEG_ROOT = osp.dirname(osp.dirname((osp.dirname(__file__))))

COLLECTIONS = [
'ANN', 'APCNet', 'BiSeNetV1', 'BiSeNetV2', 'CCNet', 'CGNet', 'DANet',
'DeepLabV3', 'DeepLabV3+', 'DMNet', 'DNLNet', 'DPT', 'EMANet', 'EncNet',
'ERFNet', 'FastFCN', 'FastSCNN', 'FCN', 'GCNet', 'ICNet', 'ISANet', 'KNet',
'NonLocalNet', 'OCRNet', 'PointRend', 'PSANet', 'PSPNet', 'Segformer',
'Segmenter', 'FPN', 'SETR', 'STDC', 'UNet', 'UPerNet'
]
COLLECTIONS_TEMP = []


def dump_yaml_and_check_difference(obj, filename, sort_keys=False):
"""Dump object to a yaml file, and check if the file content is different
Expand All @@ -30,7 +39,7 @@ def dump_yaml_and_check_difference(obj, filename, sort_keys=False):
Bool: If the target YAML file is different from the original.
"""

str_dump = mmcv.dump(obj, None, file_format='yaml', sort_keys=sort_keys)
str_dump = dump(obj, None, file_format='yaml', sort_keys=sort_keys)
if osp.isfile(filename):
file_exists = True
with open(filename, 'r', encoding='utf-8') as f:
Expand Down Expand Up @@ -88,7 +97,7 @@ def parse_md(md_file):
# should be set with head or neck of this config file.
is_backbone = None

with open(md_file, 'r') as md:
with open(md_file, 'r', encoding='UTF-8') as md:
lines = md.readlines()
i = 0
current_dataset = ''
Expand Down Expand Up @@ -127,8 +136,9 @@ def parse_md(md_file):
elif line[:15] == '<!-- [BACKBONE]':
is_backbone = True
i += 1
elif line[0] == '|' and (
i + 1) < len(lines) and lines[i + 1][:3] == '| -':
elif (line[0] == '|' and (i + 1) < len(lines)
and lines[i + 1][:3] == '| -' and 'Method' in line
and 'Crop Size' in line and 'Mem (GB)' in line):
cols = [col.strip() for col in line.split('|')]
method_id = cols.index('Method')
backbone_id = cols.index('Backbone')
Expand Down Expand Up @@ -246,11 +256,21 @@ def parse_md(md_file):
collection.pop(check_key)
else:
collection[check_key].pop(key)
yml_file = f'{md_file[:-9]}{collection_name}.yml'
if is_backbone:
result = {'Models': models}
if collection['Name'] not in COLLECTIONS:
result = {
'Collections': [collection],
'Models': models,
'Yml': yml_file
}
COLLECTIONS_TEMP.append(result)
return False
else:
result = {'Models': models}
else:
COLLECTIONS.append(collection['Name'])
result = {'Collections': [collection], 'Models': models}
yml_file = f'{md_file[:-9]}{collection_name}.yml'
return dump_yaml_and_check_difference(result, yml_file)


Expand Down Expand Up @@ -286,6 +306,12 @@ def update_model_index():
for fn in file_list:
file_modified |= parse_md(fn)

file_modified |= update_model_index()
for result in COLLECTIONS_TEMP:
collection = result['Collections'][0]
yml_file = result.pop('Yml', None)
if collection['Name'] in COLLECTIONS:
result.pop('Collections')
file_modified |= dump_yaml_and_check_difference(result, yml_file)

file_modified |= update_model_index()
sys.exit(1 if file_modified else 0)
30 changes: 15 additions & 15 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down Expand Up @@ -70,7 +70,7 @@ members of the project's leadership.
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

[homepage]: https://www.contributor-covenant.org
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ All kinds of contributions are welcome, including but not limited to the followi

- If you plan to add some new features that involve large changes, it is encouraged to open an issue for discussion first.
- If you are the author of some papers and would like to include your method to mmsegmentation,
please contact Kai Chen (chenkaidev[at]gmail[dot]com). We will much appreciate your contribution.
:::
please contact Kai Chen (chenkaidev\[at\]gmail\[dot\]com). We will much appreciate your contribution.
:::

## Code style

Expand All @@ -34,7 +34,7 @@ We use the following tools for linting and formatting:
Style configurations of yapf and isort can be found in [setup.cfg](../setup.cfg) and [.isort.cfg](../.isort.cfg).

We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`,
fixes `end-of-files`, sorts `requirments.txt` automatically on every commit.
fixes `end-of-files`, sorts `requirments.txt` automatically on every commit.
The config for a pre-commit hook is stored in [.pre-commit-config](../.pre-commit-config.yaml).

After you clone the repository, you will need to install initialize pre-commit hook.
Expand All @@ -51,7 +51,7 @@ 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.
> Before you create a PR, make sure that your code lints and is formatted by yapf.
### C++ and CUDA

Expand Down
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/error-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

Thanks for your error report and we appreciate it a lot.
Expand All @@ -21,19 +20,20 @@ A clear and concise description of what the bug is.

1. What command or script did you run?

```none
A placeholder for the command.
```
```none
A placeholder for the command.
```

2. Did you make any modifications on the code or config? Did you understand what you have modified?

3. What dataset did you use?

**Environment**

1. Please run `python mmseg/utils/collect_env.py` to collect necessary environment information and paste it here.
2. You may add addition that may be helpful for locating the problem, such as
- How you installed PyTorch [e.g., pip, conda, source]
- Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
- How you installed PyTorch \[e.g., pip, conda, source\]
- Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)

**Error traceback**

Expand Down
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

# Describe the feature

**Motivation**
A clear and concise description of the motivation of the feature.
Ex1. It is inconvenient when [....].
Ex2. There is a recent paper [....], which is very helpful for [....].
Ex1. It is inconvenient when \[....\].
Ex2. There is a recent paper \[....\], which is very helpful for \[....\].

**Related resources**
If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful.
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/general_questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ about: Ask general questions to get help
title: ''
labels: ''
assignees: ''

---
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/reimplementation_questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name: Reimplementation Questions
about: Ask about questions during model reimplementation
title: ''
labels: 'reimplementation'
labels: reimplementation
assignees: ''

---

If you feel we have helped you, give us a STAR! :satisfied:
Expand Down Expand Up @@ -54,7 +53,7 @@ A placeholder for the config.

1. Please run `PYTHONPATH=${PWD}:$PYTHONPATH python mmseg/utils/collect_env.py` to collect the necessary environment information and paste it here.
2. You may add an addition that may be helpful for locating the problem, such as
1. How you installed PyTorch [e.g., pip, conda, source]
1. How you installed PyTorch \[e.g., pip, conda, source\]
2. Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)

**Results**
Expand Down
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
default_language_version:
ruby: 2.7.1

repos:
- repo: https://gitlab.com/pycqa/flake8.git
rev: 3.8.3
Expand All @@ -27,12 +24,15 @@ repos:
args: ["--remove"]
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/markdownlint/markdownlint
rev: v0.11.0
hooks:
- id: markdownlint
args: ["-r", "~MD002,~MD013,~MD029,~MD033,~MD034",
"-t", "allow_different_nesting"]
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.9
hooks:
- id: mdformat
args: ["--number"]
additional_dependencies:
- mdformat-openmmlab
- mdformat_frontmatter
- linkify-it-py
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
Expand All @@ -48,7 +48,7 @@ repos:
name: update-model-index
description: Collect model information and update model-index.yml
entry: .dev/md2yml.py
additional_dependencies: [mmcv, lxml]
additional_dependencies: [mmcv, lxml, opencv-python]
language: python
files: ^configs/.*\.md$
require_serial: true
Expand Down
8 changes: 4 additions & 4 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ MMSegmentation 是一个由来自不同高校和企业的研发人员共同参

## 欢迎加入 OpenMMLab 社区

扫描下方的二维码可关注 OpenMMLab 团队的 [知乎官方账号](https://www.zhihu.com/people/openmmlab),加入 [OpenMMLab 团队](https://jq.qq.com/?_wv=1027&k=aCvMxdr3) 以及 [MMSegmentation](https://jq.qq.com/?_wv=1027&k=ukevz6Ie) 的 QQ 群。
扫描下方的二维码可关注 OpenMMLab 团队的 [知乎官方账号](https://www.zhihu.com/people/openmmlab),加入 [OpenMMLab 团队](https://jq.qq.com/?_wv=1027&k=aCvMxdr3) 以及 [MMSegmentation](https://jq.qq.com/?_wv=1027&k=ukevz6Ie) 的 QQ 群。

<div align="center">
<div align="center">
<img src="docs/zh_cn/imgs/zhihu_qrcode.jpg" height="400" /> <img src="docs/zh_cn/imgs/qq_group_qrcode.jpg" height="400" /> <img src="docs/zh_cn/imgs/seggroup_qrcode.jpg" height="400" />
</div>

我们会在 OpenMMLab 社区为大家
我们会在 OpenMMLab 社区为大家

- 📢 分享 AI 框架的前沿核心技术
- 💻 解读 PyTorch 常用模块源码
Expand All @@ -217,4 +217,4 @@ MMSegmentation 是一个由来自不同高校和企业的研发人员共同参
- 🏃 获取更高效的问题答疑和意见反馈
- 🔥 提供与各行各业开发者充分交流的平台

干货满满 📘,等你来撩 💗,OpenMMLab 社区期待您的加入 👬
干货满满 📘,等你来撩 💗,OpenMMLab 社区期待您的加入 👬
Loading

0 comments on commit 28a3d89

Please sign in to comment.