add modelzoo statistics (#119)
parent
4203b94643
commit
3e20b5efa6
|
@ -0,0 +1,20 @@
|
|||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
20
docs/conf.py
20
docs/conf.py
|
@ -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('..'))
|
||||
|
@ -20,10 +21,17 @@ sys.path.insert(0, os.path.abspath('..'))
|
|||
project = 'MMClassification'
|
||||
copyright = '2020, OpenMMLab'
|
||||
author = 'MMClassification Authors'
|
||||
version_file = '../mmcls/version.py'
|
||||
|
||||
|
||||
def get_version():
|
||||
with open(version_file, 'r') as f:
|
||||
exec(compile(f.read(), version_file, 'exec'))
|
||||
return locals()['__version__']
|
||||
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
with open('../mmcls/VERSION', 'r') as f:
|
||||
release = f.read().strip()
|
||||
release = get_version()
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
|
@ -65,3 +73,11 @@ html_theme = 'sphinx_rtd_theme'
|
|||
html_static_path = ['_static']
|
||||
|
||||
master_doc = 'index'
|
||||
|
||||
|
||||
def builder_inited_handler(app):
|
||||
subprocess.run(['./stat.py'])
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.connect('builder-inited', builder_inited_handler)
|
||||
|
|
|
@ -6,6 +6,7 @@ Welcome to MMClassification's documentation!
|
|||
|
||||
install.md
|
||||
getting_started.md
|
||||
modelzoo_statistics.md
|
||||
model_zoo.md
|
||||
tutorials/finetune.md
|
||||
tutorials/new_dataset.md
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env python
|
||||
import glob
|
||||
import os.path as osp
|
||||
import re
|
||||
|
||||
url_prefix = 'https://github.com/open-mmlab/mmclassification/blob/master/'
|
||||
|
||||
files = sorted(glob.glob('../configs/*/README.md'))
|
||||
|
||||
stats = []
|
||||
titles = []
|
||||
num_ckpts = 0
|
||||
num_configs = 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'\[model\]\((https?.*)\)', content))
|
||||
|
||||
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…
Reference in New Issue