Image detection method, electronic device and medium based on classification model
Through the image detection method based on the classification model, the light source correction of the motor magnetic tile pictures is performed using layer division, local adaptive correction network and gamma correction algorithm, which solves the problem of feature extraction of motor magnetic tile detection under light imbalance, and achieves efficient classification and robustness improvement.
Patent Information
- Application Number
- CN202210816429.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-12
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2042-07-12
AI Technical Summary
Traditional image processing algorithms are difficult to effectively extract the characteristics of motor magnetic tiles, especially under the conditions of lighting imbalance, which leads to a decrease in classification performance and robustness.
The image detection method based on the classification model is adopted, and the light source correction of the motor magnetic tile pictures is corrected through layer division, local adaptive correction network and EfficientNetV2 network, and the gamma correction algorithm is combined to improve the accuracy and robustness of the classification model.
It realizes the accurate classification of motor magnetic tile pictures under the condition of lighting imbalance, improves the performance and stability of the classification model, and improves the accuracy and reliability of detection.
Smart Images

Figure CN116091389B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of motor detection, and in particular to an image detection method, electronic equipment and medium based on a classification model. Background Art
[0002] Motor magnets are tile-shaped magnets used in permanent magnet motors and are the core components of motors. Therefore, during the production process of motor magnets, quality inspection of motor magnets becomes particularly important, especially to avoid cracks, scratches, gaps, etc. on the surface of motor magnets. This places high demands on image detection algorithms. When using traditional image processing algorithms to detect photos of motor magnets, the complex background of the motor magnets themselves makes it difficult to extract features from traditional images, and there may also be unbalanced lighting, resulting in the same object being measured having different offsets from the light source at different positions, and thus the same image having different texture features under different lighting, ultimately causing the classification performance of the model for feature extraction of motor magnets to decline and the robustness to weaken. Summary of the Invention
[0003] The present invention aims to solve at least one of the technical problems existing in the prior art, and provides an image detection method and electronic equipment based on a classification model, which can perform light source correction on images of motor magnetic tiles through the classification model, thereby achieving accurate classification of motor magnetic tile images and improving the classification and robustness of the model.
[0004] In a first aspect, the present invention provides an image detection method based on a classification model, comprising:
[0005] Obtain a sample atlas of the motor magnetic shoe to be tested, wherein the sample atlas includes a plurality of sample grayscale images carrying sample labels, wherein the sample labels are used to characterize the types of the sample grayscale images;
[0006] Training the classification model according to the sample atlas;
[0007] Inputting the acquired target grayscale image into the trained classification model for category detection to obtain a category label of the target grayscale image;
[0008] The training of the classification model includes:
[0009] Inputting the sample atlas into the classification model, so that the classification model divides the sample grayscale images in the sample atlas into layers to obtain tensor information of the sample grayscale images;
[0010] Performing feature extraction on the tensor information to obtain feature information of the sample grayscale image;
[0011] Correcting the tensor information according to a preset gamma correction value and a preset layered gamma correction algorithm to obtain a correction result;
[0012] The classification model is trained according to the correction result and the sample labels.
[0013] The above-mentioned image detection method based on the classification model has at least the following beneficial effects: obtaining a sample atlas of the motor magnetic shoe to be tested, inputting the classification model for training according to the sample grayscale images and sample labels in the sample atlas, inputting the sample atlas into the classification model for layer division, obtaining the tensor information of the sample grayscale image, and performing feature extraction on the tensor information to obtain the feature information of the sample grayscale image, and finally, correcting the tensor information according to the preset gamma correction value and the preset layered gamma correction algorithm to realize light source correction of the image of the motor magnetic shoe to avoid the influence of light source imbalance, training the classification model according to the correction results and sample labels, thereby improving the classification and robustness of the classification model for grayscale images, inputting the obtained target grayscale image into the trained classification model for category detection, obtaining the category label of the target grayscale image, and realizing accurate classification of the motor magnetic shoe image.
[0014] According to some embodiments of the present invention, the classification model includes a layer division module, a local adaptive correction network, and an EfficientNetV2 network, wherein the layer division module includes multiple layer channels; inputting the sample atlas into the classification model so that the classification model performs layer division on the sample grayscale images in the sample atlas to obtain tensor information of the sample grayscale images includes:
[0015] Inputting the image tensor of the sample grayscale image into the layer division module, so that the layer division module performs image clustering on the image tensor based on a preset clustering algorithm to obtain the multiple layers;
[0016] The layers are superimposed according to the layer channels, and the tensor information is output.
[0017] According to some embodiments of the present invention, correcting the tensor information according to a preset gamma correction value and a preset layered gamma correction algorithm to obtain a correction result includes:
[0018] Obtaining a feature image according to the feature information;
[0019] Performing feature processing on the feature image to obtain tensor features of the feature image;
[0020] Activating the tensor feature through an activation function to obtain the preset gamma correction value;
[0021] The tensor information and the tensor features are corrected according to the gamma correction value and the preset hierarchical gamma correction algorithm to obtain the correction result.
[0022] According to some embodiments of the present invention, the local adaptive correction network includes a filtering layer, an average pooling layer, a hierarchical convolution layer, and a global average pooling layer; and the performing feature processing on the feature image to obtain tensor features of the feature image includes:
[0023] Inputting the feature image into the filter layer for response normalization to obtain a normalized result;
[0024] Inputting the normalized result into the average pooling layer for compression to obtain compressed information of the feature image;
[0025] Inputting the layers into the layered convolution layer, so that the layered convolution layer performs feature extraction on the layers according to the compression information to obtain feature information of each layer;
[0026] The feature information is input into the global average pooling layer to obtain a plurality of tensor features.
[0027] According to some embodiments of the present invention, training the classification model according to the correction result and the sample label includes:
[0028] The correction result and the sample label are input into the EfficientNetV2 network in the classification model for training.
[0029] According to some embodiments of the present invention, the further comprising:
[0030] The sample grayscale image is input into the local adaptive correction network for brightness extraction, and a brightness vector of the sample grayscale image is output.
[0031] According to some embodiments of the present invention, the preset layered gamma correction algorithm is obtained by the following steps:
[0032] Inputting the sample grayscale image into the layer division module for layer division, and obtaining an exponential relationship according to the tensor information after the layer division;
[0033] Calculating according to the exponential relationship, the acquired size information of the sample grayscale image, and the brightness vector to obtain a vector relationship;
[0034] constraining the vector relationship according to a preset fitting function;
[0035] Obtaining fitting parameters according to the constrained vector relationship and the layer;
[0036] Calculate according to the index of the layer and the fitting parameters to obtain a gamma vector;
[0037] The gamma vector and the tensor information are input into the exponential relationship to obtain the preset hierarchical gamma correction algorithm.
[0038] In a second aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, a program stored on the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the program is executed by the processor, the steps of the image detection method based on the classification model as described in the first aspect are realized.
[0039] In a third aspect, an embodiment of the present invention provides a storage medium, which is a computer-readable storage medium for computer-readable storage, and stores one or more programs, which can be executed by one or more processors to implement the steps of the classification model-based image detection method described in the first aspect.
[0040] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the structures particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings are used to provide a further understanding of the technical solution of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the technical solution of the present invention and do not constitute a limitation to the technical solution of the present invention.
[0042] Figure 1 is a structural diagram of a classification model provided by an embodiment of the present invention;
[0043] Figure 2 This is an optional flowchart of the image detection method based on the classification model provided in an embodiment of the present application;
[0044] Figure 3 This is an optional flowchart of a training classification model provided in an embodiment of the present application;
[0045] Figure 4 yes Figure 3 Specific method flow chart of step S201 in FIG;
[0046] Figure 5 yes Figure 3 Specific method flow chart of step S204 in FIG;
[0047] Figure 6yes Figure 5 Specific method flow chart of step S402 in FIG.
[0048] Figure 7 yes Figure 3 Specific method flow chart of step S205 in;
[0049] Figure 8 This is an optional flowchart of an algorithm for calculating a preset layered gamma correction provided in an embodiment of the present application;
[0050] Figure 9 A structural example diagram of a classification model provided for a specific example of the present invention;
[0051] Figure 10 It is a structural diagram of an electronic device provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present 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 only used to explain the present invention and are not intended to limit the present invention.
[0053] The following describes embodiments of the present invention in detail. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present invention and are not to be construed as limiting the present invention.
[0054] In the description of the present invention, "several" means one or more, "many" means more than two, "greater than," "less than," and "exceed" are understood to exclude the number itself, while "above," "below," and "within" are understood to include the number itself. The use of "first" and "second" in the description is solely for the purpose of distinguishing technical features and should not be construed as indicating or implying relative importance, implicitly specifying the number of the indicated technical features, or implicitly specifying the order of the indicated technical features.
[0055] In the description of the present invention, if there is a description of first and second, it is only for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0056] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, and connecting should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.
[0057] The embodiments of the present invention are further described below with reference to the accompanying drawings.
[0058] refer to Figure 1 , Figure 1 is a structural diagram of a classification model provided by an embodiment of the present invention;
[0059] In some embodiments, the classification model 100 includes a layer division module 200, a local adaptive correction network 300 and an EfficientNetV2 network 400, wherein the local adaptive correction network includes a filtering layer, an average pooling layer, a hierarchical convolution layer and a global average pooling layer, and the layer division module 200 includes multiple layer channels and a layer divider.
[0060] In some embodiments, first, the image tensor of the sample grayscale image of the motor magnetic tile is input to the layer division module 200 for layer division. The layer division module 200 performs image clustering through the K-means clustering algorithm and is divided into multiple categories. Each category outputs a separate layer, and outputs tensor information in a fixed format through the superposition of layer channels. Secondly, the tensor information is input to the local adaptive correction network 300 for feature extraction. The local adaptive correction network 300 first performs a convolution operation on the tensor information through the convolution kernel to extract low-level features and obtain feature information of the sample grayscale image. Afterwards, the corresponding size is obtained according to the feature information. The feature image is normalized by the response of the filter in the filtering layer, and normalized according to the layer channel to obtain the normalized result. Then, the feature image is compressed by the average pooling with a preset step size to obtain the compressed information of the feature image. Furthermore, the features of each layer are extracted by the layered convolution in the layered convolution layer, and then multiple tensor features are obtained by the global average pooling layer. The gamma correction value is obtained by activation according to the preset activation function, wherein each layer has a preset gamma correction value. Finally, the tensor information and tensor features are corrected according to the preset gamma correction value and the preset layered gamma correction algorithm to complete the image correction and output the correction result.
[0061] In some embodiments, after the layer division module 200 outputs the correction result, the EfficientNetV2 network 400 classifies the sample grayscale image according to the correction result to obtain the sample label of the sample grayscale image, thereby completing the detection of the motor magnetic tile image and improving the accuracy of the motor magnetic tile image detection.
[0062] It will be understood by those skilled in the art that Figure 1 The classification model 100 shown in the figure does not constitute a limitation on the embodiments of the present invention, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0063] Based on the structure of the above-mentioned classification model 100, various embodiments of the classification model-based image detection method of the present invention are proposed below.
[0064] refer to Figure 2 , Figure 2 This is an optional flowchart of the image detection method based on the classification model provided in the embodiment of the present application. Figure 2 The method may include but is not limited to steps S101 to S103.
[0065] Step S101: obtaining a sample atlas of the motor magnetic shoe to be tested, the sample atlas including a plurality of sample grayscale images carrying sample labels;
[0066] It should be noted that the sample label is used to characterize the type of the sample grayscale image.
[0067] It can be understood that the sample grayscale images in the sample atlas include grayscale images of the motor magnetic tile surface in a standard state and an unbalanced lighting state, and different sample labels are obtained according to different states of the motor magnetic tile.
[0068] Step S102: training the classification model based on the sample atlas;
[0069] Step S103: input the acquired target grayscale image into the trained classification model for category detection to obtain a category label of the target grayscale image.
[0070] In some embodiments, a sample atlas of the motor magnetic shoe to be tested is obtained, and a classification model is trained based on the sample grayscale images and sample labels in the sample atlas, thereby improving the classification and robustness of the classification model for the grayscale images. The obtained target grayscale image is then input into the classification model for category detection, and the category label of the target grayscale image is obtained, thereby achieving accurate classification of the motor magnetic shoe image.
[0071] refer to Figure 3 , Figure 3 This is an optional flowchart of a training classification model provided in an embodiment of the present application. Figure 3 The method may include but is not limited to steps S201 to S204.
[0072] It should be noted that the layer division module includes multiple layer channels.
[0073] Step S201: inputting the sample atlas into the classification model so that the classification model divides the sample grayscale images in the sample atlas into layers to obtain tensor information of the sample grayscale images;
[0074] Step S202: extracting features from the tensor information to obtain feature information of the sample grayscale image;
[0075] In some embodiments, the tensor information is convolved with a convolution kernel to extract low-level features of the tensor information and obtain feature information of the sample grayscale image.
[0076] Step S203: Correcting the tensor information according to a preset gamma correction value and a preset layered gamma correction algorithm to obtain a correction result;
[0077] Step S204: training a classification model based on the correction results and sample labels.
[0078] In some embodiments, the sample atlas is input into the classification model for layer division to obtain tensor information of the sample grayscale image, and feature extraction is performed on the tensor information to obtain feature information of the sample grayscale image. Finally, the tensor information is corrected according to a preset gamma correction value and a preset layered gamma correction algorithm to obtain a correction result, thereby realizing light source correction of the image of the motor magnetic shoe through the classification model to avoid the influence of light source imbalance. The classification model is trained according to the correction result and sample label to improve the classification performance of the classification model.
[0079] refer to Figure 4 , Figure 4 yes Figure 3 In the flowchart of step S201 in FIG. 1 , in some embodiments, step S201 may include but is not limited to steps S301 to S302:
[0080] Step S301: inputting the image tensor of the sample grayscale image into a layer division module, so that the layer division module performs image clustering on the image tensor based on a preset clustering algorithm to obtain multiple layers;
[0081] Step S302: overlay the layers according to the layer channels and output tensor information.
[0082] In some embodiments, the image tensor of the sample grayscale image is input into a layer division module for layer division. The layer division module performs image clustering processing on the image tensor based on a preset clustering algorithm to obtain multiple layers. Then, each layer is superimposed according to the number of layer channels, and tensor information is output to facilitate subsequent local correction of the sample grayscale image.
[0083] It should be noted that the image tensor of the sample grayscale image is the tensor format of the sample grayscale image. For example, the tensor format is N*128*128*1, N*64*64*2 or N*128*64*1, etc., where N is the batch size, 128*128, 64*64 and 128*64 are the length and width of the sample grayscale image, 1 and 2 are the number of layer channels, and the preset clustering algorithm is the KMeans clustering algorithm. The image tensor of the sample grayscale image is calculated by the KMeans clustering algorithm. Assuming that the number of clustering cores is 8, 8 categories are obtained. Each category outputs a separate layer, which is superimposed through the layer channel to output tensor information.
[0084] refer to Figure 5 , Figure 5 yes Figure 3 In the flowchart of step S204 in FIG. 1 , in some embodiments, step S204 may include but is not limited to steps S401 to S404:
[0085] Step S401: obtaining a feature image according to feature information;
[0086] Step S402: performing feature processing on the feature image to obtain tensor features of the feature image;
[0087] Step S403: activating the tensor feature through an activation function to obtain a preset gamma correction value;
[0088] Step S404: Correct the tensor information and tensor features according to the gamma correction value and a preset layered gamma correction algorithm to obtain a correction result.
[0089] It should be noted that the preset activation function can be an S-shaped growth curve function (also called Sigmoid activation function), a tanh function or a ReLU activation function (Rectified Linear Unit). In this embodiment, it is a Sigmoid activation function.
[0090] In some embodiments, the tensor information is first convolved with a convolution kernel to extract low-level features of the tensor information and obtain feature information of the sample grayscale image, thereby obtaining a feature image based on the feature information. The feature image is then average pooled to obtain tensor features of the feature image. Finally, a gamma correction value is obtained according to a preset activation function, i.e., a Sigmoid activation function. The sample grayscale image is then corrected based on a preset hierarchical gamma correction algorithm and the gamma correction value to obtain a correction result, thereby improving the accuracy of the correction of the sample grayscale image.
[0091] refer to Figure 6 , Figure 6 yes Figure 5In the flowchart of step S402, in some embodiments, step S402 may include but is not limited to steps S501 to S504:
[0092] It should be noted that the local adaptive correction network includes a filtering layer, an average pooling layer, a hierarchical convolution layer, and a global average pooling layer.
[0093] Step S501: input the feature image into the filter layer for response normalization to obtain a normalized result;
[0094] It should be noted that in the process of normalizing the response of the feature image, the feature image should be normalized according to the layer channel to obtain the final normalized result.
[0095] Step S502: Input the normalized result into the average pooling layer for compression to obtain compressed information of the feature image;
[0096] Step S503: Input the layer into the layered convolution layer, so that the layered convolution layer extracts features of the layer according to the compressed information to obtain feature information of each layer;
[0097] Step S504: Input the feature information into the global average pooling layer to obtain multiple tensor features.
[0098] In some embodiments, the feature image is first input into the filter in the filtering layer for response normalization to obtain a normalized result, and then the layer is input into the hierarchical convolution layer to extract the features of each layer to obtain the feature information of each layer, and finally the feature information is input into the global average pooling layer to obtain multiple tensor features, which facilitates the calculation of the preset gamma correction value.
[0099] It should be noted that inputting the feature image into the filter in the filtering layer for response normalization can compress the pixel value range of the feature image to the interval [0, 1].
[0100] refer to Figure 7 , Figure 7 yes Figure 3 In the flowchart of step S205 in FIG. 1 , in some embodiments, step S205 may include but is not limited to step S601:
[0101] Step S601: Input the correction results and sample labels into the EfficientNetV2 network in the classification model for training.
[0102] In some embodiments, the correction results and sample labels are input into the EfficientNetV2 network in the classification model for classification to obtain classification results, thereby determining the correspondence between each sample grayscale image and the sample label, thereby improving the classification performance and robustness of the classification model.
[0103] In some embodiments, the image detection method based on the classification model also includes inputting the sample grayscale image into a local adaptive correction network for brightness extraction, and outputting the brightness vector of the sample grayscale image to facilitate reflecting the overall brightness of the layer.
[0104] It should be noted that when the layer grayscale mean is used as the base, the overall brightness of the layer can be better reflected. Therefore, the sample grayscale image is input into the local adaptive correction network, so that the local adaptive correction network extracts the image brightness of the sample grayscale image based on the local adaptive correction network to obtain a brightness vector.
[0105] refer to Figure 8 , Figure 8 This is an optional flowchart of a preset layered gamma correction algorithm provided in an embodiment of the present application. Figure 8 The method may include but is not limited to steps S701 to S706.
[0106] Step S701: Inputting the sample grayscale image into the layer division module for layer division, and obtaining an exponential relationship based on the tensor information after the layer division;
[0107] Step S702: performing calculations based on the exponential relationship, the size information of the acquired sample grayscale image, and the brightness vector to obtain a vector relationship;
[0108] Step S703: constraining the vector relationship according to a preset fitting function;
[0109] Step S704: Obtain fitting parameters based on the constrained vector relationship and the layer;
[0110] Step S705: Calculate according to the layer index and fitting parameters to obtain a gamma vector;
[0111] Step S706: input the gamma vector and tensor information into the exponential relationship to obtain a preset layered gamma correction algorithm.
[0112] In some embodiments, the specific process and derivation of the preset layered gamma correction algorithm are as follows:
[0113] Machine vision, like the human eye, is sensitive to brightness. Therefore, gamma correction is introduced to address the issue of unbalanced lighting and compensate for the adverse effects of light variations. Gamma correction is a nonlinear adjustment of the grayscale values of the input image, making the output grayscale values exponentially related to the input image grayscale values. The formula is:
[0114] f(I)=I γ (1)
[0115] Since the image is layered by the layer divider, equation (1) can be generalized to equation (2):
[0116]
[0117] When the grayscale mean of the layer is used as the base, the overall brightness of the layer can be better reflected. Therefore, Formula (2) is generalized to Formula (3), where W and H are the width and length of the input image, and α is the width and length of the input image. i The i-th dimension of the output vector of the image brightness extracted by the above local adaptive gamma correction network:
[0118]
[0119] Since γ is obtained by training a convolutional neural network, it is easy to cause large differences in the values of the γ vector, which makes the output image prone to fragmentation. Therefore, it is proposed to use the least squares method to constrain γ. The polynomial fitting function is generally used as formula (4):
[0120] h θ (x) = θ0 + θ1·x + ... + θ n ·x n (4)
[0121] Since the gradients of the continuous elements in γ are required to be consistent, the derivative of equation (4) can be obtained as equation (5), and h can be obtained as θ (x) is taken to θ1.
[0122]
[0123] Substituting Equation (3) and the number of layers K into Equation (6) yields the fitting parameters θ0 and θ1. The new γ value can then be obtained using Equation (7), where i is the index of the corresponding layer. Substituting the gamma vector obtained from Equation (7) and the output image tensor information F into Equation (2) creates a preset layered gamma correction algorithm, completing the local gamma correction of the image:
[0124]
[0125] γ i =θ0+θ1·i (7)
[0126] In order to more clearly illustrate the process of the image detection method based on the classification model, a specific example is given below.
[0127] Example 1:
[0128] refer to Figure 9 , Figure 9 A structural example diagram of a classification model provided for a specific example of the present invention;
[0129] Step 1. Build the EfficientNet-LAGC model.
[0130] The model consists of a layer splitter, a local adaptive gamma correction network, and EfficientNetV2. The model takes the original image tensor T (a sample grayscale image tensor) as input. The layer splitter divides it into eight layers using the KMeans clustering algorithm. The local adaptive gamma correction network then performs illumination correction. Finally, the layer is fed into the EfficientNetV2 network to complete defect classification.
[0131] The layer splitter takes as input a tensor T of the format N × 128 × 128 × 1, where N is the batch size, 128 × 128 for length and width, and 1 for the number of channels. This tensor is then clustered using the KMeans algorithm with 8 kernels, dividing it into 8 categories. Each category outputs a separate layer, which is then stacked with channels to produce a tensor F of the format N × 128 × 128 × 8.
[0132] The local adaptive gamma correction network first applies a convolution operation to the input F with 8 kernels to extract low-level features, resulting in an output feature map of size 128×128×8. Filter response normalization is then performed to normalize the image per channel. Average pooling with a stride of 2 is then used to compress the feature map to 64×64×8 in both dimensions. Layered convolution is then used to extract features from each layer. Global average pooling is then performed to obtain a 1×8 tensor. This tensor is activated with a sigmoid function to generate gamma correction values α, representing the gamma correction value for each layer. Finally, α and the input tensor F are fed into the layered gamma correction algorithm to complete the image correction, with an output size of 128×128×1.
[0133] Step 2: Obtain a motor magnetic tile classification training sample set, where each training sample in the motor magnetic tile classification training sample set includes a grayscale image of the motor magnetic tile surface under a standard state and an unbalanced illumination condition and a corresponding category label.
[0134] Step 3: Use the motor magnetic shoe classification training sample set to train the classification model constructed in step 1 to obtain a trained classification model.
[0135] Step 4: Collect the grayscale image of the motor magnetic tile surface of the motor magnetic tile to be tested, and input the grayscale image of the motor magnetic tile surface into the classification model trained in step 3. After model inference, the category label of the grayscale image of the motor magnetic tile surface to be tested is output.
[0136] To verify the effectiveness of the present invention in classifying motor magnet defect images under unbalanced illumination, the following experiment was designed: a three-fold cross-validation test was conducted using the motor magnet defect dataset published by the Institute of Automation, Chinese Academy of Sciences. Each fold was divided into a training set and a test set. The model was trained separately and its sparse classification accuracy was verified on the test set. The three-fold cross-validation results were averaged, as shown in Table 1 below. As can be seen from Table 1, the proposed EfficientNet-LAGC method achieves a sparse classification accuracy of 96.93% under standard conditions and 97.44% under unbalanced illumination conditions. This method outperforms the original EfficientNetV2 network in terms of classification accuracy. Comparison of EfficientNet-LAGC with other models shows that the proposed method has stronger classification capabilities.
[0137] Table 1 Accuracy of each model in image classification under standard conditions and unbalanced lighting conditions
[0138] Standard conditions (%) Light imbalance condition (%) MobileNetV2 86.46 41.77 MobileNetV3 98.71 54.17 ResNet 94.90 47.08 BiT 66.42 41.04 DenseNet201 98.20 45.67 RegNet 98.21 41.57 Xception 92.86 56.53 InceptionV3 94.89 40.28 NASNetLarge 92.54 42.54 EfficientNet-LAGC 96.93 97.44 EfficientNetV2 98.71 48.50
[0139] Taking into account the sample balance phenomenon, it is proposed to use Recall, Precision and AUC (Area under Curve) for in-depth verification, and the results are shown in Table 2. As can be seen from Table 2, the Recall and Precision achieved by the model proposed in this invention under standard conditions are 0.958 and 0.782 respectively, which are relatively excellent. Under the condition of unbalanced illumination, these two values are further improved to 0.964 and 0.787, which are far better than the other models. The AUC value under standard conditions is 0.997, which is only 0.001 lower than the highest MobileNetV3. Under unbalanced illumination data, the AUC is 0.998, which is far better than the other models. This shows that the method proposed in this study has relatively excellent performance under unbalanced illumination conditions. The EfficientNet-LAGC model can effectively reduce illumination sensitivity and is suitable for deployment in practical application scenarios.
[0140] Table 2 Comparison of recall, precision and area under the curve of each model
[0141]
[0142] See also Figure 10 , Figure 10 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes:
[0143] Specifically, the electronic device includes: one or more processors and memory, Figure 10A processor and memory are used as an example. The processor and memory can be connected via a bus or other means. Figure 10 The bus connection is taken as an example.
[0144] The memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs, such as the classification model-based image detection method in the aforementioned embodiments of the present invention. The processor implements the classification model-based image detection method in the aforementioned embodiments of the present invention by running the non-transitory software programs and programs stored in the memory.
[0145] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data required to execute the image detection method based on the classification model in the above-mentioned embodiment of the present invention, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the network data processing device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0146] In addition, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer-executable program, and the computer-executable program is executed by one or more control processors, for example, Figure 10 , so that the one or more processors can execute the image detection method based on the classification model in the above embodiment of the present invention.
[0147] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0148] It should be understood that in this application, the terms "comprises" and "has" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product or apparatus.
[0149] In addition, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0150] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "illustrative embodiments," "examples," "specific examples," or "some examples" means that a specific feature, structure, material, or characteristic described in conjunction with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, illustrative uses of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
[0151] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
[0152] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to the embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the claims and their equivalents.
[0153] The embodiments of the present invention are described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Various changes can be made within the scope of knowledge possessed by ordinary technicians in the relevant technical field without departing from the spirit of the present invention.
Claims
1. An image detection method based on a classification model, characterized in that: include: Obtain a sample atlas of the motor magnetic shoe to be tested, wherein the sample atlas includes a plurality of sample grayscale images carrying sample labels, wherein the sample labels are used to characterize the types of the sample grayscale images; Training the classification model according to the sample atlas; Inputting the acquired target grayscale image into the trained classification model for category detection to obtain a category label of the target grayscale image; The training of the classification model includes: Inputting the sample atlas into the classification model, so that the classification model divides the sample grayscale images in the sample atlas into layers to obtain tensor information of the sample grayscale images; Performing feature extraction on the tensor information to obtain feature information of the sample grayscale image; Correcting the tensor information according to a preset gamma correction value and a preset layered gamma correction algorithm to obtain a correction result; Training the classification model according to the correction result and the sample label; Correcting the tensor information according to a preset gamma correction value and a preset layered gamma correction algorithm to obtain a correction result includes: Obtaining a feature image according to the feature information; Performing feature processing on the feature image to obtain tensor features of the feature image; Activating the tensor feature through an activation function to obtain the preset gamma correction value; The tensor information and the tensor features are corrected according to the preset gamma correction value and the preset layered gamma correction algorithm to obtain the correction result.
2. The image detection method based on the classification model according to claim 1, characterized in that: The classification model includes a layer division module, a local adaptive correction network and an EfficientNetV2 network, wherein the layer division module includes multiple layer channels; the sample atlas is input into the classification model, so that the classification model performs layer division on the sample grayscale images in the sample atlas to obtain tensor information of the sample grayscale images, including: Inputting the image tensor of the sample grayscale image into the layer division module, so that the layer division module performs image clustering on the image tensor based on a preset clustering algorithm to obtain the multiple layers; The layers are superimposed according to the layer channels, and the tensor information is output.
3. The image detection method based on the classification model according to claim 2, characterized in that: The local adaptive correction network includes a filtering layer, an average pooling layer, a hierarchical convolution layer, and a global average pooling layer; the feature processing of the feature image to obtain the tensor features of the feature image includes: Inputting the feature image into the filter layer for response normalization to obtain a normalized result; Inputting the normalized result into the average pooling layer for compression to obtain compressed information of the feature image; Inputting the layers into the layered convolution layer, so that the layered convolution layer performs feature extraction on the layers according to the compression information to obtain feature information of each layer; The feature information is input into the global average pooling layer to obtain a plurality of tensor features.
4. The image detection method based on the classification model according to claim 2, characterized in that: The training of the classification model according to the correction result and the sample label includes: The correction result and the sample label are input into the EfficientNetV2 network in the classification model for training.
5. The image detection method based on the classification model according to claim 2, characterized in that: Also includes: The sample grayscale image is input into the local adaptive correction network for brightness extraction, and a brightness vector of the sample grayscale image is output.
6. The image detection method based on the classification model according to claim 5, characterized in that: The preset layered gamma correction algorithm is obtained by the following steps: Inputting the sample grayscale image into the layer division module for layer division, and obtaining an exponential relationship according to the tensor information after the layer division; Calculating according to the exponential relationship, the acquired size information of the sample grayscale image, and the brightness vector to obtain a vector relationship; constraining the vector relationship according to a preset fitting function; Obtaining fitting parameters according to the constrained vector relationship and the layer; Calculate according to the index of the layer and the fitting parameters to obtain a gamma vector; The gamma vector and the tensor information are input into the exponential relationship to obtain the preset hierarchical gamma correction algorithm.
7. An electronic device, characterized in that: The electronic device includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory. When the program is executed by the processor, the steps of the image detection method based on the classification model as described in any one of claims 1 to 6 are realized.
8. A storage medium, which is a computer-readable storage medium and is used for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the image detection method based on the classification model according to any one of claims 1 to 6.
Citation Information
Patent Citations
Retinal vessel segmentation method and device based on multi-scale attention network, and storage medium
CN113012163A
Picture classification model training method and system, and computer device
WO2021027142A1