|
1 | 1 | #!/usr/bin/env python |
| 2 | +import functools as func |
2 | 3 | import glob |
3 | 4 | import os.path as osp |
4 | 5 | import re |
5 | 6 |
|
| 7 | +import numpy as np |
| 8 | + |
6 | 9 | url_prefix = 'https://github.com/open-mmlab/mmsegmentation/blob/master/' |
7 | | -titles_to_be_excluded = ['Mixed Precision Training'] |
8 | 10 |
|
9 | 11 | files = sorted(glob.glob('../configs/*/README.md')) |
10 | 12 |
|
|
18 | 20 | with open(f, 'r') as content_file: |
19 | 21 | content = content_file.read() |
20 | 22 |
|
21 | | - title = content.split('\n')[0].replace('#', '') |
22 | | - if title.strip() in titles_to_be_excluded: |
23 | | - continue |
24 | | - |
| 23 | + title = content.split('\n')[0].replace('#', '').strip() |
25 | 24 | ckpts = set(x.lower().strip() |
26 | 25 | for x in re.findall(r'https?://download.*\.pth', content) |
27 | 26 | if 'mmsegmentation' in x) |
28 | 27 | if len(ckpts) == 0: |
29 | 28 | continue |
30 | 29 |
|
| 30 | + _papertype = [x for x in re.findall(r'\[([A-Z]+)\]', content)] |
| 31 | + assert len(_papertype) > 0 |
| 32 | + papertype = _papertype[0] |
| 33 | + |
| 34 | + paper = set([(papertype, title)]) |
| 35 | + |
31 | 36 | titles.append(title) |
32 | 37 | num_ckpts += len(ckpts) |
33 | 38 | statsmsg = f""" |
34 | | -\t* [{title}]({url}) ({len(ckpts)} ckpts) |
| 39 | +\t* [{papertype}] [{title}]({url}) ({len(ckpts)} ckpts) |
35 | 40 | """ |
36 | | - stats.append((title, ckpts, statsmsg)) |
| 41 | + stats.append((paper, ckpts, statsmsg)) |
37 | 42 |
|
| 43 | +allpapers = func.reduce(lambda a, b: a.union(b), [p for p, _, _ in stats]) |
38 | 44 | msglist = '\n'.join(x for _, _, x in stats) |
39 | 45 |
|
| 46 | +papertypes, papercounts = np.unique([t for t, _ in allpapers], |
| 47 | + return_counts=True) |
| 48 | +countstr = '\n'.join( |
| 49 | + [f' - {t}: {c}' for t, c in zip(papertypes, papercounts)]) |
| 50 | + |
40 | 51 | modelzoo = f""" |
41 | 52 | # Model Zoo Statistics |
42 | 53 |
|
43 | 54 | * Number of papers: {len(set(titles))} |
| 55 | +{countstr} |
| 56 | +
|
44 | 57 | * Number of checkpoints: {num_ckpts} |
45 | 58 | {msglist} |
46 | 59 | """ |
|
0 commit comments