diff --git a/exprements/PaddleClas/.clang_format.hook b/exprements/PaddleClas/.clang_format.hook
new file mode 100644
index 00000000..1d928216
--- /dev/null
+++ b/exprements/PaddleClas/.clang_format.hook
@@ -0,0 +1,15 @@
+#!/bin/bash
+set -e
+
+readonly VERSION="3.8"
+
+version=$(clang-format -version)
+
+if ! [[ $version == *"$VERSION"* ]]; then
+ echo "clang-format version check failed."
+ echo "a version contains '$VERSION' is needed, but get '$version'"
+ echo "you can install the right version, and make an soft-link to '\$PATH' env"
+ exit -1
+fi
+
+clang-format $@
diff --git a/exprements/PaddleClas/.gitignore b/exprements/PaddleClas/.gitignore
new file mode 100644
index 00000000..d8f8bca6
--- /dev/null
+++ b/exprements/PaddleClas/.gitignore
@@ -0,0 +1,14 @@
+__pycache__/
+*.pyc
+*.sw*
+*/workerlog*
+checkpoints/
+output*/
+pretrained/
+.ipynb_checkpoints/
+*.ipynb*
+_build/
+build/
+log/
+nohup.out
+.DS_Store
diff --git a/exprements/PaddleClas/.pre-commit-config.yaml b/exprements/PaddleClas/.pre-commit-config.yaml
new file mode 100644
index 00000000..1584bc76
--- /dev/null
+++ b/exprements/PaddleClas/.pre-commit-config.yaml
@@ -0,0 +1,35 @@
+- repo: https://github.com/PaddlePaddle/mirrors-yapf.git
+ sha: 0d79c0c469bab64f7229c9aca2b1186ef47f0e37
+ hooks:
+ - id: yapf
+ files: \.py$
+- repo: https://github.com/pre-commit/pre-commit-hooks
+ sha: a11d9314b22d8f8c7556443875b731ef05965464
+ hooks:
+ - id: check-merge-conflict
+ - id: check-symlinks
+ - id: detect-private-key
+ files: (?!.*paddle)^.*$
+ - id: end-of-file-fixer
+ files: \.md$
+ - id: trailing-whitespace
+ files: \.md$
+- repo: https://github.com/Lucas-C/pre-commit-hooks
+ sha: v1.0.1
+ hooks:
+ - id: forbid-crlf
+ files: \.md$
+ - id: remove-crlf
+ files: \.md$
+ - id: forbid-tabs
+ files: \.md$
+ - id: remove-tabs
+ files: \.md$
+- repo: local
+ hooks:
+ - id: clang-format
+ name: clang-format
+ description: Format files with ClangFormat
+ entry: bash .clang_format.hook -i
+ language: system
+ files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$
diff --git a/exprements/PaddleClas/LICENSE b/exprements/PaddleClas/LICENSE
new file mode 100644
index 00000000..261eeb9e
--- /dev/null
+++ b/exprements/PaddleClas/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/exprements/PaddleClas/MANIFEST.in b/exprements/PaddleClas/MANIFEST.in
new file mode 100644
index 00000000..b0a4f6dc
--- /dev/null
+++ b/exprements/PaddleClas/MANIFEST.in
@@ -0,0 +1,7 @@
+include LICENSE.txt
+include README.md
+include docs/en/whl_en.md
+recursive-include deploy/python predict_cls.py preprocess.py postprocess.py det_preprocess.py
+recursive-include deploy/utils get_image_list.py config.py logger.py predictor.py
+
+recursive-include ppcls/ *.py *.txt
\ No newline at end of file
diff --git a/exprements/PaddleClas/README.md b/exprements/PaddleClas/README.md
new file mode 100644
index 00000000..a80b5f53
--- /dev/null
+++ b/exprements/PaddleClas/README.md
@@ -0,0 +1 @@
+README_ch.md
diff --git a/exprements/PaddleClas/README_ch.md b/exprements/PaddleClas/README_ch.md
new file mode 100644
index 00000000..41c1d44f
--- /dev/null
+++ b/exprements/PaddleClas/README_ch.md
@@ -0,0 +1,150 @@
+简体中文 | [English](README_en.md)
+
+# PaddleClas
+
+## 简介
+
+飞桨图像识别套件PaddleClas是飞桨为工业界和学术界所准备的一个图像识别任务的工具集,助力使用者训练出更好的视觉模型和应用落地。
+
+**近期更新**
+
+- 2022.1.27 全面升级文档;新增[PaddleServing C++ pipeline部署方式](./deploy/paddleserving)和[18M图像识别安卓部署Demo](./deploy/lite_shitu)。
+- 2021.11.1 发布[PP-ShiTu技术报告](https://arxiv.org/pdf/2111.00775.pdf),新增饮料识别demo
+- 2021.10.23 发布轻量级图像识别系统PP-ShiTu,CPU上0.2s即可完成在10w+库的图像识别。
+[点击这里](./docs/zh_CN/quick_start/quick_start_recognition.md)立即体验
+- 2021.09.17 发布PP-LCNet系列超轻量骨干网络模型, 在Intel CPU上,单张图像预测速度约5ms,ImageNet-1K数据集上Top1识别准确率达到80.82%,超越ResNet152的模型效果。PP-LCNet的介绍可以参考[论文](https://arxiv.org/pdf/2109.15099.pdf), 或者[PP-LCNet模型介绍](docs/zh_CN/models/PP-LCNet.md),相关指标和预训练权重可以从 [这里](docs/zh_CN/algorithm_introduction/ImageNet_models.md)下载。
+- [more](./docs/zh_CN/others/update_history.md)
+
+## 特性
+
+- PP-ShiTu轻量图像识别系统:集成了目标检测、特征学习、图像检索等模块,广泛适用于各类图像识别任务。cpu上0.2s即可完成在10w+库的图像识别。
+
+- PP-LCNet轻量级CPU骨干网络:专门为CPU设备打造轻量级骨干网络,速度、精度均远超竞品。
+
+- 丰富的预训练模型库:提供了36个系列共175个ImageNet预训练模型,其中7个精选系列模型支持结构快速修改。
+
+- 全面易用的特征学习组件:集成arcmargin, triplet loss等12度量学习方法,通过配置文件即可随意组合切换。
+
+- SSLD知识蒸馏:14个分类预训练模型,精度普遍提升3%以上;其中ResNet50_vd模型在ImageNet-1k数据集上的Top-1精度达到了84.0%,
+Res2Net200_vd预训练模型Top-1精度高达85.1%。
+
+
+

+
+
+
+## 欢迎加入技术交流群
+
+* 您可以扫描下面的微信群二维码, 加入PaddleClas 微信交流群。获得更高效的问题答疑,与各行各业开发者充分交流,期待您的加入。
+
+
+

+
+
+## 快速体验
+
+PP-ShiTu图像识别快速体验:[点击这里](./docs/zh_CN/quick_start/quick_start_recognition.md)
+
+## 文档教程
+- 安装说明
+ - [安装Paddle](./docs/zh_CN/installation/install_paddle.md)
+ - [安装PaddleClas](./docs/zh_CN/installation/install_paddleclas.md)
+- 快速体验
+ - [PP-ShiTu图像识别快速体验](./docs/zh_CN/quick_start/quick_start_recognition.md)
+ - 图像分类快速体验
+ - [尝鲜版](./docs/zh_CN/quick_start/quick_start_classification_new_user.md)
+ - [进阶版](./docs/zh_CN/quick_start/quick_start_classification_professional.md)
+ - [多标签分类](./docs/zh_CN/quick_start/quick_start_multilabel_classification.md)
+- [PP-ShiTu图像识别系统介绍](#图像识别系统介绍)
+ - [主体检测](./docs/zh_CN/image_recognition_pipeline/mainbody_detection.md)
+ - [特征提取](./docs/zh_CN/image_recognition_pipeline/feature_extraction.md)
+ - [向量检索](./docs/zh_CN/image_recognition_pipeline/vector_search.md)
+- [骨干网络和预训练模型库](./docs/zh_CN/algorithm_introduction/ImageNet_models.md)
+- 数据准备
+ - [图像分类数据集介绍](./docs/zh_CN/data_preparation/classification_dataset.md)
+ - [图像识别数据集介绍](./docs/zh_CN/data_preparation/recognition_dataset.md)
+- 模型训练
+ - [图像分类任务](./docs/zh_CN/models_training/classification.md)
+ - [图像识别任务](./docs/zh_CN/models_training/recognition.md)
+ - [训练参数调整策略](./docs/zh_CN/models_training/train_strategy.md)
+ - [配置文件说明](./docs/zh_CN/models_training/config_description.md)
+- 模型预测部署
+ - [模型导出](./docs/zh_CN/inference_deployment/export_model.md)
+ - Python/C++ 预测引擎
+ - [基于Python预测引擎预测推理](./docs/zh_CN/inference_deployment/python_deploy.md)
+ - [基于C++分类预测引擎预测推理](./docs/zh_CN/inference_deployment/cpp_deploy.md)、[基于C++的PP-ShiTu预测引擎预测推理](deploy/cpp_shitu/readme.md)
+ - 服务化部署
+ - [Paddle Serving服务化部署(推荐)](./docs/zh_CN/inference_deployment/paddle_serving_deploy.md)
+ - [Hub serving服务化部署](./docs/zh_CN/inference_deployment/paddle_hub_serving_deploy.md)
+ - [端侧部署](./deploy/lite/readme.md)
+ - [whl包预测](./docs/zh_CN/inference_deployment/whl_deploy.md)
+- 算法介绍
+ - [图像分类任务介绍](./docs/zh_CN/algorithm_introduction/image_classification.md)
+ - [度量学习介绍](./docs/zh_CN/algorithm_introduction/metric_learning.md)
+- 高阶使用
+ - [数据增广](./docs/zh_CN/advanced_tutorials/DataAugmentation.md)
+ - [模型量化](./docs/zh_CN/advanced_tutorials/model_prune_quantization.md)
+ - [知识蒸馏](./docs/zh_CN/advanced_tutorials/knowledge_distillation.md)
+ - [PaddleClas结构解析](./docs/zh_CN/advanced_tutorials/code_overview.md)
+ - [社区贡献指南](./docs/zh_CN/advanced_tutorials/how_to_contribute.md)
+- FAQ
+ - [图像识别精选问题](docs/zh_CN/faq_series/faq_2021_s2.md)
+ - [图像分类精选问题](docs/zh_CN/faq_series/faq_selected_30.md)
+ - [图像分类FAQ第一季](docs/zh_CN/faq_series/faq_2020_s1.md)
+ - [图像分类FAQ第二季](docs/zh_CN/faq_series/faq_2021_s1.md)
+- [许可证书](#许可证书)
+- [贡献代码](#贡献代码)
+
+
+## PP-ShiTu图像识别系统介绍
+
+
+

+
+
+PP-ShiTu是一个实用的轻量级通用图像识别系统,主要由主体检测、特征学习和向量检索三个模块组成。该系统从骨干网络选择和调整、损失函数的选择、数据增强、学习率变换策略、正则化参数选择、预训练模型使用以及模型裁剪量化8个方面,采用多种策略,对各个模块的模型进行优化,最终得到在CPU上仅0.2s即可完成10w+库的图像识别的系统。更多细节请参考[PP-ShiTu技术方案](https://arxiv.org/pdf/2111.00775.pdf)。
+
+
+
+## PP-ShiTu图像识别系统效果展示
+- 瓶装饮料识别
+
+

+
+
+- 商品识别
+
+

+
+
+- 动漫人物识别
+
+

+
+
+- logo识别
+
+

+
+
+
+- 车辆识别
+
+

+
+
+
+
+
+## 许可证书
+本项目的发布受Apache 2.0 license许可认证。
+
+
+
+## 贡献代码
+我们非常欢迎你为PaddleClas贡献代码,也十分感谢你的反馈。
+如果想为PaddleCLas贡献代码,可以参考[贡献指南](./docs/zh_CN/advanced_tutorials/how_to_contribute.md)。
+
+- 非常感谢[nblib](https://github.com/nblib)修正了PaddleClas中RandErasing的数据增广配置文件。
+- 非常感谢[chenpy228](https://github.com/chenpy228)修正了PaddleClas文档中的部分错别字。
+- 非常感谢[jm12138](https://github.com/jm12138)为PaddleClas添加ViT,DeiT系列模型和RepVGG系列模型。
diff --git a/exprements/PaddleClas/README_en.md b/exprements/PaddleClas/README_en.md
new file mode 100644
index 00000000..e86ed3fe
--- /dev/null
+++ b/exprements/PaddleClas/README_en.md
@@ -0,0 +1,132 @@
+[简体中文](README_ch.md) | English
+
+# PaddleClas
+
+## Introduction
+
+PaddleClas is an image recognition toolset for industry and academia, helping users train better computer vision models and apply them in real scenarios.
+
+**Recent updates**
+
+- 2021.09.17 Add PP-LCNet series model developed by PaddleClas, these models show strong competitiveness on Intel CPUs.
+For the introduction of PP-LCNet, please refer to [paper](https://arxiv.org/pdf/2109.15099.pdf) or [PP-LCNet model introduction](docs/en/models/PP-LCNet_en.md). The metrics and pretrained model are available [here](docs/en/ImageNet_models_en.md).
+
+- 2021.06.29 Add Swin-transformer series model,Highest top1 acc on ImageNet1k dataset reaches 87.2%, training, evaluation and inference are all supported. Pretrained models can be downloaded [here](docs/en/models/models_intro_en.md).
+- 2021.06.16 PaddleClas release/2.2. Add metric learning and vector search modules. Add product recognition, animation character recognition, vehicle recognition and logo recognition. Added 30 pretrained models of LeViT, Twins, TNT, DLA, HarDNet, and RedNet, and the accuracy is roughly the same as that of the paper.
+- [more](./docs/en/update_history_en.md)
+
+## Features
+
+- A practical image recognition system consist of detection, feature learning and retrieval modules, widely applicable to all types of image recognition tasks.
+Four sample solutions are provided, including product recognition, vehicle recognition, logo recognition and animation character recognition.
+
+- Rich library of pre-trained models: Provide a total of 164 ImageNet pre-trained models in 35 series, among which 6 selected series of models support fast structural modification.
+
+- Comprehensive and easy-to-use feature learning components: 12 metric learning methods are integrated and can be combined and switched at will through configuration files.
+
+- SSLD knowledge distillation: The 14 classification pre-training models generally improved their accuracy by more than 3%; among them, the ResNet50_vd model achieved a Top-1 accuracy of 84.0% on the Image-Net-1k dataset and the Res2Net200_vd pre-training model achieved a Top-1 accuracy of 85.1%.
+
+- Data augmentation: Provide 8 data augmentation algorithms such as AutoAugment, Cutout, Cutmix, etc. with detailed introduction, code replication and evaluation of effectiveness in a unified experimental environment.
+
+
+
+
+
+

+
+
+
+## Welcome to Join the Technical Exchange Group
+
+* You can also scan the QR code below to join the PaddleClas WeChat group to get more efficient answers to your questions and to communicate with developers from all walks of life. We look forward to hearing from you.
+
+
+

+
+
+## Quick Start
+Quick experience of image recognition:[Link](./docs/en/tutorials/quick_start_recognition_en.md)
+
+## Tutorials
+
+- [Quick Installation](./docs/en/tutorials/install_en.md)
+- [Quick Start of Recognition](./docs/en/tutorials/quick_start_recognition_en.md)
+- [Introduction to Image Recognition Systems](#Introduction_to_Image_Recognition_Systems)
+- [Demo images](#Demo_images)
+- Algorithms Introduction
+ - [Backbone Network and Pre-trained Model Library](./docs/en/ImageNet_models_en.md)
+ - [Mainbody Detection](./docs/en/application/mainbody_detection_en.md)
+ - [Image Classification](./docs/en/tutorials/image_classification_en.md)
+ - [Feature Learning](./docs/en/application/feature_learning_en.md)
+ - [Product Recognition](./docs/en/application/product_recognition_en.md)
+ - [Vehicle Recognition](./docs/en/application/vehicle_recognition_en.md)
+ - [Logo Recognition](./docs/en/application/logo_recognition_en.md)
+ - [Animation Character Recognition](./docs/en/application/cartoon_character_recognition_en.md)
+ - [Vector Search](./deploy/vector_search/README.md)
+- Models Training/Evaluation
+ - [Image Classification](./docs/en/tutorials/getting_started_en.md)
+ - [Feature Learning](./docs/en/tutorials/getting_started_retrieval_en.md)
+- Inference Model Prediction
+ - [Python Inference](./docs/en/inference.md)
+ - [C++ Classfication Inference](./deploy/cpp/readme_en.md), [C++ PP-ShiTu Inference](deploy/cpp_shitu/readme_en.md)
+- Model Deploy (only support classification for now, recognition coming soon)
+ - [Hub Serving Deployment](./deploy/hubserving/readme_en.md)
+ - [Mobile Deployment](./deploy/lite/readme_en.md)
+ - [Inference Using whl](./docs/en/whl_en.md)
+- Advanced Tutorial
+ - [Knowledge Distillation](./docs/en/advanced_tutorials/distillation/distillation_en.md)
+ - [Model Quantization](./docs/en/extension/paddle_quantization_en.md)
+ - [Data Augmentation](./docs/en/advanced_tutorials/image_augmentation/ImageAugment_en.md)
+- [License](#License)
+- [Contribution](#Contribution)
+
+
+## Introduction to Image Recognition Systems
+
+
+

+
+
+Image recognition can be divided into three steps:
+- (1)Identify region proposal for target objects through a detection model;
+- (2)Extract features for each region proposal;
+- (3)Search features in the retrieval database and output results;
+
+For a new unknown category, there is no need to retrain the model, just prepare images of new category, extract features and update retrieval database and the category can be recognised.
+
+
+## Demo images [more](https://github.com/PaddlePaddle/PaddleClas/tree/release/2.2/docs/images/recognition/more_demo_images)
+- Product recognition
+
+

+
+
+- Cartoon character recognition
+
+

+
+
+- Logo recognition
+
+

+
+
+- Car recognition
+
+

+
+
+
+## License
+PaddleClas is released under the Apache 2.0 license Apache 2.0 license
+
+
+
+## Contribution
+Contributions are highly welcomed and we would really appreciate your feedback!!
+
+
+- Thank [nblib](https://github.com/nblib) to fix bug of RandErasing.
+- Thank [chenpy228](https://github.com/chenpy228) to fix some typos PaddleClas.
+- Thank [jm12138](https://github.com/jm12138) to add ViT, DeiT models and RepVGG models into PaddleClas.
+- Thank [FutureSI](https://aistudio.baidu.com/aistudio/personalcenter/thirdview/76563) to parse and summarize the PaddleClas code.
diff --git a/exprements/PaddleClas/__init__.py b/exprements/PaddleClas/__init__.py
new file mode 100644
index 00000000..2128a6cc
--- /dev/null
+++ b/exprements/PaddleClas/__init__.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+__all__ = ['PaddleClas']
+from .paddleclas import PaddleClas
+from ppcls.arch.backbone import *
diff --git a/exprements/PaddleClas/benchmark/README.md b/exprements/PaddleClas/benchmark/README.md
new file mode 100644
index 00000000..2e892d97
--- /dev/null
+++ b/exprements/PaddleClas/benchmark/README.md
@@ -0,0 +1,27 @@
+# benchmark使用说明
+
+此目录所有shell脚本是为了测试PaddleClas中不同模型的速度指标,如单卡训练速度指标、多卡训练速度指标等。
+
+## 相关脚本说明
+
+一共有3个脚本:
+
+- `prepare_data.sh`: 下载相应的测试数据,并配置好数据路径
+- `run_benchmark.sh`: 执行单独一个训练测试的脚本,具体调用方式,可查看脚本注释
+- `run_all.sh`: 执行所有训练测试的入口脚本
+
+## 使用说明
+
+**注意**:为了跟PaddleClas中其他的模块的执行目录保持一致,此模块的执行目录为`PaddleClas`的根目录。
+
+### 1.准备数据
+
+```shell
+bash benchmark/prepare_data.sh
+```
+
+### 2.执行所有模型的测试
+
+```shell
+bash benchmark/run_all.sh
+```
diff --git a/exprements/PaddleClas/benchmark/prepare_data.sh b/exprements/PaddleClas/benchmark/prepare_data.sh
new file mode 100644
index 00000000..411459cf
--- /dev/null
+++ b/exprements/PaddleClas/benchmark/prepare_data.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+dataset_url=$1
+
+package_check_list=(imageio tqdm Cython pycocotools tb_paddle scipy pandas wget h5py sklearn opencv-python visualdl)
+for package in ${package_check_list[@]}; do
+ if python -c "import ${package}" >/dev/null 2>&1; then
+ echo "${package} have already installed"
+ else
+ echo "${package} NOT FOUND"
+ pip install ${package}
+ echo "${package} installed"
+ fi
+done
+
+cd dataset
+rm -rf ILSVRC2012
+wget -nc ${dataset_url}
+tar xf ILSVRC2012_val.tar
+ln -s ILSVRC2012_val ILSVRC2012
+cd ILSVRC2012
+ln -s val_list.txt train_list.txt
+cd ../../
diff --git a/exprements/PaddleClas/benchmark/run_all.sh b/exprements/PaddleClas/benchmark/run_all.sh
new file mode 100644
index 00000000..a6d68841
--- /dev/null
+++ b/exprements/PaddleClas/benchmark/run_all.sh
@@ -0,0 +1,31 @@
+# 提供可稳定复现性能的脚本,默认在标准docker环境内py37执行: paddlepaddle/paddle:latest-gpu-cuda10.1-cudnn7 paddle=2.1.2 py=37
+# 执行目录:需说明
+# cd **
+# 1 安装该模型需要的依赖 (如需开启优化策略请注明)
+# pip install ...
+# 2 拷贝该模型需要数据、预训练模型
+# 3 批量运行(如不方便批量,1,2需放到单个模型中)
+log_path=${LOG_PATH_INDEX_DIR:-$(pwd)} # LOG_PATH_INDEX_DIR 后续QA设置参数
+model_mode_list=(MobileNetV1 MobileNetV2 MobileNetV3_large_x1_0 ShuffleNetV2_x1_0 HRNet_W48_C SwinTransformer_tiny_patch4_window7_224 alt_gvt_base) # benchmark 监控模型列表
+#model_mode_list=(MobileNetV1 MobileNetV2 MobileNetV3_large_x1_0 EfficientNetB0 ShuffleNetV2_x1_0 DenseNet121 HRNet_W48_C SwinTransformer_tiny_patch4_window7_224 alt_gvt_base) # 该脚本支持列表
+fp_item_list=(fp32)
+#bs_list=(32 64 96 128)
+for model_mode in ${model_mode_list[@]}; do
+ for fp_item in ${fp_item_list[@]}; do
+ if [ ${model_mode} = MobileNetV3_large_x1_0 ] || [ ${model_mode} = ShuffleNetV2_x1_0 ]; then
+ bs_list=(256)
+ else
+ bs_list=(64)
+ fi
+ for bs_item in ${bs_list[@]};do
+ echo "index is speed, 1gpus, begin, ${model_name}"
+ run_mode=sp
+ CUDA_VISIBLE_DEVICES=0 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} 1 ${model_mode} | tee ${log_path}/clas_${model_mode}_${run_mode}_bs${bs_item}_${fp_item}_1gpus 2>&1 # (5min)
+ sleep 10
+ echo "index is speed, 8gpus, run_mode is multi_process, begin, ${model_name}"
+ run_mode=mp
+ CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} 1 ${model_mode}| tee ${log_path}/clas_${model_mode}_${run_mode}_bs${bs_item}_${fp_item}_8gpus8p 2>&1
+ sleep 10
+ done
+ done
+done
diff --git a/exprements/PaddleClas/benchmark/run_benchmark.sh b/exprements/PaddleClas/benchmark/run_benchmark.sh
new file mode 100644
index 00000000..8cee6fce
--- /dev/null
+++ b/exprements/PaddleClas/benchmark/run_benchmark.sh
@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+set -xe
+# 运行示例:CUDA_VISIBLE_DEVICES=0 bash run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} 500 ${model_mode}
+# 参数说明
+function _set_params(){
+ run_mode=${1:-"sp"} # 单卡sp|多卡mp
+ batch_size=${2:-"64"}
+ fp_item=${3:-"fp32"} # fp32|fp16
+ epochs=${4:-"2"} # 可选,如果需要修改代码提前中断
+ model_item=${5:-"model_item"}
+ run_log_path=${TRAIN_LOG_DIR:-$(pwd)} # TRAIN_LOG_DIR 后续QA设置该参数
+
+ index=1
+ mission_name="图像分类" # 模型所属任务名称,具体可参考scripts/config.ini (必填)
+ direction_id=0 # 任务所属方向,0:CV,1:NLP,2:Rec。 (必填)
+ skip_steps=8 # 解析日志,有些模型前几个step耗时长,需要跳过 (必填)
+ keyword="ips:" # 解析日志,筛选出数据所在行的关键字 (必填)
+ keyword_loss="loss:" #选填
+ model_mode=-1 # 解析日志,具体参考scripts/analysis.py. (必填)
+ ips_unit="images/s"
+ base_batch_size=$batch_size
+# 以下不用修改
+ device=${CUDA_VISIBLE_DEVICES//,/ }
+ arr=(${device})
+ num_gpu_devices=${#arr[*]}
+ log_file=${run_log_path}/clas_${model_item}_${run_mode}_bs${batch_size}_${fp_item}_${num_gpu_devices}
+ model_name=${model_item}_bs${batch_size}_${fp_item} # model_item 用于yml匹配,model_name用于入库
+}
+function _train(){
+ echo "Train on ${num_gpu_devices} GPUs"
+ echo "current CUDA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES, gpus=$num_gpu_devices, batch_size=$batch_size"
+
+ if [ ${fp_item} = "fp32" ];then
+ model_config=`find ppcls/configs/ImageNet -name ${model_item}.yaml`
+ else
+ model_config=`find ppcls/configs/ImageNet -name ${model_item}_fp16.yaml`
+ fi
+
+ train_cmd="-c ${model_config} -o DataLoader.Train.sampler.batch_size=${batch_size} -o Global.epochs=${epochs} -o Global.eval_during_train=False -o Global.print_batch_step=2"
+ case ${run_mode} in
+ sp) train_cmd="python -u tools/train.py ${train_cmd}" ;;
+ mp)
+ train_cmd="python -m paddle.distributed.launch --log_dir=./mylog --gpus=$CUDA_VISIBLE_DEVICES tools/train.py ${train_cmd}"
+ log_parse_file="mylog/workerlog.0" ;;
+ *) echo "choose run_mode(sp or mp)"; exit 1;
+ esac
+ rm -rf mylog
+# 以下不用修改
+ timeout 5m ${train_cmd} > ${log_file} 2>&1
+ if [ $? -ne 0 ];then
+ echo -e "${model_name}, FAIL"
+ export job_fail_flag=1
+ else
+ echo -e "${model_name}, SUCCESS"
+ export job_fail_flag=0
+ fi
+ kill -9 `ps -ef|grep 'python'|awk '{print $2}'`
+
+ if [ $run_mode = "mp" -a -d mylog ]; then
+ rm ${log_file}
+ cp mylog/workerlog.0 ${log_file}
+ fi
+}
+
+source ${BENCHMARK_ROOT}/scripts/run_model.sh # 在该脚本中会对符合benchmark规范的log使用analysis.py 脚本进行性能数据解析;该脚本在连调时可从benchmark repo中下载https://github.com/PaddlePaddle/benchmark/blob/master/scripts/run_model.sh;如果不联调只想要产出训练log可以注掉本行,提交时需打开
+_set_params $@
+_run
+#_train
diff --git a/exprements/PaddleClas/dataset/.gitkeep b/exprements/PaddleClas/dataset/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/exprements/PaddleClas/deploy/__init__.py b/exprements/PaddleClas/deploy/__init__.py
new file mode 100644
index 00000000..eb018c3f
--- /dev/null
+++ b/exprements/PaddleClas/deploy/__init__.py
@@ -0,0 +1 @@
+from . import utils
diff --git a/exprements/PaddleClas/deploy/configs/build_general.yaml b/exprements/PaddleClas/deploy/configs/build_general.yaml
new file mode 100644
index 00000000..258b40a1
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/build_general.yaml
@@ -0,0 +1,36 @@
+Global:
+ rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_v1.0_infer"
+ batch_size: 32
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess: null
+
+# indexing engine config
+IndexProcess:
+ index_method: "HNSW32" # supported: HNSW32, IVF, Flat
+ image_root: "./drink_dataset_v1.0/gallery/"
+ index_dir: "./drink_dataset_v1.0/index"
+ data_file: "./drink_dataset_v1.0/gallery/drink_label.txt"
+ index_operation: "new" # suported: "append", "remove", "new"
+ delimiter: "\t"
+ dist_type: "IP"
+ embedding_size: 512
diff --git a/exprements/PaddleClas/deploy/configs/inference_cartoon.yaml b/exprements/PaddleClas/deploy/configs/inference_cartoon.yaml
new file mode 100644
index 00000000..7d93d98c
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_cartoon.yaml
@@ -0,0 +1,65 @@
+Global:
+ infer_imgs: "./recognition_demo_data_v1.1/test_cartoon"
+ det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/"
+ rec_inference_model_dir: "./models/cartoon_rec_ResNet50_iCartoon_v1.0_infer/"
+ rec_nms_thresold: 0.05
+
+ batch_size: 1
+ image_shape: [3, 640, 640]
+ threshold: 0.2
+ max_det_results: 5
+ labe_list:
+ - foreground
+
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+DetPreProcess:
+ transform_ops:
+ - DetResize:
+ interp: 2
+ keep_ratio: false
+ target_size: [640, 640]
+ - DetNormalizeImage:
+ is_scale: true
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ - DetPermute: {}
+
+DetPostProcess: {}
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ resize_short: 256
+ - CropImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess: null
+
+# indexing engine config
+IndexProcess:
+ index_method: "HNSW32" # supported: HNSW32, IVF, Flat
+ index_dir: "./recognition_demo_data_v1.1/gallery_cartoon/index/"
+ image_root: "./recognition_demo_data_v1.1/gallery_cartoon/"
+ data_file: "./recognition_demo_data_v1.1/gallery_cartoon/data_file.txt"
+ index_operation: "new" # suported: "append", "remove", "new"
+ delimiter: "\t"
+ dist_type: "IP"
+ embedding_size: 2048
+ batch_size: 32
+ return_k: 5
+ score_thres: 0.5
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_cls.yaml b/exprements/PaddleClas/deploy/configs/inference_cls.yaml
new file mode 100644
index 00000000..fc0f0fe6
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_cls.yaml
@@ -0,0 +1,35 @@
+Global:
+ infer_imgs: "./images/ILSVRC2012_val_00000010.jpeg"
+ inference_model_dir: "./models"
+ batch_size: 1
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+PreProcess:
+ transform_ops:
+ - ResizeImage:
+ resize_short: 256
+ - CropImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ channel_num: 3
+ - ToCHWImage:
+
+PostProcess:
+ main_indicator: Topk
+ Topk:
+ topk: 5
+ class_id_map_file: "../ppcls/utils/imagenet1k_label_list.txt"
+ SavePreLabel:
+ save_dir: ./pre_label/
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_cls_ch4.yaml b/exprements/PaddleClas/deploy/configs/inference_cls_ch4.yaml
new file mode 100644
index 00000000..9b740ed8
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_cls_ch4.yaml
@@ -0,0 +1,35 @@
+Global:
+ infer_imgs: "./images/ILSVRC2012_val_00000010.jpeg"
+ inference_model_dir: "./models"
+ batch_size: 1
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+PreProcess:
+ transform_ops:
+ - ResizeImage:
+ resize_short: 256
+ - CropImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ channel_num: 4
+ - ToCHWImage:
+
+PostProcess:
+ main_indicator: Topk
+ Topk:
+ topk: 5
+ class_id_map_file: "../ppcls/utils/imagenet1k_label_list.txt"
+ SavePreLabel:
+ save_dir: ./pre_label/
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_cls_multilabel.yaml b/exprements/PaddleClas/deploy/configs/inference_cls_multilabel.yaml
new file mode 100644
index 00000000..78912d0a
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_cls_multilabel.yaml
@@ -0,0 +1,35 @@
+Global:
+ infer_imgs: "./images/0517_2715693311.jpg"
+ inference_model_dir: "../inference/"
+ batch_size: 1
+ use_gpu: True
+ enable_mkldnn: False
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+PreProcess:
+ transform_ops:
+ - ResizeImage:
+ resize_short: 256
+ - CropImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ channel_num: 3
+ - ToCHWImage:
+
+PostProcess:
+ main_indicator: MultiLabelTopk
+ MultiLabelTopk:
+ topk: 5
+ class_id_map_file: None
+ SavePreLabel:
+ save_dir: ./pre_label/
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_det.yaml b/exprements/PaddleClas/deploy/configs/inference_det.yaml
new file mode 100644
index 00000000..c809a025
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_det.yaml
@@ -0,0 +1,34 @@
+Global:
+ infer_imgs: "./images/wangzai.jpg"
+ det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer"
+ batch_size: 1
+ image_shape: [3, 640, 640]
+ threshold: 0.2
+ max_det_results: 1
+ labe_list:
+ - foreground
+
+ # inference engine config
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+DetPreProcess:
+ transform_ops:
+ - DetResize:
+ interp: 2
+ keep_ratio: false
+ target_size: [640, 640]
+ - DetNormalizeImage:
+ is_scale: true
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ - DetPermute: {}
+
+DetPostProcess: {}
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_drink.yaml b/exprements/PaddleClas/deploy/configs/inference_drink.yaml
new file mode 100644
index 00000000..61d116f9
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_drink.yaml
@@ -0,0 +1,63 @@
+Global:
+ infer_imgs: "./drink_dataset_v1.0/test_images/hongniu_1.jpg"
+ det_inference_model_dir: "./models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer"
+ rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_v1.0_infer"
+ rec_nms_thresold: 0.05
+
+ batch_size: 1
+ image_shape: [3, 640, 640]
+ threshold: 0.2
+ max_det_results: 5
+ labe_list:
+ - foreground
+
+ use_gpu: True
+ enable_mkldnn: False
+ cpu_num_threads: 10
+ enable_benchmark: False
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+DetPreProcess:
+ transform_ops:
+ - DetResize:
+ interp: 2
+ keep_ratio: false
+ target_size: [640, 640]
+ - DetNormalizeImage:
+ is_scale: true
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ - DetPermute: {}
+
+DetPostProcess: {}
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess: null
+
+# indexing engine config
+IndexProcess:
+ index_method: "HNSW32" # supported: HNSW32, IVF, Flat
+ index_dir: "./drink_dataset_v1.0/gallery"
+ image_root: "./drink_dataset_v1.0/index"
+ data_file: "./drink_dataset_v1.0/gallery/drink_label.txt"
+ index_operation: "new" # suported: "append", "remove", "new"
+ delimiter: " "
+ dist_type: "IP"
+ embedding_size: 512
+ batch_size: 32
+ return_k: 5
+ score_thres: 0.4
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_general.yaml b/exprements/PaddleClas/deploy/configs/inference_general.yaml
new file mode 100644
index 00000000..6b397b50
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_general.yaml
@@ -0,0 +1,63 @@
+Global:
+ infer_imgs: "./drink_dataset_v1.0/test_images/nongfu_spring.jpeg"
+ det_inference_model_dir: "./models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer"
+ rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_v1.0_infer"
+ rec_nms_thresold: 0.05
+
+ batch_size: 1
+ image_shape: [3, 640, 640]
+ threshold: 0.2
+ max_det_results: 5
+ labe_list:
+ - foreground
+
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+DetPreProcess:
+ transform_ops:
+ - DetResize:
+ interp: 2
+ keep_ratio: false
+ target_size: [640, 640]
+ - DetNormalizeImage:
+ is_scale: true
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ - DetPermute: {}
+
+DetPostProcess: {}
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess: null
+
+# indexing engine config
+IndexProcess:
+ index_method: "HNSW32" # supported: HNSW32, IVF, Flat
+ image_root: "./drink_dataset_v1.0/gallery/"
+ index_dir: "./drink_dataset_v1.0/index"
+ data_file: "./drink_dataset_v1.0/gallery/drink_label.txt"
+ index_operation: "new" # suported: "append", "remove", "new"
+ delimiter: "\t"
+ dist_type: "IP"
+ embedding_size: 512
+ batch_size: 32
+ return_k: 5
+ score_thres: 0.5
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_general_binary.yaml b/exprements/PaddleClas/deploy/configs/inference_general_binary.yaml
new file mode 100644
index 00000000..d76dae8f
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_general_binary.yaml
@@ -0,0 +1,65 @@
+Global:
+ infer_imgs: "./drink_dataset_v1.0/test_images/001.jpeg"
+ det_inference_model_dir: "./models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer"
+ rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_binary_v1.0_infer"
+ rec_nms_thresold: 0.05
+
+ batch_size: 1
+ image_shape: [3, 640, 640]
+ threshold: 0.2
+ max_det_results: 5
+ labe_list:
+ - foreground
+
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+DetPreProcess:
+ transform_ops:
+ - DetResize:
+ interp: 2
+ keep_ratio: false
+ target_size: [640, 640]
+ - DetNormalizeImage:
+ is_scale: true
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ - DetPermute: {}
+DetPostProcess: {}
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess:
+ main_indicator: Binarize
+ Binarize:
+ method: "sign"
+
+# indexing engine config
+IndexProcess:
+ index_method: "Flat" # supported: HNSW32, Flat
+ image_root: "./drink_dataset_v1.0/gallery/"
+ index_dir: "./drink_dataset_v1.0/index_bin"
+ data_file: "./drink_dataset_v1.0/gallery/drink_label.txt"
+ index_operation: "new" # suported: "append", "remove", "new"
+ delimiter: "\t"
+ dist_type: "hamming"
+ embedding_size: 512
+ batch_size: 32
+ return_k: 5
+ hamming_radius: 100
diff --git a/exprements/PaddleClas/deploy/configs/inference_logo.yaml b/exprements/PaddleClas/deploy/configs/inference_logo.yaml
new file mode 100644
index 00000000..f78ca25a
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_logo.yaml
@@ -0,0 +1,63 @@
+Global:
+ infer_imgs: "./recognition_demo_data_v1.1/test_logo"
+ det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/"
+ rec_inference_model_dir: "./models/logo_rec_ResNet50_Logo3K_v1.0_infer/"
+ rec_nms_thresold: 0.05
+
+ batch_size: 1
+ image_shape: [3, 640, 640]
+ threshold: 0.2
+ max_det_results: 5
+ labe_list:
+ - foreground
+
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+DetPreProcess:
+ transform_ops:
+ - DetResize:
+ interp: 2
+ keep_ratio: false
+ target_size: [640, 640]
+ - DetNormalizeImage:
+ is_scale: true
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ - DetPermute: {}
+
+DetPostProcess: {}
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess: null
+
+# indexing engine config
+IndexProcess:
+ index_method: "HNSW32" # supported: HNSW32, IVF, Flat
+ index_dir: "./recognition_demo_data_v1.1/gallery_logo/index/"
+ image_root: "./recognition_demo_data_v1.1/gallery_logo/"
+ data_file: "./recognition_demo_data_v1.1/gallery_logo/data_file.txt"
+ index_operation: "new" # suported: "append", "remove", "new"
+ delimiter: "\t"
+ dist_type: "IP"
+ embedding_size: 512
+ batch_size: 32
+ return_k: 5
+ score_thres: 0.5
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_product.yaml b/exprements/PaddleClas/deploy/configs/inference_product.yaml
new file mode 100644
index 00000000..e7b494c3
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_product.yaml
@@ -0,0 +1,64 @@
+Global:
+ infer_imgs: "./recognition_demo_data_v1.1/test_product/daoxiangcunjinzhubing_6.jpg"
+ det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer"
+ rec_inference_model_dir: "./models/product_ResNet50_vd_aliproduct_v1.0_infer"
+ rec_nms_thresold: 0.05
+
+ batch_size: 1
+ image_shape: [3, 640, 640]
+ threshold: 0.2
+ max_det_results: 5
+ labe_list:
+ - foreground
+
+ # inference engine config
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+DetPreProcess:
+ transform_ops:
+ - DetResize:
+ interp: 2
+ keep_ratio: false
+ target_size: [640, 640]
+ - DetNormalizeImage:
+ is_scale: true
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ - DetPermute: {}
+
+DetPostProcess: {}
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess: null
+
+# indexing engine config
+IndexProcess:
+ index_method: "HNSW32" # supported: HNSW32, IVF, Flat
+ index_dir: "./recognition_demo_data_v1.1/gallery_product/index"
+ image_root: "./recognition_demo_data_v1.1/gallery_product/"
+ data_file: "./recognition_demo_data_v1.1/gallery_product/data_file.txt"
+ index_operation: "new" # suported: "append", "remove", "new"
+ delimiter: "\t"
+ dist_type: "IP"
+ embedding_size: 512
+ batch_size: 32
+ return_k: 5
+ score_thres: 0.5
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_rec.yaml b/exprements/PaddleClas/deploy/configs/inference_rec.yaml
new file mode 100644
index 00000000..e183ef07
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_rec.yaml
@@ -0,0 +1,28 @@
+Global:
+ infer_imgs: "./images/wangzai.jpg"
+ rec_inference_model_dir: "./models/product_ResNet50_vd_aliproduct_v1.0_infer"
+ batch_size: 1
+ use_gpu: False
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ resize_short: 256
+ - CropImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess: null
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/configs/inference_vehicle.yaml b/exprements/PaddleClas/deploy/configs/inference_vehicle.yaml
new file mode 100644
index 00000000..d99f42ad
--- /dev/null
+++ b/exprements/PaddleClas/deploy/configs/inference_vehicle.yaml
@@ -0,0 +1,63 @@
+Global:
+ infer_imgs: "./recognition_demo_data_v1.1/test_vehicle/"
+ det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/"
+ rec_inference_model_dir: "./models/vehicle_cls_ResNet50_CompCars_v1.0_infer/"
+ rec_nms_thresold: 0.05
+
+ batch_size: 1
+ image_shape: [3, 640, 640]
+ threshold: 0.2
+ max_det_results: 5
+ labe_list:
+ - foreground
+
+ use_gpu: True
+ enable_mkldnn: True
+ cpu_num_threads: 10
+ enable_benchmark: True
+ use_fp16: False
+ ir_optim: True
+ use_tensorrt: False
+ gpu_mem: 8000
+ enable_profile: False
+
+DetPreProcess:
+ transform_ops:
+ - DetResize:
+ interp: 2
+ keep_ratio: false
+ target_size: [640, 640]
+ - DetNormalizeImage:
+ is_scale: true
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ - DetPermute: {}
+
+DetPostProcess: {}
+
+RecPreProcess:
+ transform_ops:
+ - ResizeImage:
+ size: 224
+ - NormalizeImage:
+ scale: 0.00392157
+ mean: [0.485, 0.456, 0.406]
+ std: [0.229, 0.224, 0.225]
+ order: ''
+ - ToCHWImage:
+
+RecPostProcess: null
+
+# indexing engine config
+IndexProcess:
+ index_method: "HNSW32" # supported: HNSW32, IVF, Flat
+ index_dir: "./recognition_demo_data_v1.1/gallery_vehicle/index/"
+ image_root: "./recognition_demo_data_v1.1/gallery_vehicle/"
+ data_file: "./recognition_demo_data_v1.1/gallery_vehicle/data_file.txt"
+ index_operation: "new" # suported: "append", "remove", "new"
+ delimiter: "\t"
+ dist_type: "IP"
+ embedding_size: 512
+ batch_size: 32
+ return_k: 5
+ score_thres: 0.5
\ No newline at end of file
diff --git a/exprements/PaddleClas/deploy/cpp/CMakeLists.txt b/exprements/PaddleClas/deploy/cpp/CMakeLists.txt
new file mode 100644
index 00000000..74c1c72f
--- /dev/null
+++ b/exprements/PaddleClas/deploy/cpp/CMakeLists.txt
@@ -0,0 +1,225 @@
+project(clas_system CXX C)
+cmake_minimum_required(VERSION 3.14)
+
+option(WITH_MKL "Compile demo with MKL/OpenBlas support, default use MKL." ON)
+option(WITH_GPU "Compile demo with GPU/CPU, default use CPU." OFF)
+option(WITH_STATIC_LIB "Compile demo with static/shared library, default use static." ON)
+option(WITH_TENSORRT "Compile demo with TensorRT." OFF)
+
+SET(PADDLE_LIB "" CACHE PATH "Location of libraries")
+SET(OPENCV_DIR "" CACHE PATH "Location of libraries")
+SET(CUDA_LIB "" CACHE PATH "Location of libraries")
+SET(CUDNN_LIB "" CACHE PATH "Location of libraries")
+SET(TENSORRT_DIR "" CACHE PATH "Compile demo with TensorRT")
+
+set(DEMO_NAME "clas_system")
+
+include(external-cmake/yaml-cpp.cmake)
+include_directories("${CMAKE_SOURCE_DIR}/")
+include_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/yaml-cpp/src/ext-yaml-cpp/include")
+link_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/yaml-cpp/lib")
+
+macro(safe_set_static_flag)
+ foreach(flag_var
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ if(${flag_var} MATCHES "/MD")
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+ endif(${flag_var} MATCHES "/MD")
+ endforeach(flag_var)
+endmacro()
+
+if (WITH_MKL)
+ ADD_DEFINITIONS(-DUSE_MKL)
+endif()
+
+if(NOT DEFINED PADDLE_LIB)
+ message(FATAL_ERROR "please set PADDLE_LIB with -DPADDLE_LIB=/path/paddle/lib")
+endif()
+
+if(NOT DEFINED OPENCV_DIR)
+ message(FATAL_ERROR "please set OPENCV_DIR with -DOPENCV_DIR=/path/opencv")
+endif()
+
+
+if (WIN32)
+ include_directories("${PADDLE_LIB}/paddle/fluid/inference")
+ include_directories("${PADDLE_LIB}/paddle/include")
+ link_directories("${PADDLE_LIB}/paddle/fluid/inference")
+ find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH)
+
+else ()
+ find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/share/OpenCV NO_DEFAULT_PATH)
+ include_directories("${PADDLE_LIB}/paddle/include")
+ link_directories("${PADDLE_LIB}/paddle/lib")
+endif ()
+include_directories(${OpenCV_INCLUDE_DIRS})
+
+if (WIN32)
+ add_definitions("/DGOOGLE_GLOG_DLL_DECL=")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /bigobj /MTd")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /bigobj /MT")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj /MTd")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /bigobj /MT")
+ if (WITH_STATIC_LIB)
+ safe_set_static_flag()
+ add_definitions(-DSTATIC_LIB)
+ endif()
+else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 -std=c++11")
+ set(CMAKE_STATIC_LIBRARY_PREFIX "")
+endif()
+message("flags" ${CMAKE_CXX_FLAGS})
+
+
+if (WITH_GPU)
+ if (NOT DEFINED CUDA_LIB OR ${CUDA_LIB} STREQUAL "")
+ message(FATAL_ERROR "please set CUDA_LIB with -DCUDA_LIB=/path/cuda-8.0/lib64")
+ endif()
+ if (NOT WIN32)
+ if (NOT DEFINED CUDNN_LIB)
+ message(FATAL_ERROR "please set CUDNN_LIB with -DCUDNN_LIB=/path/cudnn_v7.4/cuda/lib64")
+ endif()
+ endif(NOT WIN32)
+endif()
+
+include_directories("${PADDLE_LIB}/third_party/install/protobuf/include")
+include_directories("${PADDLE_LIB}/third_party/install/glog/include")
+include_directories("${PADDLE_LIB}/third_party/install/gflags/include")
+include_directories("${PADDLE_LIB}/third_party/install/xxhash/include")
+include_directories("${PADDLE_LIB}/third_party/install/zlib/include")
+include_directories("${PADDLE_LIB}/third_party/boost")
+include_directories("${PADDLE_LIB}/third_party/eigen3")
+
+include_directories("${CMAKE_SOURCE_DIR}/")
+
+if (NOT WIN32)
+ if (WITH_TENSORRT AND WITH_GPU)
+ include_directories("${TENSORRT_DIR}/include")
+ link_directories("${TENSORRT_DIR}/lib")
+ endif()
+endif(NOT WIN32)
+
+link_directories("${PADDLE_LIB}/third_party/install/zlib/lib")
+
+link_directories("${PADDLE_LIB}/third_party/install/protobuf/lib")
+link_directories("${PADDLE_LIB}/third_party/install/glog/lib")
+link_directories("${PADDLE_LIB}/third_party/install/gflags/lib")
+link_directories("${PADDLE_LIB}/third_party/install/xxhash/lib")
+link_directories("${PADDLE_LIB}/paddle/lib")
+
+
+if(WITH_MKL)
+ include_directories("${PADDLE_LIB}/third_party/install/mklml/include")
+ if (WIN32)
+ set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.lib
+ ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.lib)
+ else ()
+ set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX}
+ ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5${CMAKE_SHARED_LIBRARY_SUFFIX})
+ execute_process(COMMAND cp -r ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX} /usr/lib)
+ endif ()
+ set(MKLDNN_PATH "${PADDLE_LIB}/third_party/install/mkldnn")
+ if(EXISTS ${MKLDNN_PATH})
+ include_directories("${MKLDNN_PATH}/include")
+ if (WIN32)
+ set(MKLDNN_LIB ${MKLDNN_PATH}/lib/mkldnn.lib)
+ else ()
+ set(MKLDNN_LIB ${MKLDNN_PATH}/lib/libmkldnn.so.0)
+ endif ()
+ endif()
+else()
+ if (WIN32)
+ set(MATH_LIB ${PADDLE_LIB}/third_party/install/openblas/lib/openblas${CMAKE_STATIC_LIBRARY_SUFFIX})
+ else ()
+ set(MATH_LIB ${PADDLE_LIB}/third_party/install/openblas/lib/libopenblas${CMAKE_STATIC_LIBRARY_SUFFIX})
+ endif ()
+endif()
+
+# Note: libpaddle_inference_api.so/a must put before libpaddle_fluid.so/a
+if(WITH_STATIC_LIB)
+ if(WIN32)
+ set(DEPS
+ ${PADDLE_LIB}/paddle/lib/paddle_inference${CMAKE_STATIC_LIBRARY_SUFFIX})
+ else()
+ set(DEPS
+ ${PADDLE_LIB}/paddle/lib/libpaddle_inference${CMAKE_STATIC_LIBRARY_SUFFIX})
+ endif()
+else()
+ if(WIN32)
+ set(DEPS
+ ${PADDLE_LIB}/paddle/lib/paddle_inference${CMAKE_SHARED_LIBRARY_SUFFIX})
+ else()
+ set(DEPS
+ ${PADDLE_LIB}/paddle/lib/libpaddle_inference${CMAKE_SHARED_LIBRARY_SUFFIX})
+ endif()
+endif(WITH_STATIC_LIB)
+
+if (NOT WIN32)
+ set(DEPS ${DEPS}
+ ${MATH_LIB} ${MKLDNN_LIB}
+ glog gflags protobuf z xxhash yaml-cpp
+ )
+ if(EXISTS "${PADDLE_LIB}/third_party/install/snappystream/lib")
+ set(DEPS ${DEPS} snappystream)
+ endif()
+ if (EXISTS "${PADDLE_LIB}/third_party/install/snappy/lib")
+ set(DEPS ${DEPS} snappy)
+ endif()
+else()
+ set(DEPS ${DEPS}
+ ${MATH_LIB} ${MKLDNN_LIB}
+ glog gflags_static libprotobuf xxhash libyaml-cppmt)
+ set(DEPS ${DEPS} libcmt shlwapi)
+ if (EXISTS "${PADDLE_LIB}/third_party/install/snappy/lib")
+ set(DEPS ${DEPS} snappy)
+ endif()
+ if(EXISTS "${PADDLE_LIB}/third_party/install/snappystream/lib")
+ set(DEPS ${DEPS} snappystream)
+ endif()
+endif(NOT WIN32)
+
+
+if(WITH_GPU)
+ if(NOT WIN32)
+ if (WITH_TENSORRT)
+ set(DEPS ${DEPS} ${TENSORRT_DIR}/lib/libnvinfer${CMAKE_SHARED_LIBRARY_SUFFIX})
+ set(DEPS ${DEPS} ${TENSORRT_DIR}/lib/libnvinfer_plugin${CMAKE_SHARED_LIBRARY_SUFFIX})
+ endif()
+ set(DEPS ${DEPS} ${CUDA_LIB}/libcudart${CMAKE_SHARED_LIBRARY_SUFFIX})
+ set(DEPS ${DEPS} ${CUDNN_LIB}/libcudnn${CMAKE_SHARED_LIBRARY_SUFFIX})
+ else()
+ set(DEPS ${DEPS} ${CUDA_LIB}/cudart${CMAKE_STATIC_LIBRARY_SUFFIX} )
+ set(DEPS ${DEPS} ${CUDA_LIB}/cublas${CMAKE_STATIC_LIBRARY_SUFFIX} )
+ set(DEPS ${DEPS} ${CUDNN_LIB}/cudnn${CMAKE_STATIC_LIBRARY_SUFFIX})
+ endif()
+endif()
+
+
+if (NOT WIN32)
+ set(EXTERNAL_LIB "-ldl -lrt -lgomp -lz -lm -lpthread")
+ set(DEPS ${DEPS} ${EXTERNAL_LIB})
+endif()
+
+set(DEPS ${DEPS} ${OpenCV_LIBS})
+
+include(FetchContent)
+include(external-cmake/auto-log.cmake)
+include_directories(${FETCHCONTENT_BASE_DIR}/extern_autolog-src)
+
+AUX_SOURCE_DIRECTORY(./src SRCS)
+add_executable(${DEMO_NAME} ${SRCS})
+ADD_DEPENDENCIES(${DEMO_NAME} ext-yaml-cpp)
+
+target_link_libraries(${DEMO_NAME} ${DEPS})
+
+if (WIN32 AND WITH_MKL)
+ add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.dll ./mklml.dll
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.dll ./libiomp5md.dll
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mkldnn/lib/mkldnn.dll ./mkldnn.dll
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.dll ./release/mklml.dll
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mklml/lib/libiomp5md.dll ./release/libiomp5md.dll
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PADDLE_LIB}/third_party/install/mkldnn/lib/mkldnn.dll ./release/mkldnn.dll
+ )
+endif()
diff --git a/exprements/PaddleClas/deploy/cpp/docs/imgs/ILSVRC2012_val_00000666.JPEG b/exprements/PaddleClas/deploy/cpp/docs/imgs/ILSVRC2012_val_00000666.JPEG
new file mode 100644
index 00000000..ebb56252
Binary files /dev/null and b/exprements/PaddleClas/deploy/cpp/docs/imgs/ILSVRC2012_val_00000666.JPEG differ
diff --git a/exprements/PaddleClas/deploy/cpp/docs/imgs/cpp_infer_result.png b/exprements/PaddleClas/deploy/cpp/docs/imgs/cpp_infer_result.png
new file mode 100644
index 00000000..6a1adfe3
Binary files /dev/null and b/exprements/PaddleClas/deploy/cpp/docs/imgs/cpp_infer_result.png differ
diff --git a/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step1.png b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step1.png
new file mode 100644
index 00000000..58fdf2fd
Binary files /dev/null and b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step1.png differ
diff --git a/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step2.png b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step2.png
new file mode 100644
index 00000000..f1b5fd0a
Binary files /dev/null and b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step2.png differ
diff --git a/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step3.png b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step3.png
new file mode 100644
index 00000000..cb1b2aea
Binary files /dev/null and b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step3.png differ
diff --git a/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step4.png b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step4.png
new file mode 100644
index 00000000..5fc04082
Binary files /dev/null and b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step4.png differ
diff --git a/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step5.png b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step5.png
new file mode 100644
index 00000000..fbb2e4ce
Binary files /dev/null and b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step5.png differ
diff --git a/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step6.png b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step6.png
new file mode 100644
index 00000000..86a8039c
Binary files /dev/null and b/exprements/PaddleClas/deploy/cpp/docs/imgs/vs2019_step6.png differ
diff --git a/exprements/PaddleClas/deploy/cpp/docs/windows_vs2019_build.md b/exprements/PaddleClas/deploy/cpp/docs/windows_vs2019_build.md
new file mode 100644
index 00000000..6e2b3703
--- /dev/null
+++ b/exprements/PaddleClas/deploy/cpp/docs/windows_vs2019_build.md
@@ -0,0 +1,119 @@
+# Visual Studio 2019 Community CMake 编译指南
+
+PaddleClas在Windows 平台下基于`Visual Studio 2019 Community` 进行了测试。微软从`Visual Studio 2017`开始即支持直接管理`CMake`跨平台编译项目,但是直到`2019`才提供了稳定和完全的支持,所以如果你想使用CMake管理项目编译构建,我们推荐使用`Visual Studio 2019`。如果您希望通过生成`sln解决方案`的方式进行编译,可以参考该文档:[https://zhuanlan.zhihu.com/p/145446681](https://zhuanlan.zhihu.com/p/145446681)。
+
+
+## 前置条件
+* Visual Studio 2019
+* CUDA 9.0 / CUDA 10.0,cudnn 7.6+ (仅在使用GPU版本的预测库时需要)
+* CMake 3.0+
+
+请确保系统已经正确安装并配置好上述基本软件,其中:
+ * 在安装`Visual Studio 2019`时,`工作负载`需要勾选`使用C++的桌面开发`;
+ * CUDA需要正确安装并设置系统环境变量;
+ * CMake需要正确安装并将路径添加到系统环境变量中。
+
+以下测试基于`Visual Studio 2019 Community`版本。
+
+**下面所有示例以工作目录为 `D:\projects`演示**。
+
+### Step1: 下载PaddlePaddle C++ 预测库 paddle_inference_install_dir
+
+PaddlePaddle C++ 预测库针对不同的`CPU`和`CUDA`版本提供了不同的预编译版本,请根据实际情况下载: [C++预测库下载列表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/05_inference_deployment/inference/windows_cpp_inference.html)。
+
+解压后`D:\projects\paddle_inference_install_dir`目录包含内容为:
+
+```
+paddle_inference_install_dir
+├── paddle # paddle核心库和头文件
+|
+├── third_party # 第三方依赖库和头文件
+|
+└── version.txt # 版本和编译信息
+```
+
+然后需要将`Paddle预测库`的路径`D:\projects\paddle_inference_install_dir\paddle\lib`添加到系统环境变量`Path`中。
+
+### Step2: 安装配置OpenCV
+
+1. 在OpenCV官网下载适用于Windows平台的3.4.6版本, [下载地址](https://sourceforge.net/projects/opencvlibrary/files/3.4.6/opencv-3.4.6-vc14_vc15.exe/download)
+2. 运行下载的可执行文件,将OpenCV解压至指定目录,如`D:\projects\opencv`
+3. 配置环境变量,如下流程所示
+ - 此电脑(我的电脑)-> 属性 -> 高级系统设置 -> 环境变量
+ - 在系统变量中找到Path(如没有,自行创建),并双击编辑
+ - 新建,将OpenCV路径填入并保存,如 `D:\projects\opencv\build\x64\vc14\bin`
+
+### Step3: 使用Visual Studio 2019直接编译CMake
+
+1. 打开Visual Studio 2019 Community,点击 `继续但无需代码`
+
+
+
+2. 点击: `文件`->`打开`->`CMake`
+
+
+
+选择项目代码所在路径,并打开`CMakeList.txt`:
+
+
+
+3. 点击:`项目`->`cpp_inference_demo的CMake设置`
+
+
+
+4. 请设置以下参数的值
+
+
+| 名称 | 值 | 保存到 JSON |
+| ----------------------------- | ------------------ | ----------- |
+| CMAKE_BACKWARDS_COMPATIBILITY | 3.17 | [√] |
+| CMAKE_BUILD_TYPE | RelWithDebInfo | [√] |
+| CUDA_LIB | CUDA的库路径 | [√] |
+| CUDNN_LIB | CUDNN的库路径 | [√] |
+| OpenCV_DIR | OpenCV的安装路径 | [√] |
+| PADDLE_LIB | Paddle预测库的路径 | [√] |
+| WITH_GPU | [√] | [√] |
+| WITH_MKL | [√] | [√] |
+| WITH_STATIC_LIB | [√] | [√] |
+
+**注意**:
+
+1. `CMAKE_BACKWARDS_COMPATIBILITY` 的值请根据自己 `cmake` 版本设置,`cmake` 版本可以通过命令:`cmake --version` 查询;
+2. `CUDA_LIB` 、 `CUDNN_LIB` 的值仅需在使用**GPU版本**预测库时指定,其中CUDA库版本尽量对齐,**使用9.0、10.0版本,不使用9.2、10.1等版本CUDA库**;
+3. 在设置 `CUDA_LIB`、`CUDNN_LIB`、`OPENCV_DIR`、`PADDLE_LIB` 时,点击 `浏览`,分别设置相应的路径;
+ * `CUDA_LIB`和`CUDNN_LIB`:该路径取决于CUDA与CUDNN的安装位置。
+ * `OpenCV_DIR`:该路径下需要有`.cmake`文件,一般为`opencv/build/`;
+ * `PADDLE_LIB`:该路径下需要有`CMakeCache.txt`文件,一般为`paddle_inference_install_dir/`。
+4. 在使用 `CPU` 版预测库时,请不要勾选 `WITH_GPU` - `保存到 JSON`。
+
+
+
+**设置完成后**, 点击上图中 `保存并生成CMake缓存以加载变量` 。
+
+5. 点击`生成`->`全部生成`
+
+
+
+
+### Step4: 预测及可视化
+
+在完成上述操作后,`Visual Studio 2019` 编译产出的可执行文件 `clas_system.exe` 在 `out\build\x64-Release`目录下,打开`cmd`,并切换到该目录:
+
+```
+cd D:\projects\PaddleClas\deploy\cpp_infer\out\build\x64-Release
+```
+可执行文件`clas_system.exe`即为编译产出的的预测程序,其使用方法如下:
+
+```shell
+.\clas_system.exe D:\projects\PaddleClas\deploy\cpp_infer\tools\config.txt .\docs\ILSVRC2012_val_00008306.JPEG
+```
+
+上述命令中,第一个参数(`D:\projects\PaddleClas\deploy\cpp_infer\tools\config.txt`)为配置文件路径,第二个参数(`.\docs\ILSVRC2012_val_00008306.JPEG`)为需要预测的图片路径。
+
+注意,需要在配置文件中正确设置预测参数,包括所用模型文件的路径(`cls_model_path`和`cls_params_path`)。
+
+
+### 注意
+* 在Windows下的终端中执行文件exe时,可能会发生乱码的现象,此时需要在终端中输入`CHCP 65001`,将终端的编码方式由GBK编码(默认)改为UTF-8编码,更加具体的解释可以参考这篇博客:[https://blog.csdn.net/qq_35038153/article/details/78430359](https://blog.csdn.net/qq_35038153/article/details/78430359)。
+* 如果需要使用CPU预测,PaddlePaddle在Windows上仅支持avx的CPU预测,目前不支持noavx的CPU预测。
+* 在使用生成的`clas_system.exe`进行预测时,如提示`由于找不到paddle_fluid.dll,无法继续执行代码。重新安装程序可能会解决此问题`,请检查是否将Paddle预测库路径添加到系统环境变量,详见[Step1: 下载PaddlePaddle C++ 预测库 paddle_inference_install_dir](#step1-下载paddlepaddle-c-预测库-paddle_inference_install_dir)
diff --git a/exprements/PaddleClas/deploy/cpp/external-cmake/auto-log.cmake b/exprements/PaddleClas/deploy/cpp/external-cmake/auto-log.cmake
new file mode 100644
index 00000000..9be9c2fb
--- /dev/null
+++ b/exprements/PaddleClas/deploy/cpp/external-cmake/auto-log.cmake
@@ -0,0 +1,12 @@
+find_package(Git REQUIRED)
+include(FetchContent)
+
+set(FETCHCONTENT_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/third-party")
+
+FetchContent_Declare(
+ extern_Autolog
+ PREFIX autolog
+ GIT_REPOSITORY https://github.com/LDOUBLEV/AutoLog.git
+ GIT_TAG main
+)
+FetchContent_MakeAvailable(extern_Autolog)
diff --git a/exprements/PaddleClas/deploy/cpp/external-cmake/yaml-cpp.cmake b/exprements/PaddleClas/deploy/cpp/external-cmake/yaml-cpp.cmake
new file mode 100644
index 00000000..7bc7f34d
--- /dev/null
+++ b/exprements/PaddleClas/deploy/cpp/external-cmake/yaml-cpp.cmake
@@ -0,0 +1,30 @@
+
+find_package(Git REQUIRED)
+
+include(ExternalProject)
+
+message("${CMAKE_BUILD_TYPE}")
+
+ExternalProject_Add(
+ ext-yaml-cpp
+ URL https://bj.bcebos.com/paddlex/deploy/deps/yaml-cpp.zip
+ URL_MD5 9542d6de397d1fbd649ed468cb5850e6
+ CMAKE_ARGS
+ -DYAML_CPP_BUILD_TESTS=OFF
+ -DYAML_CPP_BUILD_TOOLS=OFF
+ -DYAML_CPP_INSTALL=OFF
+ -DYAML_CPP_BUILD_CONTRIB=OFF
+ -DMSVC_SHARED_RT=OFF
+ -DBUILD_SHARED_LIBS=OFF
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
+ -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
+ -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
+ -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/ext/yaml-cpp/lib
+ -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/ext/yaml-cpp/lib
+ PREFIX "${CMAKE_BINARY_DIR}/ext/yaml-cpp"
+ # Disable install step
+ INSTALL_COMMAND ""
+ LOG_DOWNLOAD ON
+ LOG_BUILD 1
+)
diff --git a/exprements/PaddleClas/deploy/cpp/include/cls.h b/exprements/PaddleClas/deploy/cpp/include/cls.h
new file mode 100644
index 00000000..8456d108
--- /dev/null
+++ b/exprements/PaddleClas/deploy/cpp/include/cls.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma once
+
+#include "opencv2/core.hpp"
+#include "opencv2/imgcodecs.hpp"
+#include "opencv2/imgproc.hpp"
+#include "paddle_inference_api.h"
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "include/cls_config.h"
+#include
+
+using namespace paddle_infer;
+
+namespace PaddleClas {
+
+ class Classifier {
+ public:
+ explicit Classifier(const ClsConfig &config) {
+ this->use_gpu_ = config.use_gpu;
+ this->gpu_id_ = config.gpu_id;
+ this->gpu_mem_ = config.gpu_mem;
+ this->cpu_math_library_num_threads_ = config.cpu_threads;
+ this->use_fp16_ = config.use_fp16;
+ this->use_mkldnn_ = config.use_mkldnn;
+ this->use_tensorrt_ = config.use_tensorrt;
+ this->mean_ = config.mean;
+ this->std_ = config.std;
+ this->resize_short_size_ = config.resize_short_size;
+ this->scale_ = config.scale;
+ this->crop_size_ = config.crop_size;
+ this->ir_optim_ = config.ir_optim;
+ LoadModel(config.cls_model_path, config.cls_params_path);
+ }
+
+ // Load Paddle inference model
+ void LoadModel(const std::string &model_path, const std::string ¶ms_path);
+
+ // Run predictor
+ void Run(cv::Mat &img, std::vector &out_data, std::vector &idx,
+ std::vector ×);
+
+ private:
+ std::shared_ptr predictor_;
+
+ bool use_gpu_ = false;
+ int gpu_id_ = 0;
+ int gpu_mem_ = 4000;
+ int cpu_math_library_num_threads_ = 4;
+ bool use_mkldnn_ = false;
+ bool use_tensorrt_ = false;
+ bool use_fp16_ = false;
+ bool ir_optim_ = true;
+
+ std::vector mean_ = {0.485f, 0.456f, 0.406f};
+ std::vector std_ = {0.229f, 0.224f, 0.225f};
+ float scale_ = 0.00392157;
+
+ int resize_short_size_ = 256;
+ int crop_size_ = 224;
+
+ // pre-process
+ ResizeImg resize_op_;
+ Normalize normalize_op_;
+ Permute permute_op_;
+ CenterCropImg crop_op_;
+ };
+
+} // namespace PaddleClas
diff --git a/exprements/PaddleClas/deploy/cpp/include/cls_config.h b/exprements/PaddleClas/deploy/cpp/include/cls_config.h
new file mode 100644
index 00000000..225e728b
--- /dev/null
+++ b/exprements/PaddleClas/deploy/cpp/include/cls_config.h
@@ -0,0 +1,133 @@
+// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma once
+
+#ifdef WIN32
+#define OS_PATH_SEP "\\"
+#else
+#define OS_PATH_SEP "/"
+#endif
+
+#include "include/utility.h"
+#include "yaml-cpp/yaml.h"
+#include
+#include
+#include