提交 5035240c 编写于 作者: D dongshuilong

merge develop

......@@ -14,3 +14,4 @@
__all__ = ['PaddleClas']
from .paddleclas import PaddleClas
from ppcls.arch.backbone import *
# Knowledge Distillation
---
## Content
* [1. Introduction of model compression methods](#1)
* [2. Application of knowledge distillation](#2)
* [3. Overview of knowledge distillation methods](#3)
* [3.1 Response based distillation](#3.1)
* [3.2 Feature based distillation](#3.2)
* [3.3 Relation based distillation](#3.3)
* [4. Reference](#4)
<a name='1'></a>
## 1. Introduction of model compression methods
In recent years, deep neural networks have been proved to be an extremely effective method for solving problems in the fields of computer vision and natural language processing. A suitable neural network architecture might performs better than traditional algorithms mostly.
When the amount of data is large enough, increasing the model parameters with a reasonable method can significantly improve the model performance, but this brings about the problem of a sharp increase of the model complexity. It costs more for larger models.
Parameter redundancy exists in deep neural networks generally. At present, there are several mainstream methods to compress the model and reduce parameters. Such as pruning, quantization, knowledge distillation, etc. Knowledge distillation refers to the use of a teacher model to guide the student model to learn specific tasks to ensure that the small model obtains relatively large performance, and even has comparable performance with the large model [1].
Currently, knowledge distillation methods can be roughly divided into the following three types.
* Response based distillation: Output of student model is guided by the teacher model for
* Feature based distillation: Inner feature map of student model is guided by the teacher model.
* Relation based distillation: For different samples, the teacher model and the student model are used to calculate the correlation of the feature map between the samples, the final goal is to make sure that correlation matrix of student model and the teacher model are as consistent as possible.
<a name='2'></a>
## 2. Application of knowledge distillation
Knowledge distillation algorithm is widely used in lightweight tasks. For tasks that need to meet specific accuracy, by using the knowledge distillation method, we can achieve the required accuracy with a smaller model, thereby reducing model deployment cost.
What's more, for the same model structure, pre-trained models obtained by knowledge distillation often performs better, and these pre-trained models can also improve performance of the downstream tasks. For example, a pre-trained image classification model with higher accuracy can also help other tasks obtain significant accuracy gains such as target detection, image segmentation, OCR, and video classification.
<a name='3'></a>
## 3. Overview of knowledge distillation methods
<a name='3.1'></a>
### 3.1 Response based distillation
Knowledge distillation algorithm is firstly proposed by Hinton, which is called KD. In addition to base cross entropy loss, KL divergence loss between output of student model and teacher model is also added into the total training loss. It's noted that a larger teacher model is needed to guide the training process of the student model.
PaddleClas proposed a simple but useful knowledge distillation algorithm canlled SSLD [6], Labels are not needed for SSLD, so unlabeled data can also be used for training. Accuracy of 15 models has more than 3% improvement using SSLD.
Teacher model is needed for the above-mentioned distillation method to guide the student model training process. Deep Mutual Learning (DML) is then proposed [7], for which two models with same architecture learn from each other to obtain higher accuracy. Compared with KD and other knowledge distillation algorithms that rely on large teacher models, DML is free of dependence on large teacher models. The distillation training process is simpler.
<a name='3.2'></a>
### 3.2 Feature based distillation
Heo et al. proposed OverHaul [8], which calculates the feature map distance between the student model and the teacher model, as distillation loss. Here, feature map alignment of the student model and the teacher model is used to ensure that the feature maps' distance can be calculated.
Feature based distillation can also be integrated with the response based knowledge distillation algorithm in Chapter 3.1, which means both the inner feature map and output of the student model are guided during the training process. For the DML method, this integration process is simpler, because the alignment process is not needed since the two models' architectures are absolutely same. This integration process is used in the PP-OCRv2 system, which ultimately greatly improves the accuracy of the OCR text recognition model.
<a name='3.3'></a>
### 3.3 Relation based distillation
The papers in chapters `3.1` and `3.2` mainly consider the inner feature map or final output of the student model and the teacher model. These knowledge distillation algorithms only focus on the output for single sample, but do not consider the output relationship between different samples.
Park et al. proposed RKD [10], a relationship-based knowledge distillation algorithm. In RKD, the relationship between different samples is further considered, and two loss functions are used, which are the second-order distance loss (distance-wise) and the third-order angle loss (angle-wise). For the final distillation loss, KD loss and RKD loss are considered at the same time. The final accuracy is better than the accuracy of the model obtained just using KD loss.
<a name='4'></a>
## 4. Reference
[1] Hinton G, Vinyals O, Dean J. Distilling the knowledge in a neural network[J]. arXiv preprint arXiv:1503.02531, 2015.
[2] Bagherinezhad H, Horton M, Rastegari M, et al. Label refinery: Improving imagenet classification through label progression[J]. arXiv preprint arXiv:1805.02641, 2018.
[3] Yalniz I Z, Jégou H, Chen K, et al. Billion-scale semi-supervised learning for image classification[J]. arXiv preprint arXiv:1905.00546, 2019.
[4] Cubuk E D, Zoph B, Mane D, et al. Autoaugment: Learning augmentation strategies from data[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2019: 113-123.
[5] Touvron H, Vedaldi A, Douze M, et al. Fixing the train-test resolution discrepancy[C]//Advances in Neural Information Processing Systems. 2019: 8250-8260.
[6] Cui C, Guo R, Du Y, et al. Beyond Self-Supervision: A Simple Yet Effective Network Distillation Alternative to Improve Backbones[J]. arXiv preprint arXiv:2103.05959, 2021.
[7] Zhang Y, Xiang T, Hospedales T M, et al. Deep mutual learning[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2018: 4320-4328.
[8] Heo B, Kim J, Yun S, et al. A comprehensive overhaul of feature distillation[C]//Proceedings of the IEEE/CVF International Conference on Computer Vision. 2019: 1921-1930.
[9] Du Y, Li C, Guo R, et al. PP-OCRv2: Bag of Tricks for Ultra Lightweight OCR System[J]. arXiv preprint arXiv:2109.03144, 2021.
[10] Park W, Kim D, Lu Y, et al. Relational knowledge distillation[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2019: 3967-3976.
# Cartoon Demo Images
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069080-a821e0b7-8a10-4946-bf05-ff093cc16064.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069100-7539d292-1bd8-4655-8a6d-d1f2238bd618.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069103-f91359d4-1197-4a6e-b2f7-434c76a6b704.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069108-ad54ae1d-610d-4cfa-9cd6-8ee8d280d61d.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069114-3c771434-84a8-4e58-961e-d35edfbfe5ef.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069119-e8d85be5-da87-4125-ae8b-9fd4cac139d9.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069124-98c30894-4837-4f2f-8399-3d3ebadfd0a1.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069125-a9edf115-33a1-48bf-9e4f-7edbc4269a1e.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069129-98553a25-00e2-4f0f-9b44-dfc4e4f6b6d1.png " width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069131-f7649bb2-255c-4725-a635-799b8b4d815a.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069135-acb69b89-55db-41ac-9846-e2536ef3d955.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069137-1f0abfdb-6608-432e-bd40-c8e1ab86ef8b.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069140-18c6a439-f117-498d-9cdb-ade71cc2c248.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069145-80452f86-afcf-42b5-8423-328cca9e4750.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069154-63a25c1c-b448-44c2-8baf-eb31952c5476.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069156-1b881c6b-5680-4f9a-aef1-2491af50675d.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069161-8759f3d4-8456-43ea-bf54-99a646d5a109.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069167-937aa847-c661-431c-b3dc-5a3c890b31cd.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069170-43d0dce4-6c62-485d-adf4-364c8467c251.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069175-70bc9e50-b833-4a2a-8a3f-c0775dac49c2.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069179-d01f8a0f-4383-4b08-b064-4e6bb006e745.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069184-d423a84c-c9dd-4125-9dc7-397cae21efc9.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069188-fc4deb80-38a2-4c50-9a29-30cee4c8e374.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069193-77a19ee8-b1e2-4c27-9016-3440a1547470.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069196-5f050524-ac08-4831-89f5-9e9e3ce085c1.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069200-4f963171-c790-4f43-8ca3-2e701ad3731c.jpeg" width = "400" /> </div>
# Logo Demo Images
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096687-5b562e2d-0653-4be6-861d-1936a4440df2.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096698-4b95eb4b-6638-47dc-ae48-7b40744a31ba.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096701-4a4b2bd9-85f2-4d55-be4b-be6ab5e0fb81.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096706-ef4ad024-7284-4cb3-975a-779fd06b96f5.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096710-620b0495-cc83-4501-a104-dfe20afb53d2.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096713-48e629aa-c637-4603-b005-18570fa94d6d.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096715-709957f2-50bb-4edb-a6e4-e7d5601872c7.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096717-a74744cc-4fb8-4e78-b1cb-20409582ca52.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096721-d4af003c-7945-4591-9e47-4e428dc2628c.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096726-460af6ab-8595-4fb4-9960-4c66b18bee1e.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096728-81494000-92b5-40ad-a6a7-606dae3548a3.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096731-2e980977-9ee6-4e29-bdf7-8397820f70e8.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096732-7d425b45-6b04-4984-948d-278da13dd802.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096735-a9c85c14-5965-4529-a235-ce00035bd7ab.jpg " width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096736-3182efc6-ba43-4cde-9397-88a131f4fed8.jpg " width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096737-91e6fa24-1eb5-4aba-9271-5a3722cbe35b.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096740-f440f89b-5f95-493a-b087-00c7cd3481ef.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096747-31b924e3-ffb2-45ab-872e-4ff923ed04f1.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096752-1f98c937-5d83-4c29-b495-01971b5fb258.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096756-a994c7e2-b9e7-40ba-9934-78c10666217b.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096757-879749e0-9e04-4d1e-a07b-6a4322975a84.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096761-5b682ce8-4f83-4fbb-bfb7-df749912aa8b.png " width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096767-e8f701eb-d0e8-4304-b031-e2bff8c199f3.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096778-ec2ad374-b9fc-427e-9e8b-8e5d2afc6394.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096783-9ec5e04d-19e3-463d-ad9d-7a26202bbb9c.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096788-44f04979-18ca-4ba6-b833-7489b344ffff.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096791-6989451e-157c-4101-8b54-7578b05eb7c9.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096796-cc4477cf-016c-4b19-86c3-61824704ecf5.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096798-ba33ee0d-45b8-48ad-a8fa-14cd643a6976.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096805-e29a2ba8-4785-4ca6-9e0d-596fad6ce8dc.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096812-7d8c57a5-fbae-4496-8144-3b40ac74fef0.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096816-50f0ac3d-f2eb-4011-a34e-58e2e215b7b0.jpg " width = "400" /> </div>
## Demo images
- Product recognition
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277277-7b29f596-35f6-4f00-8d2b-0ef0be57a090.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277291-f7d2b2a1-5790-4f5b-a0e6-f5c52d04a69a.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277300-8ce0d5ce-e0ca-46ea-bb9a-74df0df66ae3.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277308-14a097bd-2bcd-41ce-a9e6-5e9cd0bd8b08.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277311-208ae574-a708-46e2-a41e-c639322913b1.jpg" width = "400" /> </div>
[More demo images](product.md)
- Cartoon character recognition
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069108-ad54ae1d-610d-4cfa-9cd6-8ee8d280d61d.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069100-7539d292-1bd8-4655-8a6d-d1f2238bd618.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069080-a821e0b7-8a10-4946-bf05-ff093cc16064.jpeg" width = "400" /> </div>
[More demo images](cartoon.md)
- Logo recognition
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096687-5b562e2d-0653-4be6-861d-1936a4440df2.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096701-4a4b2bd9-85f2-4d55-be4b-be6ab5e0fb81.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096706-ef4ad024-7284-4cb3-975a-779fd06b96f5.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096713-48e629aa-c637-4603-b005-18570fa94d6d.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096752-1f98c937-5d83-4c29-b495-01971b5fb258.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096767-e8f701eb-d0e8-4304-b031-e2bff8c199f3.jpeg" width = "400" /> </div>
[More demo images](logo.md)
- Car recognition
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243899-c60f0a51-db9b-438a-9f2d-0d2893c200bb.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243905-7eeb938d-d88f-4540-a667-06e08dcf1f55.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243911-735a6ec0-a624-4965-b3cd-2b9f52fa8d65.jpeg" width = "400" /> </div>
[More demo images](vehicle.md)
# Product Demo Images
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277277-7b29f596-35f6-4f00-8d2b-0ef0be57a090.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277287-7bdad02a-8e3c-4e04-861c-95a5dae1f3c6.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277291-f7d2b2a1-5790-4f5b-a0e6-f5c52d04a69a.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277294-80aaab94-5109-41be-97f8-3ada73118963.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277296-2a8d7846-cd2e-454e-8b72-46233da09451.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277300-8ce0d5ce-e0ca-46ea-bb9a-74df0df66ae3.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277302-25c973eb-f9aa-42ce-b9e9-66cee738c241.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277303-3d3460da-c6aa-4994-b585-17bc9f3df504.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277306-20cbef71-cc58-4ae1-965b-4806e82988a9.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277308-14a097bd-2bcd-41ce-a9e6-5e9cd0bd8b08.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277309-be092d1c-6513-472c-8b7f-685f4353ae5b.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277311-208ae574-a708-46e2-a41e-c639322913b1.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277314-72901737-5ef5-4a23-820b-1db58c5e6ca0.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277318-aef4080c-24f2-4d92-be3c-45b500b75584.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277320-8046d0df-1256-41ce-a8d6-6d2c1292462c.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277321-e3864473-6a8e-485f-81f2-562b902d6cff.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277324-0aacc27f-699a-437b-bac0-4a20c90b47b1.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277328-8d28f754-8645-4c05-a9a6-0312bbe2f890.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277333-59da1513-e7e5-455c-ab73-7a3162216923.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277335-454c0423-5398-4348-aaab-e2652fd08999.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277338-a7d09c28-1b86-4cf5-bd79-99d51c5b5311.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277343-9c456d21-8018-4cd5-9c0b-cc7c087fac69.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277345-2ef780f1-d7c9-4cf2-a370-f220a052eb71.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277347-baa4b870-7fca-4d4c-8528-fad720270024.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277351-e0691080-ede4-49ae-9075-d36a41cebf25.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277354-509f8f85-f171-44e9-8ca1-4c3cae77b5fb.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277357-39d572b8-60ee-44db-9e0e-2c0ea2be2ed3.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277359-6caf33f6-2a38-48e5-b349-f4dd1ef2566b.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277362-260daa87-1db7-4f89-ba9c-1b32876fd3b6.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277366-14cfd2f9-d044-4288-843e-463a1816163e.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277368-b0e96341-e030-4e4d-8010-6f7c3bc94d2f.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277370-1f26e4e5-9988-4427-a035-44bfd9d472d6.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277372-27e60b60-cd5c-4b05-ae38-2e9524c627f3.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277374-bd292bb2-e1f9-4d5f-aa49-d67ac571d01b.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277377-b0b8cdb9-8196-4598-ae47-b615914bf6bf.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277382-fc89d18a-a57b-4331-adbb-bda3584fb122.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277386-d676467c-9846-4051-8192-b3e089d01cdc.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277390-83f66d3f-c415-47e6-b651-6b51fbe59bbf.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277394-9895d654-3163-4dd9-882c-ac5a893e2ad3.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277396-9e5e3aa3-6d9e-40ab-a325-2edea452156d.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277399-b92e2092-eabd-45c8-bf36-b2e238167892.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277404-285f943a-de70-48b8-9545-53e229b7350d.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277406-0b7ec434-f064-4985-80f3-c00735b3e32d.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277408-4f9b8b19-42c2-4ba4-bf6d-b95ababe0313.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277409-6df0faf7-71b7-4c9a-a875-36ae7ee7129d.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277411-9c2b364a-749d-465e-a85d-29a69e9ff3ef.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277413-c54a462c-dd3b-4ad0-985d-ef0ec1f216ec.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277414-6d922055-cd59-4f84-b5b6-651209d6336a.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277417-78e1322e-4039-4232-b217-1be4f207f804.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277419-181822a3-bae6-4c4f-9959-59e991c2df6c.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277422-76f09d84-cb47-4332-aa88-a12458cd8993.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277424-a72203b5-1a99-4464-a39c-245f7a891f25.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277429-521ac9a6-e4c3-4c74-9c5b-8e8dd6cddf34.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277433-4f9fb9c8-7930-4303-b54e-a6eace347923.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277434-f3aa3565-a2c5-4c1c-ab44-930a8b073b5f.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277437-90cf1cd7-6a62-4ac4-ac85-3aa534e50cee.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277439-54e168bc-9518-429e-9e97-cb9ca5e811c9.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277441-a3c277d7-c889-4556-b74a-400cadf8b771.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277442-22a0cd38-acd8-4b5a-8e59-c4bea852fb79.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277444-ea662034-c17f-47ba-9ea3-694d3cb0c880.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277448-a71f4a0a-c3cc-4432-a803-843b7c65307f.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277449-0b3a2e98-3e09-4bd6-be32-c35f44154e8a.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277452-e36ccc63-8e39-4973-a336-4ace855d25e6.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277454-bddd9527-b189-4771-ab9e-52085db5a44d.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277455-7ea277ba-bc75-48db-9567-40e1acb56f02.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277460-0f5ee4dc-5ece-45d5-8ef9-666f1be41b76.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277461-37cab773-6341-4c91-b1f4-780d530eab3b.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277465-8f53ef9d-0465-4a90-afac-b1dd3c970b72.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277467-655ddabe-cbe0-4d1f-a30e-c2965428e8d7.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277470-4587e905-3fc8-4dad-84ee-0844ba4d2474.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277473-a155944f-efe3-492a-babc-2f3fe700a99b.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277475-c95ab821-f5ae-427a-8721-8991f9c7f29f.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277479-55b59855-2ed6-4526-9481-6b92b25fef97.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277484-556f0e4c-007b-4f6a-b21f-c485f630cbcb.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277486-a39eb069-bc13-415e-b936-ba294216dfac.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277487-80952841-6a76-4fb3-8049-fe15ce8f7cfb.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277491-e892a6a8-6f9a-46c7-83e0-261cfb92d276.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277494-520f483e-654d-4399-9684-1fcd9778b76e.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277496-54b1ada5-e6a6-4654-a8a6-739511cec750.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277500-ff7e2afd-9cd7-484a-bd1e-362226f5197f.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277501-94489261-bea5-4492-bf3e-98cc8aaa7a7f.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277504-567a32bc-a573-4154-a9cd-6acbec923768.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277506-e893d4d5-43ce-4df1-9f08-3cdf6a8c7e2c.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277509-5766629f-bb92-4552-b34a-647e29b9a89b.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277511-8821708b-09f0-4aab-86dd-40ae3794697a.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277515-ed6a0dff-bd91-4233-a9af-e2744df7c7e0.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277519-1883d6a1-9348-4514-8924-dde27dd38704.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277524-b9d8515c-4df2-410a-b4a6-da098cb9da61.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277526-52a9c666-a799-4921-b371-41d97d7d9242.jpg" width = "400" /> </div>
# Vehicle Demo Images
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243899-c60f0a51-db9b-438a-9f2d-0d2893c200bb.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243904-fdbe2e01-dc7c-449a-8e9e-baea4f85fee4.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243905-7eeb938d-d88f-4540-a667-06e08dcf1f55.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243908-c7f1e3ea-92a7-429b-888c-732b9ec5398f.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243911-735a6ec0-a624-4965-b3cd-2b9f52fa8d65.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243913-baec489a-5463-472b-b5d1-418bcd4eb978.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243916-f50dfcdd-2d5f-48f9-876f-dbc05f4afa30.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243920-7a65ec82-8312-421e-985a-c394f11af28f.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243922-458e6dca-fb80-4baf-951e-9651080dc242.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243926-5df3036b-9ea1-441c-b30a-b4f847df25ab.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243927-7673d94a-fbb0-4a92-a3f3-c879a432a7db.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243928-91082855-c5a7-4a3f-aeea-7a2e51e43183.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243929-88fe7efa-b212-4105-af2f-2248a6cb2877.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243933-49e71d02-8228-40ec-99b2-3ed862bf4ba5.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243935-530fbfa3-0d34-4d9d-bd59-2fde5659f7e5.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243940-d289fc7d-d343-4aa5-a807-9ce09a241ccd.jpeg" width = "400" /> </div>
## Demo images
- Product recognition
<div align="center">
<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_en.jpg" width = "400" />
</div>
<div align="center">
<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_en.jpg" width = "400" />
</div>
<div align="center">
<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_en.jpg" width = "400" />
</div>
<div align="center">
<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_en.jpg" width = "400" />
</div>
- Cartoon character recognition
<div align="center">
<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_en.jpeg" width = "400" />
</div>
<div align="center">
<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_en.jpg" width = "400" />
</div>
<div align="center">
<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_en.jpg" width = "400" />
</div>
- Car recognition
<div align="center">
<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_en.jpeg" width = "400" />
</div>
<div align="center">
<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)
......@@ -6,7 +6,7 @@
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277308-14a097bd-2bcd-41ce-a9e6-5e9cd0bd8b08.jpg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140277311-208ae574-a708-46e2-a41e-c639322913b1.jpg" width = "400" /> </div>
[更多效果图](../../images/recognition/more_demo_images/product.md)
[更多效果图](product.md)
- 动漫人物识别
......@@ -15,7 +15,7 @@
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069100-7539d292-1bd8-4655-8a6d-d1f2238bd618.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140069080-a821e0b7-8a10-4946-bf05-ff093cc16064.jpeg" width = "400" /> </div>
[更多效果图](../../images/recognition/more_demo_images/cartoon.md)
[更多效果图](cartoon.md)
- logo识别
......@@ -24,16 +24,10 @@
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096701-4a4b2bd9-85f2-4d55-be4b-be6ab5e0fb81.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096706-ef4ad024-7284-4cb3-975a-779fd06b96f5.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096713-48e629aa-c637-4603-b005-18570fa94d6d.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096752-1f98c937-5d83-4c29-b495-01971b5fb258.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140096767-e8f701eb-d0e8-4304-b031-e2bff8c199f3.jpeg" width = "400" /> </div>
[更多效果图](../../images/recognition/more_demo_images/logo.md)
......@@ -43,4 +37,4 @@
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243905-7eeb938d-d88f-4540-a667-06e08dcf1f55.jpeg" width = "400" /> </div>
<div align="center"> <img src="https://user-images.githubusercontent.com/12560511/140243911-735a6ec0-a624-4965-b3cd-2b9f52fa8d65.jpeg" width = "400" /> </div>
[更多效果图](../../images/recognition/more_demo_images/vehicle.md)
[更多效果图](vehicle.md)
## 识别效果展示
- 商品识别
<div align="center">
<img src="../../images/recognition/more_demo_images/output_product/channelhandle_5.jpg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_product/cliniqueblush_1.jpg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_product/daoxiangcunjinzhubing_10.jpg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_product/gannidress_10.jpg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_product/gbyingerche_15.jpg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_product/lafiolewine_03.jpg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_product/taochunqiu_8.jpg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_product/weiduomeinaiyougege_10.jpg" width = "400" />
</div>
- 动漫人物识别
<div align="center">
<img src="../../images/recognition/more_demo_images/output_cartoon/labixiaoxin-005.jpeg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_cartoon/liuchuanfeng-010.jpeg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_cartoon/zhangchulan-007.jpeg" width = "400" />
</div>
- logo 识别
<div align="center">
<img src="../images/recognition/more_demo_images/output_logo/cctv_4.jpg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_logo/mangguo_8.jpeg" width = "400" />
</div>
<div align="center">
<img src="../images/recognition/more_demo_images/output_logo/zhongshiyou-007.jpg" width = "400" />
</div>
- 车辆识别
<div align="center">
<img src="../../images/recognition/more_demo_images/output_vehicle/audia5-115.jpeg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_vehicle/bentian-yage-101.jpeg" width = "400" />
</div>
<div align="center">
<img src="../../images/recognition/more_demo_images/output_vehicle/bmw-m340-107.jpeg" width = "400" />
</div>
[更多效果图](../../images/recognition/more_demo_images)
......@@ -38,6 +38,10 @@ from deploy.utils.get_image_list import get_image_list
from deploy.utils import config
from ppcls.arch.backbone import *
from ppcls.utils.logger import init_logger
# for building model with loading pretrained weights from backbone
init_logger()
__all__ = ["PaddleClas"]
......@@ -58,20 +62,27 @@ MODEL_SERIES = {
"DenseNet121", "DenseNet161", "DenseNet169", "DenseNet201",
"DenseNet264"
],
"DLA": [
"DLA46_c", "DLA60x_c", "DLA34", "DLA60", "DLA60x", "DLA102", "DLA102x",
"DLA102x2", "DLA169"
],
"DPN": ["DPN68", "DPN92", "DPN98", "DPN107", "DPN131"],
"EfficientNet": [
"EfficientNetB0", "EfficientNetB0_small", "EfficientNetB1",
"EfficientNetB2", "EfficientNetB3", "EfficientNetB4", "EfficientNetB5",
"EfficientNetB6", "EfficientNetB7"
],
"ESNet": ["ESNet_x0_25", "ESNet_x0_5", "ESNet_x0_75", "ESNet_x1_0"],
"GhostNet":
["GhostNet_x0_5", "GhostNet_x1_0", "GhostNet_x1_3", "GhostNet_x1_3_ssld"],
"HarDNet": ["HarDNet39_ds", "HarDNet68_ds", "HarDNet68", "HarDNet85"],
"HRNet": [
"HRNet_W18_C", "HRNet_W30_C", "HRNet_W32_C", "HRNet_W40_C",
"HRNet_W44_C", "HRNet_W48_C", "HRNet_W64_C", "HRNet_W18_C_ssld",
"HRNet_W48_C_ssld"
],
"Inception": ["GoogLeNet", "InceptionV3", "InceptionV4"],
"MixNet": ["MixNet_S", "MixNet_M", "MixNet_L"],
"MobileNetV1": [
"MobileNetV1_x0_25", "MobileNetV1_x0_5", "MobileNetV1_x0_75",
"MobileNetV1", "MobileNetV1_ssld"
......@@ -89,6 +100,11 @@ MODEL_SERIES = {
"MobileNetV3_large_x1_0", "MobileNetV3_large_x1_25",
"MobileNetV3_small_x1_0_ssld", "MobileNetV3_large_x1_0_ssld"
],
"PPLCNet": [
"PPLCNet_x0_25", "PPLCNet_x0_35", "PPLCNet_x0_5", "PPLCNet_x0_75",
"PPLCNet_x1_0", "PPLCNet_x1_5", "PPLCNet_x2_0", "PPLCNet_x2_5"
],
"RedNet": ["RedNet26", "RedNet38", "RedNet50", "RedNet101", "RedNet152"],
"RegNet": ["RegNetX_4GF"],
"Res2Net": [
"Res2Net50_14w_8s", "Res2Net50_26w_4s", "Res2Net50_vd_26w_4s",
......@@ -113,6 +129,8 @@ MODEL_SERIES = {
"ResNeXt152_32x4d", "ResNeXt152_vd_32x4d", "ResNeXt152_64x4d",
"ResNeXt152_vd_64x4d"
],
"ReXNet":
["ReXNet_1_0", "ReXNet_1_3", "ReXNet_1_5", "ReXNet_2_0", "ReXNet_3_0"],
"SENet": [
"SENet154_vd", "SE_HRNet_W64_C_ssld", "SE_ResNet18_vd",
"SE_ResNet34_vd", "SE_ResNet50_vd", "SE_ResNeXt50_32x4d",
......@@ -134,6 +152,10 @@ MODEL_SERIES = {
"SwinTransformer_small_patch4_window7_224",
"SwinTransformer_tiny_patch4_window7_224"
],
"Twins": [
"pcpvt_small", "pcpvt_base", "pcpvt_large", "alt_gvt_small",
"alt_gvt_base", "alt_gvt_large"
],
"VGG": ["VGG11", "VGG13", "VGG16", "VGG19"],
"VisionTransformer": [
"ViT_base_patch16_224", "ViT_base_patch16_384", "ViT_base_patch32_384",
......@@ -465,24 +487,23 @@ class PaddleClas(object):
"""Predict input_data.
Args:
input_data (Union[str, np.array]):
input_data (Union[str, np.array]):
When the type is str, it is the path of image, or the directory containing images, or the URL of image from Internet.
When the type is np.array, it is the image data whose channel order is RGB.
print_pred (bool, optional): Whether print the prediction result. Defaults to False. Defaults to False.
print_pred (bool, optional): Whether print the prediction result. Defaults to False.
Raises:
ImageTypeError: Illegal input_data.
Yields:
Generator[list, None, None]:
The prediction result(s) of input_data by batch_size. For every one image,
prediction result(s) is zipped as a dict, that includs topk "class_ids", "scores" and "label_names".
The format is as follow: [{"class_ids": [...], "scores": [...], "label_names": [...]}, ...]
Generator[list, None, None]:
The prediction result(s) of input_data by batch_size. For every one image,
prediction result(s) is zipped as a dict, that includs topk "class_ids", "scores" and "label_names".
The format of batch prediction result(s) is as follow: [{"class_ids": [...], "scores": [...], "label_names": [...]}, ...]
"""
if isinstance(input_data, np.ndarray):
outputs = self.cls_predictor.predict(input_data)
yield self.cls_predictor.postprocess(outputs)
yield self.cls_predictor.predict(input_data)
elif isinstance(input_data, str):
if input_data.startswith("http") or input_data.startswith("https"):
image_storage_dir = partial(os.path.join, BASE_IMAGES_DIR)
......@@ -497,7 +518,7 @@ class PaddleClas(object):
image_list = get_image_list(input_data)
batch_size = self._config.Global.get("batch_size", 1)
topk = self._config.PostProcess.get('topk', 1)
topk = self._config.PostProcess.Topk.get('topk', 1)
img_list = []
img_path_list = []
......@@ -515,16 +536,15 @@ class PaddleClas(object):
cnt += 1
if cnt % batch_size == 0 or (idx + 1) == len(image_list):
outputs = self.cls_predictor.predict(img_list)
preds = self.cls_predictor.postprocess(outputs,
img_path_list)
preds = self.cls_predictor.predict(img_list)
if print_pred and preds:
for pred in preds:
filename = pred.pop("file_name")
for idx, pred in enumerate(preds):
pred_str = ", ".join(
[f"{k}: {pred[k]}" for k in pred])
print(
f"filename: {filename}, top-{topk}, {pred_str}")
f"filename: {img_path_list[idx]}, top-{topk}, {pred_str}"
)
img_list = []
img_path_list = []
......
......@@ -48,7 +48,7 @@ from ppcls.arch.backbone.model_zoo.resnext101_wsl import ResNeXt101_32x8d_wsl, R
from ppcls.arch.backbone.model_zoo.squeezenet import SqueezeNet1_0, SqueezeNet1_1
from ppcls.arch.backbone.model_zoo.darknet import DarkNet53
from ppcls.arch.backbone.model_zoo.regnet import RegNetX_200MF, RegNetX_4GF, RegNetX_32GF, RegNetY_200MF, RegNetY_4GF, RegNetY_32GF
from ppcls.arch.backbone.model_zoo.vision_transformer import ViT_small_patch16_224, ViT_base_patch16_224, ViT_base_patch16_384, ViT_base_patch32_384, ViT_large_patch16_224, ViT_large_patch16_384, ViT_large_patch32_384, ViT_huge_patch16_224, ViT_huge_patch32_384
from ppcls.arch.backbone.model_zoo.vision_transformer import ViT_small_patch16_224, ViT_base_patch16_224, ViT_base_patch16_384, ViT_base_patch32_384, ViT_large_patch16_224, ViT_large_patch16_384, ViT_large_patch32_384
from ppcls.arch.backbone.model_zoo.distilled_vision_transformer import DeiT_tiny_patch16_224, DeiT_small_patch16_224, DeiT_base_patch16_224, DeiT_tiny_distilled_patch16_224, DeiT_small_distilled_patch16_224, DeiT_base_distilled_patch16_224, DeiT_base_patch16_384, DeiT_base_distilled_patch16_384
from ppcls.arch.backbone.model_zoo.swin_transformer import SwinTransformer_tiny_patch4_window7_224, SwinTransformer_small_patch4_window7_224, SwinTransformer_base_patch4_window7_224, SwinTransformer_base_patch4_window12_384, SwinTransformer_large_patch4_window7_224, SwinTransformer_large_patch4_window12_384
from ppcls.arch.backbone.model_zoo.mixnet import MixNet_S, MixNet_M, MixNet_L
......@@ -65,6 +65,7 @@ from ppcls.arch.backbone.variant_models.vgg_variant import VGG19Sigmoid
from ppcls.arch.backbone.variant_models.pp_lcnet_variant import PPLCNet_x2_5_Tanh
# help whl get all the models' api (class type) and components' api (func type)
def get_apis():
current_func = sys._getframe().f_code.co_name
current_module = sys.modules[__name__]
......
......@@ -38,10 +38,6 @@ MODEL_URLS = {
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch16_384_pretrained.pdparams",
"ViT_large_patch32_384":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_large_patch32_384_pretrained.pdparams",
"ViT_huge_patch16_224":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_huge_patch16_224_pretrained.pdparams",
"ViT_huge_patch32_384":
"https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_huge_patch32_384_pretrained.pdparams"
}
__all__ = list(MODEL_URLS.keys())
......@@ -460,36 +456,3 @@ def ViT_large_patch32_384(pretrained=False, use_ssld=False, **kwargs):
MODEL_URLS["ViT_large_patch32_384"],
use_ssld=use_ssld)
return model
def ViT_huge_patch16_224(pretrained=False, use_ssld=False, **kwargs):
model = VisionTransformer(
patch_size=16,
embed_dim=1280,
depth=32,
num_heads=16,
mlp_ratio=4,
**kwargs)
_load_pretrained(
pretrained,
model,
MODEL_URLS["ViT_huge_patch16_224"],
use_ssld=use_ssld)
return model
def ViT_huge_patch32_384(pretrained=False, use_ssld=False, **kwargs):
model = VisionTransformer(
img_size=384,
patch_size=32,
embed_dim=1280,
depth=32,
num_heads=16,
mlp_ratio=4,
**kwargs)
_load_pretrained(
pretrained,
model,
MODEL_URLS["ViT_huge_patch32_384"],
use_ssld=use_ssld)
return model
# global configs
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 120
print_batch_step: 10
use_visualdl: False
# used for static mode and model export
image_shape: [3, 224, 224]
save_inference_dir: ./inference
# model architecture
Arch:
name: ViT_huge_patch16_224
class_num: 1000
# loss function config for traing/eval process
Loss:
Train:
- CELoss:
weight: 1.0
Eval:
- CELoss:
weight: 1.0
Optimizer:
name: Momentum
momentum: 0.9
lr:
name: Piecewise
learning_rate: 0.1
decay_epochs: [30, 60, 90]
values: [0.1, 0.01, 0.001, 0.0001]
regularizer:
name: 'L2'
coeff: 0.0001
# data loader for train and eval
DataLoader:
Train:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- RandCropImage:
size: 224
- RandFlipImage:
flip_code: 1
- NormalizeImage:
scale: 1.0/255.0
mean: [0.5, 0.5, 0.5]
std: [0.5, 0.5, 0.5]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 64
drop_last: False
shuffle: True
loader:
num_workers: 4
use_shared_memory: True
Eval:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 256
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.5, 0.5, 0.5]
std: [0.5, 0.5, 0.5]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 64
drop_last: False
shuffle: False
loader:
num_workers: 4
use_shared_memory: True
Infer:
infer_imgs: docs/images/whl/demo.jpg
batch_size: 10
transforms:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 256
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.5, 0.5, 0.5]
std: [0.5, 0.5, 0.5]
order: ''
- ToCHWImage:
PostProcess:
name: Topk
topk: 5
class_id_map_file: ppcls/utils/imagenet1k_label_list.txt
Metric:
Train:
- TopkAcc:
topk: [1, 5]
Eval:
- TopkAcc:
topk: [1, 5]
# global configs
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 120
print_batch_step: 10
use_visualdl: False
# used for static mode and model export
image_shape: [3, 384, 384]
save_inference_dir: ./inference
# model architecture
Arch:
name: ViT_huge_patch32_384
class_num: 1000
# loss function config for traing/eval process
Loss:
Train:
- CELoss:
weight: 1.0
Eval:
- CELoss:
weight: 1.0
Optimizer:
name: Momentum
momentum: 0.9
lr:
name: Piecewise
learning_rate: 0.1
decay_epochs: [30, 60, 90]
values: [0.1, 0.01, 0.001, 0.0001]
regularizer:
name: 'L2'
coeff: 0.0001
# data loader for train and eval
DataLoader:
Train:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- RandCropImage:
size: 384
- RandFlipImage:
flip_code: 1
- NormalizeImage:
scale: 1.0/255.0
mean: [0.5, 0.5, 0.5]
std: [0.5, 0.5, 0.5]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 64
drop_last: False
shuffle: True
loader:
num_workers: 4
use_shared_memory: True
Eval:
dataset:
name: ImageNetDataset
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 384
- CropImage:
size: 384
- NormalizeImage:
scale: 1.0/255.0
mean: [0.5, 0.5, 0.5]
std: [0.5, 0.5, 0.5]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 64
drop_last: False
shuffle: False
loader:
num_workers: 4
use_shared_memory: True
Infer:
infer_imgs: docs/images/whl/demo.jpg
batch_size: 10
transforms:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 384
- CropImage:
size: 384
- NormalizeImage:
scale: 1.0/255.0
mean: [0.5, 0.5, 0.5]
std: [0.5, 0.5, 0.5]
order: ''
- ToCHWImage:
PostProcess:
name: Topk
topk: 5
class_id_map_file: ppcls/utils/imagenet1k_label_list.txt
Metric:
Train:
- TopkAcc:
topk: [1, 5]
Eval:
- TopkAcc:
topk: [1, 5]
===========================train_params===========================
model_name:ViT_huge_patch16_224
python:python3.7
gpu_list:0|0,1
-o Global.device:gpu
-o Global.auto_cast:null
-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120
-o Global.output_dir:./output/
-o DataLoader.Train.sampler.batch_size:8
-o Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/ILSVRC2012/val
null:null
##
trainer:norm_train
norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_huge_patch16_224.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_huge_patch16_224.yaml
null:null
##
===========================infer_params==========================
-o Global.save_inference_dir:./inference
-o Global.pretrained_model:
norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_huge_patch16_224.yaml
quant_export:null
fpgm_export:null
distill_export:null
kl_quant:null
export2:null
pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_huge_patch16_224_pretrained.pdparams
infer_model:../inference/
infer_export:True
infer_quant:Fasle
inference:python/predict_cls.py -c configs/inference_cls.yaml
-o Global.use_gpu:True|False
-o Global.enable_mkldnn:True|False
-o Global.cpu_num_threads:1|6
-o Global.batch_size:1|16
-o Global.use_tensorrt:True|False
-o Global.use_fp16:True|False
-o Global.inference_model_dir:../inference
-o Global.infer_imgs:../dataset/ILSVRC2012/val
-o Global.save_log_path:null
-o Global.benchmark:True
null:null
null:null
===========================train_params===========================
model_name:ViT_huge_patch32_384
python:python3.7
gpu_list:0|0,1
-o Global.device:gpu
-o Global.auto_cast:null
-o Global.epochs:lite_train_lite_infer=2|whole_train_whole_infer=120
-o Global.output_dir:./output/
-o DataLoader.Train.sampler.batch_size:2
-o Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/ILSVRC2012/val
null:null
##
trainer:norm_train
norm_train:tools/train.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_huge_patch32_384.yaml -o Global.seed=1234 -o DataLoader.Train.sampler.shuffle=False -o DataLoader.Train.loader.num_workers=0 -o DataLoader.Train.loader.use_shared_memory=False
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_huge_patch32_384.yaml
null:null
##
===========================infer_params==========================
-o Global.save_inference_dir:./inference
-o Global.pretrained_model:
norm_export:tools/export_model.py -c ppcls/configs/ImageNet/VisionTransformer/ViT_huge_patch32_384.yaml
quant_export:null
fpgm_export:null
distill_export:null
kl_quant:null
export2:null
pretrained_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_huge_patch32_384_pretrained.pdparams
infer_model:../inference/
infer_export:True
infer_quant:Fasle
inference:python/predict_cls.py -c configs/inference_cls.yaml -o PreProcess.transform_ops.0.ResizeImage.resize_short=384 -o PreProcess.transform_ops.1.CropImage.size=384
-o Global.use_gpu:True|False
-o Global.enable_mkldnn:True|False
-o Global.cpu_num_threads:1|6
-o Global.batch_size:1|16
-o Global.use_tensorrt:True|False
-o Global.use_fp16:True|False
-o Global.inference_model_dir:../inference
-o Global.infer_imgs:../dataset/ILSVRC2012/val
-o Global.save_log_path:null
-o Global.benchmark:True
null:null
null:null
......@@ -288,6 +288,7 @@ else
# run train
eval "unset CUDA_VISIBLE_DEVICES"
export FLAGS_cudnn_deterministic=True
sleep 5
eval $cmd
status_check $? "${cmd}" "${status_log}"
sleep 5
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册