未验证 提交 25c32c0e 编写于 作者: C cuicheng01 提交者: GitHub

Merge branch 'PaddlePaddle:develop' into develop

简体中文 | [English](README_en.md)
# PaddleClas
## 简介
飞桨图像识别套件PaddleClas是飞桨为工业界和学术界所准备的一个图像识别任务的工具集,助力使用者训练出更好的视觉模型和应用落地。
**近期更新**
- 2021.06.22,23,24 PaddleClas官方研发团队带来技术深入解读三日直播课,6月22日、23日、24日晚上20:30,[直播地址](https://live.bilibili.com/21689802)
- 🔥🔥🔥: 2021.06.16 PaddleClas v2.2版本升级,集成Metric learning,向量检索等组件。新增商品识别、动漫人物识别、车辆识别和logo识别等4个图像识别应用。新增LeViT、Twins、TNT、DLA、HarDNet、RedNet系列30个预训练模型。
- 2021.05.14 添加`SwinTransformer` 系列模型。
- 2021.04.15 添加`MixNet_L``ReXNet_3_0`系列模型。
[more](./docs/zh_CN/update_history.md)
## 特性
- 实用的图像识别系统:集成了目标检测、特征学习、图像检索等模块,广泛适用于各类图像识别任务。
提供商品识别、车辆识别、logo识别和动漫人物识别等4个场景应用示例。
- 丰富的预训练模型库:提供了35个系列共164个ImageNet预训练模型,其中6个精选系列模型支持结构快速修改。
- 全面易用的特征学习组件:集成arcmargin, triplet loss等12度量学习方法,通过配置文件即可随意组合切换。
- SSLD知识蒸馏:14个分类预训练模型,精度普遍提升3%以上;其中ResNet50_vd模型在ImageNet-1k数据集上的Top-1精度达到了84.0%,
Res2Net200_vd预训练模型Top-1精度高达85.1%。
- 数据增广:支持AutoAugment、Cutout、Cutmix等8种数据增广算法详细介绍、代码复现和在统一实验环境下的效果评估。
## 图像识别系统效果展示
<div align="center">
<img src="./docs/images/recognition.gif" width = "400" />
</div>
更多效果图请见:[识别效果展示页面](./docs/zh_CN/more_demo.md)
## 欢迎加入技术交流群
* 您可以扫描下面的微信群二维码, 加入PaddleClas 微信交流群。获得更高效的问题答疑,与各行各业开发者充分交流,期待您的加入。
<div align="center">
<img src="./docs/images/wx_group.png" width = "200" />
</div>
## 快速体验
图像识别快速体验:[点击这里](./docs/zh_CN/tutorials/quick_start_recognition.md)
## 文档教程
- [快速安装](./docs/zh_CN/tutorials/install.md)
- [图像识别快速体验](./docs/zh_CN/tutorials/quick_start_recognition.md)
- [图像识别系统介绍](#图像识别系统介绍)
- [识别效果展示](#识别效果展示)
- 算法介绍
- [骨干网络和预训练模型库](./docs/zh_CN/ImageNet_models_cn.md)
- [主体检测](./docs/zh_CN/application/mainbody_detection.md)
- [图像分类](./docs/zh_CN/tutorials/image_classification.md)
- [特征学习](./docs/zh_CN/application/feature_learning.md)
- [商品识别](./docs/zh_CN/application/product_recognition.md)
- [车辆识别](./docs/zh_CN/application/vehicle_recognition.md)
- [logo识别](./docs/zh_CN/application/logo_recognition.md)
- [动漫人物识别](./docs/zh_CN/application/cartoon_character_recognition.md)
- [向量检索](./deploy/vector_search/README.md)
- 模型训练/评估
- [图像分类任务](./docs/zh_CN/tutorials/getting_started.md)
- [特征学习任务](./docs/zh_CN/tutorials/getting_started_retrieval.md)
- 模型预测
- [基于Python预测引擎预测推理](./docs/zh_CN/inference.md)
- [基于C++预测引擎预测推理](./deploy/cpp/readme.md)(当前只支持图像分类任务,图像识别更新中)
- 模型部署(当前只支持图像分类任务,图像识别更新中)
- [服务化部署](./deploy/hubserving/readme.md)
- [端侧部署](./deploy/lite/readme.md)
- [whl包预测](./docs/zh_CN/whl.md)
- 高阶使用
- [知识蒸馏](./docs/zh_CN/advanced_tutorials/distillation/distillation.md)
- [模型量化](./docs/zh_CN/extension/paddle_quantization.md)
- [数据增广](./docs/zh_CN/advanced_tutorials/image_augmentation/ImageAugment.md)
- FAQ(暂停更新)
- [图像分类任务FAQ](docs/zh_CN/faq.md)
- [许可证书](#许可证书)
- [贡献代码](#贡献代码)
<a name="图像识别系统介绍"></a>
## 图像识别系统介绍
<a name="图像识别系统介绍"></a>
<div align="center">
<img src="./docs/images/structure.png" width = "400" />
</div>
整个图像识别系统分为三步:(1)通过一个目标检测模型,检测图像物体候选区域(2)对每个候选区域进行特征提取(3)与检索库中图像进行特征匹配,提取识别结果。
对于新的未知类别,无需重新训练模型,只需要在检索库补入该类别图像,重新建立检索库,就可以识别该类别。
<a name="识别效果展示"></a>
## 识别效果展示 [more](./docs/zh_CN/more_demo.md)
- 商品识别
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_product/channelhandle_5.jpg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_product/daoxiangcunjinzhubing_10.jpg" width = "400" />
</div>
- 动漫人物识别
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_cartoon/labixiaoxin-005.jpeg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_cartoon/liuchuanfeng-010.jpeg" width = "400" />
</div>
- logo识别
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_logo/cctv_4.jpg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_logo/mangguo_8.jpeg" width = "400" />
</div>
- 车辆识别
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_vehicle/audia5-115.jpeg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_vehicle/bentian-yage-101.jpeg" width = "400" />
</div>
<a name="许可证书"></a>
## 许可证书
本项目的发布受<a href="https://github.com/PaddlePaddle/PaddleCLS/blob/master/LICENSE">Apache 2.0 license</a>许可认证。
<a name="贡献代码"></a>
## 贡献代码
我们非常欢迎你为PaddleClas贡献代码,也十分感谢你的反馈。
- 非常感谢[nblib](https://github.com/nblib)修正了PaddleClas中RandErasing的数据增广配置文件。
- 非常感谢[chenpy228](https://github.com/chenpy228)修正了PaddleClas文档中的部分错别字。
- 非常感谢[jm12138](https://github.com/jm12138)为PaddleClas添加ViT,DeiT系列模型和RepVGG系列模型。
- 非常感谢[FutureSI](https://aistudio.baidu.com/aistudio/personalcenter/thirdview/76563)对PaddleClas代码的解析与总结。
我们非常欢迎你为PaddleClas贡献代码,也十分感谢你的反馈。
README_en.md
\ No newline at end of file
简体中文 | [English](README_en.md)
# PaddleClas
## 简介
飞桨图像识别套件PaddleClas是飞桨为工业界和学术界所准备的一个图像识别任务的工具集,助力使用者训练出更好的视觉模型和应用落地。
**近期更新**
- 2021.06.22,23,24 PaddleClas官方研发团队带来技术深入解读三日直播课,6月22日、23日、24日晚上20:30,[直播地址](https://live.bilibili.com/21689802)
- 🔥🔥🔥: 2021.06.16 PaddleClas v2.2版本升级,集成Metric learning,向量检索等组件。新增商品识别、动漫人物识别、车辆识别和logo识别等4个图像识别应用。新增LeViT、Twins、TNT、DLA、HarDNet、RedNet系列30个预训练模型。
- [more](./docs/zh_CN/update_history.md)
## 特性
- 实用的图像识别系统:集成了目标检测、特征学习、图像检索等模块,广泛适用于各类图像识别任务。
提供商品识别、车辆识别、logo识别和动漫人物识别等4个场景应用示例。
- 丰富的预训练模型库:提供了35个系列共164个ImageNet预训练模型,其中6个精选系列模型支持结构快速修改。
- 全面易用的特征学习组件:集成arcmargin, triplet loss等12度量学习方法,通过配置文件即可随意组合切换。
- SSLD知识蒸馏:14个分类预训练模型,精度普遍提升3%以上;其中ResNet50_vd模型在ImageNet-1k数据集上的Top-1精度达到了84.0%,
Res2Net200_vd预训练模型Top-1精度高达85.1%。
- 数据增广:支持AutoAugment、Cutout、Cutmix等8种数据增广算法详细介绍、代码复现和在统一实验环境下的效果评估。
## 图像识别系统效果展示
<div align="center">
<img src="./docs/images/recognition.gif" width = "400" />
</div>
更多效果图请见:[识别效果展示页面](./docs/zh_CN/more_demo.md)
## 欢迎加入技术交流群
* 您可以扫描下面的微信群二维码, 加入PaddleClas 微信交流群。获得更高效的问题答疑,与各行各业开发者充分交流,期待您的加入。
<div align="center">
<img src="./docs/images/wx_group.jpeg" width = "200" />
</div>
## 快速体验
图像识别快速体验:[点击这里](./docs/zh_CN/tutorials/quick_start_recognition.md)
## 文档教程
- [快速安装](./docs/zh_CN/tutorials/install.md)
- [图像识别快速体验](./docs/zh_CN/tutorials/quick_start_recognition.md)
- [图像识别系统介绍](#图像识别系统介绍)
- [识别效果展示](#识别效果展示)
- 算法介绍
- [骨干网络和预训练模型库](./docs/zh_CN/ImageNet_models_cn.md)
- [主体检测](./docs/zh_CN/application/mainbody_detection.md)
- [图像分类](./docs/zh_CN/tutorials/image_classification.md)
- [特征学习](./docs/zh_CN/application/feature_learning.md)
- [商品识别](./docs/zh_CN/application/product_recognition.md)
- [车辆识别](./docs/zh_CN/application/vehicle_recognition.md)
- [logo识别](./docs/zh_CN/application/logo_recognition.md)
- [动漫人物识别](./docs/zh_CN/application/cartoon_character_recognition.md)
- [向量检索](./deploy/vector_search/README.md)
- 模型训练/评估
- [图像分类任务](./docs/zh_CN/tutorials/getting_started.md)
- [特征学习任务](./docs/zh_CN/tutorials/getting_started_retrieval.md)
- 模型预测
- [基于Python预测引擎预测推理](./docs/zh_CN/inference.md)
- [基于C++预测引擎预测推理](./deploy/cpp/readme.md)(当前只支持图像分类任务,图像识别更新中)
- 模型部署(当前只支持图像分类任务,图像识别更新中)
- [服务化部署](./deploy/hubserving/readme.md)
- [端侧部署](./deploy/lite/readme.md)
- [whl包预测](./docs/zh_CN/whl.md)
- 高阶使用
- [知识蒸馏](./docs/zh_CN/advanced_tutorials/distillation/distillation.md)
- [模型量化](./docs/zh_CN/extension/paddle_quantization.md)
- [数据增广](./docs/zh_CN/advanced_tutorials/image_augmentation/ImageAugment.md)
- FAQ(暂停更新)
- [图像分类任务FAQ](docs/zh_CN/faq.md)
- [许可证书](#许可证书)
- [贡献代码](#贡献代码)
<a name="图像识别系统介绍"></a>
## 图像识别系统介绍
<a name="图像识别系统介绍"></a>
<div align="center">
<img src="./docs/images/structure.png" width = "400" />
</div>
整个图像识别系统分为三步:(1)通过一个目标检测模型,检测图像物体候选区域(2)对每个候选区域进行特征提取(3)与检索库中图像进行特征匹配,提取识别结果。
对于新的未知类别,无需重新训练模型,只需要在检索库补入该类别图像,重新建立检索库,就可以识别该类别。
<a name="识别效果展示"></a>
## 识别效果展示 [more](./docs/zh_CN/more_demo.md)
- 商品识别
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_product/channelhandle_5.jpg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_product/daoxiangcunjinzhubing_10.jpg" width = "400" />
</div>
- 动漫人物识别
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_cartoon/labixiaoxin-005.jpeg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_cartoon/liuchuanfeng-010.jpeg" width = "400" />
</div>
- logo识别
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_logo/cctv_4.jpg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_logo/mangguo_8.jpeg" width = "400" />
</div>
- 车辆识别
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_vehicle/audia5-115.jpeg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_vehicle/bentian-yage-101.jpeg" width = "400" />
</div>
<a name="许可证书"></a>
## 许可证书
本项目的发布受<a href="https://github.com/PaddlePaddle/PaddleCLS/blob/master/LICENSE">Apache 2.0 license</a>许可认证。
<a name="贡献代码"></a>
## 贡献代码
我们非常欢迎你为PaddleClas贡献代码,也十分感谢你的反馈。
- 非常感谢[nblib](https://github.com/nblib)修正了PaddleClas中RandErasing的数据增广配置文件。
- 非常感谢[chenpy228](https://github.com/chenpy228)修正了PaddleClas文档中的部分错别字。
- 非常感谢[jm12138](https://github.com/jm12138)为PaddleClas添加ViT,DeiT系列模型和RepVGG系列模型。
- 非常感谢[FutureSI](https://aistudio.baidu.com/aistudio/personalcenter/thirdview/76563)对PaddleClas代码的解析与总结。
我们非常欢迎你为PaddleClas贡献代码,也十分感谢你的反馈。
[简体中文](README.md) | English
[简体中文](README_ch.md) | English
# PaddleClas
......@@ -8,17 +8,7 @@ PaddleClas is an image recognition toolset for industry and academia, helping us
**Recent updates**
- 🔥🔥🔥: 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.
- 2021.05.14
- Add `SwinTransformer` series pretrained models, whose Top-1 Acc on ImageNet-1k dataset reaches 87.19%.
- 2021.04.15
- Add `MixNet` and `ReXNet` pretrained models, `MixNet_L`'s Top-1 Acc on ImageNet-1k reaches 78.6% and `ReXNet_3_0` reaches 82.09%.
- 🔥🔥🔥: 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
......@@ -34,27 +24,29 @@ Four sample solutions are provided, including product recognition, vehicle recog
- 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.
## Image Recognition System Effect Demonstration
<div align="center">
<img src="./docs/images/recognition.gif" width = "400" />
<img src="./docs/images/recognition_en.gif" width = "400" />
</div>
For more effect pictures, please see [Demo images](./docs/en/more_demo.md).
## 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.
<div align="center">
<img src="./docs/images/wx_group.png" width = "200" />
<img src="./docs/images/wx_group.jpeg" width = "200" />
</div>
## Quick Start
## Quick Start
Quick experience of image recognition:[Link](./docs/en/tutorials/quick_start_recognition_en.md)
## Tutorials
- [Quick Installatiopn](./docs/en/tutorials/install_en.md)
- [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)
......@@ -89,7 +81,7 @@ Quick experience of image recognition:[Link](./docs/en/tutorials/quick_start_r
## Introduction to Image Recognition Systems
<div align="center">
<img src="./docs/images/structure.png" width = "400" />
<img src="./docs/images/mainpage/recognition_pipeline_en.png" width = "400" />
</div>
Image recognition can be divided into three steps:
......@@ -103,34 +95,34 @@ For a new unknown category, there is no need to retrain the model, just prepare
## Demo images [more](./docs/en/more_demo.md)
- Product recognition
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_product/channelhandle_5.jpg" width = "400" />
<img src="./docs/images/recognition/more_demo_images/output_product/channelhandle_5_en.jpg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_product/daoxiangcunjinzhubing_10.jpg" width = "400" />
<img src="./docs/images/recognition/more_demo_images/output_product/daoxiangcunjinzhubing_10_en.jpg" width = "400" />
</div>
- Cartoon character recognition
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_cartoon/labixiaoxin-005.jpeg" width = "400" />
<img src="./docs/images/recognition/more_demo_images/output_cartoon/labixiaoxin-005_en.jpeg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_cartoon/liuchuanfeng-010.jpeg" width = "400" />
<img src="./docs/images/recognition/more_demo_images/output_cartoon/liuchuanfeng-010_en.jpeg" width = "400" />
</div>
- Logo recognition
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_logo/cctv_4.jpg" width = "400" />
<img src="./docs/images/recognition/more_demo_images/output_logo/cctv_4_en.jpg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_logo/mangguo_8.jpeg" width = "400" />
<img src="./docs/images/recognition/more_demo_images/output_logo/mangguo_8_en.jpeg" width = "400" />
</div>
- Car recognition
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_vehicle/audia5-115.jpeg" width = "400" />
<img src="./docs/images/recognition/more_demo_images/output_vehicle/audia5-115_en.jpeg" width = "400" />
</div>
<div align="center">
<img src="./docs/images/recognition/more_demo_images/output_vehicle/bentian-yage-101.jpeg" width = "400" />
<img src="./docs/images/recognition/more_demo_images/output_vehicle/bentian-yage-101_en.jpeg" width = "400" />
</div>
<a name="License"></a>
......
......@@ -39,7 +39,8 @@ def draw_bbox_results(image,
xmin, ymin, xmax, ymax = result["bbox"]
text = "{}, {:.2f}".format(result["rec_docs"], result["rec_scores"])
th = font_size
tw = int(len(result["rec_docs"]) * font_size) + 60
tw = font.getsize(text)[0]
# tw = int(len(result["rec_docs"]) * font_size) + 60
start_y = max(0, ymin - th)
draw.rectangle(
......
## Demo images
- Product recognition
<div align="center">
<img src="../images/recognition/more_demo_images/output_product/channelhandle_5.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_product/channelhandle_5_en.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_product/cliniqueblush_1.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_product/cliniqueblush_1_en.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_product/daoxiangcunjinzhubing_10.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_product/daoxiangcunjinzhubing_10_en.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_product/gannidress_10.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_product/gannidress_10_en.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_product/gbyingerche_15.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_product/gbyingerche_15_en.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_product/lafiolewine_03.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_product/lafiolewine_03_en.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_product/taochunqiu_8.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_product/taochunqiu_8_en.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_product/weiduomeinaiyougege_10.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_product/weiduomeinaiyougege_10_en.jpg" width = "400" />
</div>
- Cartoon character recognition
<div align="center">
<img src="../images/recognition/more_demo_images/output_cartoon/labixiaoxin-005.jpeg" width = "400" />
<img src="../images/recognition/more_demo_images/output_cartoon/labixiaoxin-005_en.jpeg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_cartoon/liuchuanfeng-010.jpeg" width = "400" />
<img src="../images/recognition/more_demo_images/output_cartoon/liuchuanfeng-010_en.jpeg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_cartoon/zhangchulan-007.jpeg" width = "400" />
<img src="../images/recognition/more_demo_images/output_cartoon/zhangchulan-007_en.jpeg" width = "400" />
</div>
- Logo recognition
<div align="center">
<img src="../images/recognition/more_demo_images/output_logo/cctv_4.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_logo/cctv_4_en.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_logo/mangguo_8.jpeg" width = "400" />
<img src="../images/recognition/more_demo_images/output_logo/mangguo_8_en.jpeg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_logo/zhongshiyou-007.jpg" width = "400" />
<img src="../images/recognition/more_demo_images/output_logo/zhongshiyou-007_en.jpg" width = "400" />
</div>
- Car recognition
<div align="center">
<img src="../images/recognition/more_demo_images/output_vehicle/audia5-115.jpeg" width = "400" />
<img src="../images/recognition/more_demo_images/output_vehicle/audia5-115_en.jpeg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_vehicle/bentian-yage-101.jpeg" width = "400" />
<img src="../images/recognition/more_demo_images/output_vehicle/bentian-yage-101_en.jpeg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_vehicle/bmw-m340-107.jpeg" width = "400" />
<img src="../images/recognition/more_demo_images/output_vehicle/bmw-m340-107_en.jpeg" width = "400" />
</div>
[More demo images](../images/recognition/more_demo_images)
......@@ -41,7 +41,7 @@ You can also visit [DockerHub](https://hub.docker.com/r/paddlepaddle/paddle/tags
```
# use ctrl+P+Q to exit docker, to re-enter docker using the following command:
sudo docker container exec -it ppcls /bin/bash
sudo docker exec -it ppcls /bin/bash
```
### 1.3 Install PaddlePaddle using pip
......
......@@ -40,10 +40,10 @@ The detection model with the recognition inference model for the 4 directions (L
| Logo Recognition Model | Logo Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/logo_rec_ResNet50_Logo3K_v1.0_infer.tar) | [inference_logo.yaml](../../../deploy/configs/inference_logo.yaml) | [build_logo.yaml](../../../deploy/configs/build_logo.yaml) |
| Cartoon Face Recognition Model| Cartoon Face Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/cartoon_rec_ResNet50_iCartoon_v1.0_infer.tar) | [inference_cartoon.yaml](../../../deploy/configs/inference_cartoon.yaml) | [build_cartoon.yaml](../../../deploy/configs/build_cartoon.yaml) |
| Vehicle Subclassification Model | Vehicle Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/vehicle_cls_ResNet50_CompCars_v1.0_infer.tar) | [inference_vehicle.yaml](../../../deploy/configs/inference_vehicle.yaml) | [build_vehicle.yaml](../../../deploy/configs/build_vehicle.yaml) |
| Product Recignition Model | Product Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/product_ResNet50_vd_Inshop_v1.0_infer.tar) | [inference_inshop.yaml](../../../deploy/configs/) | [build_inshop.yaml](../../../deploy/configs/build_inshop.yaml) |
| Product Recignition Model | Product Scenario | [Model Download Link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/product_ResNet50_vd_Inshop_v1.0_infer.tar) | [inference_product.yaml](../../../deploy/configs/inference_product.yaml) | [build_product.yaml](../../../deploy/configs/build_product.yaml) |
Demo data in this tutorial can be downloaded here: [download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_v1.0.tar).
Demo data in this tutorial can be downloaded here: [download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_en_v1.0.tar).
**Attention**
......@@ -89,7 +89,7 @@ wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/infere
cd ..
# Download the demo data and unzip it
wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_v1.0.tar && tar -xf recognition_demo_data_v1.0.tar
wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_en_v1.0.tar && tar -xf recognition_demo_data_en_v1.0.tar
```
Once unpacked, the `recognition_demo_data_v1.0` folder should have the following file structure.
......@@ -123,7 +123,7 @@ The `models` folder should have the following file structure.
```
<a name="Product_recognition_and_retrival"></a>
### 2.2 Product Recognition and Retrival
### 2.2 Product Recognition and Retrieval
Take the product recognition demo as an example to show the recognition and retrieval process (if you wish to try other scenarios of recognition and retrieval, replace the corresponding configuration file after downloading and unzipping the corresponding demo data and model to complete the prediction)。
......@@ -137,7 +137,7 @@ Run the following command to identify and retrieve the image `./recognition_demo
# use the following command to predict using GPU.
python3.7 python/predict_system.py -c configs/inference_product.yaml
# use the following command to predict using CPU
python3.7 python/predict_system.py -c configs/inference_product.yaml
python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.use_gpu=False
```
**Note:** Program lib used to build index is compliled on our machine, if error occured because of the environment, you can refer to [vector search tutorial](../../../deploy/vector_search/README.md) to rebuild the lib.
......@@ -153,7 +153,7 @@ The image to be retrieved is shown below.
The final output is shown below.
```
[{'bbox': [287, 129, 497, 326], 'rec_docs': '稻香村金猪饼', 'rec_scores': 0.8309420943260193}, {'bbox': [99, 242, 313, 426], 'rec_docs': '稻香村金猪饼', 'rec_scores': 0.7245652079582214}]
[{'bbox': [287, 129, 497, 326], 'rec_docs': 'Daoxaingcun Golden Piggie Cake', 'rec_scores': 0.8309420347213745}, {'bbox': [99, 242, 313, 426], 'rec_docs': 'Daoxaingcun Golden Piggie Cake', 'rec_scores': 0.7245651483535767}]
```
......@@ -163,7 +163,7 @@ where bbox indicates the location of the detected object, rec_docs indicates the
The detection result is also saved in the folder `output`, for this image, the visualization result is as follows.
<div align="center">
<img src="../../images/recognition/product_demo/result/daoxiangcunjinzhubing_6.jpg" width = "400" />
<img src="../../images/recognition/product_demo/result/daoxiangcunjinzhubing_6_en.jpg" width = "400" />
</div>
......@@ -182,13 +182,12 @@ The results on the screen are shown as following.
```
...
[{'bbox': [37, 29, 123, 89], 'rec_docs': '香奈儿包', 'rec_scores': 0.6163763999938965}, {'bbox': [153, 96, 235, 175], 'rec_docs': '香奈儿包', 'rec_scores': 0.5279821157455444}]
[{'bbox': [735, 562, 1133, 851], 'rec_docs': '香奈儿包', 'rec_scores': 0.5588355660438538}]
[{'bbox': [124, 50, 230, 129], 'rec_docs': '香奈儿包', 'rec_scores': 0.6980369687080383}]
[{'bbox': [0, 0, 275, 183], 'rec_docs': '香奈儿包', 'rec_scores': 0.5818190574645996}]
[{'bbox': [400, 1179, 905, 1537], 'rec_docs': '香奈儿包', 'rec_scores': 0.9814301133155823}]
[{'bbox': [544, 4, 1482, 932], 'rec_docs': '香奈儿包', 'rec_scores': 0.5143815279006958}]
[{'bbox': [29, 42, 194, 183], 'rec_docs': '香奈儿包', 'rec_scores': 0.9543638229370117}]
[{'bbox': [37, 29, 123, 89], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.6163763999938965}, {'bbox': [153, 96, 235, 175], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.5279821157455444}]
[{'bbox': [735, 562, 1133, 851], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.5588355660438538}]
[{'bbox': [124, 50, 230, 129], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.6980369687080383}]
[{'bbox': [0, 0, 275, 183], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.5818190574645996}]
[{'bbox': [400, 1179, 905, 1537], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.9814301133155823}, {'bbox': [295, 713, 820, 1046], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.9496176242828369}, {'bbox': [153, 236, 694, 614], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.8395382761955261}]
[{'bbox': [544, 4, 1482, 932], 'rec_docs': 'Chanel Handbag', 'rec_scores': 0.5143815279006958}]
...
```
......@@ -238,12 +237,12 @@ cp recognition_demo_data_v1.0/gallery_product/data_file.txt recognition_demo_dat
Then add some new lines into the new label file, which is shown as follows.
```
gallery/anmuxi/001.jpg 安慕希酸奶
gallery/anmuxi/002.jpg 安慕希酸奶
gallery/anmuxi/003.jpg 安慕希酸奶
gallery/anmuxi/004.jpg 安慕希酸奶
gallery/anmuxi/005.jpg 安慕希酸奶
gallery/anmuxi/006.jpg 安慕希酸奶
gallery/anmuxi/001.jpg Anmuxi Ambrosial Yogurt
gallery/anmuxi/002.jpg Anmuxi Ambrosial Yogurt
gallery/anmuxi/003.jpg Anmuxi Ambrosial Yogurt
gallery/anmuxi/004.jpg Anmuxi Ambrosial Yogurt
gallery/anmuxi/005.jpg Anmuxi Ambrosial Yogurt
gallery/anmuxi/006.jpg Anmuxi Ambrosial Yogurt
```
Each line can be splited into two fields. The first field denotes the relative image path, and the second field denotes its label. The `delimiter` is `tab` here.
......@@ -274,11 +273,11 @@ python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.i
The output is as follows:
```
[{'bbox': [243, 80, 523, 522], 'rec_docs': '安慕希酸奶', 'rec_scores': 0.5570770502090454}]
[{'bbox': [243, 80, 523, 522], 'rec_docs': 'Anmuxi Ambrosial Yogurt', 'rec_scores': 0.5570770502090454}]
```
The final recognition result is `安慕希酸奶`, which is corrrect, the visualization result is as follows.
The final recognition result is `Anmuxi Ambrosial Yogurt`, which is corrrect, the visualization result is as follows.
<div align="center">
<img src="../../images/recognition/product_demo/result/anmuxi.jpg" width = "400" />
<img src="../../images/recognition/product_demo/result/anmuxi_en.jpg" width = "400" />
</div>
......@@ -6,7 +6,7 @@
<a name="模型库概览图"></a>
### 模型库概览图
基于ImageNet1k分类数据集,PaddleClas支持24种系列分类网络结构以及对应的122个图像分类预训练模型,训练技巧、每个系列网络结构的简单介绍和性能评估将在相应章节展现,下面所有的速度指标评估环境如下:
基于ImageNet1k分类数据集,PaddleClas支持35个系列分类网络结构以及对应的164个图像分类预训练模型,训练技巧、每个系列网络结构的简单介绍和性能评估将在相应章节展现,下面所有的速度指标评估环境如下:
* CPU的评估环境基于骁龙855(SD855)。
* GPU评估环境基于T4机器,在FP32+TensorRT配置下运行500次测得(去除前10次的warmup时间)。
......
......@@ -44,7 +44,7 @@ sudo nvidia-docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host
```
# ctrl+P+Q可退出docker 容器,重新进入docker 容器使用如下命令
sudo docker container exec -it ppcls /bin/bash
sudo docker exec -it ppcls /bin/bash
```
### 1.3 通过pip安装PaddlePaddle
......
......@@ -43,8 +43,8 @@ class _SysPathG(object):
with _SysPathG(
os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'ppcls', 'modeling')):
import architectures
os.path.dirname(os.path.abspath(__file__)), 'ppcls', 'arch')):
import backbone
def _load_pretrained_parameters(model, name):
url = 'https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/{}_pretrained.pdparams'.format(
......@@ -63,7 +63,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `AlexNet` model depends on args.
"""
model = architectures.AlexNet(**kwargs)
model = backbone.AlexNet(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'AlexNet')
......@@ -80,7 +80,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `VGG11` model depends on args.
"""
model = architectures.VGG11(**kwargs)
model = backbone.VGG11(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'VGG11')
......@@ -97,7 +97,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `VGG13` model depends on args.
"""
model = architectures.VGG13(**kwargs)
model = backbone.VGG13(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'VGG13')
......@@ -114,7 +114,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `VGG16` model depends on args.
"""
model = architectures.VGG16(**kwargs)
model = backbone.VGG16(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'VGG16')
......@@ -131,7 +131,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `VGG19` model depends on args.
"""
model = architectures.VGG19(**kwargs)
model = backbone.VGG19(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'VGG19')
......@@ -149,7 +149,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNet18` model depends on args.
"""
model = architectures.ResNet18(**kwargs)
model = backbone.ResNet18(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNet18')
......@@ -167,7 +167,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNet34` model depends on args.
"""
model = architectures.ResNet34(**kwargs)
model = backbone.ResNet34(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNet34')
......@@ -185,7 +185,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNet50` model depends on args.
"""
model = architectures.ResNet50(**kwargs)
model = backbone.ResNet50(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNet50')
......@@ -203,7 +203,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNet101` model depends on args.
"""
model = architectures.ResNet101(**kwargs)
model = backbone.ResNet101(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNet101')
......@@ -221,7 +221,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNet152` model depends on args.
"""
model = architectures.ResNet152(**kwargs)
model = backbone.ResNet152(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNet152')
......@@ -237,7 +237,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `SqueezeNet1_0` model depends on args.
"""
model = architectures.SqueezeNet1_0(**kwargs)
model = backbone.SqueezeNet1_0(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'SqueezeNet1_0')
......@@ -253,7 +253,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `SqueezeNet1_1` model depends on args.
"""
model = architectures.SqueezeNet1_1(**kwargs)
model = backbone.SqueezeNet1_1(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'SqueezeNet1_1')
......@@ -271,7 +271,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `DenseNet121` model depends on args.
"""
model = architectures.DenseNet121(**kwargs)
model = backbone.DenseNet121(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'DenseNet121')
......@@ -289,7 +289,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `DenseNet161` model depends on args.
"""
model = architectures.DenseNet161(**kwargs)
model = backbone.DenseNet161(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'DenseNet161')
......@@ -307,7 +307,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `DenseNet169` model depends on args.
"""
model = architectures.DenseNet169(**kwargs)
model = backbone.DenseNet169(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'DenseNet169')
......@@ -325,7 +325,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `DenseNet201` model depends on args.
"""
model = architectures.DenseNet201(**kwargs)
model = backbone.DenseNet201(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'DenseNet201')
......@@ -343,7 +343,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `DenseNet264` model depends on args.
"""
model = architectures.DenseNet264(**kwargs)
model = backbone.DenseNet264(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'DenseNet264')
......@@ -359,7 +359,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `InceptionV3` model depends on args.
"""
model = architectures.InceptionV3(**kwargs)
model = backbone.InceptionV3(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'InceptionV3')
......@@ -375,7 +375,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `InceptionV4` model depends on args.
"""
model = architectures.InceptionV4(**kwargs)
model = backbone.InceptionV4(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'InceptionV4')
......@@ -391,7 +391,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `GoogLeNet` model depends on args.
"""
model = architectures.GoogLeNet(**kwargs)
model = backbone.GoogLeNet(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'GoogLeNet')
......@@ -407,7 +407,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ShuffleNetV2_x0_25` model depends on args.
"""
model = architectures.ShuffleNetV2_x0_25(**kwargs)
model = backbone.ShuffleNetV2_x0_25(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ShuffleNetV2_x0_25')
......@@ -423,7 +423,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV1` model depends on args.
"""
model = architectures.MobileNetV1(**kwargs)
model = backbone.MobileNetV1(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV1')
......@@ -439,7 +439,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV1_x0_25` model depends on args.
"""
model = architectures.MobileNetV1_x0_25(**kwargs)
model = backbone.MobileNetV1_x0_25(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV1_x0_25')
......@@ -455,7 +455,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV1_x0_5` model depends on args.
"""
model = architectures.MobileNetV1_x0_5(**kwargs)
model = backbone.MobileNetV1_x0_5(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV1_x0_5')
......@@ -471,7 +471,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV1_x0_75` model depends on args.
"""
model = architectures.MobileNetV1_x0_75(**kwargs)
model = backbone.MobileNetV1_x0_75(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV1_x0_75')
......@@ -487,7 +487,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV2_x0_25` model depends on args.
"""
model = architectures.MobileNetV2_x0_25(**kwargs)
model = backbone.MobileNetV2_x0_25(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV2_x0_25')
......@@ -503,7 +503,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV2_x0_5` model depends on args.
"""
model = architectures.MobileNetV2_x0_5(**kwargs)
model = backbone.MobileNetV2_x0_5(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV2_x0_5')
......@@ -519,7 +519,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV2_x0_75` model depends on args.
"""
model = architectures.MobileNetV2_x0_75(**kwargs)
model = backbone.MobileNetV2_x0_75(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV2_x0_75')
......@@ -535,7 +535,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV2_x1_5` model depends on args.
"""
model = architectures.MobileNetV2_x1_5(**kwargs)
model = backbone.MobileNetV2_x1_5(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV2_x1_5')
......@@ -551,7 +551,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV2_x2_0` model depends on args.
"""
model = architectures.MobileNetV2_x2_0(**kwargs)
model = backbone.MobileNetV2_x2_0(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'MobileNetV2_x2_0')
......@@ -567,7 +567,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_large_x0_35` model depends on args.
"""
model = architectures.MobileNetV3_large_x0_35(**kwargs)
model = backbone.MobileNetV3_large_x0_35(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_large_x0_35')
......@@ -584,7 +584,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_large_x0_5` model depends on args.
"""
model = architectures.MobileNetV3_large_x0_5(**kwargs)
model = backbone.MobileNetV3_large_x0_5(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_large_x0_5')
......@@ -601,7 +601,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_large_x0_75` model depends on args.
"""
model = architectures.MobileNetV3_large_x0_75(**kwargs)
model = backbone.MobileNetV3_large_x0_75(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_large_x0_75')
......@@ -618,7 +618,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_large_x1_0` model depends on args.
"""
model = architectures.MobileNetV3_large_x1_0(**kwargs)
model = backbone.MobileNetV3_large_x1_0(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_large_x1_0')
......@@ -635,7 +635,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_large_x1_25` model depends on args.
"""
model = architectures.MobileNetV3_large_x1_25(**kwargs)
model = backbone.MobileNetV3_large_x1_25(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_large_x1_25')
......@@ -652,7 +652,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_small_x0_35` model depends on args.
"""
model = architectures.MobileNetV3_small_x0_35(**kwargs)
model = backbone.MobileNetV3_small_x0_35(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_small_x0_35')
......@@ -669,7 +669,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_small_x0_5` model depends on args.
"""
model = architectures.MobileNetV3_small_x0_5(**kwargs)
model = backbone.MobileNetV3_small_x0_5(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_small_x0_5')
......@@ -686,7 +686,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_small_x0_75` model depends on args.
"""
model = architectures.MobileNetV3_small_x0_75(**kwargs)
model = backbone.MobileNetV3_small_x0_75(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_small_x0_75')
......@@ -703,7 +703,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_small_x1_0` model depends on args.
"""
model = architectures.MobileNetV3_small_x1_0(**kwargs)
model = backbone.MobileNetV3_small_x1_0(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_small_x1_0')
......@@ -720,7 +720,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `MobileNetV3_small_x1_25` model depends on args.
"""
model = architectures.MobileNetV3_small_x1_25(**kwargs)
model = backbone.MobileNetV3_small_x1_25(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model,
'MobileNetV3_small_x1_25')
......@@ -737,7 +737,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNeXt101_32x4d` model depends on args.
"""
model = architectures.ResNeXt101_32x4d(**kwargs)
model = backbone.ResNeXt101_32x4d(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNeXt101_32x4d')
......@@ -753,7 +753,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNeXt101_64x4d` model depends on args.
"""
model = architectures.ResNeXt101_64x4d(**kwargs)
model = backbone.ResNeXt101_64x4d(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNeXt101_64x4d')
......@@ -769,7 +769,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNeXt152_32x4d` model depends on args.
"""
model = architectures.ResNeXt152_32x4d(**kwargs)
model = backbone.ResNeXt152_32x4d(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNeXt152_32x4d')
......@@ -785,7 +785,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNeXt152_64x4d` model depends on args.
"""
model = architectures.ResNeXt152_64x4d(**kwargs)
model = backbone.ResNeXt152_64x4d(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNeXt152_64x4d')
......@@ -801,7 +801,7 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNeXt50_32x4d` model depends on args.
"""
model = architectures.ResNeXt50_32x4d(**kwargs)
model = backbone.ResNeXt50_32x4d(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNeXt50_32x4d')
......@@ -817,8 +817,24 @@ with _SysPathG(
Returns:
model: nn.Layer. Specific `ResNeXt50_64x4d` model depends on args.
"""
model = architectures.ResNeXt50_64x4d(**kwargs)
model = backbone.ResNeXt50_64x4d(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'ResNeXt50_64x4d')
return model
def darknet53(pretrained=False, **kwargs):
"""
DarkNet53
Args:
pretrained: bool=False. If `True` load pretrained parameters, `False` otherwise.
kwargs:
class_dim: int=1000. Output dim of last fc layer.
Returns:
model: nn.Layer. Specific `ResNeXt50_64x4d` model depends on args.
"""
model = backbone.DarkNet53(**kwargs)
if pretrained:
model = _load_pretrained_parameters(model, 'DarkNet53')
return model
......@@ -16,11 +16,14 @@ import copy
import importlib
import paddle.nn as nn
from paddle.jit import to_static
from paddle.static import InputSpec
from . import backbone, gears
from .backbone import *
from .gears import build_gear
from .utils import *
from ppcls.utils import logger
from ppcls.utils.save_load import load_dygraph_pretrain
__all__ = ["build_model", "RecModel", "DistillationModel"]
......@@ -34,6 +37,19 @@ def build_model(config):
return arch
def apply_to_static(config, model):
support_to_static = config['Global'].get('to_static', False)
if support_to_static:
specs = None
if 'image_shape' in config['Global']:
specs = [InputSpec([None] + config['Global']['image_shape'])]
model = to_static(model, input_spec=specs)
logger.info("Successfully to apply @to_static with specs: {}".format(
specs))
return model
class RecModel(nn.Layer):
def __init__(self, **config):
super().__init__()
......
......@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
......
......@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
......
......@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
......
......@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
......
......@@ -14,6 +14,8 @@ Global:
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# training model under @to_static
to_static: False
# model architecture
Arch:
......
......@@ -34,6 +34,7 @@ from ppcls.utils.logger import init_logger
from ppcls.utils.config import print_config
from ppcls.data import build_dataloader
from ppcls.arch import build_model
from ppcls.arch import apply_to_static
from ppcls.loss import build_loss
from ppcls.metric import build_metrics
from ppcls.optimizer import build_optimizer
......@@ -73,6 +74,8 @@ class Trainer(object):
self.is_rec = False
self.model = build_model(self.config["Arch"])
# set @to_static for benchmark, skip this by default.
apply_to_static(self.config, self.model)
if self.config["Global"]["pretrained_model"] is not None:
load_dygraph_pretrain(self.model,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册