Skip to content

Commit 28a3d89

Browse files
committed
Update pre-commit yaml and md2yml.py
1 parent 89d6f89 commit 28a3d89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1532
-1452
lines changed

.dev/log_collector/readme.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ markdown_file ='markdowns/lr_in_trans.json.md'
4343
json_file = 'jsons/trans_in_cnn.json'
4444
```
4545

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

4848
```text
4949
├── work-dir
@@ -69,14 +69,15 @@ python log_collector.py ./example_config.py
6969

7070
The output markdown file is like:
7171

72-
|exp_num|method|mIoU best|best index|mIoU last|last index|last iter num|
73-
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
74-
|1|segformer_mit-b5_512x512_160k_ade20k_cnn_lr_with_warmup|0.2776|10|0.2776|10|160000|
75-
|2|segformer_mit-b5_512x512_160k_ade20k_cnn_no_warmup_lr|0.2802|10|0.2802|10|160000|
76-
|3|segformer_mit-b5_512x512_160k_ade20k_mit_trans_lr|0.4943|11|0.4943|11|160000|
77-
|4|segformer_mit-b5_512x512_160k_ade20k_swin_trans_lr|0.4883|11|0.4883|11|160000|
72+
| exp_num | method | mIoU best | best index | mIoU last | last index | last iter num |
73+
| :-----: | :-----------------------------------------------------: | :-------: | :--------: | :-------: | :--------: | :-----------: |
74+
| 1 | segformer_mit-b5_512x512_160k_ade20k_cnn_lr_with_warmup | 0.2776 | 10 | 0.2776 | 10 | 160000 |
75+
| 2 | segformer_mit-b5_512x512_160k_ade20k_cnn_no_warmup_lr | 0.2802 | 10 | 0.2802 | 10 | 160000 |
76+
| 3 | segformer_mit-b5_512x512_160k_ade20k_mit_trans_lr | 0.4943 | 11 | 0.4943 | 11 | 160000 |
77+
| 4 | segformer_mit-b5_512x512_160k_ade20k_swin_trans_lr | 0.4883 | 11 | 0.4883 | 11 | 160000 |
7878

7979
The output json file is like:
80+
8081
```json
8182
[
8283
{

.dev/md2yml.py

+34-8
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@
1212
import re
1313
import sys
1414

15-
import mmcv
1615
from lxml import etree
16+
from mmcv.fileio import dump
1717

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

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

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

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

91-
with open(md_file, 'r') as md:
100+
with open(md_file, 'r', encoding='UTF-8') as md:
92101
lines = md.readlines()
93102
i = 0
94103
current_dataset = ''
@@ -127,8 +136,9 @@ def parse_md(md_file):
127136
elif line[:15] == '<!-- [BACKBONE]':
128137
is_backbone = True
129138
i += 1
130-
elif line[0] == '|' and (
131-
i + 1) < len(lines) and lines[i + 1][:3] == '| -':
139+
elif (line[0] == '|' and (i + 1) < len(lines)
140+
and lines[i + 1][:3] == '| -' and 'Method' in line
141+
and 'Crop Size' in line and 'Mem (GB)' in line):
132142
cols = [col.strip() for col in line.split('|')]
133143
method_id = cols.index('Method')
134144
backbone_id = cols.index('Backbone')
@@ -246,11 +256,21 @@ def parse_md(md_file):
246256
collection.pop(check_key)
247257
else:
248258
collection[check_key].pop(key)
259+
yml_file = f'{md_file[:-9]}{collection_name}.yml'
249260
if is_backbone:
250-
result = {'Models': models}
261+
if collection['Name'] not in COLLECTIONS:
262+
result = {
263+
'Collections': [collection],
264+
'Models': models,
265+
'Yml': yml_file
266+
}
267+
COLLECTIONS_TEMP.append(result)
268+
return False
269+
else:
270+
result = {'Models': models}
251271
else:
272+
COLLECTIONS.append(collection['Name'])
252273
result = {'Collections': [collection], 'Models': models}
253-
yml_file = f'{md_file[:-9]}{collection_name}.yml'
254274
return dump_yaml_and_check_difference(result, yml_file)
255275

256276

@@ -286,6 +306,12 @@ def update_model_index():
286306
for fn in file_list:
287307
file_modified |= parse_md(fn)
288308

289-
file_modified |= update_model_index()
309+
for result in COLLECTIONS_TEMP:
310+
collection = result['Collections'][0]
311+
yml_file = result.pop('Yml', None)
312+
if collection['Name'] in COLLECTIONS:
313+
result.pop('Collections')
314+
file_modified |= dump_yaml_and_check_difference(result, yml_file)
290315

316+
file_modified |= update_model_index()
291317
sys.exit(1 if file_modified else 0)

.github/CODE_OF_CONDUCT.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

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

2323
Examples of unacceptable behavior by participants include:
2424

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

3434
## Our Responsibilities
3535

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

73-
[homepage]: https://www.contributor-covenant.org
74-
7573
For answers to common questions about this code of conduct, see
7674
https://www.contributor-covenant.org/faq
75+
76+
[homepage]: https://www.contributor-covenant.org

.github/CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ All kinds of contributions are welcome, including but not limited to the followi
1616

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

2222
## Code style
2323

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

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

4040
After you clone the repository, you will need to install initialize pre-commit hook.
@@ -51,7 +51,7 @@ pre-commit install
5151

5252
After this on every commit check code linters and formatter will be enforced.
5353

54-
>Before you create a PR, make sure that your code lints and is formatted by yapf.
54+
> Before you create a PR, make sure that your code lints and is formatted by yapf.
5555
5656
### C++ and CUDA
5757

.github/ISSUE_TEMPLATE/error-report.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Create a report to help us improve
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

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

2221
1. What command or script did you run?
2322

24-
```none
25-
A placeholder for the command.
26-
```
23+
```none
24+
A placeholder for the command.
25+
```
2726

2827
2. Did you make any modifications on the code or config? Did you understand what you have modified?
28+
2929
3. What dataset did you use?
3030

3131
**Environment**
3232

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

3838
**Error traceback**
3939

.github/ISSUE_TEMPLATE/feature_request.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ about: Suggest an idea for this project
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

109
# Describe the feature
1110

1211
**Motivation**
1312
A clear and concise description of the motivation of the feature.
14-
Ex1. It is inconvenient when [....].
15-
Ex2. There is a recent paper [....], which is very helpful for [....].
13+
Ex1. It is inconvenient when \[....\].
14+
Ex2. There is a recent paper \[....\], which is very helpful for \[....\].
1615

1716
**Related resources**
1817
If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful.

.github/ISSUE_TEMPLATE/general_questions.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ about: Ask general questions to get help
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---

.github/ISSUE_TEMPLATE/reimplementation_questions.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
name: Reimplementation Questions
33
about: Ask about questions during model reimplementation
44
title: ''
5-
labels: 'reimplementation'
5+
labels: reimplementation
66
assignees: ''
7-
87
---
98

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

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

6059
**Results**

.pre-commit-config.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
default_language_version:
2-
ruby: 2.7.1
3-
41
repos:
52
- repo: https://gitlab.com/pycqa/flake8.git
63
rev: 3.8.3
@@ -27,12 +24,15 @@ repos:
2724
args: ["--remove"]
2825
- id: mixed-line-ending
2926
args: ["--fix=lf"]
30-
- repo: https://github.com/markdownlint/markdownlint
31-
rev: v0.11.0
32-
hooks:
33-
- id: markdownlint
34-
args: ["-r", "~MD002,~MD013,~MD029,~MD033,~MD034",
35-
"-t", "allow_different_nesting"]
27+
- repo: https://github.com/executablebooks/mdformat
28+
rev: 0.7.9
29+
hooks:
30+
- id: mdformat
31+
args: ["--number"]
32+
additional_dependencies:
33+
- mdformat-openmmlab
34+
- mdformat_frontmatter
35+
- linkify-it-py
3636
- repo: https://github.com/codespell-project/codespell
3737
rev: v2.1.0
3838
hooks:
@@ -48,7 +48,7 @@ repos:
4848
name: update-model-index
4949
description: Collect model information and update model-index.yml
5050
entry: .dev/md2yml.py
51-
additional_dependencies: [mmcv, lxml]
51+
additional_dependencies: [mmcv, lxml, opencv-python]
5252
language: python
5353
files: ^configs/.*\.md$
5454
require_serial: true

README_zh-CN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ MMSegmentation 是一个由来自不同高校和企业的研发人员共同参
202202

203203
## 欢迎加入 OpenMMLab 社区
204204

205-
扫描下方的二维码可关注 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 群。
205+
扫描下方的二维码可关注 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 群。
206206

207-
<div align="center">
207+
<div align="center">
208208
<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" />
209209
</div>
210210

211-
我们会在 OpenMMLab 社区为大家
211+
我们会在 OpenMMLab 社区为大家
212212

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

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

0 commit comments

Comments
 (0)