Garbage detection and classification method and device based on improved SE-ResNet and storage medium
By improving the SE-ResNet network model, adding dual local feature processing units and bicubic interpolation preprocessing, and combining standardized dataset partitioning and optimized training strategies, the problems of insufficient global features and low training efficiency in existing garbage detection and classification technologies are solved, achieving efficient and stable garbage image classification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUILIN UNIV OF AEROSPACE TECH
- Filing Date
- 2026-01-22
- Publication Date
- 2026-05-01
AI Technical Summary
Existing garbage detection and classification technologies based on SE-ResNet suffer from problems such as insufficient global feature extraction capabilities, lack of specificity in local features, loss of detailed features due to preprocessing, interference from background noise, and low training efficiency, making it difficult to achieve efficient and stable garbage classification.
An improved SE-ResNet network model is adopted. By adding dual local feature processing units, combining bicubic interpolation preprocessing and standardized dataset partitioning, a multi-scale feature extraction structure is constructed. The model is trained using cross-entropy loss and Adam optimizer, and hyperparameter strategies are set to improve model stability and accuracy.
It achieves efficient and accurate classification of garbage images, improves the model's classification accuracy and generalization ability, and forms a complete closed loop from data input to result output, ensuring the consistency and feasibility of the technical solution.
Smart Images

Figure CN121962748A_ABST
Abstract
Description
A waste detection and classification method, device, and storage medium based on an improved SE-ResNet Technical Field
[0001] This invention mainly relates to the field of waste sorting technology, specifically to a waste detection and sorting method, device, and storage medium based on an improved SE-ResNet. Background Technology
[0002] With the acceleration of urbanization and the improvement of residents' living standards, the amount of household waste generated continues to increase. As a key link in resource recycling and environmental protection, waste sorting is becoming increasingly important. Traditional household waste treatment relies heavily on manual sorting, which suffers from problems such as low efficiency, high cost, limited sorting accuracy, and susceptibility to subjective factors. Moreover, it is difficult to adapt to the needs of large-scale and multi-category waste treatment and cannot meet the development requirements of current environmental protection policies and resource recycling.
[0003] To address the drawbacks of manual sorting, waste detection and classification technologies based on computer vision and deep learning have gradually become a research hotspot. Existing technologies include schemes using deep learning network models such as ResNet and SE-ResNet for waste image classification. Among them, SE-ResNet, by introducing the Squeeze-and-Excitation Module (SE module) to recalibrate the feature channel weights, improves the model's focus on key features, demonstrating certain advantages in image classification tasks.
[0004] However, existing waste detection and classification schemes based on SE-ResNet still have significant shortcomings: First, the original SE-ResNet relies solely on global feature extraction units to capture global image information, lacking the ability to specifically extract local features. Household waste is characterized by diverse shapes, large size variations, and complex local details, making it difficult for a single global feature to accurately distinguish different categories of waste, thus limiting classification accuracy. Second, existing schemes often use simple interpolation and scaling methods for preprocessing waste images, which easily leads to the loss of local details, affecting the subsequent model feature learning effect. Third, some schemes do not fully incorporate the location information of the waste target, making the model training process susceptible to background noise interference, further reducing classification accuracy and generalization ability. Fourth, the lack of standardized configuration for training hyperparameter settings results in low model training efficiency and unstable convergence, making it difficult to deploy efficiently in real-world scenarios.
[0005] Therefore, there is an urgent need for an efficient and stable waste detection and sorting technology to help upgrade the automation of waste sorting. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to provide a waste detection and classification method, device and storage medium based on an improved SE-ResNet, which addresses the shortcomings of the prior art.
[0007] The technical solution of this invention to solve the above-mentioned technical problems is as follows: A garbage detection and classification method based on an improved SE-ResNet, comprising the following steps: acquiring garbage images from multiple sources, and labeling the garbage images from each source with garbage types; performing bicubic interpolation on each labeled garbage image to obtain each target garbage image, and dividing all target garbage images into a training set and a test set according to a set ratio; adding a dual local feature processing unit for extracting fine-grained and coarse-grained local features of the image to the global feature extraction unit of the SE-ResNet network model, thereby constructing an improved SE-ResNet network model; training the improved SE-ResNet network model based on the training set to obtain a trained improved SE-ResNet network model; inputting the test set into the trained improved SE-ResNet network model, and outputting the garbage classification result.
[0008] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: A waste detection and classification device based on an improved SE-ResNet, comprising: a waste image annotation module, used to collect waste images from multiple sources and perform waste type annotation processing on the waste images from various sources; a waste image preprocessing module, used to perform bicubic interpolation processing on each annotated waste image to obtain each target waste image, and divide all target waste images into a training set and a test set according to a set ratio; a model building module, used to add a dual local feature processing unit for extracting fine-grained and coarse-grained local features of the image on the basis of the global feature extraction unit of the SE-ResNet network model, to form an improved SE-ResNet network model; a model training module, used to train the improved SE-ResNet network model based on the training set to obtain the trained improved SE-ResNet network model; and a waste category output module, used to input the test set into the trained improved SE-ResNet network model and output the waste classification result.
[0009] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a garbage detection and classification device based on improved SE-ResNet, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the garbage detection and classification method based on improved SE-ResNet as described above.
[0010] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the garbage detection and classification method based on the improved SE-ResNet as described above.
[0011] The beneficial effects of this invention are as follows: by collecting and labeling data, preprocessing and partitioning data, improving the model, training the model, and outputting the classification data, an integrated technical framework of "detection + classification" is constructed. With the improved SE-ResNet as the core model, the problem of functional fragmentation in traditional solutions is solved, forming a complete closed loop from data input to result output. The direction of model improvement is clarified, and a clear and feasible architectural support is provided for the detailed optimization of subsequent stages, ensuring the coherence and feasibility of the overall technical solution. Attached Figure Description
[0012] Figure 1 is a flowchart of the waste detection and classification method provided in an embodiment of the present invention; Figure 2 is a schematic diagram of the structure of the improved SE-ResNet network model provided in an embodiment of the present invention; Figure 3 is a feature size variation diagram provided in an embodiment of the present invention; Figure 4 is a block diagram of the waste detection and classification device provided in an embodiment of the present invention. Detailed Implementation
[0013] The principles and features of the present invention are described below with reference to the accompanying drawings. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.
[0014] Example 1: As shown in Figure 1, this embodiment of the invention provides a waste detection and classification method based on an improved SE-ResNet, including the following steps: S1, collecting waste images from multiple sources and labeling the waste images from each source; S2, performing bicubic interpolation on each labeled waste image to obtain each target waste image, and dividing all target waste images into a training set and a test set according to a set ratio; S3, adding a dual local feature processing unit for extracting fine-grained and coarse-grained local features of the image to the global feature extraction unit of the SE-ResNet network model, thus forming an improved SE-ResNet network model; S4, training the improved SE-ResNet network model based on the training set to obtain the trained improved SE-ResNet network model; S5, inputting the test set into the trained improved SE-ResNet network model and outputting the waste classification result.
[0015] In the above embodiments, an integrated "detection + classification" technical framework is constructed through processes such as data collection and annotation, preprocessing and partitioning, model improvement, model training, and classification output. With the improved SE-ResNet as the core model, the problem of functional fragmentation in traditional solutions is solved, forming a complete closed loop from data input to result output. The direction of model improvement is clarified, providing clear and feasible architectural support for the detailed optimization of subsequent stages, and ensuring the coherence and feasibility of the overall technical solution.
[0016] Preferably, S1 involves collecting garbage images from multiple sources and performing garbage type labeling on the garbage images from each source, including: collecting multiple garbage images from multiple specified garbage source points; classifying the multiple garbage images from each source into multiple garbage types based on specified standards; obtaining each garbage image and its corresponding category name and category number; determining the target bounding box coordinates in each garbage image used to locate the garbage target in the image; generating a corresponding text-formatted label file for each garbage image based on the category number and target bounding box coordinates; the corresponding label file includes the category number and target bounding box coordinates; generating a JSON category mapping table based on the category name and category number; and finally saving the garbage images in the format of garbage images, corresponding label files, and category mapping tables to complete the garbage type labeling and obtain the labeled garbage images.
[0017] Specifically, 1.1 Data collection and integration from three sources ensures the diversity and representativeness of the dataset: Open source dataset: Huawei's open source dataset of 4 major categories and 40 subcategories of household waste, containing 14,795 training images and 800 test images, with data quality initially verified; Web crawling data: Images related to household waste were obtained through web crawling, and low-quality images such as blurry, severely occluded, and unclear category labels were filtered out, ultimately retaining 6,000 high-quality images; Real-world scene data: 1,500 images of household waste in typical scenarios such as home kitchens, community garbage disposal points, and garbage treatment stations were captured using multiple angles (0°, 45°, 90°) and various lighting conditions (strong light, weak light, backlight) to compensate for the difference between open source data and real application scenarios.
[0018] 1.2 Data labeling strictly follows the national standard GB / T 19095-2019 "Classification Marks for Household Waste". All collected images are divided into four main categories: recyclables, kitchen waste, hazardous waste, and other waste, further subdivided into 40 subcategories. The labeling process adopts the standardized format of "waste image + corresponding label file + category mapping table": Label file: Each image corresponds to one .txt format label file, recording the category number and target bounding box coordinates (x1, y1, x2, y2, where (x1, y1) is the upper left corner coordinate and (x2, y2) is the lower right corner coordinate); Category mapping table: A JSON format category mapping table is established to clearly define the one-to-one correspondence between category names and category numbers, ensuring the consistency and traceability of the labeling information.
[0019] 1.3 Data Augmentation and Dataset Partitioning To address the model training bias caused by insufficient sample size in some garbage subcategories, data augmentation operations were performed based on the OpenCV library for categories with fewer than 450 samples. These operations included horizontal flipping, random cropping, angle rotation (-15°~15°), and brightness adjustment (0.7~1.3 times), ensuring that the number of samples in all subcategories was no less than 450, thus achieving class balance.
[0020] The enhanced dataset is randomly divided into training and test sets in a 7:3 ratio. The partitioning process uses a stratified sampling strategy to ensure that the sample distribution of each class in the training and test sets is consistent, thus guaranteeing the objectivity of the model evaluation.
[0021] In the above embodiments, images are collected from multiple waste source points, and waste types are classified according to standards and labeled with category names, numbers, and target bounding box coordinates. A label file with the same name and a JSON category mapping table are generated and saved in the format of "waste image - label file with the same name - category mapping table". This achieves dual-dimensional labeling of "location + category", provides dual supervision signals for the model, reduces background interference, and ensures the matching accuracy of subsequent steps by the standardized data format, improves data reusability, and lays a high-quality data foundation for the model to accurately learn waste features.
[0022] Preferably, S2, performing bicubic interpolation on each labeled garbage image to obtain each target garbage image, and dividing all target garbage images into a training set and a test set according to a set ratio, includes: S201, performing bicubic interpolation scaling on each labeled garbage image, wherein the bicubic interpolation scaling process includes: dividing the coordinates of each pixel of the target garbage image... By reverse mapping to the corresponding position in the currently annotated garbage image, the mapped coordinates with decimal offsets are obtained. ,in, This is the decimal offset in the row direction. This is the decimal offset in the column direction, and , Based on mapped coordinates Extract the n neighboring pixels around the current coordinate in the currently annotated garbage image. The row offset (row) and column offset (col) of the neighboring pixels are row and col ∈ [-1,2]. Calculate the pixel values in the target garbage image using the bicubic interpolation scaling formula. The grayscale value, the bicubic interpolation scaling formula is: ,in, For the pixels in the target garbage image grayscale value, This represents the grayscale value of the corresponding neighboring pixels in the currently annotated garbage image. These are bicubic interpolation basis functions. and In This is the convolution formula, which is expressed as: , among which, S yes A special case of a=-1 in the formula, It is the absolute value of the difference between the neighboring pixel offset and the corresponding fractional offset, i.e., the calculation hour ,calculate hour ;when When the sampling interval of the original function is third-order convergent, as shown in the following formula: The core idea of the bicubic interpolation image scaling algorithm is to ensure that image information is not lost and to measure the pixels and grayscale of the compared images. This scaling method ensures that the image remains unblurred and undistorted after the image size is changed, minimizing interference with the model's extraction of image feature information.
[0023] S202. Repeat step S201 to calculate the grayscale values of all pixels in each labeled garbage image, obtaining each target garbage image. Maintain a one-to-one association between the target garbage image and the corresponding labeling information of the original labeled garbage image. The labeling information includes a .txt tag file and a JSON category mapping table. S203. Divide all target garbage images into training and testing sets according to a set ratio. Specifically, collect all target garbage images processed in step S202, and use a stratified sampling strategy to divide them into training and testing sets at a set ratio of 7:3. Ensure that the sample distribution of each garbage category in the training and testing sets is consistent with the overall category distribution of all target garbage images. Simultaneously, synchronously allocate the labeling information corresponding to each target garbage image to the training or testing set, finally outputting training and testing sets containing complete labeling information.
[0024] It should be understood that the inconsistent sizes of the collected raw garbage images can affect model training efficiency and inference accuracy; therefore, all images need to be standardized in size. Based on the input requirements of the SE-ResNet model, the target size is set to 224×224×3. To preserve image details (such as garbage texture, shape, and other key features) to the greatest extent possible during the scaling process, a bicubic interpolation algorithm is used to perform the scaling operation.
[0025] In the above embodiments, a bicubic interpolation algorithm is used to scale the labeled garbage images. Preprocessing is completed through inverse mapping, neighbor pixel extraction, and grayscale value calculation. Then, the training set and test set are divided according to a set ratio. Compared with traditional interpolation methods, this method can more completely preserve the fine-grained texture and morphological details of the garbage and avoid feature loss caused by preprocessing. The balanced dataset division solves the class bias problem, improves the model's generalization, and provides high-quality and highly consistent input data for subsequent training.
[0026] Preferably, S3, based on the global feature extraction unit of the SE-ResNet network model, adds a dual local feature processing unit for extracting fine-grained and coarse-grained local features of the image, forming an improved SE-ResNet network model, including: using the ResNet50 network as the basic framework, embedding the global feature extraction unit of the SE module into the residual block of the ResNet50 network to form the SE-ResNet network model; specifically, the global feature extraction unit is located after the convolution operation and before the residual connection; based on the global feature extraction unit (denoted as unit S-1) of the SE-ResNet network model, two local feature processing units are added in parallel, namely a fine-grained local feature extraction unit (denoted as unit S-2) and a coarse-grained local feature extraction unit (denoted as unit S-3); the target garbage image is input into the ResNet50 network, and after forward propagation processing by the ResNet50 network, the feature map is output by the residual block; the global feature extraction unit uses a global average pooling operation to perform global coverage sampling on the feature map output by the residual block, and outputs a global feature weight with a dimension of 1×1×C. Where C is the number of channels in the residual block output feature map; the fine-grained local feature extraction unit uses max pooling to locally sample the feature map output by the residual block, and the pooling kernel size of the max pooling operation is... The formula for calculating the step size s is: , where the height of the feature map and width The output dimension is Fine-grained local feature weights The processing procedure is shown in Figure 3. In the formula, , Input the height and width of the feature. This represents the current module's level. Taking unit S-2 as an example, the sampling region size selected by the pooling layer is... The movement step size is Finally obtained Each weight represents the importance of a local feature in a small block. Similarly, for the S-3 unit, the final result is... Each weight represents the importance of the local features of each small block; the coarse-grained local feature extraction unit uses a pooling kernel size of [size missing]. The max pooling operation performs local sampling on the feature map output by the residual block, dynamically calculating the sampling region and the step size, resulting in an output dimension of... coarse-grained local feature weights The global feature extraction unit, the fine-grained local feature extraction unit, and the coarse-grained local feature extraction unit are recalibrated to complete the construction of the improved SE-ResNet network model.
[0027] As shown in Figure 2, the improved SE-ResNet network model includes: Input, a feature map input module, which is used to input the H×W×C dimension feature map (including garbage bottom / middle layer features) output by the ResNet50 residual block; Max Pooling (2×2), a fine-grained local feature extraction unit (S-2 unit), which is used to extract fine-grained detail features (such as texture and wrinkles) of garbage through 2×2 max pooling; Max Pooling (3×3), a coarse-grained local feature extraction unit (S-3 unit), which is used to extract coarse-grained local features (such as local region morphology) of garbage through 3×3 max pooling; Global... The Pooling global feature extraction unit (S-1 unit) is used to extract global contour features (such as overall shape) of garbage through global average pooling; FC (6 in total, divided into 3 groups) are fully connected layer modules (3 groups corresponding to three feature units), which are used to perform dimensionality transformation and linear mapping on the feature weights extracted by each unit to prepare for fusion; ReLU is the ReLU activation function module: introducing non-linear transformation to enhance the model's ability to fit complex features and alleviate gradient vanishing; Weight Layer is the weight adjustment layer module, which is used to scale and calibrate the local feature weights of S-2 and S-3 units to eliminate the scale difference between global and local features; Sigmoid is the Sigmoid activation function module, which is used to constrain the fused feature weights (outputting the 0~1 interval) to achieve adaptive weighting of feature channels; Scale is the feature scaling and fusion module, which is used to multiply the feature channel weights output by Sigmoid with the original input feature map channel by channel to enhance effective features and suppress interference.
[0028] The connection relationship between the modules is as follows: Input layer → Multi-scale feature extraction layer: The feature map input module (Input) is simultaneously connected to three feature extraction units in parallel—Global Pooling, Fine-grained Local Feature Extraction Unit (…). Max Pooling), coarse-grained local feature extraction unit ( Max Pooling), three units simultaneously sample the input feature map and output the results respectively. , , Feature weights of dimensions.
[0029] Multi-scale feature extraction layer → fully connected layer → activation layer: The outputs of the three feature extraction units are respectively connected to a set of fully connected layers (FC), and each FC contains two cascaded fully connected layers; the output of each FC is connected to a ReLU activation function module, and the adjusted feature weights are output after nonlinear transformation.
[0030] Activation layer → Weight adjustment layer: The ReLU outputs of the fine-grained (S-2) and coarse-grained (S-3) units are connected to a weight adjustment layer module to complete the scale calibration of local feature weights; the ReLU output of the global feature extraction unit (S-1) directly enters the subsequent fusion stage (without additional weight adjustment).
[0031] Weight Adjustment Layer → Feature Fusion → Sigmoid Activation: The feature weights of units S-2 and S-3 after weight adjustment are fused with the feature weights of S- through a "weighted summation" method to form a unified feature weight; the fused weights are input into the Sigmoid activation function module, which outputs the feature channel weights in the 0~1 interval.
[0032] Sigmoid → Feature Scaling and Fusion → Output: The feature channel weights output by Sigmoid are connected to the Scale module and multiplied channel by channel with the original input feature map to obtain the optimized feature map and output it, providing high-quality feature support for subsequent classification tasks.
[0033] The entire connection is designed around "parallel extraction of multi-scale features → separate optimization → fusion calibration → adaptive weighting", which ensures the comprehensive capture of global and local features, and achieves accurate feature selection through weight adjustment and activation constraints, ultimately improving the model's ability to classify garbage images.
[0034] The improved SE-ResNet network model is based on the ResNet50 network framework. The core improvement lies in the integration of a "global + dual-local" multi-scale feature extraction structure and a feature recalibration module: the bottom layer consists of residual blocks from the ResNet50 network. The target garbage image is convolved through these residual blocks to output a feature map (dimensions H×W×C, where H is the feature map height, W is the width, and C is the number of channels). The feature map is input in parallel to three feature extraction units: the global feature extraction unit (S-1 unit) uses global average pooling and outputs... global feature weights The fine-grained local feature extraction unit (S-2 unit) adopts... Max pooling, through the formula Calculate the pooling kernel size and output. Fine-grained local feature weights The coarse-grained local feature extraction unit (S-3 unit) adopts... Max pooling dynamically calculates the sampling region and step size, and outputs... coarse-grained local feature weights The output weights of the three units are connected to the feature recalibration module. After weight fusion, normalization adjustment and Sigmoid constraint, the final feature channel weights are output, which completes the adaptive optimization of multi-scale features and ensures that the model accurately captures the global contour and local detailed features of garbage.
[0035] In the above embodiments, based on ResNet50, the global feature extraction unit of the SE module is embedded into the residual block, and fine-grained features are added in parallel. Pooling) and coarse-grained ( The dual local feature processing unit (pooling) calculates pooling parameters through dynamic formulas and then completes model construction through feature recalibration, forming a "global + local" multi-scale feature extraction structure. This fills the gap in local feature capture of the original SE-ResNet. At the same time, since no additional trainable parameters are added, the accuracy of garbage identification at different scales is improved while controlling the computational cost, thus balancing performance and lightweight requirements.
[0036] Preferably, feature recalibration of the global feature extraction unit, the fine-grained local feature extraction unit, and the coarse-grained local feature extraction unit includes: adjusting the global feature weights corresponding to the global feature extraction unit. The fine-grained local feature weights corresponding to the fine-grained local feature extraction unit. and the coarse-grained local feature weights corresponding to the coarse-grained local feature extraction unit The initial fusion feature weights are obtained by performing fusion. The initial fusion feature weights Represented as: Introducing a weighting function The feature outputs of the global feature extraction unit, the fine-grained local feature extraction unit, and the coarse-grained local feature extraction unit. After normalization adjustment, the adjusted feature weights are constrained by the Sigmoid function to obtain the feature channel weights, thus completing the feature recalibration. The feature channel weights are expressed as follows: ,in, It is the Sigmoid activation function. This is the feature weight extraction function.
[0037] In the above embodiments, the initial fusion weights are obtained by first fusing global and dual local feature weights, then normalized and adjusted by the weight processing function, and finally the feature channel weights are obtained by constraining by the Sigmoid function. This achieves adaptive optimization of feature weights, which can accurately amplify effective features, suppress useless interference, eliminate the scale difference bias of features at different scales, ensure that all types of features play their full role, significantly improve feature utilization, and especially improve the recognition accuracy of small target garbage.
[0038] Preferably, S4, training the improved SE-ResNet network model based on the training set to obtain the trained improved SE-ResNet network model includes: converting text format label files into supervision signal labels using the JSON category mapping table in the training set; inputting the target garbage images and their corresponding scaled target bounding box coordinates from the training set into the improved SE-ResNet network model for feature extraction and feature recalibration, and outputting the category probability distribution corresponding to each target garbage image; calculating the batch loss value between the category probability distribution output by the model and the supervision signal labels corresponding to the training set using the cross-entropy loss function, wherein the expression for the cross-entropy loss function is: ,in, This is the batch loss value. The target number of garbage images for a single batch of training. The total number of waste categories. As an indicator variable, when the first The true category of Zhang's target garbage image is: hour ,otherwise , For the model to predict the first Zhang's target image belongs to the category of garbage images. The probability is calculated; based on the calculated batch loss value, the gradient of each layer parameter of the improved SE-ResNet network model is calculated in reverse using the backpropagation algorithm, and all training parameters of the model are updated through the Adam optimizer to minimize the loss value; after each training cycle, the training loss value and training set accuracy of the current training cycle are recorded. If the test set accuracy does not improve for a consecutive training cycles, the training is terminated early; if the early stopping strategy is not triggered, the training continues iteratively until the preset training cycle is completed, and the improved SE-ResNet network model after training is obtained.
[0039] In the above embodiments, the supervision signal labels are transformed by combining the JSON category mapping table. The target garbage image and the scaled bounding box coordinates are input for feature extraction and recalibration. The loss is calculated by the cross-entropy loss function. The parameters are updated by backpropagation and Adam optimizer. The training is completed by combining early stopping strategy. The training method focusing on garbage regions makes the model learning more targeted and accelerates the convergence speed. The combination of backpropagation and Adam optimizer stabilizes the parameter update, and the early stopping strategy effectively avoids overfitting, ensuring the generalization performance and classification result stability of the model after training.
[0040] Preferably, the method further includes a step of setting training hyperparameters, specifically: setting training hyperparameters, wherein the training hyperparameters include batch training size, initial learning rate, learning rate decay strategy, weight decay coefficient, training epochs, and early stopping strategy parameters.
[0041] The training process is as follows: using the Adam optimizer, setting batch_siz, learning_rat, and decay, training for 16 epochs, and employing an early stopping strategy to avoid overfitting during training, stopping training when the test set accuracy does not improve for 3 consecutive epochs.
[0042] In the above embodiments, key training hyperparameters such as batch training size, initial learning rate, learning rate decay strategy, weight decay coefficient, training rounds, and early stopping strategy parameters are clearly set to form a standardized combination of training parameters, avoiding model performance fluctuations caused by blindly adjusting hyperparameters; the dynamic learning rate decay and weight decay mechanism balance training efficiency and model performance, which shortens the convergence period and further suppresses overfitting, ensuring that the model can stably output high-quality classification results under different experimental environments.
[0043] Example 2: As shown in Figure 3, this embodiment of the invention also provides a waste detection and classification device based on an improved SE-ResNet, comprising: a waste image annotation module for collecting waste images from multiple sources and annotating the waste types of the waste images from each source; a waste image preprocessing module for performing bicubic interpolation on each annotated waste image to obtain each target waste image, and dividing all target waste images into a training set and a test set according to a set ratio; a model building module for adding a dual local feature processing unit for extracting fine-grained and coarse-grained local features of the image to the global feature extraction unit of the SE-ResNet network model, thereby constructing an improved SE-ResNet network model; a model training module for training the improved SE-ResNet network model based on the training set to obtain the trained improved SE-ResNet network model; and a waste category output module for inputting the test set into the trained improved SE-ResNet network model and outputting the waste classification result.
[0044] Example 3: This embodiment of the invention also provides a waste detection and classification device based on an improved SE-ResNet, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the waste detection and classification method based on the improved SE-ResNet as described above.
[0045] Example 4: This embodiment of the invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the garbage detection and classification method based on the improved SE-ResNet as described above.
[0046] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0047] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and unit can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0048] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0049] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.
[0050] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0051] 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, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A garbage detection and classification method based on an improved SE-ResNet, characterized in that, The process includes the following steps: collecting garbage images from multiple sources and labeling the garbage images from each source with garbage types; performing bicubic interpolation on each labeled garbage image to obtain each target garbage image; dividing all target garbage images into training and testing sets according to a set ratio; adding a dual local feature processing unit for extracting fine-grained and coarse-grained local features of the image to the global feature extraction unit of the SE-ResNet network model to form an improved SE-ResNet network model; S4, training the improved SE-ResNet network model based on the training set to obtain the trained improved SE-ResNet network model; S5, inputting the testing set into the trained improved SE-ResNet network model and outputting the garbage classification results.
2. The garbage detection and classification method based on the improved SE-ResNet according to claim 1, characterized in that, S1. Collect garbage images from multiple sources and perform garbage type labeling processing on the garbage images from various sources, including: collecting multiple garbage images from multiple specified garbage source points, classifying the multiple garbage images from various sources into multiple garbage types based on specified standards, obtaining each garbage image and its corresponding category name and category number, determining the target bounding box coordinates used to locate the garbage target in the image in each garbage image, and generating a text format label file with the same name for each garbage image based on the category number and the target bounding box coordinates. The label file includes the category number and the target bounding box coordinates. A JSON category mapping table is generated based on the category name and category number. Finally, the garbage images, label files with the same name, and category mapping table are saved in the format of garbage images, label files with the same name, and category mapping table to complete the garbage type labeling and obtain the labeled garbage images.
3. The garbage detection and classification method based on the improved SE-ResNet according to claim 2, characterized in that, Each labeled garbage image is subjected to bicubic interpolation to obtain a target garbage image. All target garbage images are then divided into a training set and a test set according to a predetermined ratio. This includes: S201, performing bicubic interpolation scaling on each labeled garbage image. The bicubic interpolation scaling process includes: [The text abruptly ends here, so the translation stops.] By reverse mapping to the corresponding position in the currently annotated garbage image, the mapped coordinates with decimal offsets are obtained. ,in, This is the decimal offset in the row direction. This is the decimal offset in the column direction, and 、 Based on mapped coordinates Extract the n neighboring pixels around the current coordinate in the currently annotated garbage image. The row offset (row) and column offset (col) of the neighboring pixels are row and col ∈ [-1,2]. Calculate the pixel values in the target garbage image using the bicubic interpolation scaling formula. The grayscale value, the bicubic interpolation scaling formula is: ,in, For the pixels in the target garbage image grayscale value, This represents the grayscale value of the corresponding neighboring pixels in the currently annotated garbage image. and middle S202. Repeat step S201 to calculate the grayscale values of all pixels in each labeled garbage image to obtain each target garbage image; S203. Divide all target garbage images into training set and test set according to a set ratio.
4. The garbage detection and classification method based on the improved SE-ResNet according to claim 1, characterized in that, Based on the global feature extraction unit of the SE-ResNet network model, a dual local feature processing unit for extracting fine-grained and coarse-grained local features of the image is added to form an improved SE-ResNet network model. This includes: using the ResNet50 network as the basic framework, embedding the global feature extraction unit of the SE module into the residual block of the ResNet50 network to form the SE-ResNet network model; adding two parallel local feature processing units on top of the global feature extraction unit of the SE-ResNet network model, namely a fine-grained local feature extraction unit and a coarse-grained local feature extraction unit; inputting the target garbage image into the ResNet50 network, processing it through forward propagation, and outputting the feature map from the residual block; the global feature extraction unit uses global average pooling to perform global coverage sampling on the feature map output by the residual block, outputting global feature weights with a dimension of 1×1×C. Where C is the number of channels in the residual block output feature map; the fine-grained local feature extraction unit uses max pooling to locally sample the feature map output by the residual block, and the pooling kernel size of the max pooling operation is... The formula for calculating the step size s is: , where the height of the feature map and width , Assuming the current module's level, output fine-grained local feature weights with a dimension of 2×2×C. The coarse-grained local feature extraction unit employs max pooling with a 3×3 kernel size to locally sample the feature map output by the residual block. It dynamically calculates the sampling region and the step size, outputting coarse-grained local feature weights with a dimension of 3×3×C. The global feature extraction unit, the fine-grained local feature extraction unit, and the coarse-grained local feature extraction unit are recalibrated to complete the construction of the improved SE-ResNet network model.
5. The garbage detection and classification method based on the improved SE-ResNet according to claim 4, characterized in that, Feature recalibration is performed on the global feature extraction unit, the fine-grained local feature extraction unit, and the coarse-grained local feature extraction unit, including: adjusting the global feature weights corresponding to the global feature extraction unit. The fine-grained local feature weights corresponding to the fine-grained local feature extraction unit. and the coarse-grained local feature weights corresponding to the coarse-grained local feature extraction unit The initial fusion feature weights are obtained by performing fusion. The initial fusion feature weights Represented as: Introducing a weighting function The feature outputs of the global feature extraction unit, the fine-grained local feature extraction unit, and the coarse-grained local feature extraction unit. After normalization adjustment, the adjusted feature weights are constrained by the Sigmoid function to obtain the feature channel weights, thus completing the feature recalibration. The feature channel weights are expressed as follows: ,in, It is the Sigmoid activation function. This is the feature weight extraction function.
6. The garbage detection and classification method based on the improved SE-ResNet according to claim 1, characterized in that, The improved SE-ResNet network model is trained based on the training set to obtain the trained improved SE-ResNet network model, including: converting text format label files into supervision signal labels using the JSON category mapping table in the training set; inputting the target garbage images and their corresponding scaled target bounding box coordinates from the training set into the improved SE-ResNet network model for feature extraction and feature recalibration, and outputting the category probability distribution corresponding to each target garbage image; calculating the batch loss value between the category probability distribution output by the model and the supervision signal labels corresponding to the training set using the cross-entropy loss function, the expression of which is: ,in, This is the batch loss value. The target number of garbage images for a single batch of training. The total number of waste categories. As an indicator variable, when the first The true category of Zhang's target garbage image is: hour ,otherwise , For the model to predict the first Zhang's target image belongs to the category of garbage images. The probability is calculated; based on the calculated batch loss value, the gradient of each layer parameter of the improved SE-ResNet network model is calculated in reverse using the backpropagation algorithm, and all training parameters of the model are updated through the Adam optimizer; after each training cycle, the training loss value and training set accuracy of the current training cycle are recorded. If the test set accuracy does not improve for a consecutive training cycles, the training is terminated early; if the early stopping strategy is not triggered, the training continues iteratively until the preset training cycle is completed, and the improved SE-ResNet network model after training is obtained.
7. The garbage detection and classification method based on improved SE-ResNet according to any one of claims 1 to 6, characterized in that, It also includes the step of setting training hyperparameters, specifically: setting training hyperparameters, which include batch training size, initial learning rate, learning rate decay strategy, weight decay coefficient, training rounds and early stopping strategy parameters.
8. A waste detection and sorting device based on an improved SE-ResNet, characterized in that, include: The garbage image annotation module is used to collect garbage images from multiple sources and to annotate the garbage types in the garbage images from various sources. The garbage image preprocessing module is used to perform bicubic interpolation on each labeled garbage image to obtain each target garbage image, and to divide all target garbage images into training set and test set according to a set ratio. The model building module adds a dual local feature processing unit for extracting fine-grained and coarse-grained local features of the image to the global feature extraction unit of the SE-ResNet network model, thus forming an improved SE-ResNet network model. The model training module trains the improved SE-ResNet network model based on the training set to obtain the trained improved SE-ResNet network model. The garbage category output module inputs the test set into the trained improved SE-ResNet network model and outputs the garbage classification results.
9. A waste detection and sorting device based on an improved SE-ResNet, characterized in that, The method includes 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, it implements the garbage detection and classification method based on the improved SE-ResNet as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the garbage detection and classification method based on the improved SE-ResNet as described in any one of claims 1 to 7.