PP-ShiTu: A Practical Lightweight Image Recognition System

Shengyu Wei, Ruoyu Guo, Cheng Cui, Bin Lu, Shuilong Dong, Tingquan Gao, Yuning Du, Ying Zhou, Xueying Lyu, Qiwen Liu, Xiaoguang Hu, Dianhai Yu, Yanjun MaarXiv 2021

Abstract

In recent years, image recognition applications have developed rapidly. A large number of studies and techniques have emerged in different fields, such as face recognition, pedestrian and vehicle re-identification, landmark retrieval, and product recognition. In this paper, we propose a practical lightweight image recognition system, named PP-ShiTu, consisting of the following 3 modules: mainbody detection, feature extraction, and vector search. We introduce popular strategies including metric learning, deep hash, knowledge distillation, and model quantization to improve accuracy and inference speed. With these strategies, PP-ShiTu works well in different scenarios with a set of models trained on a mixed dataset. Experiments on different datasets and benchmarks show that the system is widely effective in different domains of image recognition. All the above mentioned models are open-sourced and the code is available in the GitHub repository PaddleClas on PaddlePaddle.

Introduction

Image recognition is traditionally a fragmented field, with specialized systems built for specific domains like facial recognition or product search. While these tasks share a common logic—detecting an object, extracting features, and matching against a database—migrating strategies between domains is often a manual and costly process. Furthermore, many state-of-the-art models are too computationally expensive for real-world deployment on CPUs or mobile devices.

PP-ShiTu addresses these challenges by providing a unified, lightweight image recognition pipeline designed to work across diverse domains—from retail and landmarks to vehicles and faces. By combining a CPU-optimized backbone with advanced distillation and hashing techniques, it achieves server-grade accuracy while remaining fast enough for edge deployment.

System Architecture

The PP-ShiTu system follows a modular three-stage pipeline: Mainbody Detection, Feature Extraction, and Vector Search.

The PP-ShiTu image recognition pipeline, illustrating the flow from query image through detection and extraction to the final vector search result.
  1. Mainbody Detection: To mitigate the impact of complex backgrounds, the system first identifies the foreground object (the "mainbody"). It utilizes PP-PicoDet, an anchor-free detector specifically optimized for high-speed performance on CPUs.
  2. Feature Extraction: This core module transforms the detected object into a representative feature vector. The system employs PP-LCNet, a backbone designed for Intel CPUs that incorporates several "lite" optimizations to balance accuracy and latency.
  3. Vector Search & DeepHash: To handle massive galleries, the system uses Faiss for efficient retrieval. For mobile devices with limited storage, DeepHash compresses floating-point features into compact binary codes, reducing storage requirements by up to 32x.

Lightweight Backbone: PP-LCNet

The effectiveness of PP-ShiTu relies heavily on the PP-LCNet backbone. Designed for efficiency, it utilizes several strategic architectural choices to optimize for Intel CPUs:

  • H-Swish Activation: Replaces standard ReLU to improve fitting capability with minimal computational overhead.
  • Strategic SE Modules: Squeeze-and-Excellence modules are placed only near the end of the network to maximize accuracy gains while minimizing latency impact.
  • Larger Kernels: The network uses 5x5 convolutions at the tail end to increase the receptive field without significantly slowing down the earlier, more computationally intensive layers.
Detailed architecture of the PP-LCNet backbone, showing the layer configurations and the placement of SE modules and Global Average Pooling (GAP).

Training Strategies and Datasets

PP-ShiTu's robustness stems from its training on a massive, heterogeneous dataset. The detection module is trained on a mix of five datasets, including Objects365 and COCO2017, while the recognition module is trained on a collection of seven datasets (e.g., Aliproduct, GLDv2, VeRI-Wild) totaling roughly 5 million images across 185,000 classes.

Key training optimizations include:

  • ArcMargin Loss: A metric learning approach that increases inter-class variance in the feature space.
  • Unified-Deep Mutual Learning (U-DML): A distillation technique where two student networks supervise each other's final outputs and intermediate feature maps, improving performance without requiring a large teacher model.

Key Results and Insights

  • Efficiency: PP-PicoDet is 14x faster than PP-YOLO on CPU, with only a 2.4% drop in mAP. The PP-LCNet-1x model achieves 71.32% Top-1 accuracy on ImageNet with a latency of just 2.46ms on an Intel Xeon CPU.
  • System Performance: End-to-end tests show a total latency of 194ms on high-end CPUs and 442ms on consumer-grade laptops, making it viable for real-time applications.
  • Compression: DeepHash increases retrieval speed by 5x and reduces index size from 285MB to 8.9MB for a library of 100,000+ items.
  • Universal Embeddings: Training on diverse categories simultaneously allows the model to learn a robust feature space that generalizes well to unseen categories.

Conclusion and Future Work

PP-ShiTu demonstrates that a single, lightweight pipeline can achieve high performance across multiple recognition domains. While highly effective, the system's accuracy is dependent on the diversity of the gallery database. Failure cases can occur when the gallery lacks sufficient examples for a specific category, such as certain keyboard models. Future research will focus on "few-shot" learning to enable the system to recognize new categories from minimal examples, further enhancing its practical utility.

Summary updated

BibTeX
@misc{wei2021pp,
  author = {Shengyu Wei and Ruoyu Guo and Cheng Cui and Bin Lu and Shuilong Dong and Tingquan Gao and Yuning Du and Ying Zhou and Xueying Lyu and Qiwen Liu and Xiaoguang Hu and Dianhai Yu and Yanjun Ma},
  title = {{PP-ShiTu: A Practical Lightweight Image Recognition System}},
  year = {2021},
  eprint = {2111.00775},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2111.00775},
}
Figure