Garbage classification method based on YoloV5 and ResNet50

By using a waste sorting method based on YOLOv5 and ResNet50, the problem of poor sorting accuracy caused by overlapping waste was solved, achieving efficient and accurate waste sorting and promoting resource conservation and the construction of an environmentally friendly society.

CN115471694BActive Publication Date: 2026-03-27ZHEJIANG SCI-TECH UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-29
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing intelligent waste sorting methods do not take into account the overlapping of waste in images of household waste, resulting in poor sorting accuracy and low precision in cutting and recognition.

Method used

A waste classification method based on YOLOv5 and ResNet50 is adopted. Data augmentation is performed on the household waste dataset, a YOLOv5 model is trained to obtain the coordinates of waste areas and cut the images, and a ResNet50 model is used to identify waste categories, taking into account the overlapping of waste for cutting and identification.

Benefits of technology

It has improved the accuracy and efficiency of waste sorting, reduced the time and cost of manual sorting, and promoted resource conservation and environmental protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115471694B_ABST
    Figure CN115471694B_ABST
Patent Text Reader

Abstract

The application discloses a garbage classification method based on YoloV5 and ResNet50, first, collecting household garbage pictures, making a household garbage dataset, and performing data enhancement processing on the household garbage dataset; then, training a YoloV5 model, using the trained YoloV5 model to obtain the region coordinates of multiple household garbage on the picture, and cutting the picture containing multiple household garbage into multiple pictures containing single household garbage according to the region coordinate information; finally, training a ResNet50 model, inputting the cut picture into the trained ResNet50 model, obtaining the category of the household garbage on the picture, realizing intelligent household garbage classification, being conducive to realizing resource utilization and environmental protection, and avoiding the problems of time-consuming and laborious in the artificial garbage classification method; the garbage overlapping condition is considered during picture cutting, which is conducive to improving the accuracy of picture cutting and identification, and guaranteeing the accuracy of garbage classification.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of garbage classification, and particularly relates to a household garbage classification method based on YoloV5 and ResNet50. BACKGROUND

[0002] In recent years, with the development of economy and the improvement of living standards, the amount of household garbage has also increased dramatically. China has launched garbage classification and recycling for many years, but there are still problems such as poor recycling effect, weak public awareness of garbage classification, and so on. The current situation of urban household garbage classification and recycling is worrying. On the one hand, the traditional manual garbage classification method has poor garbage classification effect and low accuracy due to the lack of garbage classification knowledge of the public. On the other hand, the garbage classification task is heavy, the efficiency is low, and it is time-consuming and labor-intensive due to the large amount of household garbage. In view of the above situation, many intelligent garbage classification methods have been developed, but the existing intelligent garbage classification methods do not consider the overlapping of garbage on the household garbage picture, resulting in low cutting and recognition accuracy of the household garbage picture, and cannot guarantee the accuracy of household garbage classification.

[0003] In today's urgent environmental protection, China proposes the concept of sustainable development and takes building a resource-saving and environment-friendly society as the goal. Therefore, it is urgent to develop an intelligent garbage classification method with high efficiency and high precision to contribute to building a resource-saving and environment-friendly society. SUMMARY

[0004] The present application mainly aims to solve the problems of time-consuming and labor-intensive of the traditional manual garbage classification method and the poor classification accuracy of the intelligent garbage classification method without considering the overlapping of garbage, and provides a garbage classification method based on YoloV5 and ResNet50. First, collect household garbage pictures to make a household garbage dataset, and perform data enhancement processing on the household garbage dataset. Then, train the YoloV5 model, use the trained YoloV5 model to obtain the region coordinates of multiple household garbage on the picture, and cut the picture containing multiple household garbage into multiple pictures containing single household garbage according to the region coordinate information. Finally, train the ResNet50 model, input the cut picture into the trained ResNet50 model to obtain the category of household garbage on the picture, realize intelligent household garbage classification, which is conducive to realizing resource utilization and environmental protection, and avoids the problem of time-consuming and labor-intensive of the manual garbage classification method. The overlapping of garbage is considered during picture cutting, which is conducive to improving the accuracy of picture cutting and recognition and guaranteeing the accuracy of garbage classification.

[0005] The application mainly aims to solve the problem that the existing intelligent garbage classification method does not consider the overlapping of garbage on the life garbage picture, resulting in low cutting and recognition accuracy of the life garbage picture, and failing to guarantee the accuracy of life garbage classification, and provides a garbage classification method based on YoloV5 and ResNet50.

[0006] In order to achieve the above-mentioned purpose, the application adopts the following technical scheme:

[0007] The garbage classification method based on YoloV5 and ResNet50 comprises the following steps:

[0008] Step S1: collect life garbage pictures to make a life garbage dataset, divide the dataset into two types of train and val, and simultaneously contain two types of Yolo format labels;

[0009] Step S2: perform data enhancement processing on the life garbage dataset, and enrich data samples through data enhancement;

[0010] Step S3: train a YoloV5 model, and use the trained YoloV5 model to obtain the region coordinates of multiple life garbage on the picture, that is, obtain the life garbage recognition frame;

[0011] Step S4: according to the region coordinate information, use the PIL library to cut the picture, cut the picture containing multiple life garbage into multiple pictures containing single life garbage, if there is no overlapping of the life garbage recognition frame, directly cut the picture, if there is overlapping of the life garbage recognition frame, according to the ratio of the area of the overlapping part to the sum of the areas of the life garbage recognition frame, determine whether to directly cut or cut and then use the image of the non-overlapping part to fill the overlapping part, reduce the interference of different life garbage information, and improve the picture recognition accuracy;

[0012] Step S5: train a ResNet50 model, use the trained ResNet50 model to obtain the categories of multiple life garbage on the picture, that is, input the cut picture into the trained ResNet50 model, in the ResNet50 model, perform convolution operation on the picture through the convolution kernel, extract the picture feature information, then output the probability information through the full connection layer, and finally output a group of probability values, the category with the maximum probability value is the result category;

[0013] The application is based on a deep network learning method, wherein a YoloV5 model and a ResNet50 model are obtained through training, the YoloV5 model is used to obtain the region coordinate information of multiple household garbage on a picture, a household garbage recognition frame is determined according to the region coordinate information, and then the picture is cut according to the household garbage recognition frame, so that the picture containing multiple household garbage is cut into multiple pictures containing single household garbage, and then the cut picture is input into the ResNet50 model, the ResNet50 model is used to identify the category corresponding to the household garbage on the picture, and then the household garbage classification is realized, the resource value and economic value of the household garbage are improved, the household garbage treatment amount and the use of the treatment equipment are reduced, the treatment cost is reduced, the consumption of land resources is reduced, and the social, economic, ecological and other benefits are obtained, which contributes to the construction of a resource-saving and environment-friendly society; the intelligent classification is realized through the deep learning network, the problems of time-consuming and labor-intensive of the artificial garbage classification method are avoided, the convenience of people's life is brought, and the labor cost is reduced; the garbage overlapping condition is considered during the picture cutting, the cutting mode is selected according to the area proportion of the overlapping part, the picture cutting and identification accuracy are improved, and the accuracy of the garbage classification result is effectively ensured.

[0014] Preferably, the data enhancement processing in step S2 includes clockwise rotation, counterclockwise rotation, equal proportion scaling and filling a pure color background, and the enhanced data samples (data sets) are divided into three types of train, val and test according to 8.5:1:0.5, the samples in the train are used for training the model, the samples in the val are used for verifying the model, and the samples in the test are used for testing the model.

[0015] Preferably, the specific process of step S3 includes the following steps:

[0016] Step S31: training the YoloV5 model using the picture labeled with the household garbage region coordinate information to obtain the trained YoloV5 model;

[0017] Step S32: inputting the processed household garbage picture into the YoloV5 model to obtain the region coordinate information of multiple household garbage on the household garbage picture, that is, obtaining the household garbage recognition frame.

[0018] Preferably, in step S4, the household garbage recognition frame is determined according to the region coordinate information of the household garbage, and the picture containing multiple household garbage is cut into multiple pictures containing single household garbage using the PIL library. If the garbage overlapping condition occurs during the picture cutting, the cutting mode is selected according to the area proportion of the overlapping part, the interference of different garbage information is reduced, and the accuracy of the garbage classification is ensured.

[0019] Preferably, in step S4, the specific process of the picture cutting includes:

[0020] For the household garbage recognition frame without overlapping part, cutting is directly performed according to the area coordinate information;

[0021] For the household garbage recognition frame with overlapping part, a cutting mode is selected according to the ratio of the overlapping part area to the sum of the household garbage recognition frame area, and the specific process is as follows:

[0022] When the ratio of the overlapping part area to the sum of the household garbage recognition frame area is less than a set value, cutting is directly performed according to the original area coordinate information;

[0023] When the ratio of the overlapping part area to the sum of the household garbage recognition frame area is greater than the set value, cutting is first performed according to the original area coordinate information; then the picture is cut from the overlapping part to the non-overlapping part in turn until the overlapping part is not included, and multiple pictures are obtained; then the ResNet50 model is used to identify the pictures, if the identification results of the multiple pictures are the same, it is considered that the household garbage recognition frame corresponding to the original area coordinate information is located in the upper layer, and the identification result is the garbage classification result, which is directly outputted; if the identification results of the multiple pictures appear two or more, it is considered that the household garbage recognition frame corresponding to the original area coordinate information is located in the lower layer, and the overlapping part is the part of the household garbage recognition frame corresponding to the original area coordinate information that is blocked, then the image of the non-overlapping part is used to fill the overlapping part, and then cutting and identification are performed according to the original area coordinate information;

[0024] In the cutting of the picture, if the household garbage recognition frame does not overlap, the picture is directly cut; if the household garbage recognition frame overlaps, whether to directly cut or to cut and then fill the overlapping part with the image of the non-overlapping part is determined according to the ratio of the area of the overlapping part to the sum of the areas of the household garbage recognition frame, so as to reduce the interference of different household garbage information and improve the picture recognition accuracy. For example, when one kind of household garbage is completely contained in another kind of household garbage, the contained household garbage is directly cut, and the household garbage containing the contained household garbage is first filled with the image of the non-overlapping part to fill the overlapping part, and then cut.

[0025] Preferably, the specific process of step S5 includes the following steps:

[0026] Step S51: a ResNet50 model is built based on a pytorch deep learning framework and trained to obtain a trained ResNet50 model;

[0027] Step S52: the cut household garbage picture is inputted into the ResNet50 model to obtain the category information of the household garbage on the household garbage picture;

[0028] A ResNet50 model was built using the PyTorch deep learning framework. This model has 50 layers, divided into 5 stages. Each stage mainly contains convolutional layers, pooling layers, batch normalization layers, and fully connected layers. The convolutional layers extract feature information from images of household waste. After each convolutional layer, the parameters introduced by the original image data are reduced. The model utilizes the principle of local correlation in images to extract features. For the use of the trained ResNet50 model, the number of nodes in the fully connected layers can be customized according to the number of classification categories. In each fully connected layer, each neuron is fully connected to the neuron in the previous layer. The fully connected layers integrate the class-discriminating local information from the convolutional and pooling layers. Then, a softmax function after the fully connected layers predicts the normalized probability of household waste in the image belonging to each category. The category with the highest probability value is the final category.

[0029] Preferably, step S52 includes the following steps:

[0030] Step S521: Perform convolution operation on the image of household waste through convolutional layers to extract image feature information. After each convolution layer, the parameters brought by the original data image can be reduced. The feature extraction of the image is carried out by utilizing the principle of local correlation of images.

[0031] Step S522: Integrate class-discriminative feature information from convolutional and pooling layers through a fully connected layer;

[0032] Step S523: Using the softmax function after the fully connected layer, output the normalized probability value of household waste belonging to each category. The category with the highest probability value is the result category corresponding to household waste.

[0033] Preferably, the formula for calculating the softmax function in step S523 is as follows:

[0034]

[0035] in, Indicates the number of categories. Indicates the first The possibilities of each category, Represents the normalized i-th The probability values ​​of each category;

[0036] The softmax function after the fully connected layer outputs the normalized probability value of household waste belonging to each category. The category with the highest probability value is the result category corresponding to household waste.

[0037] As preferred, in step S5, the ResNet50 model parameters are further optimized by using a cross-entropy loss function and an Adam optimizer, and the calculation formula of the cross-entropy loss function is as follows:

[0038]

[0039] wherein, represents the label value of the i-th class, and is generally encoded by one-hot encoding; represents the loss function value calculated for all classes;

[0040] The cross-entropy represents the difference between the actual output and the expected output, and the smaller the cross-entropy, the smaller the error; the Adam optimizer is an advanced version of the Momentum optimizer and the AdaGrad optimizer, and can adaptively change the learning rate.

[0041] Therefore, the advantages of the present application are as follows:

[0042] (1) The present application realizes the classification of household garbage, is conducive to resource utilization and environmental protection, improves the resource value and economic value of household garbage, reduces the amount of household garbage and the use of treatment equipment, reduces the treatment cost, reduces the consumption of land resources, and has social, economic, ecological and other benefits, and contributes to the construction of a resource-saving and environment-friendly society;

[0043] (2) The intelligent classification is realized by the deep learning network, which avoids the time-consuming and laborious problem of manual garbage classification method, brings convenience to people's life while reducing labor cost;

[0044] (3) The picture cutting considers the overlapping situation of garbage, and the cutting mode is selected by the area proportion of the overlapping part, so as to improve the picture cutting and recognition precision, and effectively guarantee the accuracy of the garbage classification result. BRIEF DESCRIPTION OF DRAWINGS

[0045] Figure 1 is a flowchart of the garbage classification method based on YoloV5 and ResNet50 in the first embodiment of the present application.

[0046] Figure 2 is a picture cutting schematic diagram when the household garbage recognition frame has an overlapping part and the area proportion of the overlapping part is greater than 0.25 in the second embodiment of the present application. DETAILED DESCRIPTION

[0047] The present application will be further described below in combination with the drawings and specific embodiments.

[0048] Embodiment I:

[0049] The garbage classification method based on YoloV5 and ResNet50 is as follows:​Figure 1 As shown, comprising the following steps:

[0050] Step S1: Collecting household garbage pictures, making a household garbage dataset, dividing the dataset into two types of train and val, and simultaneously containing two types of Yolo format labels;

[0051] Step S2: Data augmentation processing is performed on the household garbage dataset, and the data samples are enriched through data augmentation. The data augmentation processing includes clockwise rotation, counterclockwise rotation, equal proportion scaling, and filling a pure color background. The enhanced data samples (dataset) are divided into three types of train, val, and test according to 8.5:1:0.5. The samples in the train are used to train the model, the samples in the val are used to verify the model, and the samples in the test are used to test the model;

[0052] Step S3: Training the YoloV5 model, and using the trained YoloV5 model to obtain the region coordinates of multiple household garbage on the picture, that is, obtaining the household garbage recognition box;

[0053] Step S4: According to the region coordinate information, using the PIL library to cut the picture, cutting the picture containing multiple household garbage into multiple pictures containing single household garbage. If there is no overlap of the household garbage recognition box, the picture is directly cut. If there is overlap of the household garbage recognition box, it is determined whether to directly cut or to cut and fill the overlapping part with the image of the non-overlapping part to reduce the interference of different household garbage information, so as to improve the picture recognition accuracy according to the ratio of the area of the overlapping part to the sum of the areas of the household garbage recognition boxes;

[0054] Step S5: Training the ResNet50 model, and using the trained ResNet50 model to obtain the categories of multiple household garbage on the picture, that is, inputting the cut picture into the trained ResNet50 model. In the ResNet50 model, the picture is convolved by a convolution kernel to extract picture feature information, and then the probability information is output through a fully connected layer. Finally, a group of probability values is output, and the category with the largest probability value is the result category;

[0055] The embodiment is based on the method of deep network learning. The YoloV5 model and the ResNet50 model are obtained by training. The YoloV5 model is used to obtain the region coordinate information of multiple household garbage on the picture. The household garbage recognition box is determined according to the region coordinate information, and then the picture is cut according to the household garbage recognition box. The picture containing multiple household garbage is cut into multiple pictures containing single household garbage. Then the cut picture is input into the ResNet50 model. The ResNet50 model is used to identify the corresponding category of the household garbage on the picture, and then the household garbage classification is realized.

[0056] The specific process of step S3 includes the following steps:

[0057] Step S31: training the YoloV5 model using the picture marked with the household garbage area coordinate information to obtain the trained YoloV5 model;

[0058] Step S32: inputting the processed household garbage picture into the YoloV5 model to obtain the area coordinate information of multiple household garbage on the household garbage picture, that is, obtaining the household garbage recognition frame.

[0059] In step S4, the specific process of picture cutting includes:

[0060] For the household garbage recognition frame without overlapping parts, cutting is directly performed according to the area coordinate information;

[0061] For the household garbage recognition frame with overlapping parts, the cutting mode is selected according to the ratio of the overlapping part area to the sum of the household garbage recognition frame area, and the specific process is as follows:

[0062] When the ratio of the overlapping part area to the sum of the household garbage recognition frame area is less than a set value, the set value is 0.25 in this embodiment, cutting is directly performed according to the original area coordinate information;

[0063] When the ratio of the overlapping part area to the sum of the household garbage recognition frame area is greater than a set value, the set value is 0.25 in this embodiment, cutting is first performed according to the original area coordinate information; then the picture is cut from the overlapping part to the non-overlapping part in turn until the overlapping part is not included, multiple pictures are obtained; then the ResNet50 model is used to identify the pictures, if the identification results of the multiple pictures are the same, it is considered that the household garbage recognition frame corresponding to the original area coordinate information is located in the upper layer, the above identification result is the garbage classification result, and the garbage category is directly output; if the identification results of the multiple pictures appear two or more, it is considered that the household garbage recognition frame corresponding to the original area coordinate information is located in the lower layer, and the overlapping part is the part of the household garbage recognition frame corresponding to the original area coordinate information that is blocked, then the image of the non-overlapping part is used to fill the overlapping part, and then cutting and identification are performed according to the original area coordinate information;

[0064] For example, when one kind of household garbage is completely contained in another kind of household garbage, the contained household garbage is directly cut, and the household garbage containing the contained household garbage is first filled with the image of the non-overlapping part to fill the overlapping part, and then cutting is performed.

[0065] The specific process of step S5 includes the following steps:

[0066] Step S51: building a ResNet50 model based on a pytorch deep learning framework and training the ResNet50 model to obtain a trained ResNet50 model;

[0067] Step S52: Input the cut-out images of household waste into the ResNet50 model to obtain the category information of household waste in the images;

[0068] A ResNet50 model was built using the PyTorch deep learning framework. This model has 50 layers, divided into 5 stages. Each stage mainly contains convolutional layers, pooling layers, batch normalization layers, and fully connected layers. Convolutional layers are used to perform convolution operations on images of household waste to extract feature information. After each convolutional layer, the parameters introduced by the original image data are reduced. The model utilizes the principle of local correlation in images to extract features. For the use of the trained ResNet50 model, the number of nodes in the fully connected layers can be customized according to the number of classification categories. In each fully connected layer, each neuron is fully connected to the neuron in the previous layer. The fully connected layers integrate the class-discriminating local information from the convolutional and pooling layers. Then, a softmax function after the fully connected layers predicts the normalized probability of household waste in the image belonging to each category. The category with the highest probability value is the final category.

[0069] The formula for calculating the softmax function is:

[0070]

[0071] in, Indicates the number of categories. Indicates the first The probability of each category, y k This represents the probability value of the k-th class after normalization;

[0072] The softmax function after the fully connected layer outputs the normalized probability value of household waste belonging to each category. The category with the highest probability value is the result category corresponding to household waste.

[0073] Step S5 also includes optimizing the ResNet50 model parameters using the cross-entropy loss function and the Adam optimizer. The formula for calculating the cross-entropy loss function is as follows:

[0074]

[0075] in, Indicates the first The label values ​​for each category are generally encoded using one-hot encoding; This represents the loss function value calculated for all categories;

[0076] Cross-entropy represents the difference between the actual output and the expected output; the smaller the cross-entropy, the smaller the error. The Adam optimizer is an advanced version of the Momentum optimizer and the AdaGrad optimizer, and it can adaptively change the learning rate.

[0077] Example 2:

[0078] like Figure 2 As shown, waste identification boxes A and B overlap, with the overlapping portion being C. Assume the areas of waste identification boxes A, B, and the overlapping portion C are respectively... Calculate the ratio of the area of ​​the overlapping part C to the sum of the areas of the household waste identification frames A and B. ,when The area is directly cut according to the coordinate information of the household waste identification box A and the coordinate information of the household waste identification box B; when First, image 1 is obtained by segmenting the image according to the original coordinate information of the waste identification box A. Then, the image is segmented from the overlapping part to the non-overlapping part until no overlapping part is included. This process is repeated nine times to obtain images 2-10. Images 1-10 are then input into a trained ResNet50 model for recognition. If the recognition results of the ten images are the same, the waste identification box A is considered to be in the upper layer, and the recognition result is the waste classification result corresponding to the waste identification box A, which is directly output. If the recognition results of the ten images are two or more, the waste identification box A is considered to be in the lower layer, and the overlapping part is the part of the waste identification box A that is occluded. The overlapping part is filled with the image of the non-overlapping part, and then the image is segmented and recognized again according to the original coordinate information. The segmentation of waste identification box B is carried out in the same way.

[0079] Example 3:

[0080] The original household waste image after being cut in step S4 is input into the YOLOV5 model again. The remaining areas in the original household waste image after cutting are re-detected and cut to avoid missed detections.

[0081] Example 4:

[0082] The network architecture of the YoloV5 model used in this embodiment includes backbone, neck, and head;

[0083] Training strategies include:

[0084] Multi-scale training(0.5~1.5x), Multi-scale training, assuming the input image size is 640 \times 640640×640, the training size is randomly taken between 0.5 \times 640 \sim 1.5 \times 6400.5×640∼1.5×640, and note that the value is always an integer multiple of 32 (because the network will be maximally down-sampled by 32 times);

[0085] AutoAnchor(For training custom data), When training your own data set, you can generate a new anchor template by clustering the targets in your data set.

[0086] Warmup and Cosine LR scheduler, Warmup before training, then use Cosine learning rate decay strategy;

[0087] EMA(Exponential Moving Average), which can be understood as giving the training parameters a momentum to make the update process smoother;

[0088] Mixed precision, mixed precision training, can reduce the memory usage and speed up the training, the premise is that the GPU hardware supports;

[0089] Evolve hyper-parameters, hyper-parameter optimization.

[0090] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited to this, any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A garbage classification method based on YoloV5 and ResNet50, characterized in that, The method comprises the following steps: Step S1: Collecting household garbage pictures to make a household garbage dataset; Step S2: Performing data enhancement processing on the household garbage dataset; Step S3: Training a YoloV5 model, and using the trained YoloV5 model to obtain the region coordinates of multiple household garbage on a picture; Step S4: According to the region coordinate information, using the PIL library to cut the picture, cutting the picture containing multiple household garbage into multiple pictures containing single household garbage, if there is no overlap of the household garbage recognition box, directly cutting the picture; If there is overlap of the household garbage recognition box, according to the ratio of the area of the overlapping part to the sum of the areas of the household garbage recognition boxes, it is determined whether to directly cut or to cut and then fill the overlapping part with the image of the non-overlapping part; When the ratio of the area of the overlapping part to the sum of the areas of the household garbage recognition boxes is greater than a set value, the picture is cut according to the original region coordinate information, and the picture is cut from the overlapping part to the non-overlapping part in turn until the overlapping part is not included, and multiple pictures are obtained, and the ResNet50 model is used to identify the pictures; If the identification results of the multiple pictures appear two or more, the overlapping part is filled with the image of the non-overlapping part, and then the picture is cut and identified according to the original region coordinate information; Step S5: Training a ResNet50 model, and using the trained ResNet50 model to obtain the categories of multiple household garbage on a picture.

2. The garbage classification method based on YoloV5 and ResNet50 according to claim 1, characterized in that, The data enhancement processing in step S2 includes clockwise rotation, counterclockwise rotation, equal proportion scaling, and filling a pure color background.

3. The garbage classification method based on YoloV5 and ResNet50 according to claim 1, characterized in that, The specific process of step S3 comprises the following steps: Step S31: Training the YoloV5 model using the picture labeled with household garbage region coordinate information to obtain the trained YoloV5 model; Step S32: Inputting the processed household garbage picture into the YoloV5 model to obtain the region coordinate information of multiple household garbage on the household garbage picture.

4. The garbage classification method based on YoloV5 and ResNet50 according to claim 1, characterized in that, In step S4, the household garbage recognition box is determined according to the region coordinate information of the household garbage, and the picture containing multiple household garbage is cut into multiple pictures containing single household garbage using the PIL library.

5. The garbage classification method based on YoloV5 and ResNet50 according to claim 1 or 4, characterized in that, In step S4, the specific process of the picture cutting comprises: For the household garbage recognition box without overlapping part, the picture is directly cut according to the region coordinate information; For the household garbage recognition box with overlapping part, the cutting method is selected according to the ratio of the area of the overlapping part to the sum of the areas of the household garbage recognition boxes, which is as follows: When the ratio of the area of the overlapping part to the sum of the areas of the household garbage recognition boxes is less than a set value, the picture is directly cut according to the original region coordinate information; When the ratio of the area of the overlapping part to the sum of the areas of the household garbage recognition boxes is greater than a set value, the original region coordinate information is used to cut first; then the picture is cut from the overlapping part to the non-overlapping part in turn until no overlapping part is included, obtaining multiple pictures; then the ResNet50 model is used to identify the pictures, and if the identification results of the multiple pictures are the same, it is considered that the household garbage recognition box corresponding to the original region coordinate information is located in the upper layer, and the garbage category is directly output; otherwise, it is considered that the household garbage recognition box corresponding to the original region coordinate information is located in the lower layer, and the overlapping part is the part of the household garbage recognition box corresponding to the original region coordinate information that is blocked, then the image of the non-overlapping part is used to fill the overlapping part, and then the original region coordinate information is used for cutting and identification.

6. The garbage classification method based on YoloV5 and ResNet50 according to claim 1, characterized in that, The specific process of step S5 includes the following steps: Step S51: build a ResNet50 model based on a pytorch deep learning framework and train the ResNet50 model to obtain a trained ResNet50 model; Step S52: input the cut household garbage picture into the ResNet50 model to obtain the category information of the household garbage on the household garbage picture.

7. The garbage classification method based on YoloV5 and ResNet50 according to claim 6, characterized in that, The specific process of step S52 includes the following steps: Step S521: perform convolution operation on the household garbage picture through a convolution layer to extract picture feature information; Step S522: integrate the feature information with class distinction in the convolution layer and the pooling layer through a full connection layer; Step S523: output the normalized probability value of the household garbage belonging to each category through a softmax function after the full connection layer, and the category with the maximum probability value is the result category corresponding to the household garbage.

8. The garbage classification method based on YoloV5 and ResNet50 according to claim 7, characterized in that, The calculation formula of the softmax function in step S523 is: wherein, represents the number of classes, represents the probability of the th class, represents the normalized probability value of the th class.

9. The garbage classification method based on YoloV5 and ResNet50 according to claim 1, characterized in that, In step S5, the ResNet50 model parameters are also optimized using a cross-entropy loss function and an Adam optimizer, and the calculation formula of the cross-entropy loss function is: wherein, represents the label value of the first category, generally using one-hot encoding; represents the loss function value calculated for all categories, y k represents the probability value of the kth category after normalization.

10. The garbage classification method based on YoloV5 and ResNet50 according to claim 1, characterized in that, The method inputs the original household garbage picture cut in step S4 into the YoloV5 model again to re-detect and cut the remaining region of the original household garbage picture, avoiding missed detection.

Citation Information

Patent Citations

  • Restoration method for building shielding information in inclined remote sensing image

    CN113298808A