mirror of
https://github.com/open-mmlab/mmclassification.git
synced 2025-06-03 21:53:55 +08:00
Build chinese translation in readthedocs (#267)
* change document layout * Add Chinese docs build file * Add switch language option
This commit is contained in:
parent
98b6c4afa4
commit
a06827bc08
@ -1,6 +1,10 @@
|
||||
Welcome to MMClassification's documentation!
|
||||
==========================================
|
||||
|
||||
You can switch between Chinese and English documents in the lower-left corner of the layout.
|
||||
|
||||
您可以在页面左下角切换中英文文档。
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Get Started
|
||||
@ -16,16 +20,6 @@ Welcome to MMClassification's documentation!
|
||||
modelzoo_statistics.md
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Dataset Preparation
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Quick Run
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Tutorials
|
||||
@ -34,14 +28,22 @@ Welcome to MMClassification's documentation!
|
||||
tutorials/new_dataset.md
|
||||
tutorials/data_pipeline.md
|
||||
tutorials/new_modules.md
|
||||
tutorials/pytorch2onnx.md
|
||||
tutorials/onnx2tensorrt.md
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Useful Tools and Scripts
|
||||
|
||||
tutorials/pytorch2onnx.md
|
||||
tutorials/onnx2tensorrt.md
|
||||
|
||||
|
||||
.. toctree::
|
||||
:caption: Language Switch
|
||||
|
||||
switch_language.md
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
3
docs/switch_language.md
Normal file
3
docs/switch_language.md
Normal file
@ -0,0 +1,3 @@
|
||||
## <a href='https://mmclassification.readthedocs.io/en/latest/'>English</a>
|
||||
|
||||
## <a href='https://mmclassification.readthedocs.io/zh_CN/latest/'>简体中文</a>
|
@ -1,4 +1,4 @@
|
||||
# Tutorial 6: ONNX to TensorRT (Experimental)
|
||||
# ONNX to TensorRT (Experimental)
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Tutorial 5: Pytorch to ONNX (Experimental)
|
||||
# Pytorch to ONNX (Experimental)
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
|
20
docs_zh-CN/Makefile
Normal file
20
docs_zh-CN/Makefile
Normal file
@ -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)
|
85
docs_zh-CN/conf.py
Normal file
85
docs_zh-CN/conf.py
Normal file
@ -0,0 +1,85 @@
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# 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('..'))
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
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
|
||||
release = get_version()
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.napoleon',
|
||||
'sphinx.ext.viewcode',
|
||||
'recommonmark',
|
||||
'sphinx_markdown_tables',
|
||||
]
|
||||
|
||||
autodoc_mock_imports = ['mmcls.version']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
source_suffix = {
|
||||
'.rst': 'restructuredtext',
|
||||
'.md': 'markdown',
|
||||
}
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# 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']
|
||||
|
||||
language = 'zh_CN'
|
||||
|
||||
master_doc = 'index'
|
||||
|
||||
|
||||
def builder_inited_handler(app):
|
||||
subprocess.run(['./stat.py'])
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.connect('builder-inited', builder_inited_handler)
|
52
docs_zh-CN/index.rst
Normal file
52
docs_zh-CN/index.rst
Normal file
@ -0,0 +1,52 @@
|
||||
欢迎来到 MMClassification 中文教程!
|
||||
==========================================
|
||||
|
||||
You can switch between Chinese and English documents in the lower-left corner of the layout.
|
||||
|
||||
您可以在页面左下角切换中英文文档。
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: 开始你的第一步
|
||||
|
||||
install.md
|
||||
getting_started.md
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: 模型库
|
||||
|
||||
modelzoo_statistics.md
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: 教程
|
||||
|
||||
tutorials/finetune.md
|
||||
tutorials/new_dataset.md
|
||||
tutorials/data_pipeline.md
|
||||
tutorials/new_modules.md
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: 实用工具
|
||||
|
||||
tutorials/pytorch2onnx.md
|
||||
tutorials/onnx2tensorrt.md
|
||||
|
||||
|
||||
.. toctree::
|
||||
:caption: 语言切换
|
||||
|
||||
switch_language.md
|
||||
|
||||
|
||||
|
||||
索引与表格
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`search`
|
65
docs_zh-CN/stat.py
Executable file
65
docs_zh-CN/stat.py
Executable file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python
|
||||
import functools as func
|
||||
import glob
|
||||
import os.path as osp
|
||||
import re
|
||||
|
||||
import numpy as np
|
||||
|
||||
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('# ', '').strip()
|
||||
|
||||
ckpts = set(x.lower().strip()
|
||||
for x in re.findall(r'\[model\]\((https?.*)\)', content))
|
||||
|
||||
if len(ckpts) == 0:
|
||||
continue
|
||||
|
||||
_papertype = [x for x in re.findall(r'\[([A-Z]+)\]', content)]
|
||||
assert len(_papertype) > 0
|
||||
papertype = _papertype[0]
|
||||
|
||||
paper = set([(papertype, title)])
|
||||
|
||||
num_ckpts += len(ckpts)
|
||||
titles.append(title)
|
||||
|
||||
statsmsg = f"""
|
||||
\t* [{papertype}] [{title}]({url}) ({len(ckpts)} ckpts)
|
||||
"""
|
||||
stats.append((paper, ckpts, statsmsg))
|
||||
|
||||
allpapers = func.reduce(lambda a, b: a.union(b), [p for p, _, _ in stats])
|
||||
msglist = '\n'.join(x for _, _, x in stats)
|
||||
|
||||
papertypes, papercounts = np.unique([t for t, _ in allpapers],
|
||||
return_counts=True)
|
||||
countstr = '\n'.join(
|
||||
[f' - {t}: {c}' for t, c in zip(papertypes, papercounts)])
|
||||
|
||||
modelzoo = f"""
|
||||
# 模型库统计
|
||||
|
||||
* 论文数量: {len(set(titles))}
|
||||
{countstr}
|
||||
|
||||
* 模型权重文件数量: {num_ckpts}
|
||||
{msglist}
|
||||
"""
|
||||
|
||||
with open('modelzoo_statistics.md', 'w') as f:
|
||||
f.write(modelzoo)
|
3
docs_zh-CN/switch_language.md
Normal file
3
docs_zh-CN/switch_language.md
Normal file
@ -0,0 +1,3 @@
|
||||
## <a href='https://mmclassification.readthedocs.io/en/latest/'>English</a>
|
||||
|
||||
## <a href='https://mmclassification.readthedocs.io/zh_CN/latest/'>简体中文</a>
|
@ -1,4 +1,4 @@
|
||||
# Tutorial 6: ONNX to TensorRT (Experimental)
|
||||
# ONNX to TensorRT (Experimental)
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Tutorial 5: Pytorch to ONNX (Experimental)
|
||||
# Pytorch to ONNX (Experimental)
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user