mirror of
https://github.com/open-mmlab/mmsegmentation.git
synced 2025-06-03 22:03:48 +08:00
[docs] add modelzoo statistics readthedocs (#263)
* add modelzoo statistics readthedocs * fix
This commit is contained in:
parent
97f10dbb04
commit
ad09482fa2
@ -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('..'))
|
||||
@ -77,3 +78,11 @@ html_theme = 'sphinx_rtd_theme'
|
||||
# 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)
|
||||
|
@ -7,6 +7,7 @@ Welcome to MMSegmenation's documentation!
|
||||
install.md
|
||||
getting_started.md
|
||||
config.md
|
||||
modelzoo_statistics.md
|
||||
model_zoo.md
|
||||
|
||||
.. toctree::
|
||||
|
42
docs/stat.py
Normal file
42
docs/stat.py
Normal file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user