The most powerful version in the history of garbage classification, look for version 001, you will be a god forever

An unknown college student, known as Caigou in the world of martial arts
original author: jacky Li
Email: [email protected]

Time of completion:2022.12.22
Last edited: 2022.12.22

 

Table of contents

Design concept and creativity

Technology application and features

Key technology

Garbage classification based on PaddleX

Pruning strategy based on PaddleSlim sensitivity analysis

Face recognition detection based on PaddleHub

Face verification

Management terminal development based on Tyadmin

Installation tutorial


Design concept and creativity

  This work uses the WeChat applet as a "personal" platform. Users can enter necessary personal information such as faces in the WeChat applet, and can use the WeChat applet as a window to query their own garbage classification details. In order to ensure the richness and humanization of the WeChat mini program, users can query the domestic waste commonly encountered in daily life through taking pictures, voice, search, etc. in the mini program and accumulate their own garbage classification knowledge. On the trash can side, the system matches the user's personal database by photographing the user's face information with the user's authorization, and records their garbage classification information. In addition, the trash can acts as a "guide" in this work to guide users to throw garbage into the correct trash can. On the management side, relevant departments can, on the one hand, get an overview of the overall garbage classification situation in a certain area, and on the other hand, they can also query the details of a specific person's garbage classification through the query interface. Based on this, relevant departments can more effectively formulate waste classification policies that are effective and adapted to local conditions and implement efficient implementation of related policies.

Technology application and features

  Based on the above solution, this work is based on the domestic deep learning development framework PaddlePaddle, integrating deep learning image classification technology, voice technology, search technology, etc., and based on the principle of convenience and ease of use, a WeChat applet that "recognizes garbage with a keen eye" was developed . This WeChat applet implements multiple functions such as garbage photography classification, voice input classification, etc., making it easier for users to carry out activities related to garbage classification reasonably, correctly and conveniently in their daily lives. At the same time, face recognition detection technology is used to enter facial information when the user logs in to the WeChat applet for the first time, and based on this connection to the personal database, it is linked to the individual's behavior records for garbage classification. This work fully considers user experience and ease of use. The prediction accuracy of the garbage classification model reaches more than 90%, covering most of the garbage categories in daily life, ensuring the efficient progress of the entire garbage classification process and a good user experience. The facial recognition detection model reaches more than 96.4%, providing a strong guarantee for the government's personal behavior management and supervision.

Software Architecture

Key technology

Garbage classification based on PaddleX

  Paddle X, as a full-process development kit for PaddlePaddle, supports developers to quickly implement projects in a low-code form. Paddle Developers implement it in practice.

  In order to improve the generalization and robustness of the model, this work added a variety of data enhancement methods such as RandomCrop, RandomVerticalFlip, RandomHorizontalFlip, RandomDistort and Normalize during the training process, and randomly cropped the images in the data set with a certain Probability performs operations such as random vertical and horizontal flipping of images, random pixel content transformation of images with a certain probability, and standardization of images.

  Judging from the results of the model in the verification set, its accuracy can reach more than 94%, and it has good recognition ability. Therefore, the model has the feasibility and effectiveness of the work.

Pruning strategy based on PaddleSlim sensitivity analysis

  PaddleSlim is a model compression tool library, including a series of model compression strategies such as model clipping, fixed-point quantization, distillation, hyperparameter search and model structure search.

  Since the model trained in this work is large in size and slow in prediction, which is not enough to meet the performance requirements in terminal testing and mobile deployment scenarios, PaddleSlim's sensitivity-based channel clipping algorithm is used to clip the model, that is, through different The sensitivity of each layer to pruning is used to determine the pruning ratio. The calculation method for the sensitivity of each layer is to prune the layer using different pruning ratios, and evaluate the accuracy loss of the model on the verification set after pruning. For the higher the pruning ratio, Large, but the smaller the accuracy loss, the layer is considered to be less sensitive and can be cropped at a larger proportion.

  After model trimming, without affecting the actual prediction accuracy of the model in this work, the model volume is effectively reduced, with the trimming rate being approximately 46.60%, and the prediction speed is significantly improved compared to before.

Face recognition detection based on PaddleHub

  PaddleHub[16] can help developers easily obtain pre-trained models in the PaddlePaddle ecosystem and complete model management and prediction. Together with the Fine-tune API, transfer learning can be quickly completed based on large-scale pre-trained models, allowing the pre-trained models to better serve users' applications in specific scenarios.

PyramidBox-Lite

  PyramidBox-Lite is a lightweight model developed based on the paper "PyramidBox: A Context-assisted Single Shot Face Detector" published by Baidu in 2018 at the top computer vision conference ECCV 2018.

  PyramidBox mainly proposes a new method of single-shot face detection based on context assistance - Pyramid Box. Based on the importance of context, this article improves the use of contextual information from the following three aspects. First, the author of the article designed a new context anchor to supervise high-level context feature learning through a semi-supervised method, namely PyramidAnchors. Secondly, the article proposes a low-level feature pyramid network that combines sufficient high-level contextual semantic features and low-level facial features to enable PyramidBox to predict faces of all sizes at once. Thirdly, we introduced a context-sensitive structure to expand the capacity of the prediction network to improve the final output accuracy. In addition, the article also uses the "data-anchor-sampling" method to expand training samples of different sizes, increasing the diversity of smaller face training data. PyramidBox makes full use of the value of context and performs exceptionally well on two commonly used face detection benchmarks - FDDB and WIDER FACE.

  PyramidBox-Lite is based on the backbone network FaceBoxes and has strong robustness to common problems such as lighting, mask occlusion, expression changes, scale changes, etc., and is suitable for use in garbage classification where there is great uncertainty in the environment. In addition, this model is a model optimized for mobile terminals, suitable for deployment on mobile terminals or edge detection devices, and has greater adaptability to this system.

Face verification

  The face verification task is to verify whether the face in the current picture is the face of a person that already exists in the database. There are generally two ways to implement this task: 1. Direct classification, that is, to determine which person is accurate, and then output the label; 2. Convert
  to a binary classification problem, that is, to determine whether a pair of two face photos is from the same person. , and then output the confidence level.
  Because the first method has many shortcomings, for example: after the model training is completed, new people cannot be added at any time, which is relatively rigid and less dynamic; it needs to collect a wider face reserve in the database, which is difficult to implement. Therefore, this work adopts the second method to achieve face verification.
  Convert face verification into a binary classification problem and implement it using Siamese Network. First, the face images are encoded in the same way through the same CNN network and embedded into a high-dimensional vector space. Then, softmax loss is used as the loss function to directly perform binary classification training on the splicing of the two sample embedding vectors, so that the model can directly output the similarity between the two identical samples. When the similarity reaches a certain threshold, it will be judged whether they are the same. personal.

Management terminal development based on Tyadmin

  Tyadmin is Django's Models-based management backend and front-end generation tool, which is mainly driven by Django Restful Framework and Ant Design Pro V4.

  Based on the complete design of the Model, Tyadmin can automatically generate front-end and back-end management backgrounds to realize fully automatic docking of page interfaces, including login verification, password modification, Dashboard data statistics and many other functions. It supports a variety of login methods including account and email login; it has a built-in automatic dashboard that can automatically register existing model count data; it implements fully automatic list display, addition, deletion, modification, search, filtering, and export to Excel to facilitate management and management of the management side. Query related data.

  Based on this, this work uses Tyadmin to implement a management backend for government supervision and inquiry. By connecting to the database, the data in the database is clearly displayed to the government supervision departments, making it convenient for relevant departments to collect garbage classification data in relevant areas and supervise a certain area. The specific situation of garbage classification, and then specify practical and reasonable garbage classification policies.

Installation tutorial

  1. Download the source code folder of this system and place it in the C drive directory of the Windows system;

  2. Install python dependent libraries: pip install -r requestment.txt;

  3. Unzip garbage_model.zip to the code folder;

  4. Open Cmd and enter the folder of this work.

  5. Execute python manage.py makemigrations;

  6. Execute python manage.py migrate;

  7. Execute python manage.py createsuperuser #Create a user who can log in to the background

  8. Execute python manage.py runserver #Run on port 8000 by default

  9. Open the developer tools, import the wx_mini_app folder under the system folder and run it to run the mini program;

  10. Open the browser and enter http://127.0.0.1:8000/xadmin/. Enter your account number and password to enter the backend management terminal.

The author has something to say

If you feel that what the blogger said is useful to you, please click "Follow" to support it. We will continue to update such issues...

If you need the source code, please chat with the blogger privately.

Guess you like

Origin blog.csdn.net/weixin_62075168/article/details/128413018