Skip to content

Commit

Permalink
[Feature] Update metafile and update_model_index.py (#615)
Browse files Browse the repository at this point in the history
* Update metafile

* Update

* Update

* add print

* Update

* Solve the difference of 'sort by length' between local and CI
  • Loading branch information
Yshuo-Li authored Dec 1, 2021
1 parent 9ea4bd3 commit deccc1d
Show file tree
Hide file tree
Showing 28 changed files with 171 additions and 82 deletions.
55 changes: 50 additions & 5 deletions .dev_scripts/github/update_model_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
# detected before a commit.

import glob
import os
import os.path as osp
import re
import sys
import warnings
from functools import reduce

import mmcv

Expand Down Expand Up @@ -76,7 +78,7 @@ def get_task_name(md_file):
"""Get task name from README.md".
Args:
md_file: Path to .md file.
md_file (str): Path to .md file.
Returns:
Str: Task name.
Expand All @@ -88,14 +90,50 @@ def get_task_name(md_file):
return 'Unknown'


def generate_unique_name(md_file):
"""Search config files and return the unique name of them.
For Confin.Name.
Args:
md_file (str): Path to .md file.
Returns:
dict: dict of unique name for each config file.
"""
files = os.listdir(osp.dirname(md_file))
config_files = [f[:-3] for f in files if f[-3:] == '.py']
config_files.sort()
config_files.sort(key=lambda x: len(x))
split_names = [f.split('_') for f in config_files]
config_sets = [set(f.split('_')) for f in config_files]
common_set = reduce(lambda x, y: x & y, config_sets)
unique_lists = [[n for n in name if n not in common_set]
for name in split_names]

unique_dict = dict()
name_list = []
for i, f in enumerate(config_files):
base = split_names[i][0]
unique_dict[f] = base
if len(unique_lists[i]) > 0:
for unique in unique_lists[i]:
candidate_name = f'{base}_{unique}'
if candidate_name not in name_list and base != unique:
unique_dict[f] = candidate_name
name_list.append(candidate_name)
break
return unique_dict


def parse_md(md_file):
"""Parse .md file and convert it to a .yml file which can be used for MIM.
Args:
md_file: Path to .md file.
md_file (str): Path to .md file.
Returns:
Bool: If the target YAML file is different from the original.
"""
unique_dict = generate_unique_name(md_file)

collection_name = osp.splitext(osp.basename(md_file))[0]
collection = dict(
Name=collection_name,
Expand Down Expand Up @@ -125,7 +163,8 @@ def parse_md(md_file):

# parse table
elif lines[i][0] == '|' and i + 1 < len(lines) and \
(lines[i + 1][:3] == '| :' or lines[i + 1][:2] == '|:'):
(lines[i + 1][:3] == '| :' or lines[i + 1][:2] == '|:'
or lines[i + 1][:2] == '|-'):
cols = [col.strip() for col in lines[i].split('|')][1:-1]
config_idx = cols.index('Method')
checkpoint_idx = cols.index('Download')
Expand Down Expand Up @@ -157,8 +196,14 @@ def parse_md(md_file):
right = line[checkpoint_idx].index(')', left)
checkpoint = line[checkpoint_idx][left:right]

model_name = osp.splitext(config)[0].replace(
'configs/', '', 1).replace('/', '--')
name_key = osp.splitext(osp.basename(config))[0]
if name_key in unique_dict:
model_name = unique_dict[name_key]
else:
model_name = name_key
warnings.warn(
f'Config file of {model_name} is not found,'
'please check it again.')

# find dataset in config file
dataset = 'Others'
Expand Down
4 changes: 2 additions & 2 deletions configs/inpainting/deepfillv1/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: DeepFillv1
Metadata:
Training Data: PLACES
Name: inpainting--deepfillv1--deepfillv1_256x256_8x2_places
Name: deepfillv1_8x2
Results:
- Dataset: PLACES
Metrics:
Expand All @@ -24,7 +24,7 @@ Models:
In Collection: DeepFillv1
Metadata:
Training Data: CELEBA
Name: inpainting--deepfillv1--deepfillv1_256x256_4x4_celeba
Name: deepfillv1_4x4
Results:
- Dataset: CELEBA
Metrics:
Expand Down
4 changes: 2 additions & 2 deletions configs/inpainting/deepfillv2/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: DeepFillv2
Metadata:
Training Data: PLACES
Name: inpainting--deepfillv2--deepfillv2_256x256_8x2_places
Name: deepfillv2_places
Results:
- Dataset: PLACES
Metrics:
Expand All @@ -24,7 +24,7 @@ Models:
In Collection: DeepFillv2
Metadata:
Training Data: CELEBA
Name: inpainting--deepfillv2--deepfillv2_256x256_8x2_celeba
Name: deepfillv2_celeba
Results:
- Dataset: CELEBA
Metrics:
Expand Down
4 changes: 2 additions & 2 deletions configs/inpainting/global_local/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: Global&Local
Metadata:
Training Data: PLACES
Name: inpainting--global_local--gl_256x256_8x12_places
Name: gl_places
Results:
- Dataset: PLACES
Metrics:
Expand All @@ -24,7 +24,7 @@ Models:
In Collection: Global&Local
Metadata:
Training Data: CELEBA
Name: inpainting--global_local--gl_256x256_8x12_celeba
Name: gl_celeba
Results:
- Dataset: CELEBA
Metrics:
Expand Down
4 changes: 2 additions & 2 deletions configs/inpainting/partial_conv/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: PConv
Metadata:
Training Data: PLACES
Name: inpainting--partial_conv--pconv_256x256_stage2_4x2_places
Name: pconv_4x2
Results:
- Dataset: PLACES
Metrics:
Expand All @@ -24,7 +24,7 @@ Models:
In Collection: PConv
Metadata:
Training Data: CELEBA
Name: inpainting--partial_conv--pconv_256x256_stage2_4x2_celeba
Name: pconv_stage2
Results:
- Dataset: CELEBA
Metrics:
Expand Down
6 changes: 3 additions & 3 deletions configs/mattors/dim/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: DIM
Metadata:
Training Data: COMP1K
Name: mattors--dim--dim_stage1_v16_1x1_1000k_comp1k
Name: dim_stage1
Results:
- Dataset: COMP1K
Metrics:
Expand All @@ -25,7 +25,7 @@ Models:
In Collection: DIM
Metadata:
Training Data: COMP1K
Name: mattors--dim--dim_stage2_v16_pln_1x1_1000k_comp1k
Name: dim_stage2
Results:
- Dataset: COMP1K
Metrics:
Expand All @@ -39,7 +39,7 @@ Models:
In Collection: DIM
Metadata:
Training Data: COMP1K
Name: mattors--dim--dim_stage3_v16_pln_1x1_1000k_comp1k
Name: dim_stage3
Results:
- Dataset: COMP1K
Metrics:
Expand Down
8 changes: 4 additions & 4 deletions configs/mattors/gca/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: GCA
Metadata:
Training Data: COMP1K
Name: mattors--gca--baseline_r34_4x10_200k_comp1k
Name: baseline
Results:
- Dataset: COMP1K
Metrics:
Expand All @@ -25,7 +25,7 @@ Models:
In Collection: GCA
Metadata:
Training Data: COMP1K
Name: mattors--gca--gca_r34_4x10_200k_comp1k
Name: gca
Results:
- Dataset: COMP1K
Metrics:
Expand All @@ -39,7 +39,7 @@ Models:
In Collection: GCA
Metadata:
Training Data: COMP1K
Name: mattors--gca--baseline_dimaug_r34_4x10_200k_comp1k
Name: baseline_dimaug
Results:
- Dataset: COMP1K
Metrics:
Expand All @@ -53,7 +53,7 @@ Models:
In Collection: GCA
Metadata:
Training Data: COMP1K
Name: mattors--gca--gca_dimaug_r34_4x10_200k_comp1k
Name: gca_dimaug
Results:
- Dataset: COMP1K
Metrics:
Expand Down
4 changes: 2 additions & 2 deletions configs/mattors/indexnet/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: IndexNet
Metadata:
Training Data: COMP1K
Name: mattors--indexnet--indexnet_mobv2_1x16_78k_comp1k
Name: indexnet
Results:
- Dataset: COMP1K
Metrics:
Expand All @@ -25,7 +25,7 @@ Models:
In Collection: IndexNet
Metadata:
Training Data: COMP1K
Name: mattors--indexnet--indexnet_dimaug_mobv2_1x16_78k_comp1k
Name: indexnet_dimaug
Results:
- Dataset: COMP1K
Metrics:
Expand Down
6 changes: 3 additions & 3 deletions configs/restorers/basicvsr/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: BasicVSR
Metadata:
Training Data: REDS
Name: https:----github.com--open-mmlab--mmediting--blob--master--restorers--basicvsr--basicvsr_reds4
Name: basicvsr_reds4
Results:
- Dataset: REDS
Metrics:
Expand Down Expand Up @@ -39,7 +39,7 @@ Models:
In Collection: BasicVSR
Metadata:
Training Data: VIMEO90K
Name: https:----github.com--open-mmlab--mmediting--blob--master--restorers--basicvsr--basicvsr_vimeo90k_bi
Name: basicvsr_bi
Results:
- Dataset: VIMEO90K
Metrics:
Expand Down Expand Up @@ -67,7 +67,7 @@ Models:
In Collection: BasicVSR
Metadata:
Training Data: VIMEO90K
Name: https:----github.com--open-mmlab--mmediting--blob--master--restorers--basicvsr--basicvsr_vimeo90k_bd
Name: basicvsr_vimeo90k
Results:
- Dataset: VIMEO90K
Metrics:
Expand Down
6 changes: 3 additions & 3 deletions configs/restorers/basicvsr_plusplus/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: BasicVSR++
Metadata:
Training Data: REDS
Name: restorers--basicvsr--basicvsr_plusplus_c64n7_8x1_600k_reds4
Name: basicvsr_c64n7
Results:
- Dataset: REDS
Metrics:
Expand Down Expand Up @@ -39,7 +39,7 @@ Models:
In Collection: BasicVSR++
Metadata:
Training Data: VIMEO90K
Name: restorers--basicvsr--basicvsr_plusplus_c64n7_4x2_300k_vimeo90k_bi
Name: basicvsr_300k
Results:
- Dataset: VIMEO90K
Metrics:
Expand Down Expand Up @@ -67,7 +67,7 @@ Models:
In Collection: BasicVSR++
Metadata:
Training Data: VIMEO90K
Name: restorers--basicvsr--basicvsr_plusplus_c64n7_4x2_300k_vimeo90k_bd
Name: basicvsr_4x2
Results:
- Dataset: VIMEO90K
Metrics:
Expand Down
4 changes: 2 additions & 2 deletions configs/restorers/dic/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: DIC
Metadata:
Training Data: CELEBA
Name: restorers--dic--dic_x8c48b6_g4_150k_CelebAHQ
Name: dic_150k
Results:
- Dataset: CELEBA
Metrics:
Expand All @@ -24,7 +24,7 @@ Models:
In Collection: DIC
Metadata:
Training Data: CELEBA
Name: restorers--dic--dic_gan_x8c48b6_g4_500k_CelebAHQ
Name: dic_gan
Results:
- Dataset: CELEBA
Metrics:
Expand Down
6 changes: 3 additions & 3 deletions configs/restorers/edsr/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: EDSR
Metadata:
Training Data: DIV2K
Name: restorers--edsr--edsr_x2c64b16_g1_300k_div2k
Name: edsr_x2c64b16
Results:
- Dataset: DIV2K
Metrics:
Expand All @@ -30,7 +30,7 @@ Models:
In Collection: EDSR
Metadata:
Training Data: DIV2K
Name: restorers--edsr--edsr_x3c64b16_g1_300k_div2k
Name: edsr_x3c64b16
Results:
- Dataset: DIV2K
Metrics:
Expand All @@ -49,7 +49,7 @@ Models:
In Collection: EDSR
Metadata:
Training Data: DIV2K
Name: restorers--edsr--edsr_x4c64b16_g1_300k_div2k
Name: edsr_x4c64b16
Results:
- Dataset: DIV2K
Metrics:
Expand Down
4 changes: 2 additions & 2 deletions configs/restorers/edvr/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: EDVR
Metadata:
Training Data: REDS
Name: restorers--edvr--edvrm_wotsa_x4_g8_600k_reds
Name: edvrm_wotsa
Results:
- Dataset: REDS
Metrics:
Expand All @@ -24,7 +24,7 @@ Models:
In Collection: EDVR
Metadata:
Training Data: REDS
Name: restorers--edvr--edvrm_x4_g8_600k_reds
Name: edvrm
Results:
- Dataset: REDS
Metrics:
Expand Down
4 changes: 2 additions & 2 deletions configs/restorers/esrgan/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Models:
In Collection: ESRGAN
Metadata:
Training Data: DIV2K
Name: restorers--esrgan--esrgan_psnr_x4c64b23g32_g1_1000k_div2k
Name: esrgan_psnr
Results:
- Dataset: DIV2K
Metrics:
Expand All @@ -30,7 +30,7 @@ Models:
In Collection: ESRGAN
Metadata:
Training Data: DIV2K
Name: restorers--esrgan--esrgan_x4c64b23g32_g1_400k_div2k
Name: esrgan_400k
Results:
- Dataset: DIV2K
Metrics:
Expand Down
2 changes: 1 addition & 1 deletion configs/restorers/glean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ We show that pre-trained Generative Adversarial Networks (GANs), e.g., StyleGAN,
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.

| Method | PSNR | Download |
|--------------------------------------------------------------------------------------------------------------------|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| :----------------------------------------------------------------------------------------------------------------: | :---: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| [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) |
| [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) |
| [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) |
Expand Down
Loading

0 comments on commit deccc1d

Please sign in to comment.