forked from open-mmlab/mmpose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Auto modelzoo statistics (open-mmlab#327)
* add stat.py * update changelog * update mmcv bound
- Loading branch information
1 parent
f8ea671
commit 7053406
Showing
6 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python | ||
import functools as func | ||
import glob | ||
import re | ||
|
||
files = sorted(glob.glob('*_models.md')) | ||
|
||
stats = [] | ||
|
||
for f in files: | ||
with open(f, 'r') as content_file: | ||
content = content_file.read() | ||
|
||
# title | ||
title = content.split('\n')[0].replace('#', '') | ||
|
||
# count papers | ||
papers = set(x.lower().strip() | ||
for x in re.findall(r'\btitle={(.*)}', content)) | ||
paperlist = '\n'.join(sorted(' - ' + x for x in papers)) | ||
|
||
# count configs | ||
configs = set(x.lower().strip() | ||
for x in re.findall(r'https.*configs/.*\.py', content)) | ||
|
||
# count ckpts | ||
ckpts = set(x.lower().strip() | ||
for x in re.findall(r'https://download.*\.pth', content) | ||
if 'mmaction' in x) | ||
|
||
statsmsg = f""" | ||
## [{title}]({f}) | ||
* Number of checkpoints: {len(ckpts)} | ||
* Number of configs: {len(configs)} | ||
* Number of papers: {len(papers)} | ||
{paperlist} | ||
""" | ||
|
||
stats.append((papers, configs, ckpts, statsmsg)) | ||
|
||
allpapers = func.reduce(lambda a, b: a.union(b), [p for p, _, _, _ in stats]) | ||
allconfigs = func.reduce(lambda a, b: a.union(b), [c for _, c, _, _ in stats]) | ||
allckpts = func.reduce(lambda a, b: a.union(b), [c for _, _, c, _ in stats]) | ||
msglist = '\n'.join(x for _, _, _, x in stats) | ||
|
||
modelzoo = f""" | ||
# Model Zoo Statistics | ||
* Number of checkpoints: {len(allckpts)} | ||
* Number of configs: {len(allconfigs)} | ||
* Number of papers: {len(allpapers)} | ||
{msglist} | ||
""" | ||
|
||
with open('modelzoo.md', 'w') as f: | ||
f.write(modelzoo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters