diff --git a/.gitignore b/.gitignore index 53c72a699c961cc5d95d9f9f9c4fe7db8dc8ea35..0f5052db9f82dd6a342b696ce2f83944f015fe74 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ checkpoints/ output/ pretrained/ *.ipynb* -build/ +_build/ diff --git a/configs/pretrained.list b/configs/pretrained.list new file mode 100644 index 0000000000000000000000000000000000000000..a3ef2e9335fd9ce032afda5172c6a06499cc3d86 --- /dev/null +++ b/configs/pretrained.list @@ -0,0 +1,117 @@ +ResNet18 +ResNet34 +ResNet50 +ResNet101 +ResNet152 +ResNet50_vc +ResNet18_vd +ResNet34_vd +ResNet50_vd +ResNet50_vd_v2 +ResNet101_vd +ResNet152_vd +ResNet200_vd +ResNet50_vd_ssld +MobileNetV3_large_x0_35 +MobileNetV3_large_x0_5 +MobileNetV3_large_x0_75 +MobileNetV3_large_x1_0 +MobileNetV3_large_x1_25 +MobileNetV3_small_x0_35 +MobileNetV3_small_x0_5 +MobileNetV3_small_x0_75 +MobileNetV3_small_x1_0 +MobileNetV3_small_x1_25 +MobileNetV3_large_x1_0_ssld +MobileNetV3_large_x1_0_ssld_int8 +MobileNetV3_small_x1_0_ssld +MobileNetV2_x0_25 +MobileNetV2_x0_5 +MobileNetV2_x0_75 +MobileNetV2 +MobileNetV2_x1_5 +MobileNetV2_x2_0 +MobileNetV2_ssld +MobileNetV1_x0_25 +MobileNetV1_x0_5 +MobileNetV1_x0_75 +MobileNetV1 +MobileNetV1_ssld +ShuffleNetV2_x0_25 +ShuffleNetV2_x0_33 +ShuffleNetV2_x0_5 +ShuffleNetV2 +ShuffleNetV2_x1_5 +ShuffleNetV2_x2_0 +ShuffleNetV2_swish +ResNeXt50_32x4d +ResNeXt50_64x4d +ResNeXt101_32x4d +ResNeXt101_64x4d +ResNeXt152_32x4d +ResNeXt152_64x4d +ResNeXt50_vd_32x4d +ResNeXt50_vd_64x4d +ResNeXt101_vd_32x4d +ResNeXt101_vd_64x4d +ResNeXt152_vd_32x4d +ResNeXt152_vd_64x4d +SE_ResNet18_vd +SE_ResNet34_vd +SE_ResNet50_vd +SE_ResNeXt50_32x4d +SE_ResNeXt101_32x4d +SE_ResNeXt50_vd_32x4d +SENet154_vd +Res2Net50_26w_4s +Res2Net50_vd_26w_4s +Res2Net50_14w_8s +Res2Net101_vd_26w_4s +Res2Net200_vd_26w_4s +GoogLeNet +InceptionV4 +Xception41 +Xception41_deeplab +Xception65 +Xception65_deeplab +Xception71 +HRNet_W18_C +HRNet_W30_C +HRNet_W32_C +HRNet_W40_C +HRNet_W44_C +HRNet_W48_C +HRNet_W64_C +DPN68 +DPN92 +DPN98 +DPN107 +DPN131 +DenseNet121 +DenseNet161 +DenseNet169 +DenseNet201 +DenseNet264 +EfficientNetB0_small +EfficientNetB0 +EfficientNetB1 +EfficientNetB2 +EfficientNetB3 +EfficientNetB4 +EfficientNetB5 +EfficientNetB6 +EfficientNetB7 +ResNeXt101_32x8d_wsl +ResNeXt101_32x16d_wsl +ResNeXt101_32x32d_wsl +ResNeXt101_32x48d_wsl +Fix_ResNeXt101_32x48d_wsl +AlexNet +SqueezeNet1_0 +SqueezeNet1_1 +VGG11 +VGG13 +VGG16 +VGG19 +DarkNet53 +ResNet50_ACNet_deploy diff --git a/docs/Makefile b/docs/en/Makefile similarity index 96% rename from docs/Makefile rename to docs/en/Makefile index ed88099027f775942fa65dce2314f1ae9675cb36..d4bb2cbb9eddb1bb1b4f366623044af8e4830919 100644 --- a/docs/Makefile +++ b/docs/en/Makefile @@ -6,7 +6,7 @@ SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = . -BUILDDIR = build +BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: diff --git a/docs/en/advanced_tutorials/distillation/index.rst b/docs/en/advanced_tutorials/distillation/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..fcd7515c53a65419fce5e50606ea573f106defe8 --- /dev/null +++ b/docs/en/advanced_tutorials/distillation/index.rst @@ -0,0 +1,7 @@ +distillation +================================ + +.. toctree:: + :maxdepth: 3 + + distillation.md diff --git a/docs/en/advanced_tutorials/image_augmentation/index.rst b/docs/en/advanced_tutorials/image_augmentation/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..7f47334d5543d77b9b465ce21c23a741c6fa2ac9 --- /dev/null +++ b/docs/en/advanced_tutorials/image_augmentation/index.rst @@ -0,0 +1,7 @@ +image_augmentation +================================ + +.. toctree:: + :maxdepth: 3 + + ImageAugment.md diff --git a/docs/en/advanced_tutorials/index.rst b/docs/en/advanced_tutorials/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..2042d4541aa9a0de6d538eca6bc22f8f573fd1e2 --- /dev/null +++ b/docs/en/advanced_tutorials/index.rst @@ -0,0 +1,9 @@ +advanced_tutorials +================================ + +.. toctree:: + :maxdepth: 1 + + image_augmentation/index + distillation/index + diff --git a/docs/en/application/index.rst b/docs/en/application/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..16bfb703ac79a553d9b7c3b4842d797a9a18558a --- /dev/null +++ b/docs/en/application/index.rst @@ -0,0 +1,8 @@ +application +================================ + +.. toctree:: + :maxdepth: 2 + + transfer_learning.md + object_detection.md diff --git a/docs/en/change_log.md b/docs/en/change_log.md new file mode 100644 index 0000000000000000000000000000000000000000..406a49ea51e6c92016a3732263085bc845bf0568 --- /dev/null +++ b/docs/en/change_log.md @@ -0,0 +1,3 @@ +# Release Notes + +* 2020.04.14: first commit diff --git a/docs/conf.py b/docs/en/conf.py similarity index 92% rename from docs/conf.py rename to docs/en/conf.py index 28409a2e2319f1c88aaef03154e24ce4745ddfc0..1b5a0c12462c502baf2e68018c63bc7b118bc968 100644 --- a/docs/conf.py +++ b/docs/en/conf.py @@ -11,12 +11,9 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os -import sys import recommonmark -sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('..')) -exclude_patterns = ['tmp', 'build', 'tools', 'README.md'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # -- Project information ----------------------------------------------------- @@ -56,7 +53,7 @@ master_doc = 'index' # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = 'zh' +language = 'en' # -- Options for HTML output ------------------------------------------------- @@ -79,5 +76,4 @@ if not on_rtd: # only import and set the theme if we're building docs locally html_static_path = ['_static'] -#html_logo = './images/logo.png' - +html_logo = '../images/logo.png' diff --git a/docs/en/index.rst b/docs/en/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..f0a88b27d55f1383badc83e98d860e600a7fed39 --- /dev/null +++ b/docs/en/index.rst @@ -0,0 +1,19 @@ +Welcome to PaddleClas! +================================ + +.. toctree:: + :maxdepth: 1 + :numbered: + :caption: Contents: + + tutorials/index + models/index + advanced_tutorials/index + application/index + extension/index + competition_support.md + model_zoo.md + change_log.md + faq.md + +:math:`PaddlePaddle2020` diff --git a/docs/en/make.bat b/docs/en/make.bat new file mode 100644 index 0000000000000000000000000000000000000000..2119f51099bf37e4fdb6071dce9f451ea44c62dd --- /dev/null +++ b/docs/en/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/en/models/index.rst b/docs/en/models/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..0fa65a89735ec3b6d970ac3c3c41323dd1dc6a3f --- /dev/null +++ b/docs/en/models/index.rst @@ -0,0 +1,16 @@ +models +================================ + +.. toctree:: + :maxdepth: 1 + + models_intro.md + Tricks.md + ResNet_and_vd.md + Mobile.md + SEResNext_and_Res2Net.md + Inception.md + HRNet.md + DPN_DenseNet.md + EfficientNet_and_ResNeXt101_wsl.md + Others.md diff --git a/docs/en/tutorials/index.rst b/docs/en/tutorials/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..e763bccba0a46d851c8421ac8df4f4ef737eab67 --- /dev/null +++ b/docs/en/tutorials/index.rst @@ -0,0 +1,9 @@ +tutorials +================================ + +.. toctree:: + :maxdepth: 1 + + install.md + getting_started.md + config.md diff --git a/docs/images/logo.png b/docs/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..bc1135abfab7aa48f29392da4bca614f688314af Binary files /dev/null and b/docs/images/logo.png differ diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index d56626063110c02186c31b39947c9b70f56fbb07..0000000000000000000000000000000000000000 --- a/docs/index.rst +++ /dev/null @@ -1,17 +0,0 @@ -欢迎使用PaddleClas图像分类库! -================================ - -.. toctree:: - :maxdepth: 1 - - zh_cn/tutorials/index - zh_cn/models/index - zh_cn/advanced_tutorials/index - zh_cn/application/index - zh_cn/extension/index - zh_cn/competition_support.md - zh_cn/model_zoo.md - zh_cn/change_log.md - zh_cn/faq.md - -:math:`PaddlePaddle2020` diff --git a/docs/zh_CN/Makefile b/docs/zh_CN/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d4bb2cbb9eddb1bb1b4f366623044af8e4830919 --- /dev/null +++ b/docs/zh_CN/Makefile @@ -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) diff --git a/docs/zh_cn/advanced_tutorials/image_augmentation/ImageAugment.md b/docs/zh_CN/advanced_tutorials/image_augmentation/ImageAugment.md similarity index 100% rename from docs/zh_cn/advanced_tutorials/image_augmentation/ImageAugment.md rename to docs/zh_CN/advanced_tutorials/image_augmentation/ImageAugment.md diff --git a/docs/zh_cn/advanced_tutorials/image_augmentation/index.rst b/docs/zh_CN/advanced_tutorials/image_augmentation/index.rst similarity index 100% rename from docs/zh_cn/advanced_tutorials/image_augmentation/index.rst rename to docs/zh_CN/advanced_tutorials/image_augmentation/index.rst diff --git a/docs/zh_cn/advanced_tutorials/index.rst b/docs/zh_CN/advanced_tutorials/index.rst similarity index 100% rename from docs/zh_cn/advanced_tutorials/index.rst rename to docs/zh_CN/advanced_tutorials/index.rst diff --git a/docs/zh_CN/change_log.md b/docs/zh_CN/change_log.md new file mode 100644 index 0000000000000000000000000000000000000000..a3ba148b2be262e920e8a8f06c87c6b429b30413 --- /dev/null +++ b/docs/zh_CN/change_log.md @@ -0,0 +1,3 @@ +# 更新日志 + +* 2020.04.10: 第一次提交 diff --git a/docs/zh_cn/competition_support.md b/docs/zh_CN/competition_support.md similarity index 100% rename from docs/zh_cn/competition_support.md rename to docs/zh_CN/competition_support.md diff --git a/docs/zh_CN/conf.py b/docs/zh_CN/conf.py new file mode 100644 index 0000000000000000000000000000000000000000..165295079d77157d1025cf4e630b6b394b7ae8df --- /dev/null +++ b/docs/zh_CN/conf.py @@ -0,0 +1,79 @@ +# 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 recommonmark + +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# -- Project information ----------------------------------------------------- + +project = 'PaddleClas' +copyright = '2020, paddlepaddle' +author = 'paddlepaddle' + +# -- 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.coverage', + 'sphinx.ext.viewcode', + 'sphinx.ext.mathjax', + 'sphinx.ext.githubpages', + 'sphinx.ext.napoleon', + 'recommonmark', + 'sphinx_markdown_tables', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# md file can also be parased +source_suffix = ['.rst', '.md'] + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = 'zh_CN' + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. + +# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' + +if not on_rtd: # only import and set the theme if we're building docs locally + import sphinx_rtd_theme + html_theme = 'sphinx_rtd_theme' + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + +# otherwise, readthedocs.org uses their theme by default, so no need to specify it + +# 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'] + +html_logo = '../images/logo.png' diff --git a/docs/zh_cn/extension/code_overview.md b/docs/zh_CN/extension/code_overview.md similarity index 100% rename from docs/zh_cn/extension/code_overview.md rename to docs/zh_CN/extension/code_overview.md diff --git a/docs/zh_cn/extension/index.rst b/docs/zh_CN/extension/index.rst similarity index 91% rename from docs/zh_cn/extension/index.rst rename to docs/zh_CN/extension/index.rst index f74b4321a7d2a77c0cea1dd165a05d21dcd9fd00..657349a00b5687a7afa55500f593a5a23c056470 100644 --- a/docs/zh_cn/extension/index.rst +++ b/docs/zh_CN/extension/index.rst @@ -4,7 +4,6 @@ .. toctree:: :maxdepth: 1 - code_overview.md paddle_inference.md paddle_mobile_inference.md paddle_quantization.md diff --git a/docs/zh_cn/extension/multi_machine_training.md b/docs/zh_CN/extension/multi_machine_training.md similarity index 100% rename from docs/zh_cn/extension/multi_machine_training.md rename to docs/zh_CN/extension/multi_machine_training.md diff --git a/docs/zh_cn/extension/paddle_hub.md b/docs/zh_CN/extension/paddle_hub.md similarity index 100% rename from docs/zh_cn/extension/paddle_hub.md rename to docs/zh_CN/extension/paddle_hub.md diff --git a/docs/zh_cn/extension/paddle_inference.md b/docs/zh_CN/extension/paddle_inference.md similarity index 100% rename from docs/zh_cn/extension/paddle_inference.md rename to docs/zh_CN/extension/paddle_inference.md diff --git a/docs/zh_cn/extension/paddle_mobile_inference.md b/docs/zh_CN/extension/paddle_mobile_inference.md similarity index 100% rename from docs/zh_cn/extension/paddle_mobile_inference.md rename to docs/zh_CN/extension/paddle_mobile_inference.md diff --git a/docs/zh_cn/extension/paddle_quantization.md b/docs/zh_CN/extension/paddle_quantization.md similarity index 91% rename from docs/zh_cn/extension/paddle_quantization.md rename to docs/zh_CN/extension/paddle_quantization.md index 28ec30efd5ff43e7e6c8992caf8684b8625c1e13..32dbcdabd86ba77686465b99165b8610db0f5e62 100644 --- a/docs/zh_cn/extension/paddle_quantization.md +++ b/docs/zh_CN/extension/paddle_quantization.md @@ -1,5 +1,5 @@ # 模型量化 -模型量化是 [PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim) 的特色功能之一,支持动态和静态两种量化训练方式,对权重全局量化和 Channel-Wise 量化,同时以兼容 Paddle Mobile 的格式保存模型。 +模型量化是 [PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim) 的特色功能之一,支持动态和静态两种量化训练方式,对权重全局量化和 Channel-Wise 量化,同时以兼容 Paddle-Lite 的格式保存模型。 [PaddleClas](https://github.com/PaddlePaddle/PaddleClas) 使用该量化工具,量化了78.9%的mobilenet_v3_large_x1_0的蒸馏模型, 量化后SD855上预测速度从19.308ms加速到14.395ms,存储大小从21M减小到10M, top1识别准确率75.9%。 具体的训练方法可以参见 [PaddleSlim 量化训练](https://paddlepaddle.github.io/PaddleSlim/quick_start/quant_aware_tutorial.html)。 diff --git a/docs/zh_cn/extension/paddle_serving.md b/docs/zh_CN/extension/paddle_serving.md similarity index 100% rename from docs/zh_cn/extension/paddle_serving.md rename to docs/zh_CN/extension/paddle_serving.md diff --git a/docs/zh_CN/faq.md b/docs/zh_CN/faq.md new file mode 100644 index 0000000000000000000000000000000000000000..1ceb9c7806e556eb7eac8d323f60692af8e831b1 --- /dev/null +++ b/docs/zh_CN/faq.md @@ -0,0 +1,3 @@ +# FAQ + +## 评估 \ No newline at end of file diff --git a/docs/zh_CN/index.rst b/docs/zh_CN/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..151b4dadf374074720a6f930f0b6512cfa4546be --- /dev/null +++ b/docs/zh_CN/index.rst @@ -0,0 +1,17 @@ +欢迎使用PaddleClas图像分类库! +================================ + +.. toctree:: + :maxdepth: 1 + + tutorials/index + models/index + advanced_tutorials/index + application/index + extension/index + competition_support.md + model_zoo.md + change_log.md + faq.md + +:math:`PaddlePaddle2020` diff --git a/docs/zh_CN/make.bat b/docs/zh_CN/make.bat new file mode 100644 index 0000000000000000000000000000000000000000..2119f51099bf37e4fdb6071dce9f451ea44c62dd --- /dev/null +++ b/docs/zh_CN/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/zh_cn/models/DPN_DenseNet.md b/docs/zh_CN/models/DPN_DenseNet.md similarity index 100% rename from docs/zh_cn/models/DPN_DenseNet.md rename to docs/zh_CN/models/DPN_DenseNet.md diff --git a/docs/zh_cn/models/EfficientNet_and_ResNeXt101_wsl.md b/docs/zh_CN/models/EfficientNet_and_ResNeXt101_wsl.md similarity index 100% rename from docs/zh_cn/models/EfficientNet_and_ResNeXt101_wsl.md rename to docs/zh_CN/models/EfficientNet_and_ResNeXt101_wsl.md diff --git a/docs/zh_cn/models/HRNet.md b/docs/zh_CN/models/HRNet.md similarity index 100% rename from docs/zh_cn/models/HRNet.md rename to docs/zh_CN/models/HRNet.md diff --git a/docs/zh_cn/models/Inception.md b/docs/zh_CN/models/Inception.md similarity index 100% rename from docs/zh_cn/models/Inception.md rename to docs/zh_CN/models/Inception.md diff --git a/docs/zh_cn/models/Mobile.md b/docs/zh_CN/models/Mobile.md similarity index 100% rename from docs/zh_cn/models/Mobile.md rename to docs/zh_CN/models/Mobile.md diff --git a/docs/zh_cn/models/Others.md b/docs/zh_CN/models/Others.md similarity index 100% rename from docs/zh_cn/models/Others.md rename to docs/zh_CN/models/Others.md diff --git a/docs/zh_cn/models/ResNet_and_vd.md b/docs/zh_CN/models/ResNet_and_vd.md similarity index 100% rename from docs/zh_cn/models/ResNet_and_vd.md rename to docs/zh_CN/models/ResNet_and_vd.md diff --git a/docs/zh_cn/models/SEResNext_and_Res2Net.md b/docs/zh_CN/models/SEResNext_and_Res2Net.md similarity index 100% rename from docs/zh_cn/models/SEResNext_and_Res2Net.md rename to docs/zh_CN/models/SEResNext_and_Res2Net.md diff --git a/docs/zh_cn/models/Tricks.md b/docs/zh_CN/models/Tricks.md similarity index 100% rename from docs/zh_cn/models/Tricks.md rename to docs/zh_CN/models/Tricks.md diff --git a/docs/zh_cn/models/index.rst b/docs/zh_CN/models/index.rst similarity index 100% rename from docs/zh_cn/models/index.rst rename to docs/zh_CN/models/index.rst diff --git a/docs/zh_cn/models/models_intro.md b/docs/zh_CN/models/models_intro.md similarity index 100% rename from docs/zh_cn/models/models_intro.md rename to docs/zh_CN/models/models_intro.md diff --git a/docs/zh_cn/tutorials/config.md b/docs/zh_CN/tutorials/config.md similarity index 100% rename from docs/zh_cn/tutorials/config.md rename to docs/zh_CN/tutorials/config.md diff --git a/docs/zh_cn/tutorials/getting_started.md b/docs/zh_CN/tutorials/getting_started.md similarity index 100% rename from docs/zh_cn/tutorials/getting_started.md rename to docs/zh_CN/tutorials/getting_started.md diff --git a/docs/zh_cn/tutorials/index.rst b/docs/zh_CN/tutorials/index.rst similarity index 100% rename from docs/zh_cn/tutorials/index.rst rename to docs/zh_CN/tutorials/index.rst diff --git a/docs/zh_cn/tutorials/install.md b/docs/zh_CN/tutorials/install.md similarity index 100% rename from docs/zh_cn/tutorials/install.md rename to docs/zh_CN/tutorials/install.md diff --git a/ppcls/modeling/__init__.py b/ppcls/modeling/__init__.py index e5badd50a9f69743a6637c7de295d4c9c2812041..e97542690028422b00aef8ea20881ee4b2683b59 100644 --- a/ppcls/modeling/__init__.py +++ b/ppcls/modeling/__init__.py @@ -17,4 +17,4 @@ from . import loss from .architectures import * from .loss import * -from .utils import similar_architectures +from .utils import * diff --git a/ppcls/modeling/utils.py b/ppcls/modeling/utils.py index b239b9e41ac945221a879792cf666d80242e1e4f..acc4d1948264e72c3cffad52b8139331cfb28420 100644 --- a/ppcls/modeling/utils.py +++ b/ppcls/modeling/utils.py @@ -12,8 +12,8 @@ #See the License for the specific language governing permissions and #limitations under the License. -import types import architectures +import types from difflib import SequenceMatcher @@ -28,12 +28,11 @@ def get_architectures(): return names -def similar_architectures(name='', thresh=0.1, topk=10): +def similar_architectures(name='', names=[], thresh=0.1, topk=10): """ inferred similar architectures """ scores = [] - names = get_architectures() for idx, n in enumerate(names): if n[:2] == '__': continue score = SequenceMatcher(None, n.lower(), name.lower()).quick_ratio() diff --git a/ppcls/utils/check.py b/ppcls/utils/check.py index 3c3eadb42d1c531b74b1203a2722236a938e83bc..3e2864472303b13f8d5c6fe2f744c31c45bfa509 100644 --- a/ppcls/utils/check.py +++ b/ppcls/utils/check.py @@ -20,6 +20,7 @@ import sys import paddle.fluid as fluid +from ppcls.modeling import get_architectures from ppcls.modeling import similar_architectures from ppcls.utils import logger @@ -60,7 +61,7 @@ def check_architecture(architecture): """ assert isinstance(architecture, str), \ ("the type of architecture({}) should be str". format(architecture)) - similar_names = similar_architectures(architecture) + similar_names = similar_architectures(architecture, get_architectures()) model_list = ', '.join(similar_names) err = "{} is not exist! Maybe you want: [{}]" \ "".format(architecture, model_list) diff --git a/ppcls/utils/model_zoo.py b/ppcls/utils/model_zoo.py index 543b2558e89b3e31b41ce458a2216b5c42bc1bda..8a154a90de99432c44ec004c08f0b5cb2a61d26e 100644 --- a/ppcls/utils/model_zoo.py +++ b/ppcls/utils/model_zoo.py @@ -17,12 +17,13 @@ from __future__ import division from __future__ import print_function import os -import shutil import requests -import tqdm +import shutil import tarfile +import tqdm import zipfile +from ppcls.modeling import similar_architectures from ppcls.utils.check import check_architecture from ppcls.utils import logger @@ -44,11 +45,7 @@ class ModelNameError(Exception): """ ModelNameError """ - def __init__(self, message='', architecture=''): - similar_names = similar_architectures(architecture) - model_list = ', '.join(similar_names) - message += '\n{} is not exist. \nMaybe you want: [{}]'.format( - architecture, model_list) + def __init__(self, message=''): super(ModelNameError, self).__init__(message) @@ -171,8 +168,24 @@ def _decompress(fname): os.remove(fname) +def _check_pretrained_name(architecture): + assert isinstance(architecture, str), \ + ("the type of architecture({}) should be str". format(architecture)) + with open('./configs/pretrained.list') as flist: + pretrained = [line.strip() for line in flist] + similar_names = similar_architectures(architecture, pretrained) + model_list = ', '.join(similar_names) + err = "{} is not exist! Maybe you want: [{}]" \ + "".format(architecture, model_list) + if architecture not in similar_names: + raise ModelNameError(err) + + def get(architecture, path, decompress=True): - check_architecture(architecture) + """ + Get the pretrained model. + """ + _check_pretrained_name(architecture) url = _get_url(architecture) fname = _download(url, path) if decompress: _decompress(fname)