Skip to content

Commit

Permalink
[Doc] improve Chinese documents (#1532)
Browse files Browse the repository at this point in the history
* refactor doctreee

* refactor doctree

* update zh-cn

* update model zoo

* fix invalid link

* add caption for faq and changelog
  • Loading branch information
zengyh1900 authored Dec 14, 2022
1 parent 0cf8177 commit b8397d3
Show file tree
Hide file tree
Showing 64 changed files with 2,578 additions and 1,471 deletions.
8 changes: 4 additions & 4 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
[📘使用文档](https://mmediting.readthedocs.io/zh_CN/1.x/) |
[🛠️安装教程](https://mmediting.readthedocs.io/zh_CN/1.x/2_get_started.htmll) |
[👀模型库](https://mmediting.readthedocs.io/zh_CN/1.x/3_model_zoo.html) |
[🆕更新记录](docs/zh_cn/community/changelog.md) |
[🆕更新记录](docs/zh_cn/changelog.md) |
[🚀进行中的项目](https://github.com/open-mmlab/mmediting/projects) |
[🤔提出问题](https://github.com/open-mmlab/mmediting/issues)

Expand Down Expand Up @@ -124,7 +124,7 @@ MMEditing 缜密地设计新的框架并将其精心实现,希望能够为您
- 修复 FLAVR 的注册问题。
- 修正 RDB 模型中的通道数。

如果像了解更多版本更新细节和历史信息,请阅读[更新日志](docs/en/community/changelog.md)
如果像了解更多版本更新细节和历史信息,请阅读[更新日志](docs/en/changelog.md)

## 安装

Expand All @@ -151,11 +151,11 @@ cd mmediting
pip3 install -e .
```

更详细的安装指南请参考 [get_started.md](docs/zh_cn/2_get_started.md)
更详细的安装指南请参考 [installation](docs/zh_cn/get_started/install.md)

## 开始使用

请参考[使用教程](docs/zh_cn/2_get_started.md)[功能演示](docs/zh_cn/user_guides/3_inference.md)获取MMEditing的基本用法。
请参考[使用教程](docs/zh_cn/get_started/install.md)[功能演示](docs/zh_cn/get_started/quick_run.md)获取MMEditing的基本用法。

## 模型库

Expand Down
2 changes: 1 addition & 1 deletion docs/en/.dev_scripts/update_dataset_zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def update_dataset_zoo():
"""

subfolders = os.listdir(source_dir)
for subf in tqdm(subfolders):
for subf in tqdm(subfolders, desc='update dataset zoo'):

target_subf = subf.replace('-', '_').lower()
target_readme = os.path.join(target_dir, target_subf + '.md')
Expand Down
36 changes: 21 additions & 15 deletions docs/en/.dev_scripts/update_model_zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ def anchor(name):
name.strip().lower())).strip('-')


def summarize(stats, name, task='all'):
def summarize(stats, name):
allpapers = func.reduce(lambda a, b: a.union(b),
[p for p, _, _, _, _, _ in stats])
[p for p, _, _, _, _, _, _ in stats])
allconfigs = func.reduce(lambda a, b: a.union(b),
[c for _, c, _, _, _, _ in stats])
[c for _, c, _, _, _, _, _ in stats])
allckpts = func.reduce(lambda a, b: a.union(b),
[c for _, _, c, _, _, _ in stats])
[c for _, _, c, _, _, _, _ in stats])
alltasks = func.reduce(lambda a, b: a.union(b),
[t for _, _, _, t, _, _ in stats])
task_desc = '\n - '.join(list(alltasks))
[t for _, _, _, t, _, _, _ in stats])
task_desc = '\n'.join([
f" - [{task}]({task.replace('-', '_').replace(' ', '_').lower()}.md)" # noqa
for task in list(alltasks)
])

# Overview
papertypes, papercounts = np.unique([t for t, _ in allpapers],
Expand All @@ -55,9 +58,9 @@ def summarize(stats, name, task='all'):
if name == 'Overview':
summary += f"""
* Tasks:
- {task_desc}
{task_desc}
"""
"""

return summary

Expand Down Expand Up @@ -138,15 +141,16 @@ def update_model_zoo():
"""
# * We should have: {len(glob.glob(osp.join(dirname(f), '*.py')))}
stats.append((papers, configs, ckpts, tasks, year, statsmsg))
content = content.replace('# ', '## ')
stats.append((papers, configs, ckpts, tasks, year, statsmsg, content))

# overview
overview = summarize(stats, 'Overview')
with open(osp.join(target_dir, 'overview.md'), 'w') as f:
f.write(overview)

alltasks = func.reduce(lambda a, b: a.union(b),
[t for _, _, _, t, _, _ in stats])
[t for _, _, _, t, _, _, _ in stats])

# index.rst
indexmsg = """
Expand All @@ -166,13 +170,15 @@ def update_model_zoo():

# task-specific
for task in alltasks:
filtered_model = [(paper, config, ckpt, tasks, year, x)
for paper, config, ckpt, tasks, year, x in stats
if task in tasks]
filtered_model = sorted(filtered_model, key=lambda x: x[-2])[::-1]
filtered_model = [
(paper, config, ckpt, tasks, year, x, content)
for paper, config, ckpt, tasks, year, x, content in stats
if task in tasks
]
filtered_model = sorted(filtered_model, key=lambda x: x[-3])[::-1]
overview = summarize(filtered_model, task)
msglist = '\n'.join(x for _, _, _, _, _, x in filtered_model)

msglist = '\n'.join(x for _, _, _, _, _, _, x in filtered_model)
task = task.replace(' ', '_').replace('-', '_').lower()
with open(osp.join(target_dir, f'{task}.md'), 'w') as f:
f.write(overview + '\n' + msglist)
Expand Down
1 change: 0 additions & 1 deletion docs/en/get_started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ In this section, you will know about:
- [Best practices](#best-practices)
- [Customize installation](#customize-installation)
- [Developing with multiple MMEditing versions](#developing-with-multiple-mmediting-versions)
- [Quick run](#quick-run)

## Installation

Expand Down
5 changes: 4 additions & 1 deletion docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ Documentation
user_guides/visualization.md
user_guides/useful_tools.md
user_guides/deploy.md
user_guides/faq.md


.. toctree::
Expand All @@ -90,6 +89,8 @@ Documentation
howto/losses.md

.. toctree::
:maxdepth: 1
:caption: FAQ

faq.md

Expand All @@ -107,6 +108,8 @@ Documentation
dataset_zoo/index.rst

.. toctree::
:maxdepth: 1
:caption: Changelog

changelog.md

Expand Down
2 changes: 1 addition & 1 deletion docs/en/user_guides/deploy.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tutorial 7: Deploy models in MMEditing
# Tutorial 8: Deploy models in MMEditing

[MMDeploy](https://github.com/open-mmlab/mmdeploy) is an open-source deep learning model deployment toolset.
MMDeploy supports deploying models in MMEditing. Please refer to [MMDeploy](https://github.com/open-mmlab/mmdeploy) for more information.
2 changes: 1 addition & 1 deletion docs/en/user_guides/metrics.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tutorial 8: Using metrics in MMEditing
# Tutorial 5: Using metrics in MMEditing

MMEditing supports **17 metrics** to assess the quality of models.

Expand Down
2 changes: 1 addition & 1 deletion docs/en/user_guides/useful_tools.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tutorial 6: Useful tools
# Tutorial 7: Useful tools

We provide lots of useful tools under `tools/` directory.

Expand Down
2 changes: 1 addition & 1 deletion docs/en/user_guides/visualization.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tutorial 5: Visualization
# Tutorial 6: Visualization

The visualization of images is an important way to measure the quality of image processing, editing and synthesis.
Using `visualizer` in config file can save visual results when training or testing. You can follow [MMEngine Documents](https://github.com/open-mmlab/mmengine/blob/main/docs/en/tutorials/visualization.md) to learn the usage of visualization. MMEditing provides a rich set of visualization functions.
Expand Down
51 changes: 51 additions & 0 deletions docs/zh_cn/.dev_scripts/update_dataset_zoo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os

from tqdm import tqdm


def update_dataset_zoo():

target_dir = 'dataset_zoo'
source_dir = '../../tools/dataset_converters'
os.makedirs(target_dir, exist_ok=True)

# generate overview
overviewmsg = """
# 概览
"""

# generate index.rst
rstmsg = """
.. toctree::
:maxdepth: 1
:caption: Dataset Zoo
overview.md
"""

subfolders = os.listdir(source_dir)
for subf in tqdm(subfolders, desc='update dataset zoo'):

target_subf = subf.replace('-', '_').lower()
target_readme = os.path.join(target_dir, target_subf + '.md')
source_readme = os.path.join(source_dir, subf, 'README_zh-CN.md')
if not os.path.exists(source_readme):
continue

overviewmsg += f'\n- [{subf}]({target_subf}.md)'
rstmsg += f'\n {target_subf}.md'

# generate all tasks dataset_zoo
command = f'cat {source_readme} > {target_readme}'
os.popen(command)

with open(os.path.join(target_dir, 'overview.md'), 'w') as f:
f.write(overviewmsg)

with open(os.path.join(target_dir, 'index.rst'), 'w') as f:
f.write(rstmsg)


if __name__ == '__main__':
update_dataset_zoo()
Loading

0 comments on commit b8397d3

Please sign in to comment.