Skip to content

Commit f31e0e9

Browse files
authored
[docs] add modelzoo statistics readthedocs (#263)
* add modelzoo statistics readthedocs * fix
1 parent 8d568fb commit f31e0e9

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

docs/conf.py

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
1313
import os
14+
import subprocess
1415
import sys
1516

1617
sys.path.insert(0, os.path.abspath('..'))
@@ -77,3 +78,11 @@ def get_version():
7778
# relative to this directory. They are copied after the builtin static files,
7879
# so a file named "default.css" will overwrite the builtin "default.css".
7980
html_static_path = ['_static']
81+
82+
83+
def builder_inited_handler(app):
84+
subprocess.run(['./stat.py'])
85+
86+
87+
def setup(app):
88+
app.connect('builder-inited', builder_inited_handler)

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Welcome to MMSegmenation's documentation!
77
install.md
88
getting_started.md
99
config.md
10+
modelzoo_statistics.md
1011
model_zoo.md
1112

1213
.. toctree::

docs/stat.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python
2+
import glob
3+
import os.path as osp
4+
import re
5+
6+
url_prefix = 'https://github.com/open-mmlab/mmsegmentation/blob/master/'
7+
8+
files = sorted(glob.glob('../configs/*/README.md'))
9+
10+
stats = []
11+
titles = []
12+
num_ckpts = 0
13+
14+
for f in files:
15+
url = osp.dirname(f.replace('../', url_prefix))
16+
17+
with open(f, 'r') as content_file:
18+
content = content_file.read()
19+
20+
title = content.split('\n')[0].replace('#', '')
21+
titles.append(title)
22+
ckpts = set(x.lower().strip()
23+
for x in re.findall(r'https?://download.*\.pth', content)
24+
if 'mmsegmentation' in x)
25+
num_ckpts += len(ckpts)
26+
statsmsg = f"""
27+
\t* [{title}]({url}) ({len(ckpts)} ckpts)
28+
"""
29+
stats.append((title, ckpts, statsmsg))
30+
31+
msglist = '\n'.join(x for _, _, x in stats)
32+
33+
modelzoo = f"""
34+
# Model Zoo Statistics
35+
36+
* Number of papers: {len(titles)}
37+
* Number of checkpoints: {num_ckpts}
38+
{msglist}
39+
"""
40+
41+
with open('modelzoo_statistics.md', 'w') as f:
42+
f.write(modelzoo)

0 commit comments

Comments
 (0)