Skip to content

Commit deccc1d

Browse files
authored
[Feature] Update metafile and update_model_index.py (open-mmlab#615)
* Update metafile * Update * Update * add print * Update * Solve the difference of 'sort by length' between local and CI
1 parent 9ea4bd3 commit deccc1d

File tree

28 files changed

+171
-82
lines changed

28 files changed

+171
-82
lines changed

.dev_scripts/github/update_model_index.py

+50-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
# detected before a commit.
88

99
import glob
10+
import os
1011
import os.path as osp
1112
import re
1213
import sys
1314
import warnings
15+
from functools import reduce
1416

1517
import mmcv
1618

@@ -76,7 +78,7 @@ def get_task_name(md_file):
7678
"""Get task name from README.md".
7779
7880
Args:
79-
md_file: Path to .md file.
81+
md_file (str): Path to .md file.
8082
8183
Returns:
8284
Str: Task name.
@@ -88,14 +90,50 @@ def get_task_name(md_file):
8890
return 'Unknown'
8991

9092

93+
def generate_unique_name(md_file):
94+
"""Search config files and return the unique name of them.
95+
For Confin.Name.
96+
97+
Args:
98+
md_file (str): Path to .md file.
99+
Returns:
100+
dict: dict of unique name for each config file.
101+
"""
102+
files = os.listdir(osp.dirname(md_file))
103+
config_files = [f[:-3] for f in files if f[-3:] == '.py']
104+
config_files.sort()
105+
config_files.sort(key=lambda x: len(x))
106+
split_names = [f.split('_') for f in config_files]
107+
config_sets = [set(f.split('_')) for f in config_files]
108+
common_set = reduce(lambda x, y: x & y, config_sets)
109+
unique_lists = [[n for n in name if n not in common_set]
110+
for name in split_names]
111+
112+
unique_dict = dict()
113+
name_list = []
114+
for i, f in enumerate(config_files):
115+
base = split_names[i][0]
116+
unique_dict[f] = base
117+
if len(unique_lists[i]) > 0:
118+
for unique in unique_lists[i]:
119+
candidate_name = f'{base}_{unique}'
120+
if candidate_name not in name_list and base != unique:
121+
unique_dict[f] = candidate_name
122+
name_list.append(candidate_name)
123+
break
124+
return unique_dict
125+
126+
91127
def parse_md(md_file):
92128
"""Parse .md file and convert it to a .yml file which can be used for MIM.
93129
94130
Args:
95-
md_file: Path to .md file.
131+
md_file (str): Path to .md file.
96132
Returns:
97133
Bool: If the target YAML file is different from the original.
98134
"""
135+
unique_dict = generate_unique_name(md_file)
136+
99137
collection_name = osp.splitext(osp.basename(md_file))[0]
100138
collection = dict(
101139
Name=collection_name,
@@ -125,7 +163,8 @@ def parse_md(md_file):
125163

126164
# parse table
127165
elif lines[i][0] == '|' and i + 1 < len(lines) and \
128-
(lines[i + 1][:3] == '| :' or lines[i + 1][:2] == '|:'):
166+
(lines[i + 1][:3] == '| :' or lines[i + 1][:2] == '|:'
167+
or lines[i + 1][:2] == '|-'):
129168
cols = [col.strip() for col in lines[i].split('|')][1:-1]
130169
config_idx = cols.index('Method')
131170
checkpoint_idx = cols.index('Download')
@@ -157,8 +196,14 @@ def parse_md(md_file):
157196
right = line[checkpoint_idx].index(')', left)
158197
checkpoint = line[checkpoint_idx][left:right]
159198

160-
model_name = osp.splitext(config)[0].replace(
161-
'configs/', '', 1).replace('/', '--')
199+
name_key = osp.splitext(osp.basename(config))[0]
200+
if name_key in unique_dict:
201+
model_name = unique_dict[name_key]
202+
else:
203+
model_name = name_key
204+
warnings.warn(
205+
f'Config file of {model_name} is not found,'
206+
'please check it again.')
162207

163208
# find dataset in config file
164209
dataset = 'Others'

configs/inpainting/deepfillv1/metafile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: DeepFillv1
1212
Metadata:
1313
Training Data: PLACES
14-
Name: inpainting--deepfillv1--deepfillv1_256x256_8x2_places
14+
Name: deepfillv1_8x2
1515
Results:
1616
- Dataset: PLACES
1717
Metrics:
@@ -24,7 +24,7 @@ Models:
2424
In Collection: DeepFillv1
2525
Metadata:
2626
Training Data: CELEBA
27-
Name: inpainting--deepfillv1--deepfillv1_256x256_4x4_celeba
27+
Name: deepfillv1_4x4
2828
Results:
2929
- Dataset: CELEBA
3030
Metrics:

configs/inpainting/deepfillv2/metafile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: DeepFillv2
1212
Metadata:
1313
Training Data: PLACES
14-
Name: inpainting--deepfillv2--deepfillv2_256x256_8x2_places
14+
Name: deepfillv2_places
1515
Results:
1616
- Dataset: PLACES
1717
Metrics:
@@ -24,7 +24,7 @@ Models:
2424
In Collection: DeepFillv2
2525
Metadata:
2626
Training Data: CELEBA
27-
Name: inpainting--deepfillv2--deepfillv2_256x256_8x2_celeba
27+
Name: deepfillv2_celeba
2828
Results:
2929
- Dataset: CELEBA
3030
Metrics:

configs/inpainting/global_local/metafile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: Global&Local
1212
Metadata:
1313
Training Data: PLACES
14-
Name: inpainting--global_local--gl_256x256_8x12_places
14+
Name: gl_places
1515
Results:
1616
- Dataset: PLACES
1717
Metrics:
@@ -24,7 +24,7 @@ Models:
2424
In Collection: Global&Local
2525
Metadata:
2626
Training Data: CELEBA
27-
Name: inpainting--global_local--gl_256x256_8x12_celeba
27+
Name: gl_celeba
2828
Results:
2929
- Dataset: CELEBA
3030
Metrics:

configs/inpainting/partial_conv/metafile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: PConv
1212
Metadata:
1313
Training Data: PLACES
14-
Name: inpainting--partial_conv--pconv_256x256_stage2_4x2_places
14+
Name: pconv_4x2
1515
Results:
1616
- Dataset: PLACES
1717
Metrics:
@@ -24,7 +24,7 @@ Models:
2424
In Collection: PConv
2525
Metadata:
2626
Training Data: CELEBA
27-
Name: inpainting--partial_conv--pconv_256x256_stage2_4x2_celeba
27+
Name: pconv_stage2
2828
Results:
2929
- Dataset: CELEBA
3030
Metrics:

configs/mattors/dim/metafile.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: DIM
1212
Metadata:
1313
Training Data: COMP1K
14-
Name: mattors--dim--dim_stage1_v16_1x1_1000k_comp1k
14+
Name: dim_stage1
1515
Results:
1616
- Dataset: COMP1K
1717
Metrics:
@@ -25,7 +25,7 @@ Models:
2525
In Collection: DIM
2626
Metadata:
2727
Training Data: COMP1K
28-
Name: mattors--dim--dim_stage2_v16_pln_1x1_1000k_comp1k
28+
Name: dim_stage2
2929
Results:
3030
- Dataset: COMP1K
3131
Metrics:
@@ -39,7 +39,7 @@ Models:
3939
In Collection: DIM
4040
Metadata:
4141
Training Data: COMP1K
42-
Name: mattors--dim--dim_stage3_v16_pln_1x1_1000k_comp1k
42+
Name: dim_stage3
4343
Results:
4444
- Dataset: COMP1K
4545
Metrics:

configs/mattors/gca/metafile.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: GCA
1212
Metadata:
1313
Training Data: COMP1K
14-
Name: mattors--gca--baseline_r34_4x10_200k_comp1k
14+
Name: baseline
1515
Results:
1616
- Dataset: COMP1K
1717
Metrics:
@@ -25,7 +25,7 @@ Models:
2525
In Collection: GCA
2626
Metadata:
2727
Training Data: COMP1K
28-
Name: mattors--gca--gca_r34_4x10_200k_comp1k
28+
Name: gca
2929
Results:
3030
- Dataset: COMP1K
3131
Metrics:
@@ -39,7 +39,7 @@ Models:
3939
In Collection: GCA
4040
Metadata:
4141
Training Data: COMP1K
42-
Name: mattors--gca--baseline_dimaug_r34_4x10_200k_comp1k
42+
Name: baseline_dimaug
4343
Results:
4444
- Dataset: COMP1K
4545
Metrics:
@@ -53,7 +53,7 @@ Models:
5353
In Collection: GCA
5454
Metadata:
5555
Training Data: COMP1K
56-
Name: mattors--gca--gca_dimaug_r34_4x10_200k_comp1k
56+
Name: gca_dimaug
5757
Results:
5858
- Dataset: COMP1K
5959
Metrics:

configs/mattors/indexnet/metafile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: IndexNet
1212
Metadata:
1313
Training Data: COMP1K
14-
Name: mattors--indexnet--indexnet_mobv2_1x16_78k_comp1k
14+
Name: indexnet
1515
Results:
1616
- Dataset: COMP1K
1717
Metrics:
@@ -25,7 +25,7 @@ Models:
2525
In Collection: IndexNet
2626
Metadata:
2727
Training Data: COMP1K
28-
Name: mattors--indexnet--indexnet_dimaug_mobv2_1x16_78k_comp1k
28+
Name: indexnet_dimaug
2929
Results:
3030
- Dataset: COMP1K
3131
Metrics:

configs/restorers/basicvsr/metafile.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: BasicVSR
1212
Metadata:
1313
Training Data: REDS
14-
Name: https:----github.com--open-mmlab--mmediting--blob--master--restorers--basicvsr--basicvsr_reds4
14+
Name: basicvsr_reds4
1515
Results:
1616
- Dataset: REDS
1717
Metrics:
@@ -39,7 +39,7 @@ Models:
3939
In Collection: BasicVSR
4040
Metadata:
4141
Training Data: VIMEO90K
42-
Name: https:----github.com--open-mmlab--mmediting--blob--master--restorers--basicvsr--basicvsr_vimeo90k_bi
42+
Name: basicvsr_bi
4343
Results:
4444
- Dataset: VIMEO90K
4545
Metrics:
@@ -67,7 +67,7 @@ Models:
6767
In Collection: BasicVSR
6868
Metadata:
6969
Training Data: VIMEO90K
70-
Name: https:----github.com--open-mmlab--mmediting--blob--master--restorers--basicvsr--basicvsr_vimeo90k_bd
70+
Name: basicvsr_vimeo90k
7171
Results:
7272
- Dataset: VIMEO90K
7373
Metrics:

configs/restorers/basicvsr_plusplus/metafile.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: BasicVSR++
1212
Metadata:
1313
Training Data: REDS
14-
Name: restorers--basicvsr--basicvsr_plusplus_c64n7_8x1_600k_reds4
14+
Name: basicvsr_c64n7
1515
Results:
1616
- Dataset: REDS
1717
Metrics:
@@ -39,7 +39,7 @@ Models:
3939
In Collection: BasicVSR++
4040
Metadata:
4141
Training Data: VIMEO90K
42-
Name: restorers--basicvsr--basicvsr_plusplus_c64n7_4x2_300k_vimeo90k_bi
42+
Name: basicvsr_300k
4343
Results:
4444
- Dataset: VIMEO90K
4545
Metrics:
@@ -67,7 +67,7 @@ Models:
6767
In Collection: BasicVSR++
6868
Metadata:
6969
Training Data: VIMEO90K
70-
Name: restorers--basicvsr--basicvsr_plusplus_c64n7_4x2_300k_vimeo90k_bd
70+
Name: basicvsr_4x2
7171
Results:
7272
- Dataset: VIMEO90K
7373
Metrics:

configs/restorers/dic/metafile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: DIC
1212
Metadata:
1313
Training Data: CELEBA
14-
Name: restorers--dic--dic_x8c48b6_g4_150k_CelebAHQ
14+
Name: dic_150k
1515
Results:
1616
- Dataset: CELEBA
1717
Metrics:
@@ -24,7 +24,7 @@ Models:
2424
In Collection: DIC
2525
Metadata:
2626
Training Data: CELEBA
27-
Name: restorers--dic--dic_gan_x8c48b6_g4_500k_CelebAHQ
27+
Name: dic_gan
2828
Results:
2929
- Dataset: CELEBA
3030
Metrics:

configs/restorers/edsr/metafile.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: EDSR
1212
Metadata:
1313
Training Data: DIV2K
14-
Name: restorers--edsr--edsr_x2c64b16_g1_300k_div2k
14+
Name: edsr_x2c64b16
1515
Results:
1616
- Dataset: DIV2K
1717
Metrics:
@@ -30,7 +30,7 @@ Models:
3030
In Collection: EDSR
3131
Metadata:
3232
Training Data: DIV2K
33-
Name: restorers--edsr--edsr_x3c64b16_g1_300k_div2k
33+
Name: edsr_x3c64b16
3434
Results:
3535
- Dataset: DIV2K
3636
Metrics:
@@ -49,7 +49,7 @@ Models:
4949
In Collection: EDSR
5050
Metadata:
5151
Training Data: DIV2K
52-
Name: restorers--edsr--edsr_x4c64b16_g1_300k_div2k
52+
Name: edsr_x4c64b16
5353
Results:
5454
- Dataset: DIV2K
5555
Metrics:

configs/restorers/edvr/metafile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: EDVR
1212
Metadata:
1313
Training Data: REDS
14-
Name: restorers--edvr--edvrm_wotsa_x4_g8_600k_reds
14+
Name: edvrm_wotsa
1515
Results:
1616
- Dataset: REDS
1717
Metrics:
@@ -24,7 +24,7 @@ Models:
2424
In Collection: EDVR
2525
Metadata:
2626
Training Data: REDS
27-
Name: restorers--edvr--edvrm_x4_g8_600k_reds
27+
Name: edvrm
2828
Results:
2929
- Dataset: REDS
3030
Metrics:

configs/restorers/esrgan/metafile.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Models:
1111
In Collection: ESRGAN
1212
Metadata:
1313
Training Data: DIV2K
14-
Name: restorers--esrgan--esrgan_psnr_x4c64b23g32_g1_1000k_div2k
14+
Name: esrgan_psnr
1515
Results:
1616
- Dataset: DIV2K
1717
Metrics:
@@ -30,7 +30,7 @@ Models:
3030
In Collection: ESRGAN
3131
Metadata:
3232
Training Data: DIV2K
33-
Name: restorers--esrgan--esrgan_x4c64b23g32_g1_400k_div2k
33+
Name: esrgan_400k
3434
Results:
3535
- Dataset: DIV2K
3636
Metrics:

configs/restorers/glean/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ We show that pre-trained Generative Adversarial Networks (GANs), e.g., StyleGAN,
2828
For the meta info used in training and test, please refer to [here](https://github.com/ckkelvinchan/GLEAN). The results are evaluated on RGB channels.
2929

3030
| Method | PSNR | Download |
31-
|--------------------------------------------------------------------------------------------------------------------|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
31+
| :----------------------------------------------------------------------------------------------------------------: | :---: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
3232
| [glean_cat_8x](/configs/restorers/glean/glean_cat_8x.py) | 23.98 | [model](https://download.openmmlab.com/mmediting/restorers/glean/glean_cat_8x_20210614-d3ac8683.pth) \| [log](https://download.openmmlab.com/mmediting/restorers/glean/glean_cat_8x_20210614_145540.log.json) |
3333
| [glean_ffhq_16x](/configs/restorers/glean/glean_ffhq_16x.py) | 26.91 | [model](https://download.openmmlab.com/mmediting/restorers/glean/glean_ffhq_16x_20210527-61a3afad.pth) \| [log](https://download.openmmlab.com/mmediting/restorers/glean/glean_ffhq_16x_20210527_194536.log.json) |
3434
| [glean_cat_16x](/configs/restorers/glean/glean_cat_16x.py) | 20.88 | [model](https://download.openmmlab.com/mmediting/restorers/glean/glean_cat_16x_20210527-68912543.pth) \| [log](https://download.openmmlab.com/mmediting/restorers/glean/glean_cat_16x_20210527_103708.log.json) |

0 commit comments

Comments
 (0)