Equipment control method and system based on hierarchical feature optimization and data detection, terminal and storage medium

By optimizing hierarchical features and performing data inspection, the problem of models ignoring scarce samples due to uneven data distribution was solved, resulting in more accurate defect detection and equipment management.

CN122045807APending Publication Date: 2026-05-15深圳开鸿数字产业发展有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
深圳开鸿数字产业发展有限公司
Filing Date
2025-12-26
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

In existing technologies, the uneven distribution of data leads to the model ignoring scarce samples, resulting in inaccurate defect detection results. Furthermore, data augmentation techniques struggle to generate realistic rare defect variants, affecting the model's defect detection performance.

Method used

By optimizing hierarchical features and data detection, and employing methods such as category-aware resampling, intra-group weight adjustment, hybrid activation functions, and spatiotemporal decision functions, the model's sampling and classification of scarce samples are optimized to generate accurate defect decision results.

Benefits of technology

It increases the sampling rate of rare defect samples, improves the model's accuracy in defect analysis and the equipment's adaptive management capabilities, and outputs highly targeted decision results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122045807A_ABST
    Figure CN122045807A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of equipment control, and discloses an equipment control method and system based on hierarchical feature optimization and data detection, a terminal and a storage medium, and the method comprises the steps: carrying out the category perception resampling of original data, and obtaining classification samples corresponding to different probabilities; performing grouping and defect classification on the classification samples according to the probability to obtain defect categories; and respectively transmitting the defect categories to a plurality of target equipment nodes for fusion, generating a corresponding decision result according to each fusion feature, and controlling the corresponding target equipment through the decision result. According to the method, the sampling rate of rare defect samples is improved by optimizing the hierarchical features of the data, so that the model can perform global sampling on the samples, the practicability of the data is improved, and the defect analysis accuracy is improved through the space-time constraint decision function, so that a targeted decision result is output to control target equipment; and the self-adaptive management process of the equipment is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of equipment control technology, and in particular to an equipment control method, system, terminal, and computer-readable storage medium based on hierarchical feature optimization and data detection. Background Technology

[0002] In key areas such as industrial quality inspection, medical image analysis, and building safety monitoring, automated defect detection systems are facing a severe challenge of uneven data distribution.

[0003] Traditional loss functions (such as cross-entropy) can lead to an imbalance in sample weighting on long-tailed data, causing model parameters to tilt towards the head category and significantly reducing the activation probability of neurons corresponding to tail features. More seriously, the scarcity of rare defect samples hinders the model from learning their differentiated features, while data augmentation techniques (such as rotation and cropping) struggle to generate physically realistic rare defect variants, further exacerbating the model's neglect of tail categories.

[0004] Therefore, existing technologies still need to be improved and developed. Summary of the Invention

[0005] The main objective of this invention is to provide a device control method, system, terminal, and computer-readable storage medium based on hierarchical feature optimization and data detection, aiming to solve the problem in the prior art where scarce samples are ignored during sample sampling, resulting in inaccurate model output results.

[0006] To achieve the above objectives, the present invention provides a device control method based on hierarchical feature optimization and data detection, the device control method based on hierarchical feature optimization and data detection comprising the following steps: Multiple raw data sets are acquired, and each raw data set is resampled using category-aware methods to obtain all classification samples corresponding to different probabilities. All the classified samples are grouped according to all the probabilities, and different model optimization processes are used to classify the classified samples in different groups for defects to obtain the corresponding defect categories; Each defect category is transmitted to multiple target device nodes for fusion, and a corresponding decision result is generated based on each fusion feature. Calculate the similarity between the historical data of each target device node and the corresponding decision result. Based on the similarity and the probability corresponding to the decision result, output the decision result according to a preset protocol and control the corresponding target device through the decision result.

[0007] Optionally, the device control method based on hierarchical feature optimization and data detection, wherein acquiring multiple raw data sets and performing category-aware resampling on each raw data set to obtain all classification samples corresponding to different probabilities specifically includes: Multiple raw data sets are acquired, and each raw data set is preprocessed to obtain the corresponding initial sample; By using a dynamic sampling function to resample initial samples with different probabilities, corresponding classification samples can be obtained.

[0008] Optionally, the device control method based on hierarchical feature optimization and data detection, wherein the resampling of initial samples with different probabilities using a dynamic sampling function to obtain corresponding classification samples specifically includes: All initial samples with a probability higher than the preset probability are defined as high-probability initial samples, and all initial samples with a probability not higher than the preset probability are defined as low-probability initial samples. A dynamic sampling function is constructed based on the number of high-probability initial samples and the number of low-probability initial samples: ; in, This represents the probability distribution of a high-probability initial sample or a low-probability initial sample. express i The number of class samples, express j The number of class samples, Indicates the first adjustment parameter; Resample all the high-probability initial samples and all the low-probability initial samples according to the dynamic sampling function to obtain the corresponding classification samples: ; in, X Represents the original data. H , W and C These represent the image height, width, and number of channels of the original data, respectively. Indicates the initial sample. E This indicates the resampling process. Indicates the first i A number of categorized samples.

[0009] Optionally, the device control method based on hierarchical feature optimization and data detection, wherein grouping all the classification samples according to all the probabilities and using different model optimization processes to classify the classification samples in different groups to obtain the corresponding defect categories, specifically includes: Multiple defect sample data are acquired, and all the defect sample data are input into a grouping model. The grouping model groups the defect sample data with different probabilities to obtain multiple defect data groups, and constructs corresponding intra-group weights based on the number of samples in each defect data group. A standard cross-entropy loss function and a focus loss function are constructed based on the weights within each group and the classification probability of the defective data group. The grouping model is then optimized based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model. All the classified samples are input into the optimized grouping model for grouping, and multiple data groups are output. The defect classification model is optimized using each defect data group and its corresponding intra-group weights. The optimized defect classification model is then used to classify defects in all data groups and output the corresponding defect categories.

[0010] Optionally, the device control method based on hierarchical feature optimization and data detection, wherein acquiring multiple defect sample data, inputting all the defect sample data into a grouping model, the grouping model grouping the defect sample data with different probabilities to obtain multiple defect data groups, and constructing corresponding intra-group weights based on the number of samples in each defect data group, specifically includes: Multiple defect sample data are acquired, and all defect sample data are input into a grouping model. The grouping model divides all defect sample data into multiple defect data groups based on the frequency of occurrence of each type of defect sample data using a grouping mapping function, and outputs the results. ; in, This represents the result of the function mapping. c Indicates the category of defect sample data. Indicates the first data group. Indicates the second data group. Indicates the third data group. This represents the fourth data group. Defect sample data c Frequency; For each defect sample data, a corresponding in-group weight is constructed based on the frequency of each type of defect sample data in the corresponding defect data group: ; in, Represents categorized samples i Within-group weights, Indicates defect data group k , Represents categorized samples iThe reciprocal of the frequency, Represents categorized samples j The reciprocal of the frequency.

[0011] Optionally, the device control method based on hierarchical feature optimization and data detection, wherein constructing a standard cross-entropy loss function and a focus loss function based on the weights within each group and the classification probability of the defective data group, and optimizing the grouping model based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model, specifically includes: Based on the weights within each group and the classification probability of each defective data group, a standard cross-entropy loss function is constructed: ; in, Represents the standard cross-entropy loss function. Indicates the first i A defective data set, This indicates that the defect sample data belongs to The classification probability; Based on the classification probability of each defective data group, a focus loss function is constructed: ; in, Represents the focus loss function. This indicates the second adjustment parameter; A hybrid activation function is constructed based on the standard cross-entropy loss function and the focus loss function, and the grouping model is optimized using the hybrid activation function to obtain the optimized grouping model: ; Where L represents the hybrid activation function, Indicates the contribution parameter. This represents the result of the function mapping. Indicates the first data group. This indicates the fourth data group.

[0012] Optionally, the device control method based on hierarchical feature optimization and data detection, wherein optimizing the defect classification model using each defect data group and its corresponding intra-group weights, and classifying all data groups using the optimized defect classification model to output the corresponding defect category, specifically includes: Obtain the intra-class features of each defect sample data and the class center distance from each defect sample data to the corresponding defect data group, and construct a center loss function based on each intra-class feature and the corresponding class center distance: ; in, Represents the central loss function. m This indicates the number of defect sample data in the defect data group. Indicates the first i In-class features of each defect sample data Indicates defect data group The first in i The distance from each defective sample data point to the class center; Based on the inter-class angular interval of each of the defective data groups, a large-interval loss function is constructed: ; in, Represents the large-margin loss function. s Indicates the scaling factor. m Indicates angular intervals, e Represents the natural constant. express, express, Indicates the first i Inter-class angular intervals of defective data groups; The defect classification model is optimized using the center loss function and the large margin loss function, and all the data sets are input into the optimized defect classification model. For each categorized sample in each of the data sets, the optimized defect classification model determines the defect category of the categorized sample based on the nearest class center and outputs: ; in, Indicates the predicted defect category, Indicates the first q Within-class features of each classified sample, Indicates the first element in the current data set. k The distance from each defective sample data point to the class center.

[0013] Optionally, the device control method based on hierarchical feature optimization and data detection, wherein transmitting each defect category to multiple target device nodes for fusion, and generating a corresponding decision result based on each fused feature, specifically includes: Each of the aforementioned defect categories is transmitted to the corresponding target device node; For each target device node, the grouping optimization feature vector and metric learning feature vector of all classification samples corresponding to each defect category input into the target device node are extracted, and the grouping optimization feature vector and the metric learning feature vector are fused using the fusion function in the gating mechanism to obtain the fused feature corresponding to each defect category: ; in, h Indicates fusion features, Indicates a gating mechanism. Indicates the gating weight, This represents the optimized feature vector for grouping. This represents the metric for learning the feature vector; The accelerated fusion matrix of the target device node is used to analyze each fusion feature, and the probability of the decision corresponding to each defect category is output: ; in, This indicates that given input features are fused. x Output decision results under the following circumstances y The probability, This represents the activation function. Represents the accelerated fusion matrix; For each defect category, the decision with the highest probability is defined as the decision result for that defect category.

[0014] Optionally, the device control method based on hierarchical feature optimization and data detection, wherein calculating the similarity between the historical data of each target device node and the corresponding decision result, outputting the decision result according to a preset protocol based on the similarity and the probability corresponding to the decision result, and controlling the corresponding target device through the decision result, specifically includes: For each target device node, historical data of the target device node is obtained, and the historical location similarity of each decision result is determined based on the historical data. The probability of the decision outcome and the similarity to the historical location are analyzed using a spatiotemporal decision function: ; in, Represents the spatiotemporal decision function. Indicates the similarity of historical locations. b Indicates the location of the decision result. Indicates the location of historical data; If the rules are met, the decision result and the corresponding target device representation are packaged into a control command, and the control command is transmitted to the corresponding target device using a preset protocol to control the target device.

[0015] Furthermore, to achieve the above objectives, the present invention also provides a device control system based on hierarchical feature optimization and data detection, wherein the device control system based on hierarchical feature optimization and data detection includes: The frequency classification module is used to acquire multiple raw data and perform category-aware resampling on each raw data to obtain all classification samples corresponding to different probabilities; The defect classification module is used to group all the classification samples according to all the probabilities, and to classify the defects of the classification samples in different groups using different model optimization processes to obtain the corresponding defect categories. The decision generation module is used to transmit each defect category to multiple target device nodes for fusion, and generate a corresponding decision result based on each fusion feature. The decision output module is used to calculate the similarity between the historical data of each target device node and the corresponding decision result, and output the decision result according to a preset protocol based on the similarity and the probability corresponding to the decision result, and control the corresponding target device through the decision result.

[0016] The frequency classification module in the device control system based on hierarchical feature optimization and data detection includes: A data preprocessing unit is used to acquire multiple raw data, preprocess each raw data, and obtain a corresponding initial sample. The data resampling unit is used to resample initial samples with different probabilities using a dynamic sampling function to obtain corresponding classification samples.

[0017] The data resampling unit in the device control system based on hierarchical feature optimization and data detection includes: The sample definition subunit is used to define all initial samples with a probability higher than the preset probability as high-probability initial samples, and all initial samples with a probability not higher than the preset probability as low-probability initial samples. A sampling function construction subunit is used to construct a dynamic sampling function based on the number of high-probability initial samples and the number of low-probability initial samples. The probability classification subunit is used to resample all the high-probability initial samples and all the low-probability initial samples according to the dynamic sampling function to obtain the corresponding classification samples.

[0018] The defect classification module in the equipment control system based on hierarchical feature optimization and data detection includes: The defect sample acquisition unit is used to acquire multiple defect sample data, input all the defect sample data into the grouping model, the grouping model groups the defect sample data with different probabilities to obtain multiple defect data groups, and constructs corresponding intra-group weights according to the number of samples in each defect data group. The grouping model optimization unit is used to construct a standard cross-entropy loss function and a focus loss function based on the weights within each group and the classification probability of the defective data group, and to optimize the grouping model based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model; The sample classification unit is used to input all the classified samples into the optimized grouping model for grouping and output multiple data groups. The defect analysis unit is used to optimize the defect classification model using each defect data group and the corresponding intra-group weights, and to classify all data groups for defects using the optimized defect classification model, and output the corresponding defect category.

[0019] The defect sample acquisition unit in the equipment control system based on hierarchical feature optimization and data detection includes: The data mapping subunit is used to acquire multiple defect sample data, input all the defect sample data into the grouping model, and the grouping model divides all the defect sample data into multiple defect data groups according to the frequency of occurrence of each type of defect sample data through a grouping mapping function, and outputs the data. The weight construction subunit is used to construct a corresponding intra-group weight for each defect sample data based on the frequency of each defect sample data in the corresponding defect data group.

[0020] The device control system based on hierarchical feature optimization and data detection includes a grouping model optimization unit comprising: The first function construction subunit is used to construct a standard cross-entropy loss function based on the weights within each group and the classification probability of each defective data group. The second function construction subunit is used to construct a focus loss function based on the classification probability of each defective data group; The first model optimization subunit is used to construct a hybrid activation function based on the standard cross-entropy loss function and the focus loss function, and to optimize the grouping model using the hybrid activation function to obtain an optimized grouping model.

[0021] The defect analysis unit in the equipment control system based on hierarchical feature optimization and data detection includes: The third function construction subunit is used to obtain the intra-class features of each defect sample data and the class center distance from each defect sample data to the corresponding defect data group, and to construct a center loss function based on each intra-class feature and the corresponding class center distance. The fourth function construction subunit is used to construct a large-interval loss function based on the inter-class angular interval of each defect data group; The second model optimization subunit is used to optimize the defect classification model using the center loss function and the large margin loss function, and input all the data sets into the optimized defect classification model. The defect output subunit is used to determine the defect category of each classified sample in each data group based on the nearest class center of the classified sample, and output the result.

[0022] The decision generation module of the equipment control system based on hierarchical feature optimization and data detection includes: A data transmission unit is used to transmit each of the defect categories to the corresponding target device node; The feature fusion unit is used to extract, for each target device node, all classification samples corresponding to each defect category input to the target device node, the grouping optimization feature vector and the metric learning feature vector, and use the fusion function in the gating mechanism to fuse the grouping optimization feature vector and the metric learning feature vector to obtain the fused feature corresponding to each defect category; The decision probability analysis unit is used to analyze each of the fusion features using the accelerated fusion matrix of the target device node and output the probability of the decision corresponding to each defect category. The decision result judgment unit is used to define the decision with the highest probability for each defect category as the decision result for that defect category.

[0023] The decision output module of the device control system based on hierarchical feature optimization and data detection includes: The historical data acquisition unit is used to acquire historical data of each target device node and determine the historical location similarity of each decision result based on the historical data. The similarity comparison unit is used to analyze the probability of the decision result and the similarity of the historical location using a spatiotemporal decision function; The device control unit is configured to, if the rules are met, package the decision result and the corresponding target device representation into a control command, and transmit the control command to the corresponding target device according to a preset protocol, so as to control the target device.

[0024] Furthermore, to achieve the above objectives, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a device control program based on hierarchical feature optimization and data detection stored in the memory and executable on the processor, wherein when the device control program based on hierarchical feature optimization and data detection is executed by the processor, it implements the steps of the device control method based on hierarchical feature optimization and data detection as described above.

[0025] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a device control program based on hierarchical feature optimization and data detection, and the device control program based on hierarchical feature optimization and data detection, when executed by a processor, implements the steps of the device control method based on hierarchical feature optimization and data detection as described above.

[0026] In this invention, multiple raw data sets are acquired, and each set is resampled using category-aware methods to obtain all categorized samples with different probabilities. These categorized samples are then grouped according to their probabilities, and different model optimization processes are used to classify defects in each group, resulting in corresponding defect categories. Each defect category is then transmitted to multiple target device nodes for fusion, and a corresponding decision result is generated based on each fusion feature. The similarity between the historical data of each target device node and the corresponding decision result is calculated. Based on the similarity and the probability corresponding to the decision result, the decision result is output according to a preset protocol, and the decision result controls the corresponding target device. This invention improves the sampling rate of rare defect samples through hierarchical feature optimization of the data, enabling the model to perform global sampling and improving the data's usability. The spatiotemporal constraint decision function enhances the accuracy of defect analysis, thereby outputting targeted decision results to control target devices and improving the adaptive management process of the devices. Attached Figure Description

[0027] Figure 1 This is a first flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 2 This is a second flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 3 This is a third flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 4 This is a fourth flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 5 This is the fifth flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 6 This is the sixth flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 7This is the seventh flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 8 This is the eighth flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 9 This is the ninth flowchart of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 10 This is a detailed structural diagram of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention. Figure 11 This is another specific principle structure diagram of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 12 This is an overall flowchart of a preferred embodiment of the device control system based on hierarchical feature optimization and data detection of the present invention; Figure 13 This is a flowchart of the hierarchical feature optimization process, which is a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention. Figure 14 This is a flowchart of the decision output of a preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention; Figure 15 This is a structural diagram of a preferred embodiment of the terminal of the present invention. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0029] The preferred embodiment of the device control method based on hierarchical feature optimization and data detection of the present invention, such as... Figure 1 As shown, the device control method based on hierarchical feature optimization and data detection includes the following steps: Step S10: Obtain multiple raw data sets and perform category-aware resampling on each raw data set to obtain all classification samples corresponding to different probabilities.

[0030] In this case, the long-tail distribution of data often exhibits a situation where a few categories (such as normal samples) constitute the vast majority, while a large number of important but rare categories (such as defects and anomalies) have very few samples. This leads to a high bias in the model during training towards the main categories, resulting in extremely weak discrimination ability towards the tail categories. Standard deep learning models tend to favor the main categories during training, leading to extremely low recall rates for the tail categories. Furthermore, the model may frequently fail to recognize, understand, or correctly identify key targets, directly impacting production and safety. Therefore, the device control method based on hierarchical feature optimization and data detection disclosed in this invention first improves the sampling probability of absent samples by performing hierarchical optimization on the data, thereby ensuring the completeness of sample sampling.

[0031] Specifically, such as Figure 2 As shown, in step S101, multiple raw data are obtained, and each raw data is preprocessed to obtain the corresponding initial sample.

[0032] Step S102: Use a dynamic sampling function to resample the initial samples with different probabilities to obtain the corresponding classification samples.

[0033] Step S20: Group all the classified samples according to all the probabilities, and use different model optimization processes to classify the classified samples in different groups for defects to obtain the corresponding defect categories.

[0034] In one of the embodiments disclosed in this invention, the original industrial image is first resampled using category perception, which increases the sampling probability of low-probability samples, thereby solving the problem of scarce equipment defect samples and improving sample diversity and completeness.

[0035] Furthermore, such as Figure 3 As shown, in step S1021, all initial samples with a probability higher than the preset probability are defined as high-probability initial samples, and all initial samples with a probability not higher than the preset probability are defined as low-probability initial samples.

[0036] Step S1022: Construct a dynamic sampling function based on the number of high-probability initial samples and the number of low-probability initial samples: ; in, This represents the probability distribution of a high-probability initial sample or a low-probability initial sample. express i The number of class samples, express j The number of class samples, This indicates the first adjustment parameter.

[0037] Step S1023: Resample all the high-probability initial samples and all the low-probability initial samples according to the dynamic sampling function to obtain the corresponding classification samples: ; in, X Represents the original data. H , W and C These represent the image height, width, and number of channels of the original data, respectively. Indicates the initial sample. E This indicates the resampling process. Indicates the first i A number of categorized samples.

[0038] The core idea of ​​category-aware resampling is to adjust the sampling probability of samples of different categories according to their frequency characteristics. When resampling the original data, the quality of the image is improved through feature preprocessing to obtain the corresponding initial samples. Both high-probability and low-probability initial samples follow a probability distribution.

[0039] Furthermore, the sampling probability is adjusted for different categories. When a category is low-frequency, meaning there are few samples, the sampling probability of that category calculated by the dynamic sampling function will be increased by a certain factor. This increases the likelihood of low-frequency categories being selected in subsequent sampling processes, thereby compensating for the scarcity of equipment defect samples to some extent. This allows the model to learn the feature information of low-frequency categories (usually defect categories) more fully during training, improving the model's ability to identify equipment defects and other performance aspects.

[0040] Specifically, such as Figure 4 As shown, in step S201, multiple defect sample data are obtained, and all the defect sample data are input into the grouping model. The grouping model groups the defect sample data with different probabilities to obtain multiple defect data groups, and constructs the corresponding intra-group weights according to the number of samples in each defect data group.

[0041] Furthermore, such as Figure 5 As shown, in step S2011, multiple defect sample data are acquired, and all the defect sample data are input into a grouping model. The grouping model divides all the defect sample data into multiple defect data groups according to the frequency of occurrence of each type of defect sample data through a grouping mapping function, and outputs: ; in, This represents the result of the function mapping. c Indicates the category of defect sample data. Indicates the first data group. Indicates the second data group. Indicates the third data group. This represents the fourth data group. Defect sample data c The frequency of.

[0042] Step S2012: For each defect sample data, construct a corresponding intra-group weight based on the frequency of each type of defect sample data in the corresponding defect data group: ; in, Represents categorized samples i Within-group weights, Indicates defect data group k , Represents categorized samples i The reciprocal of the frequency, Represents categorized samples j The reciprocal of the frequency.

[0043] In processing the dataset related to equipment defect categories, a specific strategy was adopted to address the issue of imbalanced sample sizes across different categories. In the embodiments disclosed in this invention, samples from 1203 equipment defect categories were collected and divided into four defect sample data groups. Within each group, an inverse sample frequency weighting method was used to balance the gradients. This weighting calculation ensures that categories with fewer samples receive a relatively larger influence during training, thereby balancing the contributions of different categories to model training.

[0044] Step S202: Construct a standard cross-entropy loss function and a focus loss function based on the weights within each group and the classification probability of the defective data group. Optimize the grouping model based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model.

[0045] Furthermore, such as Figure 6 As shown, in step S2021, a standard cross-entropy loss function is constructed based on the weights within each group and the classification probability of each defective data group: ; in, Represents the standard cross-entropy loss function. Indicates the first i A defective data set, This indicates that the defect sample data belongs to The classification probability.

[0046] Step S2022: Construct a focus loss function based on the classification probability of each defective data group: ; in, Represents the focus loss function. This indicates the second adjustment parameter.

[0047] Different loss function strategies were adopted to address the characteristics of different sample size groups. For the low-frequency group (groups with fewer samples), Focal Loss was used to enhance the learning of difficult samples. This loss function allows the model to focus more on samples that are difficult to classify correctly, improving the model's ability to identify difficult samples in low-frequency categories.

[0048] Furthermore, for high-frequency groups (groups with a large number of samples), the standard cross-entropy loss function is retained to ensure the stability of model training and avoid affecting the overall performance of the model due to over-adjustment of high-frequency categories.

[0049] Step S2023: Construct a hybrid activation function based on the standard cross-entropy loss function and the focus loss function, and optimize the grouping model using the hybrid activation function to obtain an optimized grouping model: ; Where L represents the hybrid activation function, Indicates the contribution parameter. This represents the result of the function mapping. Indicates the first data group. This indicates the fourth data group.

[0050] In this study, based on the construction of the standard cross-entropy loss function and the focus loss function, the loss contribution of different groups during the training process can be coordinated by further restricting the two functions, thereby further optimizing the training effect of the model. This approach effectively solves the problem of imbalance of equipment defect category samples by using strategies such as grouping, intra-group weighting, and different loss functions for different groups, which helps to improve the model's recognition performance of various equipment defects.

[0051] Step S203: Input all the classified samples into the optimized grouping model for grouping, and output multiple data groups.

[0052] Step S204: Optimize the defect classification model using each defect data group and its corresponding intra-group weights, and use the optimized defect classification model to classify defects in all data groups, outputting the corresponding defect categories.

[0053] In the embodiments disclosed in this invention, the feature learning process of the model is optimized by using a center loss function and a standard cross-entropy loss function.

[0054] Furthermore, such as Figure 7 As shown, in step S2041, the intra-class features of each defect sample data and the class center distance from each defect sample data to the corresponding defect data group are obtained, and a center loss function is constructed based on each intra-class feature and the corresponding class center distance. ; in, Represents the central loss function. m This indicates the number of defect sample data in the defect data group. Indicates the first i In-class features of each defect sample data Indicates defect data group The first in i The distance from each defective sample data point to the class center.

[0055] The role of center loss is to compress the distance between intra-class features and class centers. For each sample's intra-class features and the distance to the class center of its class, minimizing the center loss function allows the features of samples of the same class to cluster more tightly around the class center in the feature space, thus enhancing the compactness of intra-class samples.

[0056] Step S2042: Construct a large-interval loss function based on the inter-class angular interval of each defect data group: ; in, Represents the large-margin loss function. s Indicates the scaling factor. m Indicates angular intervals, e Represents the natural constant. express, express, Indicates the first i The inter-class angular interval of the defective data group.

[0057] The cosine loss method aims to increase the inter-class angular spacing. Assume the inter-class angular spacing of the i-th defect data group is... Introducing angular spacing at this point allows the model to achieve greater angular spacing between features of different categories during the learning process, thus better distinguishing between them.

[0058] Step S2043: Optimize the defect classification model using the center loss function and the large margin loss function, and input all the data sets into the optimized defect classification model.

[0059] Step S2044: For each classified sample in each data group, the optimized defect classification model determines the defect category of the classified sample based on the nearest class center and outputs: ; in, Indicates the predicted defect category, Indicates the first q Within-class features of each classified sample, Indicates the first element in the current data set. k The distance from each defective sample data point to the class center.

[0060] In the deployment phase, this invention abandons the traditional Softmax decision-making method and instead uses the nearest class center decision. Specifically, for a sample feature to be classified, the distance (e.g., Euclidean distance) between it and each class center is calculated. Then, the class to which the sample belongs is determined based on the nearest class center. This decision-making method has advantages in classifying low-frequency defects such as welding bubbles because the number of low-frequency defect samples is small. Traditional Softmax decision may be affected by factors such as sample imbalance, while the nearest class center decision relies more on the similarity between the sample feature and the class center, and can classify low-frequency defects more accurately, effectively solving the problem of classification ambiguity. By optimizing feature learning through center loss and cosine loss in the training phase, and the nearest class center decision in the deployment phase, this strategy can improve the model's classification accuracy for low-frequency defects such as welding bubbles.

[0061] Step S30: Transmit each defect category to multiple target device nodes for fusion, and generate a corresponding decision result based on each fusion feature.

[0062] In the embodiments disclosed in this invention, when performing related computing tasks using edge devices, a specific feature fusion and computing acceleration strategy is adopted in order to efficiently process features and accelerate computation.

[0063] Specifically, such as Figure 8 As shown, in step S301, each defect category is transmitted to the corresponding target device node.

[0064] Step S302: For each target device node, extract the grouping optimization feature vector and metric learning feature vector of all classification samples corresponding to each defect category input into the target device node, and fuse the grouping optimization feature vector and the metric learning feature vector using the fusion function in the gating mechanism to obtain the fused feature corresponding to each defect category: ; in, hIndicates fusion features, Indicates a gating mechanism. Indicates the gating weight, This represents the optimized feature vector for grouping. This represents the feature vector learned by the metric.

[0065] Step S303: Analyze each fusion feature using the accelerated fusion matrix of the target device node, and output the probability of the decision corresponding to each defect category: ; in, This indicates that given input features are fused. x Output decision results under the following circumstances y The probability, This represents the activation function. This represents the accelerated fusion matrix.

[0066] For the input data, group optimization features and metric learning features are extracted. Group optimization features may be features obtained by dividing the data into different groups based on certain characteristics of the data and then optimizing them. They can reflect the characteristics of the data from the perspective of different groups. Metric learning features are features formed by learning the similarity or distance between data through metric learning methods, which helps to better characterize the internal structure of the data.

[0067] Furthermore, these two types of features are concatenated. First, the grouped optimized feature vector and the metric learning feature vector are obtained. These two feature vectors are then concatenated sequentially to form a longer feature vector that integrates the information carried by the two different types of features. Then, the concatenated features are fused using gating weights.

[0068] By using gating weights, the importance of different features in the fusion process is automatically adjusted according to the input features, thereby ensuring that the fused features can more reasonably integrate the information of grouped optimization features and metric learning features.

[0069] Step S304: For each defect category, the decision with the highest probability is defined as the decision result for that defect category.

[0070] After feature fusion is completed, the fusion matrix is ​​involved in computation. To accelerate this process, the NPU (Neural Processing Unit) of the HarmonyOS edge device is utilized. The NPU is a hardware unit specifically designed for high-performance computing tasks such as neural network computation, and it can efficiently handle operations such as matrix operations. Deploying the fusion matrix computation to the NPU can fully leverage its advantages such as parallel computing, greatly improving computational efficiency and reducing computation time.

[0071] Step S40: Calculate the similarity between the historical data of each target device node and the corresponding decision result. Based on the similarity and the probability corresponding to the decision result, output the decision result according to a preset protocol and control the corresponding target device through the decision result.

[0072] Specifically, for the detection target bound to the device ID, the decision is made by combining the current prediction confidence (i.e., the probability of the decision result predicted in the above steps) and the historical location similarity (IoU) to avoid false alarms caused by production line vibration.

[0073] Specifically, such as Figure 9 As shown, in step S401, for each target device node, historical data of the target device node is obtained, and the historical location similarity of each decision result is determined based on the historical data.

[0074] Step S402: Analyze the probability of the decision result and the similarity of the historical location using a spatiotemporal decision function: ; in, Represents the spatiotemporal decision function. Indicates the similarity of historical locations. b Indicates the location of the decision result. Indicates the location of historical data.

[0075] Step S403: If the rules are met, the decision result and the corresponding target device representation are packaged into a control command, and the control command is transmitted to the corresponding target device using a preset protocol to control the target device.

[0076] In the industrial production line equipment detection scenario disclosed in this invention, a specific decision-making mechanism is adopted to accurately detect targets bound to device IDs, avoid false alarms caused by factors such as production line vibration, and ensure that the output conforms to the OPC-UA protocol (a core communication protocol in the field of industrial automation). For detection targets bound to device IDs, the decision-making process comprehensively considers the current prediction confidence and historical location similarity. This reflects the reliability of the model for the current detection results; the higher the value, the more confident the model is in judging that the detected target belongs to a certain category. Historical location similarity, on the other hand, compares the current detected target location (i.e., ...) with the historical location similarity. b ) and the target location in the historical record (i.e. The intersection-union ratio (IUU) is used to compare the two positions and measure their similarity. The larger the IUU value, the closer the current target position is to the historical position.

[0077] when When the index is greater than 0.7 and the historical location similarity is greater than 0.5, the spatiotemporal decision function takes the value of 1, which means that a valid target has been detected. Otherwise, it is considered that no valid target has been detected (i.e., the value is 0). In this way, false alarms caused by production line vibration and other reasons can be effectively filtered out, thereby improving the accuracy of detection.

[0078] After making a testing decision, to ensure that the testing results can interact and integrate well with other industrial systems, the output results need to conform to the OPC-UA protocol. OPC-UA (OLE for Process Control - Unified Architecture) is an industrial communication protocol that provides a unified, open, and secure communication standard, enabling easy data exchange and interoperability between devices and applications from different manufacturers. Outputting testing results according to the OPC-UA protocol ensures that testing information can be accurately and efficiently transmitted to other relevant industrial systems, achieving information sharing and collaborative work.

[0079] Furthermore, such as Figure 10 As shown, based on the above-mentioned equipment control method based on hierarchical feature optimization and data detection, the present invention also provides an equipment control system based on hierarchical feature optimization and data detection, wherein the equipment control system based on hierarchical feature optimization and data detection includes: a frequency classification module 10, a defect classification module 20, a decision generation module 30, and a decision output module 40; The frequency classification module 10 is used to acquire multiple raw data and perform category-aware resampling on each raw data to obtain all classification samples corresponding to different probabilities. The defect classification module 20 is used to group all the classification samples according to all the probabilities, and to classify the defects of the classification samples in different groups using different model optimization processes to obtain the corresponding defect categories. The decision generation module 30 is used to transmit each defect category to multiple target device nodes for fusion, and generate a corresponding decision result based on each fusion feature. The decision output module 40 is used to calculate the similarity between the historical data of each target device node and the corresponding decision result, and output the decision result according to a preset protocol based on the similarity and the probability corresponding to the decision result, and control the corresponding target device through the decision result.

[0080] like Figure 11 As shown, another specific embodiment of the device control method and system based on hierarchical feature optimization and data detection in this invention includes: a frequency classification module 10, a defect classification module 20, a decision generation module 30, and a decision output module 40.

[0081] Among them, such as Figure 12 As shown, this invention performs category-aware resampling on the original data to obtain classification samples corresponding to different probabilities; groups and classifies the classification samples according to probabilities to obtain defect categories; transmits the defect categories to multiple target device nodes for fusion, generates corresponding decision results based on each fusion feature, and controls the corresponding target device through the decision results; by optimizing the hierarchical features of the data, the sampling rate of rare defect samples is improved, enabling the model to perform global sampling of samples, thus improving the practicality of the data; the spatiotemporal constraint decision function improves the accuracy of defect analysis, thereby outputting targeted decision results to control the target device and improving the adaptive management process of the device.

[0082] Specifically, the frequency classification module 10 includes: a data preprocessing unit 101 and a data resampling unit 102; The data preprocessing unit 101 is used to acquire multiple raw data, preprocess each raw data, and obtain a corresponding initial sample. The data resampling unit 102 is used to resample initial samples with different probabilities using a dynamic sampling function to obtain corresponding classification samples.

[0083] Furthermore, the data resampling unit 102 includes: a sample definition subunit 1021, a sampling function construction subunit 1022, and a probability classification subunit 1023; The sample definition subunit 1021 is used to define all initial samples with a probability higher than a preset probability as high-probability initial samples, and to define all initial samples with a probability not higher than a preset probability as low-probability initial samples. The sampling function construction subunit 1022 is used to construct a dynamic sampling function based on the number of high-probability initial samples and the number of low-probability initial samples. The probability classification subunit 1023 is used to resample all the high-probability initial samples and all the low-probability initial samples according to the dynamic sampling function to obtain the corresponding classification samples.

[0084] In the embodiments disclosed in this invention, low-frequency defects such as micron-level welding bubbles or gold wire misalignment can be detected in real time, and long-tail defect categories such as gear tooth surface scratches and bearing corrosion can be dynamically identified; the sampling rate of rare defect samples can be increased by 8-15 times through the dynamic sampling function of the hierarchical feature optimization module.

[0085] Furthermore, the defect classification module 20 includes: a defect sample acquisition unit 201, a grouping model optimization unit 202, a sample classification unit 203, and a defect analysis unit 204; The defect sample acquisition unit 201 is used to acquire multiple defect sample data, input all the defect sample data into a grouping model, the grouping model groups the defect sample data with different probabilities to obtain multiple defect data groups, and constructs corresponding intra-group weights according to the number of samples in each defect data group. The grouping model optimization unit 202 is used to construct a standard cross-entropy loss function and a focus loss function based on the weights within each group and the classification probability of the defective data group, and to optimize the grouping model based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model; The sample classification unit 203 is used to input all the classified samples into the optimized grouping model for grouping and output multiple data groups. The defect analysis unit 204 is used to optimize the defect classification model using each defect data group and the corresponding intra-group weights, and to classify all the data groups for defects using the optimized defect classification model, and output the corresponding defect category.

[0086] Furthermore, the defect sample acquisition unit 201 includes: a data mapping subunit 2011 and a weight construction subunit 2012; The data mapping subunit 2011 is used to acquire multiple defect sample data, input all the defect sample data into the grouping model, and the grouping model divides all the defect sample data into multiple defect data groups according to the frequency of occurrence of each type of defect sample data through a grouping mapping function, and outputs the data. The weight construction subunit 2012 is used to construct a corresponding intra-group weight for each defect sample data based on the frequency of each type of defect sample data in the corresponding defect data group.

[0087] Among them, such as Figure 13 As shown, in the embodiments disclosed in this invention, cross-camera collaborative identification of helmet wearing violations (high-frequency events) and intrusion behavior (low-frequency events) is used to detect sparse targets such as abnormal heat points in thermal imaging monitoring of power transmission and transformation facilities; the device status is classified into four groups of gradients for independent updates through an adaptive grouping mechanism, while the edge-side NPU can accelerate the extraction of basic features and reconstruct the metric features.

[0088] Furthermore, traditional Softmax classification is easily dominated by the gradient of high-frequency classes, while fixed threshold resampling causes high-frequency classes to underlearn and low-frequency classes to overfit. To address this issue, this invention optimizes by dynamic grouping and adds intra-group class weighting factors, which significantly improves the average accuracy of less common defects.

[0089] Furthermore, the grouping model optimization unit 202 includes: a first function construction subunit 2021, a second function construction subunit 2022, and a first model optimization subunit 2023; The first function construction subunit 2021 is used to construct a standard cross-entropy loss function based on the weights within each group and the classification probability of each defective data group. The second function construction subunit 2022 is used to construct a focus loss function based on the classification probability of each defective data group; The first model optimization subunit 2023 is used to construct a hybrid activation function based on the standard cross-entropy loss function and the focus loss function, and to optimize the grouping model using the hybrid activation function to obtain an optimized grouping model.

[0090] Furthermore, the defect analysis unit 204 includes: a third function construction subunit 2041, a fourth function construction subunit 2042, a second model optimization subunit 2043, and a defect output subunit 2044; The third function construction subunit 2041 is used to obtain the intra-class features of each defect sample data and the class center distance from each defect sample data to the corresponding defect data group, and to construct a center loss function based on each intra-class feature and the corresponding class center distance. The fourth function construction subunit 2042 is used to construct a large-interval loss function based on the inter-class angular interval of each defect data group; The second model optimization subunit 2043 is used to optimize the defect classification model using the center loss function and the large margin loss function, and input all the data sets into the optimized defect classification model; The defect output subunit 2044 is used to determine the defect category of each classified sample in each data group based on the nearest class center of the classified sample, and output the result.

[0091] In existing industrial environment feature discrimination, welding bubbles have an intra-class difference of 62% and an inter-class cosine similarity of >0.7, resulting in a false detection rate of 22%. Furthermore, environmental interference (such as oil stains and reflections) causes feature space confusion. In the embodiments disclosed in this invention, the intra-class distance is compressed by the center loss function and the inter-class angle is expanded by the large-interval loss function, which improves gear scratch detection by 22% and reduces intra-class distance by 37%.

[0092] Furthermore, the decision generation module 30 includes: a data transmission unit 301, a feature fusion unit 302, a decision probability analysis unit 303, and a decision result judgment unit 304; The data transmission unit 301 is used to transmit each defect category to the corresponding target device node; The feature fusion unit 302 is used to extract, for each target device node, all classification samples corresponding to each defect category input to the target device node, the grouping optimization feature vector and the metric learning feature vector, and use the fusion function in the gating mechanism to fuse the grouping optimization feature vector and the metric learning feature vector to obtain the fused feature corresponding to each defect category; The decision probability analysis unit 303 is used to analyze each of the fusion features using the accelerated fusion matrix of the target device node and output the probability of the decision corresponding to each defect category. The decision result judgment unit 304 is used to define the decision with the highest probability as the decision result of the defect category for each defect category.

[0093] Among them, such as Figure 14 As shown, for existing industrial real-time systems, cloud-based detection solutions have a latency of over 100ms, which is more than 10 times the production line's tolerance threshold. Furthermore, lightweight models sacrifice low-frequency defect samples, resulting in insufficient detection accuracy. In contrast, this invention optimizes feature vectors by outputting grouped features on the edge and supplements them with metric-learned feature vectors on the edge. Finally, it achieves feature fusion through an adaptive gating mechanism, which significantly reduces processing latency.

[0094] Furthermore, the decision output module 40 includes: a historical data acquisition unit 401, a similarity comparison unit 402, and a device control unit 403; The historical data acquisition unit 401 is used to acquire historical data of each target device node and determine the historical location similarity of each decision result based on the historical data. The similarity comparison unit 402 is used to analyze the probability of the decision result and the similarity of the historical position using a spatiotemporal decision function; The device control unit 403 is configured to, if the rules are met, package the decision result and the corresponding target device representation into a control command, and transmit the control command to the corresponding target device according to a preset protocol, so as to control the target device.

[0095] In the embodiments disclosed in this invention, for example, machine tool vibration data is synchronized and mechanical fault types are located (where high-frequency vibration modes account for 98% and rare faults account for 2%), or leaks and label misalignment defects with extremely low probability are detected in a sterile environment; the spatiotemporal constraint decision function can filter out 80% of equipment vibration false alarms by combining equipment location data, and directly encapsulate the detection results into OPC-UA protocol messages to transmit back to the equipment for adjustment.

[0096] Furthermore, such as Figure 15 As shown, based on the above-mentioned device control method and system based on hierarchical feature optimization and data detection, the present invention also provides a terminal, which includes a processor 100, a memory 200 and a display 300. Figure 15 Only some of the terminal components are shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0097] In some embodiments, the memory 200 may be an internal storage unit of the terminal, such as a hard disk or memory. In other embodiments, the memory 200 may be an external storage device of the terminal, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc. Further, the memory 200 may include both internal and external storage devices. The memory 200 is used to store application software and various types of data installed on the terminal, such as the program code installed on the terminal. The memory 200 can also be used to temporarily store data that has been output or will be output. In one embodiment, the memory 200 stores a device control program 400 based on hierarchical feature optimization and data detection, which can be executed by the processor 100 to implement the device control method based on hierarchical feature optimization and data detection in this application.

[0098] In some embodiments, the processor 100 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in the memory 200 or process data, such as executing the device control method based on hierarchical feature optimization and data detection.

[0099] In some embodiments, the display 300 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display 300 is used to display information on the terminal and to display a visual user interface. The components of the terminal communicate with each other via a system bus.

[0100] In one embodiment, when the processor 100 executes the device control program 400 based on hierarchical feature optimization and data detection in the memory 200, the following steps are performed: Multiple raw data sets are acquired, and each raw data set is resampled using category-aware methods to obtain all classification samples corresponding to different probabilities. All the classified samples are grouped according to all the probabilities, and different model optimization processes are used to classify the classified samples in different groups for defects to obtain the corresponding defect categories; Each defect category is transmitted to multiple target device nodes for fusion, and a corresponding decision result is generated based on each fusion feature. Calculate the similarity between the historical data of each target device node and the corresponding decision result. Based on the similarity and the probability corresponding to the decision result, output the decision result according to a preset protocol and control the corresponding target device through the decision result.

[0101] The step of acquiring multiple raw data sets and performing category-aware resampling on each raw data set to obtain all classification samples corresponding to different probabilities specifically includes: Multiple raw data sets are acquired, and each raw data set is preprocessed to obtain the corresponding initial sample; By using a dynamic sampling function to resample initial samples with different probabilities, corresponding classification samples can be obtained.

[0102] The step of resampling initial samples with different probabilities using a dynamic sampling function to obtain corresponding classification samples specifically includes: All initial samples with a probability higher than the preset probability are defined as high-probability initial samples, and all initial samples with a probability not higher than the preset probability are defined as low-probability initial samples. A dynamic sampling function is constructed based on the number of high-probability initial samples and the number of low-probability initial samples: ; in, This represents the probability distribution of a high-probability initial sample or a low-probability initial sample. express iThe number of class samples, express j The number of class samples, Indicates the first adjustment parameter; Resample all the high-probability initial samples and all the low-probability initial samples according to the dynamic sampling function to obtain the corresponding classification samples: ; in, X Represents the original data. H , W and C These represent the image height, width, and number of channels of the original data, respectively. Indicates the initial sample. E This indicates the resampling process. Indicates the first i A number of categorized samples.

[0103] Specifically, the step of grouping all the classified samples according to all the probabilities and using different model optimization processes to classify the classified samples in different groups to obtain the corresponding defect categories includes: Multiple defect sample data are acquired, and all the defect sample data are input into a grouping model. The grouping model groups the defect sample data with different probabilities to obtain multiple defect data groups, and constructs corresponding intra-group weights based on the number of samples in each defect data group. A standard cross-entropy loss function and a focus loss function are constructed based on the weights within each group and the classification probability of the defective data group. The grouping model is then optimized based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model. All the classified samples are input into the optimized grouping model for grouping, and multiple data groups are output. The defect classification model is optimized using each defect data group and its corresponding intra-group weights. The optimized defect classification model is then used to classify defects in all data groups and output the corresponding defect categories.

[0104] The process of acquiring multiple defect sample data, inputting all the defect sample data into a grouping model, and grouping the defect sample data with different probabilities into multiple defect data groups, and constructing corresponding intra-group weights based on the number of samples in each defect data group, specifically includes: Multiple defect sample data are acquired, and all defect sample data are input into a grouping model. The grouping model divides all defect sample data into multiple defect data groups based on the frequency of occurrence of each type of defect sample data using a grouping mapping function, and outputs the results. ; in, This represents the result of the function mapping. c Indicates the category of defect sample data. Indicates the first data group. Indicates the second data group. Indicates the third data group. This represents the fourth data group. Defect sample data c Frequency; For each defect sample data, a corresponding in-group weight is constructed based on the frequency of each type of defect sample data in the corresponding defect data group: ; in, Represents categorized samples i Within-group weights, Indicates defect data group k , Represents categorized samples i The reciprocal of the frequency, Represents categorized samples j The reciprocal of the frequency.

[0105] Specifically, the step of constructing a standard cross-entropy loss function and a focus loss function based on the weights within each group and the classification probability of the defective data group, and optimizing the grouping model based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model, includes: Based on the weights within each group and the classification probability of each defective data group, a standard cross-entropy loss function is constructed: ; in, Represents the standard cross-entropy loss function. Indicates the first i A defective data set, This indicates that the defect sample data belongs to The classification probability; Based on the classification probability of each defective data group, a focus loss function is constructed: ; in, Represents the focus loss function. This indicates the second adjustment parameter; A hybrid activation function is constructed based on the standard cross-entropy loss function and the focus loss function, and the grouping model is optimized using the hybrid activation function to obtain the optimized grouping model: ; Where L represents the hybrid activation function, Indicates the contribution parameter. This represents the result of the function mapping. Indicates the first data group. This indicates the fourth data group.

[0106] Specifically, the step of optimizing the defect classification model using each defect data group and its corresponding intra-group weights, and then using the optimized defect classification model to classify defects in all data groups and output the corresponding defect categories, includes: Obtain the intra-class features of each defect sample data and the class center distance from each defect sample data to the corresponding defect data group, and construct a center loss function based on each intra-class feature and the corresponding class center distance: ; in, Represents the central loss function. m This indicates the number of defect sample data in the defect data group. Indicates the first i In-class features of each defect sample data Indicates defect data group The first in i The distance from each defective sample data point to the class center; Based on the inter-class angular interval of each of the defective data groups, a large-interval loss function is constructed: ; in, Represents the large-margin loss function. s Indicates the scaling factor. m Indicates angular intervals, e Represents the natural constant. express, express, Indicates the first i Inter-class angular intervals of defective data groups; The defect classification model is optimized using the center loss function and the large margin loss function, and all the data sets are input into the optimized defect classification model. For each categorized sample in each of the data sets, the optimized defect classification model determines the defect category of the categorized sample based on the nearest class center and outputs: ; in, Indicates the predicted defect category, Indicates the first q Within-class features of each classified sample, Indicates the first element in the current data set. k The distance from each defective sample data point to the class center.

[0107] Specifically, the step of transmitting each defect category to multiple target device nodes for fusion, and generating a corresponding decision result based on each fusion feature, includes: Each of the aforementioned defect categories is transmitted to the corresponding target device node; For each target device node, the grouping optimization feature vector and metric learning feature vector of all classification samples corresponding to each defect category input into the target device node are extracted, and the grouping optimization feature vector and the metric learning feature vector are fused using the fusion function in the gating mechanism to obtain the fused feature corresponding to each defect category: ; in, h Indicates fusion features, Indicates a gating mechanism. Indicates the gating weight, This represents the optimized feature vector for grouping. This represents the metric for learning the feature vector; The accelerated fusion matrix of the target device node is used to analyze each fusion feature, and the probability of the decision corresponding to each defect category is output: ; in, This indicates that given input features are fused. x Output decision results under the following circumstances y The probability, This represents the activation function. Represents the accelerated fusion matrix; For each defect category, the decision with the highest probability is defined as the decision result for that defect category.

[0108] Specifically, the step of calculating the similarity between the historical data of each target device node and the corresponding decision result, outputting the decision result according to a preset protocol based on the similarity and the probability corresponding to the decision result, and controlling the corresponding target device through the decision result includes: For each target device node, historical data of the target device node is obtained, and the historical location similarity of each decision result is determined based on the historical data. The probability of the decision outcome and the similarity to the historical location are analyzed using a spatiotemporal decision function: ; in, Represents the spatiotemporal decision function. Indicates the similarity of historical locations. b Indicates the location of the decision result. Indicates the location of historical data; If the rules are met, the decision result and the corresponding target device representation are packaged into a control command, and the control command is transmitted to the corresponding target device using a preset protocol to control the target device.

[0109] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a device control program based on hierarchical feature optimization and data detection, and the device control program based on hierarchical feature optimization and data detection, when executed by a processor, implements the steps of the device control method based on hierarchical feature optimization and data detection as described above.

[0110] In summary, this invention provides a device control method and related equipment based on hierarchical feature optimization and data detection. The method includes: acquiring multiple raw data sets and performing category-aware resampling on each raw data set to obtain all classification samples corresponding to different probabilities; grouping all classification samples according to all probabilities and classifying the classification samples in different groups using different model optimization processes to obtain corresponding defect categories; transmitting each defect category to multiple target device nodes for fusion, and generating corresponding decision results based on each fusion feature; calculating the similarity between the historical data of each target device node and the corresponding decision results; outputting the decision results according to a preset protocol based on the similarity and the probability corresponding to the decision results; and controlling the corresponding target device through the decision results. This invention improves the sampling rate of rare defect samples by optimizing the hierarchical features of the data, enabling the model to perform global sampling of samples, thus improving the practicality of the data. It also improves the accuracy of defect analysis through spatiotemporal constraint decision functions, thereby outputting targeted decision results to control the target device and improving the adaptive management process of the device.

[0111] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal that includes that element.

[0112] Of course, 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 (such as a processor, controller, etc.). The program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The computer-readable storage medium can be a memory, magnetic disk, optical disk, etc.

[0113] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A device control method based on hierarchical feature optimization and data detection, characterized in that, The device control method based on hierarchical feature optimization and data detection includes: Multiple raw data sets are acquired, and each raw data set is resampled using category-aware methods to obtain all classification samples corresponding to different probabilities. All the classified samples are grouped according to all the probabilities, and different model optimization processes are used to classify the classified samples in different groups for defects to obtain the corresponding defect categories; Each defect category is transmitted to multiple target device nodes for fusion, and a corresponding decision result is generated based on each fusion feature. Calculate the similarity between the historical data of each target device node and the corresponding decision result. Based on the similarity and the probability corresponding to the decision result, output the decision result according to a preset protocol and control the corresponding target device through the decision result.

2. The device control method based on hierarchical feature optimization and data detection according to claim 1, characterized in that, The process of acquiring multiple raw data sets and performing category-aware resampling on each raw data set to obtain all classification samples corresponding to different probabilities specifically includes: Multiple raw data sets are acquired, and each raw data set is preprocessed to obtain the corresponding initial sample; By using a dynamic sampling function to resample initial samples with different probabilities, corresponding classification samples can be obtained.

3. The device control method based on hierarchical feature optimization and data detection according to claim 2, characterized in that, The process of resampling initial samples with different probabilities using a dynamic sampling function to obtain corresponding classification samples specifically includes: All initial samples with a probability higher than the preset probability are defined as high-probability initial samples, and all initial samples with a probability not higher than the preset probability are defined as low-probability initial samples. A dynamic sampling function is constructed based on the number of high-probability initial samples and the number of low-probability initial samples: ; in, This represents the probability distribution of a high-probability initial sample or a low-probability initial sample. express i The number of class samples, express j The number of class samples, Indicates the first adjustment parameter; Resample all the high-probability initial samples and all the low-probability initial samples according to the dynamic sampling function to obtain the corresponding classification samples: ; in, X Represents the original data. H , W and C These represent the image height, width, and number of channels of the original data, respectively. Indicates the initial sample. E This indicates the resampling process. Indicates the first i A number of categorized samples.

4. The device control method based on hierarchical feature optimization and data detection according to claim 1, characterized in that, The step of grouping all the classified samples according to all the probabilities and using different model optimization processes to classify the classified samples in different groups to obtain the corresponding defect categories specifically includes: Multiple defect sample data are acquired, and all the defect sample data are input into a grouping model. The grouping model groups the defect sample data with different probabilities to obtain multiple defect data groups, and constructs corresponding intra-group weights based on the number of samples in each defect data group. A standard cross-entropy loss function and a focus loss function are constructed based on the weights within each group and the classification probability of the defective data group. The grouping model is then optimized based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model. All the classified samples are input into the optimized grouping model for grouping, and multiple data groups are output. The defect classification model is optimized using each defect data group and its corresponding intra-group weights. The optimized defect classification model is then used to classify defects in all data groups and output the corresponding defect categories.

5. The device control method based on hierarchical feature optimization and data detection according to claim 4, characterized in that, The process involves acquiring multiple defect sample data, inputting all the defect sample data into a grouping model, and grouping the defect sample data with different probabilities into multiple defect data groups. Based on the number of samples in each defect data group, a corresponding intra-group weight is constructed. Specifically, this includes: Multiple defect sample data are acquired, and all defect sample data are input into a grouping model. The grouping model divides all defect sample data into multiple defect data groups based on the frequency of occurrence of each type of defect sample data using a grouping mapping function, and outputs the results. ; in, This represents the result of the function mapping. c Indicates the category of defect sample data. Indicates the first data group. Indicates the second data group. Indicates the third data group. This indicates the fourth data group. Defect sample data c Frequency; For each defect sample data, a corresponding in-group weight is constructed based on the frequency of each type of defect sample data in the corresponding defect data group: ; in, Represents categorized samples i Within-group weights, Indicates defect data group k , Represents categorized samples i The reciprocal of the frequency, Represents categorized samples j The reciprocal of the frequency.

6. The device control method based on hierarchical feature optimization and data detection according to claim 4, characterized in that, The step of constructing a standard cross-entropy loss function and a focus loss function based on the weights within each group and the classification probability of the defective data group, and optimizing the grouping model based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model, specifically includes: Based on the weights within each group and the classification probability of each defective data group, a standard cross-entropy loss function is constructed: ; in, Represents the standard cross-entropy loss function. Indicates the first i A defective data set, This indicates that the defect sample data belongs to The classification probability; Based on the classification probability of each defective data group, a focus loss function is constructed: ; in, Represents the focus loss function. This indicates the second adjustment parameter; A hybrid activation function is constructed based on the standard cross-entropy loss function and the focus loss function, and the grouping model is optimized using the hybrid activation function to obtain the optimized grouping model: ; Where L represents the hybrid activation function, Indicates the contribution parameter. This represents the result of the function mapping. Indicates the first data group. This indicates the fourth data group.

7. The device control method based on hierarchical feature optimization and data detection according to claim 4, characterized in that, The process of optimizing the defect classification model using each defect data group and its corresponding intra-group weights, and then using the optimized defect classification model to classify defects in all data groups and output the corresponding defect categories, specifically includes: Obtain the intra-class features of each defect sample data and the class center distance from each defect sample data to the corresponding defect data group, and construct a center loss function based on each intra-class feature and the corresponding class center distance: ; in, Represents the central loss function. m This indicates the number of defect sample data in the defect data group. Indicates the first i In-class features of each defect sample data Indicates defect data group The first in i The distance from each defective sample data point to the class center; Based on the inter-class angular interval of each of the defective data groups, a large-interval loss function is constructed: ; in, Represents the large-margin loss function. s Indicates the scaling factor. m Indicates angular intervals, e Represents the natural constant. express, express, Indicates the first i Inter-class angular intervals of defective data groups; The defect classification model is optimized using the center loss function and the large margin loss function, and all the data sets are input into the optimized defect classification model. For each categorized sample in each of the data sets, the optimized defect classification model determines the defect category of the categorized sample based on the nearest class center and outputs: ; in, Indicates the predicted defect category, Indicates the first q Within-class features of each classified sample, Indicates the first element in the current data set. k The distance from each defective sample data point to the class center.

8. The device control method based on hierarchical feature optimization and data detection according to claim 1, characterized in that, The step of transmitting each defect category to multiple target device nodes for fusion, and generating a corresponding decision result based on each fusion feature, specifically includes: Each of the aforementioned defect categories is transmitted to the corresponding target device node; For each target device node, the grouping optimization feature vector and metric learning feature vector of all classification samples corresponding to each defect category input into the target device node are extracted, and the grouping optimization feature vector and the metric learning feature vector are fused using the fusion function in the gating mechanism to obtain the fused feature corresponding to each defect category: ; in, h Indicates fusion characteristics, Indicates a gating mechanism. Indicates the gating weight, This represents the optimized feature vector for grouping. This represents the metric for learning feature vectors; The accelerated fusion matrix of the target device node is used to analyze each fusion feature, and the probability of the decision corresponding to each defect category is output: ; in, This indicates that given input features are fused. x Output decision results under the following circumstances y The probability, This represents the activation function. Represents the accelerated fusion matrix; For each defect category, the decision with the highest probability is defined as the decision result for that defect category.

9. The device control method based on hierarchical feature optimization and data detection according to claim 8, characterized in that, The step of calculating the similarity between the historical data of each target device node and the corresponding decision result, and outputting the decision result according to a preset protocol based on the similarity and the probability corresponding to the decision result, and controlling the corresponding target device through the decision result, specifically includes: For each target device node, historical data of the target device node is obtained, and the historical location similarity of each decision result is determined based on the historical data. The probability of the decision outcome and the similarity to the historical location are analyzed using a spatiotemporal decision function: ; in, Represents the spatiotemporal decision function. Indicates the similarity of historical locations. b Indicates the location of the decision result. Indicates the location of historical data; If the rules are met, the decision result and the corresponding target device representation are packaged into a control command, and the control command is transmitted to the corresponding target device using a preset protocol to control the target device.

10. A device control system based on hierarchical feature optimization and data detection, characterized in that, The device control system based on hierarchical feature optimization and data detection is used to implement the device control method based on hierarchical feature optimization and data detection as described in any one of claims 1-9, including: The frequency classification module is used to acquire multiple raw data and perform category-aware resampling on each raw data to obtain all classification samples corresponding to different probabilities; The defect classification module is used to group all the classification samples according to all the probabilities, and to classify the defects of the classification samples in different groups using different model optimization processes to obtain the corresponding defect categories. The decision generation module is used to transmit each defect category to multiple target device nodes for fusion, and generate a corresponding decision result based on each fusion feature. The decision output module is used to calculate the similarity between the historical data of each target device node and the corresponding decision result, and output the decision result according to a preset protocol based on the similarity and the probability corresponding to the decision result, and control the corresponding target device through the decision result.

11. The equipment control system based on hierarchical feature optimization and data detection according to claim 10, characterized in that, The frequency classification module includes: A data preprocessing unit is used to acquire multiple raw data, preprocess each raw data, and obtain a corresponding initial sample. The data resampling unit is used to resample initial samples with different probabilities using a dynamic sampling function to obtain corresponding classification samples.

12. The equipment control system based on hierarchical feature optimization and data detection according to claim 11, characterized in that, The data resampling unit includes: The sample definition subunit is used to define all initial samples with a probability higher than the preset probability as high-probability initial samples, and all initial samples with a probability not higher than the preset probability as low-probability initial samples. A sampling function construction subunit is used to construct a dynamic sampling function based on the number of high-probability initial samples and the number of low-probability initial samples. The probability classification subunit is used to resample all the high-probability initial samples and all the low-probability initial samples according to the dynamic sampling function to obtain the corresponding classification samples.

13. The equipment control system based on hierarchical feature optimization and data detection according to claim 10, characterized in that, The defect classification module includes: The defect sample acquisition unit is used to acquire multiple defect sample data, input all the defect sample data into the grouping model, the grouping model groups the defect sample data with different probabilities to obtain multiple defect data groups, and constructs corresponding intra-group weights according to the number of samples in each defect data group. The grouping model optimization unit is used to construct a standard cross-entropy loss function and a focus loss function based on the weights within each group and the classification probability of the defective data group, and to optimize the grouping model based on the standard cross-entropy loss function and the focus loss function to obtain an optimized grouping model; The sample classification unit is used to input all the classified samples into the optimized grouping model for grouping and output multiple data groups. The defect analysis unit is used to optimize the defect classification model using each defect data group and the corresponding intra-group weights, and to classify all data groups for defects using the optimized defect classification model, and output the corresponding defect category.

14. The equipment control system based on hierarchical feature optimization and data detection according to claim 13, characterized in that, The defect sample acquisition unit includes: The data mapping subunit is used to acquire multiple defect sample data, input all the defect sample data into the grouping model, and the grouping model divides all the defect sample data into multiple defect data groups according to the frequency of occurrence of each type of defect sample data through a grouping mapping function, and outputs the data. The weight construction subunit is used to construct a corresponding intra-group weight for each defect sample data based on the frequency of each defect sample data in the corresponding defect data group.

15. The equipment control system based on hierarchical feature optimization and data detection according to claim 13, characterized in that, The grouping model optimization unit includes: The first function construction subunit is used to construct a standard cross-entropy loss function based on the weights within each group and the classification probability of each defective data group. The second function construction subunit is used to construct a focus loss function based on the classification probability of each defective data group; The first model optimization subunit is used to construct a hybrid activation function based on the standard cross-entropy loss function and the focus loss function, and to optimize the grouping model using the hybrid activation function to obtain an optimized grouping model.

16. The equipment control system based on hierarchical feature optimization and data detection according to claim 13, characterized in that, The defect analysis unit includes: The third function construction subunit is used to obtain the intra-class features of each defect sample data and the class center distance from each defect sample data to the corresponding defect data group, and to construct a center loss function based on each intra-class feature and the corresponding class center distance. The fourth function construction subunit is used to construct a large-interval loss function based on the inter-class angular interval of each defect data group; The second model optimization subunit is used to optimize the defect classification model using the center loss function and the large margin loss function, and input all the data sets into the optimized defect classification model. The defect output subunit is used to determine the defect category of each classified sample in each data group based on the nearest class center of the classified sample, and output the result.

17. The equipment control system based on hierarchical feature optimization and data detection according to claim 10, characterized in that, The decision generation module includes: A data transmission unit is used to transmit each of the defect categories to the corresponding target device node; The feature fusion unit is used to extract, for each target device node, all classification samples corresponding to each defect category input to the target device node, the grouping optimization feature vector and the metric learning feature vector, and use the fusion function in the gating mechanism to fuse the grouping optimization feature vector and the metric learning feature vector to obtain the fused feature corresponding to each defect category; The decision probability analysis unit is used to analyze each of the fusion features using the accelerated fusion matrix of the target device node and output the probability of the decision corresponding to each defect category. The decision result judgment unit is used to define the decision with the highest probability for each defect category as the decision result for that defect category.

18. The equipment control system based on hierarchical feature optimization and data detection according to claim 17, characterized in that, The decision output module includes: The historical data acquisition unit is used to acquire historical data of each target device node and determine the historical location similarity of each decision result based on the historical data. The similarity comparison unit is used to analyze the probability of the decision result and the similarity of the historical location using a spatiotemporal decision function; The device control unit is configured to, if the rules are met, package the decision result and the corresponding target device representation into a control command, and transmit the control command to the corresponding target device according to a preset protocol, so as to control the target device.

19. A terminal, characterized in that, The terminal includes: a memory, a processor, and a device control program based on hierarchical feature optimization and data detection stored in the memory and executable on the processor. When the device control program based on hierarchical feature optimization and data detection is executed by the processor, it implements the steps of the device control method based on hierarchical feature optimization and data detection as described in any one of claims 1-12.

20. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a device control program based on hierarchical feature optimization and data detection, which, when executed by a processor, implements the steps of the device control method based on hierarchical feature optimization and data detection as described in any one of claims 1-12.