Method and device for constructing garbage classification processing model, and electronic equipment

By constructing a waste classification model through multi-dimensional feature fusion and automatic node splitting, the problem of incomplete feature extraction in existing technologies is solved, achieving efficient and low-cost waste classification and improving the model's classification accuracy and generalization ability.

CN122176386APending Publication Date: 2026-06-09SHENZHEN NXROBO

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN NXROBO
Filing Date
2026-03-10
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing garbage classification models have incomplete feature extraction, resulting in low classification accuracy. They also rely on large model datasets and high-performance hardware, leading to low training efficiency, high cost, and insufficient generalization ability.

Method used

By acquiring training image samples labeled with waste type, we extract three types of waste features: geometry, color, and texture. We then construct a waste classification model by using multi-dimensional feature fusion and automatic node splitting. We set training parameters and recursively traverse features and candidate splitting thresholds until the stopping condition is met, and finally determine the leaf node output results.

Benefits of technology

It improves model building efficiency, reduces costs, ensures the stability and accuracy of model classification, and enables rapid and accurate determination of waste categories.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176386A_ABST
    Figure CN122176386A_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, and electronic device for constructing a waste sorting and processing model. This solution acquires training image samples labeled with waste type, extracts three types of waste features: geometric, color, and texture, and avoids the limitations of single features through multi-dimensional feature fusion. After setting training parameters, it recursively traverses features and candidate splitting thresholds starting from the initial node, selecting the optimal splitting combination to split nodes until the stopping condition is met and the leaf node output result is determined, ultimately obtaining the waste sorting and processing model. This method automatically splits nodes to replace manually setting classification rules, improving the efficiency of model construction and ensuring the stability of model classification. It also reduces the cost of model construction and enables the model to quickly and accurately determine waste categories.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of battery technology, and in particular to a method, apparatus and electronic device for constructing a waste sorting and processing model. Background Technology

[0002] With increasing environmental awareness and the implementation of waste sorting policies, waste sorting has become an important part of resource recycling and ecological protection. In recent years, automatic waste sorting technology based on image recognition has been widely used because it can improve sorting efficiency and reduce labor costs. However, some existing waste sorting models have low accuracy due to incomplete feature extraction. Other models, while having higher accuracy, rely on large model datasets and high-performance hardware for training, resulting in overly complex model structures, low training efficiency, high costs, and insufficient generalization ability, making them difficult to promote and use. Summary of the Invention

[0003] This application aims to provide a method, apparatus, and electronic device for constructing a waste sorting and processing model, in order to solve the problem of low accuracy in waste type classification of existing models.

[0004] Firstly, this application proposes a method for constructing a waste classification and processing model, comprising: acquiring multiple training image samples from a training dataset, wherein the training image samples are labeled with waste type tags; determining corresponding waste features based on the training image samples, wherein the waste features include geometric features, color features, and texture features; acquiring training parameters, wherein the training parameters include a preset node purity index, a maximum depth, a minimum number of split samples, and a minimum number of leaf node samples; starting from an initial node, executing a first process: traversing each feature and multiple candidate split thresholds corresponding to the feature, calculating the node purity value of each combination of candidate split thresholds based on the waste type tags, and selecting the node that best matches the description. The node purity value corresponding to the node's purity preset index is used as the first combination. Based on the first combination, two child nodes are split from the current node. The initial node contains all training image samples of the training dataset. The combination of feature candidate split thresholds includes a feature and a candidate split threshold corresponding to the feature. The first process is repeated for each child node until at least one of the maximum depth, the minimum number of split samples, and the minimum number of samples in the leaf node is satisfied. The current node at the time of stopping is recorded as the leaf node, and the garbage type with the most samples in the leaf node is used as the output result of the leaf node to obtain the garbage classification processing model.

[0005] This solution acquires training image samples labeled with waste type, extracts three types of waste features: geometry, color, and texture, and avoids the limitations of single features through multi-dimensional feature fusion. After setting training parameters, it recursively traverses features and candidate splitting thresholds starting from the initial node, and selects the optimal splitting combination to split the node until the stopping condition is met and the leaf node output result is determined, finally obtaining a waste classification processing model. This method uses automatic node splitting to replace manual setting of classification rules, improving the efficiency of model construction and ensuring the stability of model classification. It can also reduce the cost of model construction and enable the model to quickly and accurately determine the waste category.

[0006] In some embodiments, determining the corresponding garbage features based on the training image samples includes: acquiring a grayscale image and a garbage subject outline corresponding to the training image samples; determining the geometric features of the corresponding garbage subject based on the garbage subject outline, wherein the geometric features include aspect ratio, density, roundness, rectangularity, and outline complexity; extracting the color features of the corresponding garbage subject based on a color space based on the garbage subject outline, wherein the color features include average hue, average saturation, white area proportion, highlight area proportion, and color consistency index; and determining the texture features of the corresponding garbage subject based on the grayscale image, wherein the texture features include texture entropy and texture contrast.

[0007] This approach obtains grayscale images and the outlines of the main body of the waste from training image samples, and then extracts multiple features in combination with color space. It comprehensively considers the complementary and synergistic training of multi-dimensional features that can reflect the shape, color, and surface material characteristics of the waste. This solves the problem that a single feature cannot distinguish similar waste, thereby improving the model's ability to distinguish different types of waste and its classification accuracy.

[0008] In some embodiments, obtaining the grayscale image and the outline of the garbage subject corresponding to the training image sample includes: adjusting the size of the training image sample to conform to a preset pixel size; performing noise reduction processing on the adjusted training image sample; obtaining the grayscale image and binary image of the training image sample after noise removal; performing morphological optimization on the binary image, including removing noise points and filling holes; extracting the outline based on the optimized binary image, and determining the outline with the largest area as the outline of the garbage subject.

[0009] This solution ensures input consistency by adjusting image size and performs various image optimizations. Based on the maximum area criterion, it accurately locates the main garbage area, thereby obtaining a high-quality and complete outline of the garbage. This provides accurate image data for the subsequent extraction of various features, thus improving the quality of training data for the input model and the accuracy of model construction.

[0010] In some embodiments, the node purity preset index is the Gini index, which is calculated as follows: for the current node, the proportion of each category of samples is counted; the sum of the squares of the proportions of each category of samples is calculated and subtracted to obtain the Gini index of the current node.

[0011] This scheme calculates the weighted average Gini index corresponding to each candidate splitting threshold, solves for the Gini gain, and selects the combination of the feature with the largest Gini gain and the candidate splitting threshold as the first combination. The Gini gain can quantify the degree of improvement in node purity before and after splitting. Selecting the combination with the largest Gini gain for node splitting can ensure that each split can significantly improve the purity of the node category, avoid invalid splits, improve the classification accuracy and generalization ability of the model, and ensure that the model can accurately classify garbage.

[0012] In some embodiments, selecting the feature candidate splitting threshold combination corresponding to the node purity value that best matches the preset node purity index as the first combination includes: for each candidate splitting threshold, calculating the weighted average Gini index of the two child nodes after splitting; calculating the difference between the Gini index of the current node before splitting and the weighted average Gini index to obtain the Gini gain; and selecting the feature candidate splitting threshold combination with the largest Gini gain as the first combination.

[0013] This solution tests the completed model by obtaining a test dataset with the same class distribution as the training dataset. Based on the test results, the training parameters are adjusted or training samples are supplemented until the test results meet the preset requirements. This avoids test bias caused by uneven class distribution in the test set and can promptly correct the model's shortcomings, solving problems such as overfitting, underfitting, or excessively high misclassification rates for some classes. This improves the model's practicality and robustness, enabling it to adapt to the needs of real-world waste classification scenarios.

[0014] In some embodiments, the method further includes: acquiring multiple test image samples from a test dataset and determining the waste features corresponding to each test image sample, wherein the proportion of test image samples of each type of waste in the test dataset is the same as the proportion of training image samples of each type of waste in the training dataset; testing the waste classification and processing model based on the test dataset to obtain test results; and when the test results do not meet preset result indicators, adjusting the training parameters or adding new training image samples and retraining and testing the waste classification and processing model until the test results meet the preset results.

[0015] This scheme calculates the Gini index by statistically analyzing the proportion of each category of samples in the current node, clearly quantifying the category purity of the node, providing a unified judgment standard for node splitting, avoiding excessive subjectivity in node purity judgment, and ensuring that each node split has a clear scientific basis, thereby improving the standardization and rationality of model construction, as well as the accuracy of model classification.

[0016] In some embodiments, the method for determining the candidate split threshold includes: for the current garbage feature, sorting the feature values ​​of all training image samples in the current node in ascending order; and calculating the median of two adjacent feature values ​​as the candidate split threshold for the current garbage feature.

[0017] This scheme sorts the feature values ​​of training image samples in the current node in ascending order and calculates the median of two adjacent feature values ​​as a candidate splitting threshold. This covers the true distribution range of feature values, filters out candidate thresholds with practical distinguishing significance, and reduces blind attempts at invalid thresholds. This not only improves the efficiency of node splitting but also makes the candidate thresholds fit the distribution characteristics of the training data, thus making node splitting more reasonable, classifying types more accurately, and further optimizing the model construction effect.

[0018] Secondly, this application also proposes a waste sorting and processing method, comprising: acquiring a waste image of the waste to be sorted; determining multiple waste features corresponding to the waste based on the waste image, wherein the waste features include geometric features, color features, and texture features; and performing type recognition on the waste image using the aforementioned waste sorting and processing model and the waste features to obtain the classification result of the waste image.

[0019] Thirdly, this application also proposes a device for constructing a waste classification and processing model, comprising: a first acquisition module for acquiring multiple training image samples in a training dataset, wherein the training image samples are labeled with waste type tags; a feature determination module for determining corresponding waste features based on the training image samples, wherein the waste features include geometric features, color features, and texture features; a parameter acquisition module for acquiring training parameters, wherein the training parameters include a preset node purity index, a maximum depth, a minimum number of split samples, and a minimum number of leaf node samples; and a first training module for executing a first process starting from an initial node: traversing each feature and multiple candidate split thresholds corresponding to the feature, and calculating the node of each combination of feature candidate split thresholds based on the waste type tags. The purity value is selected, and the feature candidate splitting threshold corresponding to the node purity value that best matches the preset node purity index is selected as the first combination. Based on the first combination, two child nodes are split from the current node. The initial node contains all training image samples of the training dataset. The feature candidate splitting threshold combination includes a feature and a candidate splitting threshold corresponding to the feature. The second training module is used to repeatedly execute the above first process for each child node until at least one of the maximum depth, the minimum number of splitting samples, and the minimum number of samples in the leaf node is satisfied. The current node at the time of stopping is recorded as the leaf node, and the garbage type with the most samples in the leaf node is used as the output result of the leaf node to obtain the garbage classification processing model.

[0020] Fourthly, this application also proposes an electronic device comprising: at least one processor and a memory; the memory being coupled to the processor, the memory being used to store instructions or programs that, when executed by the at least one processor, cause the at least one processor to perform the method described above.

[0021] Unlike related technologies, this solution acquires training image samples labeled with waste type, extracts three types of waste features: geometry, color, and texture, and avoids the limitations of single features through multi-dimensional feature fusion. After setting training parameters, it recursively traverses features and candidate splitting thresholds starting from the initial node, and selects the optimal splitting combination to split the node until the stopping condition is met and the leaf node output result is determined, finally obtaining the waste classification processing model. This method uses automatic node splitting to replace manual setting of classification rules, improving the efficiency of model construction and ensuring the stability of model classification. It can also reduce the cost of model construction and enable the model to quickly and accurately determine the waste category. Attached Figure Description

[0022] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations are not intended to limit the embodiments. Elements having the same reference numerals in the drawings are designated as similar elements. Unless otherwise stated, the figures in the drawings are not intended to be scaled.

[0023] Figure 1 A flowchart illustrating the construction method of a waste sorting and treatment model provided in some embodiments of this application; Figure 2 A schematic flowchart illustrating a waste sorting and processing method provided in some embodiments of this application; Figure 3 A schematic diagram of the structure of a waste sorting and treatment model construction device provided in some embodiments of this application; Figure 4 The diagram shows the structure of an electronic device provided in some embodiments of this application. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of this application, but not all embodiments.

[0025] In this application, the reference to "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments.

[0026] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly indicating the number, specific order, or primary and secondary relationship of the indicated technical features.

[0027] The technical features involved in the different embodiments of this application described below can be combined with each other as long as they do not conflict with each other.

[0028] It should be noted that the user personal information involved in this application embodiment is all authorized (knowing and consenting) by the relevant parties or fully authorized by all parties, and the executing entity can obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with the relevant laws and regulations of the relevant countries and regions, and do not violate public order and good morals.

[0029] This application proposes a method for constructing a waste sorting and treatment model; please refer to [link / reference]. Figure 1The method includes: S11. Obtain multiple training image samples from the training dataset, wherein the training image samples are labeled with waste type tags. Before starting to build the model, a certain number of waste images are obtained as training image samples. These images need to cover multiple waste categories to be identified, and each image is manually labeled to clearly define its corresponding waste type tag, such as 0 representing plastic bottles, 1 representing aluminum cans, etc., so that the rules of waste classification can be mastered by analyzing the features of these samples during subsequent model training.

[0030] S12. Determine the corresponding garbage features based on the training image samples, wherein the garbage features include geometric features, color features, and texture features. For the training image samples, convert them into computer training values, and provide multi-dimensional analytical data for the model training process through multi-angle analysis of geometric features, color features, and texture features.

[0031] In some embodiments, this step specifically includes: acquiring the grayscale image and the outline of the garbage subject corresponding to the training image sample; determining the geometric features of the corresponding garbage subject based on the garbage subject outline, the geometric features including aspect ratio, density, roundness, rectangularity, and outline complexity; extracting the color features of the corresponding garbage subject based on the color space based on the garbage subject outline, the color features including average hue, average saturation, white area proportion, highlight area proportion, and color consistency index; and determining the texture features of the corresponding garbage subject based on the grayscale image, the texture features including texture entropy and texture contrast.

[0032] Specifically, obtaining the grayscale image and garbage subject outline corresponding to the training image sample may include: adjusting the size of the training image sample to conform to a preset pixel size; thereby ensuring input consistency by adjusting the image size. The adjusted training image sample is then denoised to reduce image noise interference. The grayscale image and binary image of the denoised training image sample are obtained; the binary image is morphologically optimized, including removing noise points and filling holes; then, contours are extracted based on the optimized binary image, and the contour with the largest area is determined as the garbage subject outline. This allows for accurate localization of the garbage subject region based on the largest area criterion, thereby obtaining a high-quality and complete garbage subject outline. This provides accurate image data for subsequent model training, thereby improving the quality of training data input to the model and the accuracy of model construction.

[0033] Based on grayscale images and the main outline of the waste, multiple features are extracted using color space. These include geometric features such as aspect ratio, density, roundness, rectangularity, and outline complexity calculated based on the outline to describe the shape attributes of the waste; color features such as average hue, average saturation, white area proportion, highlight area proportion, and color consistency extracted in the HSV color space using outline masks to describe the color attributes of the waste; and texture features such as texture entropy and texture contrast calculated based on the grayscale image to describe the roughness and texture complexity of the waste surface. This comprehensive approach, considering the complementary and synergistic effects of multidimensional features reflecting the shape, color, and surface material characteristics of waste, addresses the problem of single features being unable to distinguish similar waste, and improves the model's ability to differentiate between different types of waste and its classification accuracy.

[0034] S13. Obtain training parameters, including a preset node purity index, maximum depth, minimum number of split samples, and minimum number of leaf nodes. The training parameters constrain the model training process. The preset node purity index measures the degree of heterogeneity among node samples; the maximum depth limits the number of splits (e.g., 6) to prevent overfitting during training; the minimum number of split samples and the minimum number of leaf nodes restrict child node splits. For example, setting the minimum number of split samples to 6 prohibits further splitting when the number of samples in a node is less than 6; setting the minimum number of leaf nodes to 3 ensures that each final decision has at least three supporting samples, thus providing sufficient sample support for the recognition result of each leaf node. This scheme constrains the rule boundaries of model training through training parameters, ensuring sufficient model complexity to learn effective features while preventing model overgrowth, thereby improving the model's generalization ability and the reliability of the recognition results.

[0035] This scheme uses the Gini index as a preset indicator of node purity. The Gini index is calculated as follows: for the current node, the proportion of each type of sample is counted; the sum of the squares of the proportions of each type of sample is calculated and then subtracted to obtain the Gini index of the current node.

[0036] For example, for a given node, the proportion of samples from each category within that node is calculated, and then the squares of these proportions are summed. Finally, this sum of squares is subtracted from 1 to obtain the Gini index value for that node. Typically, the Gini index ranges from 0 to 1. A smaller value indicates a more concentrated distribution of categories within the node, meaning higher purity; a larger value indicates a more mixed distribution of categories. If all samples in a node belong to the same category, the Gini index is 0, reaching the purest state, indicating that only one type of garbage exists in that node. The Gini index provides a quantitative basis for subsequent feature selection. When splitting a node, the feature and threshold combinations that minimize the Gini index of child nodes are prioritized, thereby gradually building a model structure with optimal classification performance.

[0037] This scheme calculates the weighted average Gini index corresponding to each candidate splitting threshold, solves for the Gini gain, and selects the combination of the feature with the largest Gini gain and the candidate splitting threshold as the first combination. The Gini gain can quantify the degree of improvement in node purity before and after splitting. Selecting the combination with the largest Gini gain for node splitting can ensure that each split can significantly improve the purity of the node category, avoid invalid splits, improve the classification accuracy and generalization ability of the model, and ensure that the model can accurately classify garbage.

[0038] S14. Starting from the initial node, execute the first process: traverse each feature and the multiple candidate splitting thresholds corresponding to the feature, calculate the node purity value of each combination of feature candidate splitting thresholds based on the garbage type label, and select the feature candidate splitting threshold corresponding to the node purity value that best meets the preset node purity index as the first combination, and split two child nodes based on the current node according to the first combination; wherein, the initial node contains all training image samples of the training dataset, and the combination of feature candidate splitting thresholds includes one feature and a candidate splitting threshold corresponding to the feature.

[0039] In this embodiment, the method for determining the candidate split threshold includes: for the current garbage feature, sorting the feature values ​​of all training image samples in the current node in ascending order; and calculating the median of two adjacent feature values ​​as the candidate split threshold for the current garbage feature.

[0040] Specifically, for each feature, such as aspect ratio, all samples in the current node are first sorted in ascending order according to the feature value. For example, each sample in the node is sorted in order according to the aspect ratio value. Then, the midpoint of the feature values ​​of every two adjacent samples is taken as the candidate split threshold. In this way, a set of candidate thresholds will be generated for each feature. For example, if the node contains 6 samples and the aspect ratio values ​​of each sample are different, after sorting, the midpoint of adjacent values ​​will be taken, resulting in 5 candidate split thresholds. Therefore, the aspect ratio of the node corresponds to 5 sets of feature candidate split threshold combinations.

[0041] Then, try multiple candidate splitting threshold combinations for each feature, calculate the Gini index after splitting based on the sample label of the current node, and select the candidate splitting threshold combination that makes the Gini index decrease the most as the optimal splitting scheme, which is the first combination; finally, divide the current node into two child nodes, left and right, according to the selected first combination. For example, samples with feature values ​​less than or equal to a certain threshold enter the left child node, and those with feature values ​​greater than the threshold enter the right child node, thus completing one splitting process.

[0042] This scheme sorts the feature values ​​of training image samples in the current node in ascending order and calculates the median of two adjacent feature values ​​as a candidate splitting threshold. This covers the true distribution range of feature values, filters out candidate thresholds with practical distinguishing significance, and reduces blind attempts at invalid thresholds. This not only improves the efficiency of node splitting but also makes the candidate thresholds fit the distribution characteristics of the training data, thus making node splitting more reasonable, classifying types more accurately, and further optimizing the model construction effect.

[0043] It is understood that the above method is only an example of a method for determining the candidate split threshold provided in the embodiments of this application, and is not a limitation thereof. In other embodiments, the candidate split threshold may be determined in a different way.

[0044] In some embodiments, selecting the feature candidate splitting threshold combination corresponding to the node purity value that best matches the preset node purity index as the first combination includes: for each candidate splitting threshold, calculating the weighted average Gini index of the two child nodes after splitting; calculating the difference between the Gini index of the current node before splitting and the weighted average Gini index to obtain the Gini gain; and selecting the feature candidate splitting threshold combination with the largest Gini gain as the first combination.

[0045] In this scheme, the optimal combination of feature candidate splitting thresholds, i.e., the first combination, is selected from numerous candidate splitting schemes using Gini gain as the evaluation criterion. Specifically, for each feature candidate splitting threshold combination, the current node is divided into left and right child nodes according to the corresponding threshold. The Gini index of each child node is calculated, and the weighted average Gini index after splitting is calculated using the proportion of the number of samples in each child node to the total number of samples in the current node as the weight. Then, the weighted average Gini index is subtracted from the Gini index of the current node before splitting to obtain the Gini gain corresponding to the splitting scheme. The larger the gain, the greater the improvement in node purity after splitting. Finally, the case of all feature candidate splitting threshold combinations for all features is traversed, and the feature candidate splitting threshold combination with the largest Gini gain is selected as the first combination. This ensures that each split maximizes the improvement in node purity, thereby constructing a decision tree model with optimal classification performance.

[0046] This scheme calculates the Gini index by statistically analyzing the proportion of each category of samples in the current node, clearly quantifying the category purity of the node, providing a unified judgment standard for node splitting, avoiding excessive subjectivity in node purity judgment, and ensuring that each node split has a clear scientific basis, thereby improving the standardization and rationality of model construction, as well as the accuracy of model classification.

[0047] S15. Repeat the first process described above for each child node until at least one of the maximum depth, the minimum number of split samples, and the minimum number of samples in the leaf node is satisfied. The current node at the time of stopping is recorded as a leaf node, and the waste type with the most samples in the leaf node is used as the output result of the leaf node to obtain the waste classification and processing model.

[0048] For each child node generated by a split, the process described in step S14 is repeated. Each child node continues to search for the feature and threshold combination that maximizes its purity for the next level of splitting. This recursive process continues until one of the preset stopping conditions is met, such as the node reaching its maximum depth limit, the node's sample count falling below the minimum number of samples for splitting, or the node's sample count falling below the minimum number of samples for a leaf node. At this point, the node stops splitting and is marked as a leaf node. For each leaf node, the number of samples for each category of waste is counted, and the category with the most samples is taken as the output of that node. For example, if a leaf node has 15 plastic bottle samples and 2 aluminum can samples, then the output of that leaf node is plastic bottle. Through this recursive construction method of layer-by-layer splitting and gradual refinement, a complete waste sorting and processing model is finally generated.

[0049] This solution acquires training image samples labeled with waste type, extracts three types of waste features: geometry, color, and texture, and avoids the limitations of single features through multi-dimensional feature fusion. After setting training parameters, it recursively traverses features and candidate splitting thresholds starting from the initial node, and selects the optimal splitting combination to split the node until the stopping condition is met and the leaf node output result is determined, finally obtaining a waste classification processing model. This method uses automatic node splitting to replace manual setting of classification rules, improving the efficiency of model construction and ensuring the stability of model classification. It can also reduce the cost of model construction and enable the model to quickly and accurately determine the waste category.

[0050] In some embodiments, the method further includes: acquiring multiple test image samples from a test dataset and determining the waste features corresponding to each test image sample, wherein the proportion of test image samples of each type of waste in the test dataset is the same as the proportion of training image samples of each type of waste in the training dataset; testing the waste classification and processing model based on the test dataset to obtain test results; and when the test results do not meet preset result indicators, adjusting the training parameters or adding new training image samples and retraining and testing the waste classification and processing model until the test results meet the preset results.

[0051] The preset result metrics can be evaluation indicators such as accuracy, precision, recall, and F1 score. Specifically, a test dataset with the same category distribution as the training set is obtained. Stratified sampling can be used to ensure that the proportion of each type of waste is the same, and the same feature extraction process as in the training phase is performed on the test images to obtain the corresponding 12-dimensional feature vectors. These test samples are then input into the trained decision tree model for prediction, and the prediction results are compared with the true labels to calculate accuracy, precision, recall, and F1 score as test results. Taking the F1 score as an example, if the F1 score of a certain type of waste is lower than the preset threshold and does not meet the requirements, the model can be retrained and tested by adjusting the training parameters (such as modifying the maximum depth, minimum number of split samples, etc.) or by supplementing the training samples of that type of waste. Through this iterative optimization method, the model performance is continuously improved until all evaluation indicators meet the preset requirements, and finally a waste classification and processing model that meets the needs of practical applications is obtained.

[0052] This solution tests the completed model by obtaining a test dataset with the same class distribution as the training dataset. Based on the test results, the training parameters are adjusted or training samples are supplemented until the test results meet the preset requirements. This avoids test bias caused by uneven class distribution in the test set and can promptly correct the model's shortcomings, solving problems such as overfitting, underfitting, or excessively high misclassification rates for some classes. This improves the model's practicality and robustness, enabling it to adapt to the needs of real-world waste classification scenarios.

[0053] This embodiment provides a waste sorting and disposal method. Please refer to it in conjunction with... Figure 2 This method includes: S21. Obtain images of the waste to be sorted.

[0054] S22. Determine multiple garbage features corresponding to the garbage based on the garbage image, wherein the garbage features include geometric features, color features, and texture features.

[0055] S23. Using the waste classification processing model and the waste features, the waste image is type-identified to obtain the classification result of the waste image. The waste classification processing model is obtained from the above-described waste classification processing model construction method embodiment.

[0056] In a specific example, a real-time image of the waste to be classified can be obtained using a high-definition camera or image acquisition device as the waste image; then, the same method as step S12 in the above embodiment is performed on the image to extract waste features, and these feature vectors are input into a waste classification processing model pre-trained according to steps S11-S15 of the above method. The model reasons along the trained rule path, judging layer by layer from the initial node, and finally reaches a certain leaf node and outputs the waste type and recognition confidence corresponding to the node, thereby completing the automatic classification and recognition of the current waste.

[0057] This application provides a device for constructing a waste sorting and treatment model. Please refer to the embodiments thereof. Figure 3 The device 300 includes a first acquisition module 301, a feature determination module 302, a parameter acquisition module 303, a first training module 304, and a second training module 305.

[0058] Specifically, the first acquisition module 301 is used to acquire multiple training image samples in the training dataset, wherein the training image samples are labeled with garbage type tags; the feature determination module 302 is used to determine the corresponding garbage features based on the training image samples, wherein the garbage features include geometric features, color features, and texture features; the parameter acquisition module 303 is used to acquire training parameters, wherein the training parameters include a preset node purity index, a maximum depth, a minimum number of split samples, and a minimum number of leaf node samples; the first training module 304 is used to execute a first process starting from the initial node: traversing each feature and multiple candidate split thresholds corresponding to the feature, calculating the node purity value of each combination of feature candidate split thresholds based on the garbage type tags, and selecting the one that best matches the target node purity. The node purity preset index is used as the first combination of the feature candidate splitting threshold corresponding to the node purity value. Based on the first combination, two child nodes are split from the current node. The initial node contains all training image samples of the training dataset. The feature candidate splitting threshold combination includes a feature and a candidate splitting threshold corresponding to the feature. The second training module 305 is used to repeatedly execute the first process for each child node until at least one of the maximum depth, the minimum number of splitting samples, and the minimum number of leaf nodes is satisfied. The current node at the time of stopping is recorded as a leaf node, and the garbage type with the most samples in the leaf node is used as the output result of the leaf node to obtain the garbage classification processing model.

[0059] It should be noted that the above-mentioned waste sorting and treatment model construction device can execute the waste sorting and treatment model construction method provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in the waste sorting and treatment model construction device embodiments can be found in the waste sorting and treatment model construction method provided in the embodiments of this application.

[0060] like Figure 4 As shown, Figure 4 This is a schematic diagram of the hardware structure of the electronic device 500 provided in an embodiment of the present invention. The electronic device 500 includes one or more processors 501 and a memory 502. Figure 4 Taking a processor 501 as an example, the processor 501 and the memory 502 can be connected via a bus or other means. Figure 4 Taking the example of a connection between China and Israel via a bus.

[0061] The memory 501, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the waste sorting and processing model construction method in the embodiments of the present invention. The processor 501 executes various functional applications and data processing of the electronic device 500 by running the non-volatile software programs, non-volatile computer-executable programs, and modules stored in the memory 502, thereby implementing the waste sorting and processing model construction method or the waste sorting and processing method in the above method embodiments.

[0062] Memory 502 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the waste sorting and processing model building apparatus. Furthermore, memory 502 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 502 may optionally include memory remotely located relative to processor 501, which can be connected to the waste sorting and processing model building apparatus via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0063] The one or more modules are stored in the memory 502, and when executed by the one or more processors 501, they execute the waste sorting and processing model construction method or the waste sorting and processing method in the above method embodiments.

[0064] The above-described product can execute the waste sorting and processing model construction method or waste sorting and processing method provided in the embodiments of the present invention, and has the corresponding functional modules and beneficial effects for executing the waste sorting and processing model construction method or waste sorting and processing method. Technical details not described in detail in this embodiment can be found in the waste sorting and processing model construction method provided in the embodiments of the present invention.

[0065] The electronic device 500 of this invention can exist in various forms, including but not limited to servers, server clusters, cloud servers, and other electronic devices with data interaction functions.

[0066] This invention also provides a non-volatile computer storage medium storing computer-executable instructions that are executed by one or more processors, for example... Figure 4 One of the processors 501 can enable the above one or more processors to execute the method for constructing the waste sorting and processing model or the waste sorting and processing method in any of the above method embodiments.

[0067] This invention also provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium. The computer program includes program instructions, which, when executed by the electronic device, cause the electronic device to perform the waste sorting and processing model construction method or the waste sorting and processing method described in the above embodiments.

[0068] The device or equipment embodiments described above are merely illustrative. The unit modules described as separate components may or may not be physically separate. The components shown as module units may or may not be physical units; that is, they may be located in one place or distributed across multiple network module units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0069] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0070] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above. For the sake of brevity, they are not provided in detail; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method for constructing a waste sorting and treatment model, characterized in that, include: Obtain multiple training image samples from the training dataset, wherein the training image samples are labeled with garbage type tags; Based on the training image samples, corresponding garbage features are determined, wherein the garbage features include geometric features, color features, and texture features; Obtain training parameters, which include a preset node purity index, maximum depth, minimum number of split samples, and minimum number of leaf node samples. Starting from the initial node, the first process is executed: traversing each feature and multiple candidate splitting thresholds corresponding to the feature, calculating the node purity value of each combination of feature candidate splitting thresholds based on the garbage type label, and selecting the feature candidate splitting threshold corresponding to the node purity value that best meets the preset node purity index as the first combination, and splitting the current node into two child nodes based on the first combination; wherein, the initial node contains all training image samples of the training dataset, and the combination of feature candidate splitting thresholds includes one feature and a candidate splitting threshold corresponding to the feature; The first process described above is repeated for each child node until at least one of the maximum depth, the minimum number of split samples, and the minimum number of samples in the leaf node is satisfied. The current node at the time of stopping is recorded as a leaf node, and the waste type with the most samples in the leaf node is used as the output result of the leaf node to obtain the waste classification and processing model.

2. The method according to claim 1, characterized in that, The step of determining the corresponding garbage features based on the training image samples includes: Obtain the grayscale image and the outline of the garbage subject corresponding to the training image sample; The geometric features of the corresponding waste body are determined by combining the outline of the waste body. The geometric features include aspect ratio, density, roundness, rectangularity and outline complexity. Based on the outline of the main body of the waste, the color features of the corresponding main body of the waste are extracted according to the color space. The color features include average hue, average saturation, white area ratio, highlight area ratio and color consistency index. The texture features of the corresponding garbage subject are determined by combining the grayscale image, and the texture features include texture entropy and texture contrast.

3. The method according to claim 2, characterized in that, The step of obtaining the grayscale image and the outline of the garbage subject corresponding to the training image sample includes: Adjust the size of the training image samples to conform to the preset pixel size; The adjusted training image samples are then denoised. Obtain the grayscale and binary images of the training image samples after noise removal; The binary image is morphologically optimized, including removing noise points and filling holes; Based on the optimized binary image, the contour is extracted, and the contour with the largest area is determined as the main contour of the garbage.

4. The method according to claim 1, characterized in that, The preset index for node purity is the Gini index, which is calculated as follows: For the current node, calculate the percentage of samples in each category; The Gini index of the current node is obtained by subtracting the sum of squares of the proportions of samples in each category from the first subtraction.

5. The method according to claim 4, characterized in that, The step of selecting the feature candidate splitting threshold combination corresponding to the node purity value that best matches the preset node purity index as the first combination includes: For each candidate split threshold, calculate the weighted average Gini index of the two child nodes after the split; The Gini gain is obtained by calculating the difference between the Gini index of the current node before the split and the weighted average Gini index. The feature candidate splitting threshold combination with the largest Gini gain is selected as the first combination.

6. The method according to any one of claims 1-5, characterized in that, The method further includes: Obtain multiple test image samples from the test dataset and determine the garbage feature corresponding to each test image sample, wherein the proportion of test image samples of each type of garbage in the test dataset is the same as the proportion of training image samples of each type of garbage in the training dataset; The waste sorting and processing model was tested based on the test dataset to obtain test results; If the test results do not meet the preset result indicators, adjust the training parameters or add new training image samples and retrain and test the waste classification and processing model until the test results meet the preset results.

7. The method according to claim 1, characterized in that, The method for determining the candidate splitting threshold includes: For the current garbage feature, sort the feature values ​​of all training image samples in the current node in ascending order; The median of two adjacent feature values ​​is used as the candidate split threshold for the current garbage feature.

8. A method for sorting and disposing of waste, characterized in that, include: Obtain images of the waste to be sorted; Based on the garbage image, multiple garbage features corresponding to the garbage are determined, wherein the garbage features include geometric features, color features, and texture features; Using the waste classification and processing model according to any one of claims 1-7, and the waste features, the waste image is type-identified to obtain the classification result of the waste image.

9. A device for constructing a waste sorting and treatment model, characterized in that, include: The first acquisition module is used to acquire multiple training image samples in the training dataset, wherein the training image samples are labeled with garbage type tags; The feature determination module is used to determine the corresponding garbage features based on the training image samples, wherein the garbage features include geometric features, color features, and texture features; The parameter acquisition module is used to acquire training parameters, which include a preset node purity index, maximum depth, minimum number of split samples, and minimum number of leaf node samples. The first training module is used to execute a first process starting from the initial node: traversing each feature and multiple candidate splitting thresholds corresponding to the feature, calculating the node purity value of each combination of feature candidate splitting thresholds based on the garbage type label, and selecting the feature candidate splitting threshold corresponding to the node purity value that best meets the preset node purity index as the first combination, and splitting two child nodes based on the current node according to the first combination; wherein, the initial node contains all training image samples of the training dataset, and the combination of feature candidate splitting thresholds includes one feature and a candidate splitting threshold corresponding to the feature; The second training module is used to repeatedly execute the first process described above for each of the child nodes until at least one of the maximum depth, the minimum number of split samples, and the minimum number of samples in the leaf node is satisfied, and then stops. The current node at the time of stopping is recorded as a leaf node, and the garbage type with the most samples in the leaf node is used as the output result of the leaf node to obtain the garbage classification and processing model.

10. An electronic device, characterized in that, include: At least one processor and memory; The memory is coupled to the processor and is used to store instructions or programs that, when executed by the at least one processor, cause the at least one processor to perform the method as described in any one of claims 1-8.