Skip to content

Commit e7c0539

Browse files
authored
Merge pull request #1566 from open-mmlab/dev-1.x
bump version to v1.0.0rc5
2 parents 1735f5c + 740757f commit e7c0539

File tree

510 files changed

+19283
-5513
lines changed

Some content is hidden

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

510 files changed

+19283
-5513
lines changed

.circleci/config.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ workflows:
2323
mmedit/.* lint_only false
2424
requirements/.* lint_only false
2525
tests/.* lint_only false
26-
tools/.* lint_only false
27-
configs/.* lint_only false
2826
.circleci/.* lint_only false
27+
tools/.* lint_only true
28+
configs/.* lint_only true
29+
docs/.* lint_only true
2930
.dev_scripts/.* lint_only true
30-
base-revision: 1.x
31+
.github/.* lint_only true
32+
demo/.* lint_only true
33+
projects/.* lint_only true
34+
base-revision: dev-1.x
3135
# this is the path of the configuration we should trigger once
3236
# path filtering and pipeline parameter value updates are
3337
# complete. In this case, we are using the parent dynamic

.circleci/test.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ jobs:
5959
- run:
6060
name: Install mmediting dependencies
6161
command: |
62+
pip install 'opencv-python!=4.7.0.68'
6263
pip install git+https://github.com/open-mmlab/mmengine.git@main
6364
pip install -U openmim
6465
mim install 'mmcv >= 2.0.0rc1'
65-
mim install 'mmdet >= 3.0.0rc2'
6666
pip install -r requirements/tests.txt
67-
pip install git+https://github.com/openai/CLIP.git
68-
pip install imageio-ffmpeg
6967
- run:
7068
name: Build and install
7169
command: |
@@ -105,13 +103,11 @@ jobs:
105103
- run:
106104
name: Install mmedit dependencies
107105
command: |
106+
docker exec mmedit pip install 'opencv-python!=4.7.0.68'
108107
docker exec mmedit pip install -e /mmengine
109108
docker exec mmedit pip install -U openmim
110109
docker exec mmedit mim install 'mmcv >= 2.0.0rc1'
111-
docker exec mmedit mim install 'mmdet >= 3.0.0rc2'
112110
docker exec mmedit pip install -r requirements/tests.txt
113-
docker exec mmedit pip install git+https://github.com/openai/CLIP.git
114-
docker exec mmedit pip install imageio-ffmpeg
115111
- run:
116112
name: Build and install
117113
command: |
@@ -131,7 +127,6 @@ workflows:
131127
branches:
132128
ignore:
133129
- dev-1.x
134-
- test-1.x
135130
- 1.x
136131
pr_stage_test:
137132
when:
@@ -144,7 +139,6 @@ workflows:
144139
branches:
145140
ignore:
146141
- dev-1.x
147-
- test-1.x
148142
- 1.x
149143
- build_cpu:
150144
name: minimum_version_cpu
@@ -155,8 +149,8 @@ workflows:
155149
- lint
156150
- build_cpu:
157151
name: maximum_version_cpu
158-
torch: 1.12.1
159-
torchvision: 0.13.1
152+
torch: 1.13.0
153+
torchvision: 0.14.0
160154
python: 3.9.0
161155
requires:
162156
- minimum_version_cpu
@@ -187,5 +181,3 @@ workflows:
187181
branches:
188182
only:
189183
- dev-1.x
190-
- test-1.x
191-
- 1.x

.dev_scripts/README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Scripts for developing MMEditing
22

3-
- [1. Check UT](#check-ut)
4-
- [2. Test all the models](#test-benchmark)
3+
- [1. Check UT](#1-check-ut)
4+
- [2. Test all the models](#2-test-all-the-models)
55
- [3. Train all the models](#3-train-all-the-models)
66
- [3.1 Train for debugging](#31-train-for-debugging)
77
- [3.2 Train for FP32](#32-train-for-fp32)
88
- [3.3 Train for FP16](#33-train-for-fp16)
99
- [4. Monitor your training](#4-monitor-your-training)
1010
- [5. Train with a list of models](#5-train-with-a-list-of-models)
1111
- [6. Train with skipping a list of models](#6-train-with-skipping-a-list-of-models)
12-
- [7. Automatically check links](#automatically-check-links)
12+
- [7. Train failed or canceled jobs](#7-train-failed-or-canceled-jobs)
13+
- [8. Deterministic training](#8-deterministic-training)
14+
- [9. Automatically check links](#9-automatically-check-links)
15+
- [10. Calculate flops](#10-calculate-flops)
16+
- [11. Update model idnex](#11-update-model-index)
1317

1418
## 1. Check UT
1519

@@ -224,12 +228,28 @@ python .dev_scripts/train_benchmark.py mm_lol --job-name xzn --models pix2pix --
224228
Use the following script to check whether the links in documentations are valid:
225229

226230
```shell
227-
python3 .github/scripts/doc_link_checker.py --target docs/zh_cn
228-
python3 .github/scripts/doc_link_checker.py --target README_zh-CN.md
229-
python3 .github/scripts/doc_link_checker.py --target docs/en
230-
python3 .github/scripts/doc_link_checker.py --target README.md
231+
python .dev_scripts/doc_link_checker.py --target docs/zh_cn
232+
python .dev_scripts/doc_link_checker.py --target README_zh-CN.md
233+
python .dev_scripts/doc_link_checker.py --target docs/en
234+
python .dev_scripts/doc_link_checker.py --target README.md
231235
```
232236

233237
You can specify the `--target` by a file or a directory.
234238

235239
**Notes:** DO NOT use it in CI, because requiring too many http requirements by CI will cause 503 and CI will propabaly fail.
240+
241+
## 10. Calculate flops
242+
243+
To summarize the flops of different models, you can run the following commands:
244+
245+
```bash
246+
python .dev_scripts/benchmark_valid_flop.py --flops --flops-str
247+
```
248+
249+
## 11. Update model index
250+
251+
To update model-index according to `README.md`, please run the following commands,
252+
253+
```bash
254+
python .dev_scripts/update_model_index.py
255+
```

.dev_scripts/doc_link_checker.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
# Copyright (c) MegFlow. All rights reserved.
2+
# Copyright (c) OpenMMLab. All rights reserved.
23
# /bin/python3
34

45
import argparse
56
import os
67
import re
78

9+
import requests
10+
from tqdm import tqdm
11+
812

913
def make_parser():
1014
parser = argparse.ArgumentParser('Doc link checker')
11-
parser.add_argument(
12-
'--http', default=False, type=bool, help='check http or not ')
1315
parser.add_argument(
1416
'--target',
1517
default='./docs',
1618
type=str,
1719
help='the directory or file to check')
20+
parser.add_argument(
21+
'--ignore', type=str, nargs='+', default=[], help='input image size')
1822
return parser
1923

2024

2125
pattern = re.compile(r'\[.*?\]\(.*?\)')
2226

2327

2428
def analyze_doc(home, path):
25-
print('analyze {}'.format(path))
2629
problem_list = []
2730
code_block = 0
2831
with open(path) as f:
@@ -51,11 +54,31 @@ def analyze_doc(home, path):
5154
end = item.find(')')
5255
ref = item[start + 1:end]
5356

54-
if ref.startswith('http') or ref.startswith('#'):
57+
if ref.startswith('http'):
58+
if ref.startswith(
59+
'https://download.openmmlab.com/'
60+
) or ref.startswith('http://download.openmmlab.com/'):
61+
resp = requests.head(ref)
62+
if resp.status_code == 200:
63+
continue
64+
else:
65+
problem_list.append(ref)
66+
else:
67+
continue
68+
69+
if ref.startswith('#'):
5570
continue
71+
72+
if ref == '<>':
73+
continue
74+
5675
if '.md#' in ref:
57-
ref = ref[ref.find('#'):]
58-
fullpath = os.path.join(home, ref)
76+
ref = ref[:ref.find('#')]
77+
if ref.startswith('/'):
78+
fullpath = os.path.join(
79+
os.path.dirname(__file__), '../', ref[1:])
80+
else:
81+
fullpath = os.path.join(home, ref)
5982
if not os.path.exists(fullpath):
6083
problem_list.append(ref)
6184
else:
@@ -68,11 +91,16 @@ def analyze_doc(home, path):
6891
raise Exception('found link error')
6992

7093

71-
def traverse(target):
94+
def traverse(args):
95+
target = args.target
7296
if os.path.isfile(target):
7397
analyze_doc(os.path.dirname(target), target)
7498
return
75-
for home, dirs, files in os.walk(target):
99+
target_files = list(os.walk(target))
100+
target_files.sort()
101+
for home, dirs, files in tqdm(target_files):
102+
if home in args.ignore:
103+
continue
76104
for filename in files:
77105
if filename.endswith('.md'):
78106
path = os.path.join(home, filename)
@@ -82,4 +110,4 @@ def traverse(target):
82110

83111
if __name__ == '__main__':
84112
args = make_parser().parse_args()
85-
traverse(args.target)
113+
traverse(args)

.dev_scripts/download_models.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ def download(args):
7474
model_index.build_models_with_collections()
7575
models = OrderedDict({model.name: model for model in model_index.models})
7676

77-
http_prefix_long = 'https://openmmlab-share.oss-cn-hangzhou.aliyuncs.com/mmediting/' # noqa
7877
http_prefix_short = 'https://download.openmmlab.com/mmediting/'
79-
http_prefix_gen = 'https://download.openmmlab.com/mmgen/'
8078

8179
# load model list
8280
if args.model_list:
@@ -109,12 +107,8 @@ def download(args):
109107

110108
model_weight_url = model_info.weights
111109

112-
if model_weight_url.startswith(http_prefix_long):
113-
model_name = model_weight_url[len(http_prefix_long):]
114-
elif model_weight_url.startswith(http_prefix_short):
110+
if model_weight_url.startswith(http_prefix_short):
115111
model_name = model_weight_url[len(http_prefix_short):]
116-
elif model_weight_url.startswith(http_prefix_gen):
117-
model_name = model_weight_url[len(http_prefix_gen):]
118112
elif model_weight_url == '':
119113
print(f'{model_info.Name} weight is missing')
120114
return None

.dev_scripts/test_benchmark.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,10 @@ def create_test_job_batch(commands, model_info, args, port, script_name):
9999
assert config.exists(), f'{fname}: {config} not found.'
100100

101101
http_prefix_short = 'https://download.openmmlab.com/mmediting/'
102-
http_prefix_long = 'https://openmmlab-share.oss-cn-hangzhou.aliyuncs.com/mmediting/' # noqa
103-
http_prefix_gen = 'https://download.openmmlab.com/mmgen/'
104102
model_weight_url = model_info.weights
105103

106-
if model_weight_url.startswith(http_prefix_long):
107-
model_name = model_weight_url[len(http_prefix_long):]
108-
elif model_weight_url.startswith(http_prefix_short):
104+
if model_weight_url.startswith(http_prefix_short):
109105
model_name = model_weight_url[len(http_prefix_short):]
110-
elif model_weight_url.startswith(http_prefix_gen):
111-
model_name = model_weight_url[len(http_prefix_gen):]
112106
elif model_weight_url == '':
113107
print(f'{fname} weight is missing')
114108
return None

.dev_scripts/update_model_index.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def dump_yaml_and_check_difference(obj, file):
4141

4242
if osp.isfile(file):
4343
file_exists = True
44-
print(f' exist {file}')
44+
# print(f' exist {file}')
4545
with open(file, 'r', encoding='utf-8') as f:
4646
str_orig = f.read()
4747
else:
@@ -144,20 +144,26 @@ def parse_md(md_file):
144144
Name=collection_name,
145145
Metadata={'Architecture': []},
146146
README=readme,
147-
Paper=[])
147+
Paper=[],
148+
Task=[],
149+
Year=0,
150+
)
148151
models = []
149152
# force utf-8 instead of system defined
150153
with open(md_file, 'r', encoding='utf-8') as md:
151154
lines = md.readlines()
152155
i = 0
153156
name = lines[0][2:]
157+
year = re.sub('[^0-9]', '', name.split('(', 1)[-1])
154158
name = name.split('(', 1)[0].strip()
155159
collection['Metadata']['Architecture'].append(name)
156160
collection['Name'] = name
157161
collection_name = name
158162
is_liif = collection_name.upper() == 'LIIF'
159163
task_line = lines[4]
160164
task = task_line.strip().split(':')[-1].strip()
165+
collection['Task'] = task.lower().split(', ')
166+
collection['Year'] = int(year)
161167
while i < len(lines):
162168
# parse reference
163169
if lines[i].startswith('> ['):
@@ -177,16 +183,19 @@ def parse_md(md_file):
177183
# import ipdb
178184
# ipdb.set_trace()
179185
if 'Config' not in cols and 'Download' not in cols:
180-
warnings.warn(f"Lack 'Config' or 'Download' in line {i+1}")
186+
warnings.warn("Lack 'Config' or 'Download' in"
187+
f'line {i+1} in {md_file}')
181188
i += 1
182189
continue
190+
183191
if 'Method' in cols:
184192
config_idx = cols.index('Method')
185193
elif 'Config' in cols:
186194
config_idx = cols.index('Config')
187195
else:
188196
print(cols)
189197
raise ValueError('Cannot find config Table.')
198+
190199
checkpoint_idx = cols.index('Download')
191200
try:
192201
flops_idx = cols.index('FLOPs')
@@ -210,6 +219,8 @@ def parse_md(md_file):
210219
left = line[config_idx].index('](') + 2
211220
right = line[config_idx].index(')', left)
212221
config = line[config_idx][left:right].strip('./')
222+
config = osp.join(
223+
osp.dirname(md_file), osp.basename(config))
213224
elif line[config_idx].find('△') == -1:
214225
j += 1
215226
continue
@@ -315,7 +326,7 @@ def parse_md(md_file):
315326
i += 1
316327

317328
if len(models) == 0:
318-
warnings.warn('no model is found in this md file')
329+
warnings.warn(f'no model is found in {md_file}')
319330

320331
result = {'Collections': [collection], 'Models': models}
321332
yml_file = md_file.replace('README.md', 'metafile.yml')
@@ -363,9 +374,11 @@ def update_model_index():
363374
sys.exit(0)
364375

365376
file_modified = False
377+
# pbar = tqdm.tqdm(range(len(file_list)), initial=0, dynamic_ncols=True)
366378
for fn in file_list:
367-
print(f'process {fn}')
368379
file_modified |= parse_md(fn)
380+
# pbar.update(1)
381+
# pbar.set_description(f'processing {fn}')
369382

370383
file_modified |= update_model_index()
371384

0 commit comments

Comments
 (0)