Garbage classification and identification method and system, electronic equipment and storage medium

The garbage picture collection is obtained through crawling technology, and the perceived hashing algorithm and YOLOV5 network structure optimization detection model are used to solve the problem of both recognition accuracy and efficiency in multi-category garbage recognition, achieving efficient and accurate garbage recognition.

CN119152275APending Publication Date: 2024-12-17江西源春环保科技有限公司

Patent Information

Application Number
CN202411372700.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

The existing computer vision recognition technology for garbage recognition has problems that the recognition accuracy and recognition efficiency cannot be taken into account in multiple categories of garbage recognition, and its applicability is poor.

Method used

The crawler technology is used to obtain a picture collection of multiple categories of domestic waste, deduplication is performed through perceived hashing algorithm and Labelimg annotation, and data enhancement is used using smooth labels, and the detection model is optimized by combining YOLOV5 network structure and K-mean algorithm.

Benefits of technology

It improves the accuracy and efficiency of garbage identification, enhances the robustness of the detection model, solves the problem of taking into account both recognition accuracy and efficiency, and improves applicability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119152275A_ABST
    Figure CN119152275A_ABST
Patent Text Reader

Abstract

The invention provides a garbage classification and identification method and system, electronic equipment and a storage medium, and belongs to the field of intelligent garbage identification. The method comprises the following steps: acquiring picture sets of different types of household garbage by adopting a crawler technology, carrying out duplicate removal processing on the picture sets through a perceptual hash algorithm, and carrying out category label processing on the picture sets subjected to duplicate removal processing by adopting a Labelimg labeling method to obtain a sample data set, carrying out data enhancement processing on the sample data set in a smooth label mode, training a detection model by using the enhanced sample data set and a minimization loss function, and introducing a K-means algorithm to carry out optimization processing on the detection model, and inputting a to-be-recognized target picture into the optimized detection model to recognize an object in the target picture in real time. According to the method and the device, the defects that an existing detection model cannot give consideration to both the recognition precision and the recognition efficiency in multi-category garbage recognition and is poor in applicability can be overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of intelligent garbage identification, and specifically relates to a garbage classification identification method, system, electronic equipment and storage medium. Background Art

[0002] As people's material production and life become more and more abundant, more and more waste is generated in industrial production and daily life, and the typical representative is domestic garbage. In the early days, most garbage was sorted manually, which had obvious disadvantages and required huge manpower and material resources, and the efficiency was greatly reduced. With the development of computer vision technology, machines are used instead of eyes to identify targets. Computer vision technology is applied to the field of garbage classification and identification mainly by using pattern recognition and image processing methods, obtaining candidate areas in the image through sliding windows, and then using classification algorithms to determine whether it is the required target or obtaining candidate areas based on the characteristics of the target object such as the texture, etc. This greatly improves work efficiency and meets the needs of garbage classification automation to a certain extent.

[0003] At present, garbage classification and recognition based on computer vision technology has effectively improved the traditional manual garbage sorting work mode. However, the existing computer vision garbage recognition technology generally has the following problems: 1. Public data sets for multiple categories of domestic garbage are relatively scarce, and the data obtained through crawling and shooting systems have high errors, so the current detection model is not suitable for the recognition of multiple categories of domestic garbage. 2. The model structure of the target detection model is complex, and its recognition accuracy and recognition efficiency cannot be achieved at the same time. If you want to ensure recognition accuracy, the recognition efficiency is low, and if you want to ensure recognition efficiency, the recognition accuracy is poor.

[0004] Therefore, how to improve the existing detection models in multi-category garbage identification, such as the inability to strike a balance between recognition accuracy and recognition efficiency, as well as poor applicability, is an issue that needs to be urgently addressed by those skilled in the art. Summary of the invention

[0005] In order to solve the above technical problems, the present invention provides a garbage classification and identification method, system, electronic device and storage medium.

[0006] In a first aspect, the invention provides a method for identifying garbage classification, comprising: Use crawler technology to obtain a collection of pictures of different categories of domestic waste; Deduplication processing is performed on the image set by using a perceptual hash algorithm; The deduplicated image set is processed with the Labelimg labeling method to obtain a sample data set; Performing data enhancement processing on the sample data set by means of smoothing labels; Using the enhanced sample data set, and training the detection model by minimizing the loss function; introducing the K-means algorithm to optimize the detection model; The target image to be identified is input into the optimized detection model to identify the object in the target image in real time.

[0007] Preferably, the step of using crawler technology to obtain picture sets of different categories of domestic waste specifically includes: Acquire the resource locator of each shooting point through the visual image acquisition system, and transfer the resource locator to the queue to be captured; Read the resource locators in sequence according to a first-in-first-out order; Resolving the resource locator using DNS resolution to obtain the IP address of the website; The IP address and the website relative path are combined to download web pages to obtain picture sets of different categories of domestic waste.

[0008] Preferably, the step of performing deduplication processing on the picture set by using the perceptual hash algorithm specifically includes: Performing grayscale processing on the picture set; Transforming the discrete cosine transform values ​​of the grayscale processed picture set to obtain a coefficient matrix; Downscaling the discrete cosine transform value until the lowest frequency of the image is presented to calculate a hash value corresponding to the change; According to the coefficient matrix and based on the setting rule of the hash value, a fingerprint corresponding to the picture set is formed; According to the fingerprint, and based on setting corresponding deduplication parameters, the picture set is deduplicated.

[0009] Preferably, the step of performing data enhancement processing on the sample data set by smoothing labels specifically includes: Convert the category labels corresponding to the sample data set into one-hot-vector labels; Adjust the one-hot-vector label based on a smooth label adjustment algorithm, wherein the adjustment algorithm is label=label×(1-smooth_factor)+smooth_factor×num_class; The sample data set is enhanced and processed according to the adjusted one-hot-vector label.

[0010] Preferably, the step of using the enhanced processed sample data set and training the detection model by minimizing the loss function specifically includes: A detection model is constructed based on the YOLOV5 network structure, wherein the detection model includes a Backbone module, a Neck module, a Head module, and a serial communication module connected in sequence; The enhanced sample data set is used to train the detection model through a loss function method, wherein the loss function method is specifically binary cross entropy and complete cross union.

[0011] Preferably, the Serial module obtains the identification information obtained by the head module from the output layer of the detection model, encodes the identification information into a decimal data frame, converts it into hexadecimal and outputs it to the serial port.

[0012] Preferably, the K-means algorithm is specifically as follows: randomly selecting several samples from the sample set as cluster centers, calculating the distances between all samples and several cluster centers, dividing each sample into the cluster with the cluster center closest to it, and calculating new cluster centers with new clusters.

[0013] In a second aspect, a garbage classification identification system includes: An acquisition module is used to acquire a collection of pictures of different categories of domestic waste using crawler technology; A deduplication module, used for performing deduplication processing on the picture set by using a perceptual hash algorithm; A labeling module, used to process the deduplicated image set by using the Labelimg labeling method to obtain a sample data set; An enhancement module, used for performing data enhancement processing on the sample data set by smoothing labels; A training module, used for training a detection model by using the enhanced processed sample data set and minimizing a loss function; The optimization module is used to introduce the K-means algorithm to optimize the detection model; The recognition module is used to input the target image to be recognized into the optimized detection model to recognize the object in the target image in real time.

[0014] Preferably, the acquisition module specifically includes: A collection unit, used for acquiring a resource locator of each shooting point through a visual image collection system, and transferring the resource locator to a queue to be captured; A reading unit, used for reading the resource locators in sequence according to a first-in-first-out order; A resolution unit, used to resolve the resource locator using a DNS resolution method to obtain an IP address of the website; The combining unit is used to combine the IP address and the website relative path to download the web page to obtain a picture set of different categories of domestic waste.

[0015] Preferably, the deduplication module specifically includes: A grayscale unit, used for performing grayscale processing on the picture set; A transformation unit, used for transforming the discrete cosine transform values ​​of the picture set after grayscale processing to obtain a coefficient matrix; A calculation unit, configured to reduce the discrete cosine transform value until the lowest frequency of the image is presented to calculate a hash value corresponding to the change; A forming unit, configured to form a fingerprint corresponding to the picture set according to the coefficient matrix and based on a setting rule of the hash value; A deduplication unit is used to perform deduplication processing on the picture set according to the fingerprint and based on setting corresponding deduplication parameters.

[0016] Preferably, the enhancement module specifically includes: A conversion unit, used to convert the category label corresponding to the sample data set into a one-hot-vector label; An adjustment unit, configured to adjust the one-hot-vector label based on an adjustment algorithm for a smooth label, wherein the adjustment algorithm is label=label×(1-smooth_factor)+smooth_factor×num_class; The enhancement unit is used to enhance the sample data set according to the adjusted one-hot-vector label.

[0017] Preferably, the training module specifically includes: A construction unit, used to construct a detection model based on the YOLOV5 network structure, wherein the detection model includes a Backbone module, a Neck module, a Head module and a serial communication module connected in sequence; A training unit is used to train the detection model using the enhanced sample data set through a loss function method, wherein the loss function method is specifically binary cross entropy and complete cross union.

[0018] Preferably, the Serial module obtains the identification information obtained by the head module from the output layer of the detection model, encodes the identification information into a decimal data frame, converts it into hexadecimal and outputs it to the serial port.

[0019] Preferably, the K-means algorithm is specifically as follows: randomly selecting several samples from the sample set as cluster centers, calculating the distances between all samples and several cluster centers, dividing each sample into the cluster with the cluster center closest to it, and calculating new cluster centers with new clusters.

[0020] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the garbage classification identification method as described in the first aspect is implemented.

[0021] In a fourth aspect, the present application provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the garbage classification and identification method as described in the first aspect.

[0022] Compared with the prior art, the present invention has the following beneficial effects: 1. Using crawler technology to obtain data sets on the background of the shooting system's web page can save a lot of time. Automatic data acquisition can also avoid human errors and obtain more effective data.

[0023] 2. The perceptual hashing algorithm is used to extract the features of the garbage data set, and the discrete cosine transform signal processing method is adopted to eliminate the perceptual redundancy in the garbage image, more accurately capture the perceptual feature parameters of the data, and ensure the effectiveness of the perceptual hashing algorithm.

[0024] 3. For multi-classified domestic waste, the category labels are converted into one-hot-vector labels, and the one-hot-vector labels are adjusted using label smoothing, which can make the prediction results of the detection model continuously tend to be true, thereby improving the robustness of the detection model.

[0025] 4. Using the YOLOv5 network structure to build a detection model and training it through the minimum loss function can effectively solve the problem of less junk data sets and has good accuracy and efficiency.

[0026] 5. By optimizing the detection model through the K-means algorithm, the recognition accuracy of the image can be further improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0028] Figure 1 A flowchart of a garbage classification and identification method provided in Embodiment 1 of the present invention; Figure 2 is a structural block diagram of a garbage classification identification system corresponding to the method of embodiment 1 and provided in embodiment 2 of the present invention; Figure 3It is a schematic diagram of the hardware structure of the computer provided in Example 3 of the present invention.

[0029] Description of reference numerals: 10-acquisition module, 11-collection unit, 12-reading unit, 13-analysis unit, 14-combination unit; 20-de-duplication module, 21-grayscale unit, 22-transformation unit, 23-calculation unit, 24-composition unit, 25-de-duplication unit; 30- Annotation module; 40-enhancement module, 41-conversion unit, 42-adjustment unit, 43-enhancement unit; 50-training module, 51-construction unit, 52-training unit; 60-Optimization module; 70- identification module; 80 - bus, 81 - processor, 82 - memory, 83 - communication interface. DETAILED DESCRIPTION

[0030] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more comprehensive and complete and will fully convey the concept of the example embodiments to those skilled in the art.

[0031] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring the various aspects of the present disclosure.

[0032] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0033] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0034] Example 1 Specifically, Figure 1 The figure is a schematic flow chart of the garbage classification and identification method provided in this embodiment.

[0035] like Figure 1 As shown, the garbage classification identification method of this embodiment includes the following steps: S101,uses crawler technology to obtain a collection of images of different categories of domestic waste.

[0036] Specifically, after the machine vision image acquisition system is running, the acquisition system can be managed as a whole by a computer. Since there are many shooting points, manually clicking on each shooting point one by one to intercept data will waste a lot of time. This embodiment uses crawler technology to obtain data sets in the background of the web page of the visual acquisition system, which can save a lot of time, and automatically obtaining data can also avoid manual errors and obtain more effective data.

[0037] Furthermore, the specific steps of step S101 include: S1011, obtaining the resource locator of each shooting point through the visual image acquisition system, and transferring the resource locator to the queue to be captured.

[0038] Specifically, a resource locator (URL) is a concise representation of the location and access method of a resource that can be obtained from the Internet. It is the address of a standard resource on the Internet. Each file on the Internet has a unique URL, which contains information indicating the location of the file and how the browser should handle it. Among them, the URL consists of two main parts: the protocol and the destination. The "protocol" tells us what type of Internet resource we are facing; the "destination" can be a file name, directory name, or the name of a computer.

[0039] S1012, reading the resource locators in sequence according to a first-in-first-out order.

[0040] Specifically, in order to avoid repeated crawling of the same web page, this embodiment will establish a web page library to store the URLs of web pages that have been crawled. For the web page that has just been processed, the web page link is extracted from it and matched with the one in the queue. If it has not been crawled, it is placed in the waiting queue until there is no URL in the queue. S1013, using DNS resolution to resolve the resource locator to obtain the IP address of the website.

[0041] Specifically, as is known to all, an IP address is the only logical address of a computer on the Internet. The IP address enables mutual communication between different computers, and each networked computer needs to be connected and distinguished through the IP address. However, since the IP address is composed of a string of easily confused numbers, a more recognizable symbolic identifier is used on the basis of the IP address. This identifier is composed of letters and numbers selected by people themselves, which is easier to recognize and remember than the IP address. It gradually replaces the IP address and becomes the main entrance for Internet users to access the Internet. This symbolic identifier is the domain name. Although the domain name is easier to be accepted and used by users, computers can only recognize IP addresses composed of pure numbers and cannot directly read the domain name; therefore, in order to achieve the access effect, the domain name needs to be translated into an IP address, and DNS resolution is responsible for this translation effect.

[0042] S1014, combining the IP address and the website relative path to download a web page to obtain a picture set of different categories of domestic waste.

[0043] Specifically, this embodiment uses Python 3.7 to write scripts for web crawler technology, which makes it easier to process web pages after crawling, and can filter out unnecessary information and directly obtain useful information. Python 3.7 is also suitable for personalized crawler development for different websites, and has high development efficiency. In addition, Python 3.7 also has mature and powerful crawler framework support, which is easy to operate.

[0044] S102, performing deduplication processing on the picture set by using a perceptual hash algorithm.

[0045] Specifically, the images captured by crawler technology are repetitive and some images are blurry, which are not suitable for model training. In addition, image information has the advantages of high dimensionality and rich information types compared to other information, so preprocessing junk images is an indispensable means. This embodiment specifically uses perceptual hash deduplication technology to deduplicate data, uses perceptual hash algorithm to extract features of junk data sets, and uses discrete cosine transform signal processing methods to eliminate perceptual redundancy in junk images, more accurately capture perceptual feature parameters of data, and ensure the effectiveness of perceptual hash algorithm.

[0046] Furthermore, the specific steps of step S102 include: S1021, grayscale processing is performed on the picture set.

[0047] Specifically, in this embodiment, the junk images in the image set are reduced in size and the colors of the junk images are simplified, and the images are converted into grayscale images in order to reduce the amount of calculation. In practice, in the process of image acquisition, transmission, and processing, it is inevitable to be affected by various factors. If the signal-to-noise ratio of the image is particularly low, it will affect the pixel value of the image, which will seriously affect the subsequent image processing work. Therefore, before the image processing, the image is first preprocessed. The specific grayscale of a color image refers to converting the RGB three-channel data into a single-channel data image, and the image is converted from color to gray. The purpose is to reduce the processing cost as much as possible and reduce the amount of algorithm calculation. Improving real-time performance is an important performance requirement of the image processing algorithm.

[0048] S1022, transform the discrete cosine transform values ​​of the picture set after grayscale processing to obtain a coefficient matrix.

[0049] Specifically, the purpose of preprocessing junk images is to remove information that is irrelevant to the original data and improve the accuracy of subsequent perceptual hash feature extraction. This embodiment uses a perceptual hash algorithm to extract features of a junk data set, and adopts a discrete cosine transform change signal processing method to eliminate perceptual redundancy in junk images, more accurately capture perceptual feature parameters of data, and ensure the effectiveness of the perceptual hash algorithm. The calculation of the discrete cosine transform is to decompose the image into frequency clusters and ladder shapes.

[0050] S1023, reducing the discrete cosine transform value until the lowest frequency of the image is presented to calculate a corresponding changed hash value.

[0051] Specifically, reducing the discrete cosine transform value in this embodiment is to reduce the length of the perceptual hash sequence, quantize and encode the extracted effective feature parameters, and finally generate the perceptual hash value.

[0052] S1024: construct a fingerprint corresponding to the picture set according to the coefficient matrix and based on a setting rule of the hash value.

[0053] Specifically, the perceptual hash algorithm generates a "fingerprint" string for each image, and then compares the fingerprints of different images. The closer the results are, the more similar the images are. The rules set in this embodiment are as follows: a 64-bit hash value of 0 or 1 is set, and a value greater than or equal to the discrete cosine transform mean is set to 1, and a value less than the discrete cosine transform value is set to 0. The combination of these constitutes the fingerprint of the junk image.

[0054] S1025: Deduplication processing is performed on the picture set according to the fingerprint and by setting corresponding deduplication parameters.

[0055] Specifically, when comparing different images, if the number of identical data bits exceeds 59 (which is greater than 0.92 in terms of ratio), it means that the two images are very similar; if it is less than 54 (which is less than 0.84 in terms of ratio), it means that these are two different images.

[0056] S103, performing category label processing on the deduplicated picture set using a Labelimg labeling method to obtain a sample data set.

[0057] Specifically, this embodiment uses the Labelimg annotation tool to perform target label annotation, and the Labelimg annotation method is the most common target contour annotation method. It is a visual drawing target calibration method written in Python programming statements and uses Qt as its standard graphical interface. According to the type information and position coordinate information captured by the label, it will eventually be saved in the generated XML file, as shown below: <annotation> <folder> JPEGimages< / folder> <filename> 1879.jpg< / filename> <path> D:\DesktopUPEGlmages\1879.jpg< / path> <source> <database> Unknown< / database> <size> <width> 3000< / width> <height> 4000< / height> <depth> 3< / depth> < / size> <segmented> 0< / segmented> <object> <name> paper_cup< / name> <pose> Unspecified< / pose> <truncated> 0< / truncated> <difficult> 0< / difficult> <bndbox> <xmin> 388< / xmin> <ymin> 1050< / ymin> <xmax> 1988< / xmax> <ymax> 2491< / ymax> < / bndbox> < / object> < / annotation> .

[0058] S104: performing data enhancement processing on the sample data set by smoothing labels.

[0059] Specifically, data enhancement is performed on the sample data set before training the detection model. Usually, data enhancement methods use flipping, offsetting, random rotation, random erasing, etc.; flipping, offsetting, and random rotation methods expand the data set exponentially by flipping the original image horizontally and vertically and rotating it by a certain angle; random erasing randomly selects rectangular areas in the training image during training, and uses random values ​​to erase its pixels to generate noise with occlusion levels, which can reduce the overfitting of the model during training. In order to solve the problem of overfitting of the detection model to the training set, this embodiment uses a smooth label method for data enhancement, so that the prediction results of the detection model continue to tend towards the true label.

[0060] Furthermore, the specific steps of step S104 include: S1041, converting the category labels corresponding to the sample data set into one-hot-vector labels.

[0061] Specifically, one-hot-vector is a unique hot code, which mainly uses an N-bit state register to encode N states. Each state has its own independent register bit, and only one bit is valid at any time. In the classification machine learning algorithm, the calculation of the distance or similarity between features is very important, and the commonly used distance or similarity calculations are similarity calculations in Euclidean space. The calculation of cosine similarity is based on Euclidean space. This embodiment converts the category label into a one-hot-vector label, with the aim of improving the recognition accuracy of the detection model.

[0062] S1042: Adjust the one-hot-vector label based on a smooth label adjustment algorithm.

[0063] Specifically, although this embodiment adopts the smooth label method to solve the problem of overfitting of the detection model to the training set, this method cannot guarantee the generalization ability of the detection model. At the same time, excessive trust in the label and the wrong label in the sample data set will have a greater impact on the detection model. This embodiment adjusts the one-hot-vector label through the following adjustment formula, thereby improving the robustness of the detection model; label=label×(1-smooth_factor)+smooth_factor×num_class; Where: The value of the smoothing label parameter smooth_factor is set to 0.9.

[0064] S1043, enhancing the sample data set according to the adjusted one-hot-vector label.

[0065] Specifically, the values ​​of discrete features are extended to the Euclidean space, and a certain value of the discrete feature corresponds to a certain point in the Euclidean space. This embodiment makes the distance calculation between features more reasonable by using adjusted unique hot codes for discrete features, thereby achieving the purpose of enhancing the sample data set.

[0066] S105, using the enhanced sample data set and training a detection model by minimizing a loss function.

[0067] Specifically, this embodiment uses the YOLOv5 network feature extraction detection model and the transfer learning garbage identification method to effectively solve the problem of small sample data sets. The detection model built based on the YOLOv5 network includes a Backbone module, a Neck module, a Head module and a serial communication module connected in sequence. The model is trained and tested on the sample data set after data enhancement, and the average recognition accuracy reaches 99%.

[0068] Furthermore, the specific steps of step S105 include: S1051: Build a detection model based on the YOLOV5 network structure.

[0069] Specifically, the YOLOv5 network of the efficient deep learning algorithm has strong real-time performance and accuracy, and is widely used in target detection and image recognition and other fields. In this embodiment, the detection model of this embodiment includes a Backbone module, a Neck module, a Head module and a serial communication module connected in sequence. The Backbone module is based on the Darknet53 network and applies the CSP strategy to reduce the number of parameters of the model and enhance the efficiency of feature extraction. The Neck module adopts fast spatial pyramid pooling and an improved path aggregation network; fast spatial pyramid pooling aggregates the input information and has a fixed output length without reducing the network speed; the improved path aggregation network introduces BottleNeckCSP in its structure to further optimize the information flow and contribute to accurate pixel-level positioning. It includes three convolutional layers for predicting bounding box positions, scores, and object categories.

[0070] Among them, the detection model is improved on the basis of the YOLOv5 network, including replacing the Focus layer to reduce parameters and calculations, and eliminating grid sensitivity problems to improve bounding box detection capabilities.

[0071] Among them, the detection model adds a serial communication module in the output layer. The serial communication module is designed to send information to the serial port of the hardware device running the model to achieve the purpose of sending the classification results to the main control. First, the serial communication module obtains the identification information obtained by the Head module from the output layer of the detection model, and encodes the identification information into a decimal data frame, converts it to hexadecimal and outputs it to the serial port. It should be noted that the structure of the data frame specifically includes: start bit, data payload, calibration bit, and end bit.

[0072] S1052, training the detection model with the enhanced sample data set through a loss function method.

[0073] Specifically, the loss function plays a vital role in machine learning and deep learning. It is a function that evaluates the degree of difference between the model prediction output and the true label. The loss function quantifies the degree of model prediction error and serves as an optimization target during the training process. The model continuously adjusts internal parameters to minimize the value of the loss function, thereby achieving better fitting data and generalization capabilities. The loss functions used in this embodiment are specifically binary cross entropy and complete cross union. By adopting binary cross entropy and complete cross union loss calculation methods, which are used to calculate the loss and position loss of detection categories and objects respectively, the accuracy and efficiency of the detection model in identifying domestic waste can be effectively improved.

[0074] S106, introducing the K-means algorithm to optimize the detection model.

[0075] Specifically, the K in the K-means algorithm (K-means algorithm) represents clustering into K clusters, and means represents the mean of the data objects in the cluster. The algorithm is roughly as follows: randomly select several samples from the sample set as cluster centers, and calculate the distances between all samples and several cluster centers, divide each sample into the cluster with the closest cluster center, and calculate the new cluster center with the new cluster. In this embodiment, for a given sample data set, the sample data set is divided into K clusters according to the distance between the sample data sets, so that the points in the cluster are as closely connected as possible, and the distance between clusters is as large as possible; the distance metric uses the Euclidean distance to calculate the distance between data objects.

[0076] S107, inputting the target image to be identified into the optimized detection model to identify the object in the target image in real time.

[0077] Specifically, after optimization, the detection model of this embodiment takes into account both recognition efficiency and recognition accuracy. By inputting the target image to be identified into the detection model, real-time and accurate identification of garbage classification in the target image can be achieved.

[0078] To sum up: this embodiment uses crawler technology to capture data on junk images, and performs preprocessing operations such as deduplication, labeling and enhancement on the data, thereby enhancing the effectiveness of the sample data set and saving the time for producing the sample data set. The produced sample data set is conducive to the training and optimization of the detection model, so that the detection model takes into account both recognition efficiency and accuracy, and effectively improves the shortcomings of the existing detection model in multi-category junk identification, such as the inability to balance recognition accuracy and recognition efficiency, and poor applicability.

[0079] Example 2 This embodiment provides a structural block diagram of a system corresponding to the method described in Embodiment 1. Figure 3 is a structural block diagram of the garbage classification identification system according to this embodiment. Figure 3 As shown, the system includes: The acquisition module 10 is used to acquire picture sets of different categories of domestic waste using crawler technology.

[0080] The deduplication module 20 is used to perform deduplication processing on the picture set by using a perceptual hash algorithm.

[0081] The labeling module 30 is used to process the deduplicated picture set by using a Labelimg labeling method to perform category labeling to obtain a sample data set.

[0082] The enhancement module 40 is used to perform data enhancement processing on the sample data set by smoothing labels.

[0083] The training module 50 is used to use the enhanced sample data set to train the detection model by minimizing the loss function.

[0084] The optimization module 60 is used to introduce the K-means algorithm to optimize the detection model; wherein the K-means algorithm specifically randomly selects several samples from the sample set as cluster centers, calculates the distances between all samples and several cluster centers, divides each sample into the cluster where the cluster center closest to it is located, and calculates a new cluster center with the new cluster.

[0085] The recognition module 70 is used to input the target image to be recognized into the optimized detection model to recognize the object in the target image in real time.

[0086] Furthermore, the acquisition module 10 specifically includes: The acquisition unit 11 is used to acquire the resource locator of each shooting point through the visual image acquisition system, and transfer the resource locator to the queue to be captured.

[0087] The reading unit 12 is used to read the resource locators in sequence according to a first-in-first-out order.

[0088] The parsing unit 13 is used to parse the resource locator by using the DNS parsing method to obtain the IP address of the website.

[0089] The combining unit 14 is used to combine the IP address and the website relative path to download the web page to obtain a picture set of different categories of domestic waste.

[0090] Furthermore, the deduplication module 20 specifically includes: The grayscale unit 21 is used to perform grayscale processing on the picture set.

[0091] The transformation unit 22 is used to transform the discrete cosine transform values ​​of the picture set after grayscale processing to obtain a coefficient matrix.

[0092] The calculation unit 23 is used to reduce the discrete cosine transform value until the lowest frequency of the image is presented to calculate the corresponding changed hash value.

[0093] The forming unit 24 is used to form a fingerprint corresponding to the picture set according to the coefficient matrix and based on the setting rule of the hash value.

[0094] The deduplication unit 25 is used to perform deduplication processing on the picture set according to the fingerprint and based on setting corresponding deduplication parameters.

[0095] Furthermore, the enhancement module 40 specifically includes: The conversion unit 41 is used to convert the category label corresponding to the sample data set into a one-hot-vector label.

[0096] The adjustment unit 42 is used to adjust the one-hot-vector label based on an adjustment algorithm for a smooth label, wherein the adjustment algorithm is label=label×(1-smooth_factor)+smooth_factor×num_class.

[0097] The enhancement unit 43 is used to enhance the sample data set according to the adjusted one-hot-vector label.

[0098] Furthermore, the training module 50 specifically includes: The construction unit 51 is used to construct a detection model based on the YOLOV5 network structure, wherein the detection model includes a Backbone module, a Neck module, a Head module and a serial communication module connected in sequence; wherein the Serial module obtains the identification information obtained by the head module from the output layer of the detection model, and encodes the identification information into a decimal data frame, converts it into hexadecimal and then outputs it to the serial port.

[0099] The training unit 52 is used to train the detection model using the enhanced sample data set through a loss function method, wherein the loss function method is specifically binary cross entropy and complete cross union.

[0100] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0101] Example 3 Combination Figure 1 The described garbage classification identification method can be implemented by a computer. Figure 3 Schematic diagram of the hardware structure of a computer according to this embodiment.

[0102] The computer may include a processor 81 and a memory 82 storing computer program instructions.

[0103] Specifically, the processor 81 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the present application.

[0104] Among them, the memory 82 may include a large-capacity memory for data or instructions. For example, but not limitation, the memory 82 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 82 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 82 may be inside or outside the data processing device. In a specific embodiment, the memory 82 is a non-volatile memory. In a specific embodiment, the memory 82 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable Programmable Read-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable Programmable Read-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (Static Random-Access Memory, referred to as SRAM) or a dynamic random access memory (Dynamic Random Access Memory, referred to as DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (Fast Page Mode Dynamic Random Access Memory, referred to as FPMDRAM), an extended data output dynamic random access memory (Extended Date Out Dynamic Random Access Memory, referred to as EDODRAM), a synchronous dynamic random access memory (Synchronous Dynamic Random-Access Memory, referred to as SDRAM), etc.

[0105] The memory 82 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 81 .

[0106] The processor 81 implements the garbage classification identification method of the above-mentioned embodiment 1 by reading and executing the computer program instructions stored in the memory 82.

[0107] In some embodiments, the computer may further include a communication interface 83 and a bus 80. Figure 3 As shown, the processor 81, the memory 82, and the communication interface 83 are connected via a bus 80 and communicate with each other.

[0108] The communication interface 83 is used to realize the communication between the modules, devices, units and / or equipment in the present application. The communication interface 83 can also realize data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage and image / data processing workstations.

[0109] The bus 80 includes hardware, software or both, and couples the components of the computer to each other. The bus 80 includes, but is not limited to, at least one of the following: a data bus (DataBus), an address bus (AddressBus), a control bus (ControlBus), an expansion bus (ExpansionBus), and a local bus (LocalBus). By way of example and not limitation, the bus 80 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB) bus, a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, or a 100% Ethernet bus. Bus 80 may include one or more buses, memory bus, Micro Channel Architecture (MCA) bus, Peripheral Component Interconnect (PCI) bus, PCI-Express (PCI-X) bus, Serial Advanced Technology Attachment (SATA) bus, Video Electronics Standards Association Local Bus (VLB) bus or other suitable buses or a combination of two or more of these. Where appropriate, bus 80 may include one or more buses. Although the present application describes and illustrates a specific bus, the present application contemplates any suitable bus or interconnect.

[0110] The computer can obtain the garbage classification identification system and execute the garbage classification identification method of Example 1.

[0111] In addition, in combination with the garbage classification identification method in the above embodiment 1, the present application can provide a storage medium for implementation. The storage medium stores computer program instructions; when the computer program instructions are executed by a processor, the garbage classification identification method in the above embodiment 1 is implemented.

[0112] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0113] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for identifying garbage classification, It is characterized in that include: Use crawler technology to obtain a collection of pictures of different categories of domestic waste; Deduplication processing is performed on the image set by using a perceptual hash algorithm; The deduplicated image set is processed with the Labelimg labeling method to obtain a sample data set; Performing data enhancement processing on the sample data set by means of smoothing labels; Using the enhanced processed sample data set, and training the detection model by minimizing the loss function; The K-means algorithm is introduced to optimize the detection model; The target image to be identified is input into the optimized detection model to identify the object in the target image in real time.

2. The garbage classification identification method according to claim 1, It is characterized in that The steps of using crawler technology to obtain picture sets of different categories of domestic waste specifically include: Acquire the resource locator of each shooting point through the visual image acquisition system, and transfer the resource locator to the queue to be captured; Read the resource locators in sequence according to a first-in-first-out order; Resolving the resource locator using DNS resolution to obtain the IP address of the website; The IP address and the website relative path are combined to download web pages to obtain picture sets of different categories of domestic waste.

3. The garbage classification identification method according to claim 1, It is characterized in that The step of performing deduplication processing on the picture set by using the perceptual hash algorithm specifically includes: Performing grayscale processing on the picture set; Transforming the discrete cosine transform values ​​of the grayscale processed picture set to obtain a coefficient matrix; Downscaling the discrete cosine transform value until the lowest frequency of the image is presented to calculate a hash value corresponding to the change; According to the coefficient matrix and based on the setting rule of the hash value, a fingerprint corresponding to the picture set is formed; According to the fingerprint, and based on setting corresponding deduplication parameters, the picture set is deduplicated.

4. The garbage classification identification method according to claim 1, It is characterized in that The step of performing data enhancement processing on the sample data set by smoothing labels specifically includes: Convert the category labels corresponding to the sample data set into one-hot-vector labels; Adjust the one-hot-vector label based on a smooth label adjustment algorithm, wherein the adjustment algorithm is label=label×(1-smooth_factor)+smooth_factor×num_class; The sample data set is enhanced and processed according to the adjusted one-hot-vector label.

5. The garbage classification identification method according to claim 1, It is characterized in that The step of using the enhanced processed sample data set and training the detection model by minimizing the loss function specifically includes: A detection model is constructed based on the YOLOV5 network structure, wherein the detection model includes a Backbone module, a Neck module, a Head module, and a serial communication module connected in sequence; The enhanced sample data set is used to train the detection model through a loss function method, wherein the loss function method is specifically binary cross entropy and complete cross union.

6. The garbage classification identification method according to claim 5, It is characterized in that The Serial module obtains the identification information obtained by the head module from the output layer of the detection model, encodes the identification information into a decimal data frame, converts it into hexadecimal, and then outputs it to the serial port.

7. The garbage classification identification method according to claim 1, It is characterized in that The K-means algorithm is specifically as follows: randomly select several samples from the sample set as cluster centers, calculate the distances between all samples and several cluster centers, divide each sample into the cluster where the cluster center closest to it is located, and calculate new cluster centers with new clusters.

8. A garbage classification and identification system, It is characterized in that include: An acquisition module is used to acquire a collection of pictures of different categories of domestic waste using crawler technology; A deduplication module, used for performing deduplication processing on the picture set by using a perceptual hash algorithm; A labeling module, used to process the deduplicated image set by using the Labelimg labeling method to obtain a sample data set; An enhancement module, used for performing data enhancement processing on the sample data set by smoothing labels; A training module, used for training a detection model by using the enhanced processed sample data set and minimizing a loss function; The optimization module is used to introduce the K-means algorithm to optimize the detection model; The recognition module is used to input the target image to be recognized into the optimized detection model to recognize the object in the target image in real time.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the garbage classification and identification method according to any one of claims 1 to 7 is implemented.

10. A storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the garbage classification and identification method as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Video character recognition method and device based on key frame extraction

    CN112507842A

  • Garbage image classification method and system

    CN116630604A

Cited By

  • Data acquisition system of robot

    CN120245000A