Skip to content

Commit

Permalink
[docs] add modelzoo statistics readthedocs (open-mmlab#263)
Browse files Browse the repository at this point in the history
* add modelzoo statistics readthedocs

* fix
  • Loading branch information
dreamerlin authored Nov 18, 2020
1 parent 97f10db commit ad09482
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import subprocess
import sys

sys.path.insert(0, os.path.abspath('..'))
Expand Down Expand Up @@ -77,3 +78,11 @@ def get_version():
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


def builder_inited_handler(app):
subprocess.run(['./stat.py'])


def setup(app):
app.connect('builder-inited', builder_inited_handler)
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Welcome to MMSegmenation's documentation!
install.md
getting_started.md
config.md
modelzoo_statistics.md
model_zoo.md

.. toctree::
Expand Down
42 changes: 42 additions & 0 deletions docs/stat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python
import glob
import os.path as osp
import re

url_prefix = 'https://github.com/open-mmlab/mmsegmentation/blob/master/'

files = sorted(glob.glob('../configs/*/README.md'))

stats = []
titles = []
num_ckpts = 0

for f in files:
url = osp.dirname(f.replace('../', url_prefix))

with open(f, 'r') as content_file:
content = content_file.read()

title = content.split('\n')[0].replace('#', '')
titles.append(title)
ckpts = set(x.lower().strip()
for x in re.findall(r'https?://download.*\.pth', content)
if 'mmsegmentation' in x)
num_ckpts += len(ckpts)
statsmsg = f"""
\t* [{title}]({url}) ({len(ckpts)} ckpts)
"""
stats.append((title, ckpts, statsmsg))

msglist = '\n'.join(x for _, _, x in stats)

modelzoo = f"""
# Model Zoo Statistics
* Number of papers: {len(titles)}
* Number of checkpoints: {num_ckpts}
{msglist}
"""

with open('modelzoo_statistics.md', 'w') as f:
f.write(modelzoo)

0 comments on commit ad09482

Please sign in to comment.