Training method, device and medium for abnormal image detection model
Through the improved abnormal image detection network model, combined with the residual network structure and channel attention mechanism module, the image feature vector is tested and iterated, and the accuracy of the abnormal image detection in the existing technologies is not high and over -fitting. The problem improves the training efficiency and detection accuracy of the model.
Patent Information
- Application Number
- CN202210036055.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-10
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2042-01-10
AI Technical Summary
The prediction accuracy of the prior art in abnormal image detection is not high, and deep learning technology requires a large amount of training sample data and basic deep neural network model architecture, which is prone to overfitting and affecting the detection accuracy.
Provide a training method of an abnormal image detection model. By obtaining multiple image training samples and corresponding sample labels, the improved abnormal image detection network model is used to combine the residual network structure and channel attention mechanism module. Detect and iterate training to obtain an abnormal image detection model completed by training.
It has improved the training efficiency and detection accuracy of the model, reducing the dependence of a large number of training sample data and basic deep neural network model architecture, and reducing the risk of overfitting.
Smart Images

Figure CN114387451B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image detection technology, and in particular to a training method, device and medium for an abnormal image detection model. Background Art
[0002] For social entities (telecommunications operators, Internet service providers), abnormal image recognition technology needs to quickly and conveniently feedback whether the detection target is suspected of illegal information, so as to support relevant units and individuals to circumvent the corresponding legal direction; for law enforcement agencies, the review and identification of illegal images is essentially a judicial act, and its identification results should be issued by units with relevant qualifications. Detection technology can be used to assist in review and identification and improve work efficiency. In summary, it is crucial to build a system that automatically identifies abnormal image detection.
[0003] Currently, common methods for identifying abnormal images include traditional machine learning methods based on the extraction of feature information such as shape, color, gradient, optical flow, etc., combined with classifiers, as well as deep learning technology that combines automatic feature extraction and classification.
[0004] However, the prediction accuracy of traditional machine learning methods is not high, and deep learning technology requires a large amount of training sample data and a basic deep neural network model architecture. For the training sample data obtained by horizontally flipping, vertically flipping, and modifying the brightness of the original image, overfitting problems are prone to occur in the training of the basic deep neural network model, which in turn affects the accuracy of image detection. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a training method, device and medium for an abnormal image detection model, so as to solve the above-mentioned problems existing in the prior art, improve the training efficiency of the model, and improve the detection accuracy of the model.
[0006] In a first aspect, a method for training an abnormal image detection model is provided, and the method may include:
[0007] Obtain multiple image training samples and corresponding sample labels;
[0008] For each image training sample, the image training sample is used as input data, and the input network structure of the preset improved abnormal image detection network model is input. The residual network structure configured in the improved abnormal image detection network model extracts an image feature vector from the image information output by the input network structure, and the extracted image feature vector is detected by the output network structure of the improved abnormal image detection network model to obtain the output detection result of the image training sample; wherein the initial network weight value of the improved abnormal image detection network model is a network weight value pre-trained based on a sample training data set in the ImageNet database of a computer vision system recognition project;
[0009] Based on the detection result of each image training sample and the sample label of the corresponding sample, the pre-trained detection model is iteratively trained to obtain a trained abnormal image detection model.
[0010] In an optional implementation, the input network structure of the improved abnormal image detection network model includes 1 convolution layer, 1 maximum pooling layer and 1 channel attention mechanism module;
[0011] The convolution layer is used to extract features from the input data to obtain a primary image feature vector;
[0012] The channel attention mechanism module is used to compress the primary image feature vector to obtain a global compressed feature vector of the primary image feature vector; process the global compressed feature vector of the primary image feature vector according to the feature channel to obtain a feature channel weight vector of the primary image feature vector, and multiply the feature channel weight vector by the primary image feature vector to output a secondary image feature vector focused on the feature channel;
[0013] The maximum pooling layer is used to obtain the maximum image feature vector corresponding to the secondary image feature vector output by the channel attention mechanism layer.
[0014] In an optional implementation, the residual network structure configured in the improved abnormal image detection network model includes a plurality of configured residual units connected in sequence;
[0015] Each configured residual unit includes 1 initial residual unit and 1 channel attention mechanism module; the channel attention mechanism module is embedded before the last convolution layer in the initial residual unit.
[0016] In an optional implementation, when the configured residual network structure includes 4 configured residual units connected in sequence, the first configured residual unit among the 4 configured residual units includes 3 convolutional layers, the second configured residual unit includes 4 convolutional layers, the third configured residual unit includes 6 convolutional layers, and the fourth configured residual unit includes 3 convolutional layers, wherein the convolution kernel size in each convolutional layer is the same.
[0017] In an optional implementation, the output network structure of the improved abnormal image detection network model includes 1 channel attention mechanism module, 1 average pooling layer and 1 fully connected layer;
[0018] The channel attention mechanism module is used to compress the image feature vector output by the configured residual network structure to obtain a global compressed feature vector of the image feature vector; process the global compressed feature vector of the image feature vector according to the feature channel to obtain a feature channel weight vector of the image feature vector, and multiply the feature channel weight vector of the image feature vector by the image feature vector to output a secondary image feature vector focused on the output network structure;
[0019] The average pooling layer is used to calculate the secondary image feature vector corresponding to the output network structure to obtain a compressed feature vector corresponding to the secondary image feature vector;
[0020] The fully connected layer is used to obtain the detection result of the image training sample based on the obtained compressed feature vector.
[0021] In an optional implementation, obtaining multiple image training samples includes:
[0022] Obtain candidate image samples;
[0023] Processing the candidate image samples by using a preset sample quantity expansion method to obtain processed candidate image samples;
[0024] The candidate image samples and the processed candidate image samples are determined as image training samples.
[0025] In an optional implementation, after obtaining the trained abnormal image detection model, the method further includes:
[0026] Acquire at least one image to be detected;
[0027] The at least one image to be detected is used as input data and input into the trained abnormal image detection model to obtain a detection result of the at least one image to be detected.
[0028] In a second aspect, a training device for an abnormal image detection model is provided, and the device may include:
[0029] An acquisition unit, used for acquiring a plurality of image training samples and corresponding sample labels;
[0030] An input unit is used to, for each image training sample, use the image training sample as input data, input a preset input network structure of an improved abnormal image detection network model, and a residual network structure configured in the improved abnormal image detection network model, extract an image feature vector from the image information output by the input network structure, and use the output network structure of the improved abnormal image detection network model to detect the extracted image feature vector to obtain an output detection result of the image training sample; wherein the initial network weight value of the improved abnormal image detection network model is a network weight value pre-trained based on a sample training data set in an ImageNet database of a computer vision system recognition project;
[0031] The training unit is used to iteratively train the improved abnormal image detection network model based on the detection result of each image training sample and the sample label of the corresponding sample to obtain a trained abnormal image detection model.
[0032] In an optional implementation, the input network structure of the improved abnormal image detection network model includes 1 convolution layer, 1 maximum pooling layer and 1 channel attention mechanism module;
[0033] The convolution layer is used to extract features from the input data to obtain a primary image feature vector;
[0034] The channel attention mechanism module is used to compress the primary image feature vector to obtain a global compressed feature vector of the primary image feature vector; process the global compressed feature vector of the primary image feature vector according to the feature channel to obtain a feature channel weight vector of the primary image feature vector, and multiply the feature channel weight vector by the primary image feature vector to output a secondary image feature vector focused on the feature channel;
[0035] The maximum pooling layer is used to obtain the maximum image feature vector corresponding to the secondary image feature vector output by the channel attention mechanism layer.
[0036] In an optional implementation, the residual network structure configured in the improved abnormal image detection network model includes a plurality of configured residual units connected in sequence;
[0037] Each configured residual unit includes 1 initial residual unit and 1 channel attention mechanism module; the channel attention mechanism module is embedded before the last convolution layer in the initial residual unit.
[0038] In an optional implementation, when the configured residual network structure includes 4 configured residual units connected in sequence, the first configured residual unit among the 4 configured residual units includes 3 convolutional layers, the second configured residual unit includes 4 convolutional layers, the third configured residual unit includes 6 convolutional layers, and the fourth configured residual unit includes 3 convolutional layers, wherein the convolution kernel size in each convolutional layer is the same.
[0039] In an optional implementation, the output network structure of the improved abnormal image detection network model includes 1 channel attention mechanism module, 1 average pooling layer and 1 fully connected layer;
[0040] The channel attention mechanism module is used to compress the image feature vector output by the configured residual network structure to obtain a global compressed feature vector of the image feature vector; process the global compressed feature vector of the image feature vector according to the feature channel to obtain a feature channel weight vector of the image feature vector, and multiply the feature channel weight vector of the image feature vector by the image feature vector to output a secondary image feature vector focused on the output network structure;
[0041] The average pooling layer is used to calculate the secondary image feature vector corresponding to the output network structure to obtain a compressed feature vector corresponding to the secondary image feature vector;
[0042] The fully connected layer is used to obtain the detection result of the image training sample based on the obtained compressed feature vector.
[0043] In an optional implementation, the acquisition unit is specifically used to:
[0044] Obtain candidate image samples;
[0045] Processing the candidate image samples by using a preset sample quantity expansion method to obtain processed candidate image samples;
[0046] The candidate image samples and the processed candidate image samples are determined as image training samples.
[0047] In an optional implementation, the acquisition unit is further used to acquire at least one image to be detected;
[0048] The input unit is used to input the at least one image to be detected as input data into the trained abnormal image detection model to obtain the detection result of the at least one image to be detected.
[0049] In a third aspect, an electronic device is provided, the electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0050] Memory, used to store computer programs;
[0051] The processor is used to implement any method step described in the first aspect when executing the program stored in the memory.
[0052] In a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.
[0053] The training method of the abnormal image detection model provided in the embodiment of the present application obtains multiple image training samples and corresponding sample labels. For each image training sample, the image training sample is used as input data, and the input network structure of the preset improved abnormal image detection network model is input, and the residual network structure configured in the improved abnormal image detection network model is used to extract the image feature vector from the image information output by the input network structure. The extracted image feature vector is detected by the output network structure of the improved abnormal image detection network model to obtain the detection result of the output image training sample; wherein, the initial network weight value of the improved abnormal image detection network model is the network weight value pre-trained based on the sample training data set in the ImageNet database of the computer vision system recognition project; based on the detection result of each image training sample and the sample label of the corresponding sample, the improved abnormal image detection network model is iteratively trained to obtain the abnormal image detection model after training. The method introduces a channel attention mechanism module between the original residual network structure to utilize the feature information inside the channel. The parameter information obtained by training on the ImageNet dataset is migrated to the abnormal image detection field after the channel attention mechanism module is introduced, which improves the accuracy of image detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0055] Figure 1 A flowchart of a method for training an abnormal image detection model provided in an embodiment of the present application;
[0056] Figure 2 A schematic diagram of the model structure of an improved abnormal image detection network model provided in an embodiment of the present application;
[0057] Figure 3 A schematic diagram of the structure of a training device for an abnormal image detection model provided in an embodiment of the present application;
[0058] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0060] For ease of understanding, the terms involved in the embodiments of the present application are explained below:
[0061] Transfer learning refers to a machine learning method that uses existing knowledge to solve new domain problems that are different but still have certain relevance between samples or problems. In other words, it is to re-use existing knowledge to transfer and fine-tune the network structure to solve the problem of neural network training in the target domain with only a small amount of or even no labeled sample data. The core idea is to transplant the model trained in task A to task B.
[0062] The channel attention mechanism (Squeeze-and-excitation networks, SE) module is the core module of the channel attention mechanism network (Squeeze-and-excitation networks, SENet), and is a typical channel attention mechanism. The two operations of squeeze and excitation constitute the main part of the SE module, where:
[0063] The squeezing operation first performs a global average pooling operation on the input feature map of size H×W×C (H is the length of the input feature map, W is the width of the input feature map, and C is the number of feature channels) to transform it into a 1×1×C feature vector with a global receptive field. Then, it passes through two fully connected layers using the ReLU activation function (the dimensions of the input and output feature channels are the same) to obtain the global compressed feature quantity of the current Feature Map.
[0064] The excitation operation uses the Sigmooid activation function to obtain the weight of each feature channel. Finally, through the Scale operation, the output feature channel weight vector is multiplied by the original input feature map, that is, the weighted Feature Map is used as the input of the next layer of the network to complete the original feature calibration in the channel dimension. The final extracted features have stronger directionality than the initial features, thereby achieving the purpose of improving classification performance.
[0065] The SE module was created to solve the problem of loss caused by the different importance of different channels of the feature map during convolution and pooling. In the traditional convolution and pooling process, each channel of the feature map is assumed to be equally important, but in actual problems, the importance of different channels varies.
[0066] Figure 1 The following is a flow chart of a method for training an abnormal image detection model provided in an embodiment of the present application. Figure 1 As shown, the method may include:
[0067] Step S110: Acquire multiple image training samples and corresponding sample labels.
[0068] Considering that real-world images have many changes in brightness, saturation, angle, and position, after obtaining candidate image samples, it is necessary to use a preset sample quantity expansion method to process the candidate image samples and obtain the processed candidate image samples, that is, to perform data enhancement preprocessing operations on the candidate image samples;
[0069] Afterwards, the candidate image samples and the processed candidate image samples are determined as image training samples, thereby obtaining multiple image training samples and sample labels corresponding to the corresponding image training samples. The sample label is identification information used to characterize that the image training sample is a normal image sample or an abnormal image sample. In other words, the image training samples include normal image samples and abnormal image samples.
[0070] Step S120: for each image training sample, the image training sample is used as input data and input into a preset improved abnormal image detection network model to obtain an output detection result of the image training sample.
[0071] In the era of big data, in order to train deep learning models and obtain relatively ideal results, huge data resources and computing resources are required. However, in reality, the data set used for training the model is often small. Using only effective data sets for training can easily cause the trained network model to not converge or overfit. After the weight files of model parameters, i.e., model parameter values, are trained on sample training data sets in the ImageNet database of the computer vision system recognition project, such as VGGNet, DenseNet, EfficientNet, and Resnet neural networks, the trained network model is the improved abnormal image detection network model. The embodiment of the present application adopts a Resnet neural network with an initial residual structure, and the output of the improved abnormal image detection network model is adjusted from 1000 classifications to 2 classifications. The initial residual structure is the existing residual structure of the Resnet neural network.
[0072] Therefore, before executing this step, a sample training data set in the ImageNet database is obtained, and based on the sample training data set, the original network (such as the Resnet network) is iteratively trained to obtain an improved abnormal image detection network model and pre-trained model parameter values.
[0073] For each image training sample, the image training sample is used as input data, and the input network structure of the preset improved abnormal image detection network model is input. The residual network structure configured in the improved abnormal image detection network model is used to extract the image feature vector from the image information output by the input network structure. The output network structure of the improved abnormal image detection network model is used to detect the extracted image feature vector, and the detection result of the image training sample is output.
[0074] Figure 2 A schematic diagram of the model structure of an improved abnormal image detection network model provided in an embodiment of the present application is shown in FIG. Figure 2 As shown in the figure, the model structure of the improved abnormal image detection network model is as follows:
[0075] (1) The input network structure of the improved abnormal image detection network model may include 1 convolution layer, 1 maximum pooling layer and 1 channel attention mechanism module, namely, SE module;
[0076] Among them, the convolution layer is used to extract features from the input data to obtain the primary image feature vector;
[0077] The channel attention mechanism module is used to compress the primary image feature vector to obtain the global compressed feature vector of the primary image feature vector; process the global compressed feature vector of the primary image feature vector according to the feature channel to obtain the feature channel weight vector of the primary image feature vector, and multiply the feature channel weight vector with the primary image feature vector to output a secondary image feature vector focused on the feature channel; the channel attention mechanism module realizes the correction of the extracted features.
[0078] The maximum pooling layer is used to obtain the maximum image feature vector corresponding to the secondary image feature vector output by the channel attention mechanism layer.
[0079] Among them, the module structure of the channel attention mechanism module may include a global average pooling layer, a first fully connected layer (FC) connected to the global average pooling layer, a ReLU activation function layer connected to the first fully connected layer, a second fully connected layer connected to the ReLU activation function layer, and a Sigmoid activation function layer connected to the second fully connected layer.
[0080] The global average pooling layer reduces the number of parameters and the amount of calculation; the first fully connected layer distinguishes the results obtained in the previous step; and the RELU activation function is used to correct the linear unit to reduce the error.
[0081] (2) The residual network structure configured in the improved abnormal image detection network model may include multiple configured residual units connected in sequence; each configured residual unit includes an initial residual unit and a channel attention mechanism module; the channel attention mechanism module is embedded before the last convolutional layer in the initial residual unit.
[0082] Among them, Figure 2 As shown in the figure, when the residual network structure configured includes 4 residual units configured sequentially, from left to right, the first residual unit configured in the 4 residual units includes 3 convolutional layers, the second residual unit configured includes 4 convolutional layers, the third residual unit configured includes 6 convolutional layers, and the fourth residual unit configured includes 3 convolutional layers, wherein the convolution kernel size in each convolutional layer is the same. The main difference between the 4 residual units configured is the number of convolution kernels. Due to the different number of layers, the number of convolution kernels is also different (that is, the convolution kernel dimensions are different).
[0083] It can be understood that in the residual unit of the first configuration, the channel attention mechanism module is embedded between the second convolutional layer and the third 3 convolutional layers; in the residual unit of the second configuration, the channel attention mechanism module is embedded between the third convolutional layer and the third 4 convolutional layers, and so on. The embedding position of the channel attention mechanism module in the residual units of other configurations is not elaborated in the embodiments of the present application.
[0084] (3) The output network structure of the improved abnormal image detection network model may include 1 channel attention mechanism module, 1 average pooling layer and 1 fully connected layer;
[0085] The channel attention mechanism module is used to compress the image feature vector output by the configured residual network structure to obtain a global compressed feature vector of the image feature vector; process the global compressed feature vector of the image feature vector according to the feature channel to obtain a feature channel weight vector of the image feature vector, and multiply the feature channel weight vector of the image feature vector by the image feature vector, and output a secondary image feature vector that focuses on the output network structure;
[0086] The average pooling layer is used to calculate the secondary image feature vector corresponding to the output network structure to obtain a compressed feature vector corresponding to the secondary image feature vector;
[0087] The fully connected layer is used to obtain the detection results of the image training samples based on the obtained compressed feature vector.
[0088] The output network structure further corrects the obtained image features through the channel attention mechanism module, and uses the average pooling layer to average the obtained image feature vectors to reduce the problem of increased variance of the estimated value caused by the limited size of the domain. Then the fully connected layer outputs the final discrimination result to achieve classification.
[0089] Step S130: Based on the detection result of each image training sample and the sample label of the corresponding sample, the pre-trained detection model is iteratively trained to obtain a trained abnormal image detection model.
[0090] Furthermore, at least one image to be detected can be obtained in the application stage; and the at least one image to be detected is used as input data and input into a trained abnormal image detection model to obtain a detection result of the at least one image to be detected.
[0091] Using the learned abnormal image detection model, Pyqt is used to build a Windows client window program. The input end can select a single image to be detected or a collection of images to be detected, such as all images in a folder. After the image is loaded, the trained model parameters are loaded to classify the input image. The learned abnormal image detection model, that is, the improved residual model, is used. If the image is identified to meet the abnormal image characteristics, the identification result will be displayed in text form, and an early warning can also be issued.
[0092] After the abnormal image detection model is trained, the embodiment of the present application can build an image detection system. The system can be a server-client, that is, a Client-Server (C / S) structure, wherein the abnormal image detection model is located in the server, which can greatly shorten the manpower, material resources and financial resources spent on reviewing abnormal images.
[0093] For the detection of a single image, the single image needs to be input into the server. The server performs operations such as adaptive image scaling on the single image, determines whether the input image is an abnormal image based on pre-defined abnormal image rules, and outputs the results and possibilities in text form through the associated client.
[0094] For batch image detection, the folder needs to be uploaded to the server. The server classifies all the images in the folder and finally outputs the results and possibilities through the associated client.
[0095] The training method of the abnormal image detection model provided in the embodiment of the present application obtains multiple image training samples and corresponding sample labels. For each image training sample, the image training sample is used as input data, and the input network structure of the preset improved abnormal image detection network model is input, and the residual network structure configured in the improved abnormal image detection network model is used to extract the image feature vector from the image information output by the input network structure. The extracted image feature vector is detected by the output network structure of the improved abnormal image detection network model to obtain the detection result of the output image training sample; wherein, the initial network weight value of the improved abnormal image detection network model is a network weight value pre-trained based on the sample training data set in the ImageNet database of the computer vision system recognition project; based on the detection result of each image training sample and the sample label of the corresponding sample, the pre-trained detection model is iteratively trained to obtain the abnormal image detection model after training. The method introduces a channel attention mechanism module between the original residual network structure to utilize the feature information inside the channel. The parameter information obtained by training on the ImageNet dataset is migrated to the abnormal image detection field after the channel attention mechanism module is introduced, which improves the training efficiency of the model and improves the detection accuracy of the model.
[0096] Corresponding to the above method, the present application embodiment also provides a training device for an abnormal image detection model, such as Figure 3 As shown, the training device of the abnormal image detection model includes:
[0097] An acquisition unit 310 is used to acquire a plurality of image training samples and corresponding sample labels;
[0098] The input unit 320 is used to input each image training sample as input data into the input network structure of the preset improved abnormal image detection network model, and the residual network structure configured in the improved abnormal image detection network model extracts the image feature vector from the image information output by the input network structure, and the output network structure of the improved abnormal image detection network model detects the extracted image feature vector to obtain the output detection result of the image training sample; wherein the initial network weight value of the improved abnormal image detection network model is a network weight value pre-trained based on a sample training data set in the ImageNet database of the computer vision system recognition project;
[0099] The training unit 330 is used to iteratively train the improved abnormal image detection network model based on the detection result of each image training sample and the sample label of the corresponding sample to obtain a trained abnormal image detection model.
[0100] In an optional implementation, the input network structure of the improved abnormal image detection network model includes 1 convolution layer, 1 maximum pooling layer and 1 channel attention mechanism module;
[0101] The convolution layer is used to extract features from the input data to obtain a primary image feature vector;
[0102] The channel attention mechanism module is used to compress the primary image feature vector to obtain a global compressed feature vector of the primary image feature vector; process the global compressed feature vector of the primary image feature vector according to the feature channel to obtain a feature channel weight vector of the primary image feature vector, and multiply the feature channel weight vector by the primary image feature vector to output a secondary image feature vector focused on the feature channel;
[0103] The maximum pooling layer is used to obtain the maximum image feature vector corresponding to the secondary image feature vector output by the channel attention mechanism layer.
[0104] In an optional implementation, the residual network structure configured in the improved abnormal image detection network model includes a plurality of configured residual units connected in sequence;
[0105] Each configured residual unit includes 1 initial residual unit and 1 channel attention mechanism module; the channel attention mechanism module is embedded before the last convolution layer in the initial residual unit.
[0106] In an optional implementation, when the configured residual network structure includes 4 configured residual units connected in sequence, the first configured residual unit among the 4 configured residual units includes 3 convolutional layers, the second configured residual unit includes 4 convolutional layers, the third configured residual unit includes 6 convolutional layers, and the fourth configured residual unit includes 3 convolutional layers, wherein the convolution kernel size in each convolutional layer is the same.
[0107] In an optional implementation, the output network structure of the improved abnormal image detection network model includes 1 channel attention mechanism module, 1 average pooling layer and 1 fully connected layer;
[0108] The channel attention mechanism module is used to compress the image feature vector output by the configured residual network structure to obtain a global compressed feature vector of the image feature vector; process the global compressed feature vector of the image feature vector according to the feature channel to obtain a feature channel weight vector of the image feature vector, and multiply the feature channel weight vector of the image feature vector by the image feature vector to output a secondary image feature vector focused on the output network structure;
[0109] The average pooling layer is used to calculate the secondary image feature vector corresponding to the output network structure to obtain a compressed feature vector corresponding to the secondary image feature vector;
[0110] The fully connected layer is used to obtain the detection result of the image training sample based on the obtained compressed feature vector.
[0111] In an optional implementation, the acquisition unit 310 is specifically configured to:
[0112] Obtain candidate image samples;
[0113] Processing the candidate image samples by using a preset sample quantity expansion method to obtain processed candidate image samples;
[0114] The candidate image samples and the processed candidate image samples are determined as image training samples.
[0115] In an optional implementation, the acquisition unit 310 is further configured to acquire at least one image to be detected;
[0116] The input unit 320 is used to input the at least one image to be detected as input data into the trained abnormal image detection model to obtain a detection result of the at least one image to be detected.
[0117] The functions of each functional unit of the training device for the abnormal image detection model provided in the above-mentioned embodiments of the present application can be realized through the above-mentioned method steps. Therefore, the specific working process and beneficial effects of each unit in the training device for the abnormal image detection model provided in the embodiments of the present application will not be repeated here.
[0118] The present application also provides an electronic device, such as Figure 4 As shown, it includes a processor 410 , a communication interface 420 , a memory 430 and a communication bus 440 , wherein the processor 410 , the communication interface 420 , and the memory 430 communicate with each other via the communication bus 440 .
[0119] Memory 430, for storing computer programs;
[0120] The processor 410 is used to execute the program stored in the memory 430 to implement the following steps:
[0121] Obtain multiple image training samples and corresponding sample labels;
[0122] For each image training sample, the image training sample is used as input data, and the input network structure of the preset improved abnormal image detection network model is input. The residual network structure configured in the improved abnormal image detection network model extracts an image feature vector from the image information output by the input network structure, and the extracted image feature vector is detected by the output network structure of the improved abnormal image detection network model to obtain the output detection result of the image training sample; wherein the initial network weight value of the improved abnormal image detection network model is a network weight value pre-trained based on a sample training data set in the ImageNet database of a computer vision system recognition project;
[0123] Based on the detection result of each image training sample and the sample label of the corresponding sample, the pre-trained detection model is iteratively trained to obtain a trained abnormal image detection model.
[0124] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0125] The communication interface is used for communication between the above electronic device and other devices.
[0126] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0127] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0128] The implementation methods and beneficial effects of the components of the electronic device in the above embodiments to solve the problems can be found in Figure 1 The various steps in the illustrated embodiment are implemented, therefore, the specific working process and beneficial effects of the electronic device provided by the embodiment of the present application are not repeated here.
[0129] In another embodiment provided in the present application, a computer-readable storage medium is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the training method of the abnormal image detection model described in any of the above embodiments.
[0130] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the training method of the abnormal image detection model described in any of the above embodiments.
[0131] Those skilled in the art will appreciate that the embodiments in the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt a complete hardware embodiment, a complete software embodiment, or a form of an embodiment combining software and hardware. Moreover, the present application may adopt a form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0132] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0133] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0135] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present application.
[0136] Obviously, those skilled in the art can make various changes and modifications to the embodiments in the present application without departing from the spirit and scope of the embodiments in the present application. Thus, if these modifications and variations of the embodiments in the present application fall within the scope of the claims and their equivalents in the embodiments of the present application, the embodiments of the present application are also intended to include these modifications and variations.
Claims
1. A training method for an abnormal image detection model, characterized in that: The method comprises: Acquire a plurality of image training samples and corresponding sample labels, wherein the plurality of image training samples include normal image training samples and abnormal image training samples; For each image training sample, the image training sample is used as input data and input into a preset improved abnormal image detection network model, wherein the preset improved abnormal image detection network model includes an input network structure, a residual network structure and an output network structure connected in sequence; the residual network structure configured in the improved abnormal image detection network model extracts an image feature vector from the image information output by the input network structure; the output network structure of the improved abnormal image detection network model detects the extracted image feature vector to obtain the output detection result of the image training sample; wherein the initial network weight value of the improved abnormal image detection network model is a network weight value pre-trained based on a sample training data set in the ImageNet database of a computer vision system recognition project; Based on the detection result of each image training sample and the sample label of the corresponding sample, iteratively training the improved abnormal image detection network model to obtain a trained abnormal image detection model; Among them, the input network structure of the improved abnormal image detection network model includes 1 convolution layer, 1 maximum pooling layer and 1 channel attention mechanism module; The residual network structure configured in the improved abnormal image detection network model includes a plurality of configured residual units connected in sequence; Each configured residual unit includes an initial residual unit and a channel attention mechanism module; the channel attention mechanism module is embedded before the last convolutional layer in the initial residual unit; The output network structure of the improved abnormal image detection network model includes 1 channel attention mechanism module, 1 average pooling layer and 1 fully connected layer.
2. The method according to claim 1, characterized in that The convolution layer in the input network structure is used to extract features from the input data to obtain a primary image feature vector; The channel attention mechanism module in the input network structure is used to compress the primary image feature vector to obtain a global compressed feature vector of the primary image feature vector; process the global compressed feature vector of the primary image feature vector according to the feature channel to obtain a feature channel weight vector of the primary image feature vector, and multiply the feature channel weight vector by the primary image feature vector to output a secondary image feature vector focused on the feature channel; The maximum pooling layer is used to obtain the maximum image feature vector corresponding to the secondary image feature vector output by the channel attention mechanism layer.
3. The method according to claim 1, characterized in that When the configured residual network structure includes 4 configured residual units connected in sequence, the first configured residual unit among the 4 configured residual units includes 3 convolutional layers, the second configured residual unit includes 4 convolutional layers, the third configured residual unit includes 6 convolutional layers, and the fourth configured residual unit includes 3 convolutional layers, wherein the convolution kernel size in each convolutional layer is the same.
4. The method according to claim 1, characterized in that The channel attention mechanism module in the output network structure is used to compress the image feature vector output by the configured residual network structure to obtain a global compressed feature vector of the image feature vector; process the global compressed feature vector of the image feature vector according to the feature channel to obtain a feature channel weight vector of the image feature vector, and multiply the feature channel weight vector of the image feature vector by the image feature vector to output a secondary image feature vector focused on the output network structure; The average pooling layer is used to calculate the secondary image feature vector corresponding to the output network structure to obtain a compressed feature vector corresponding to the secondary image feature vector; The fully connected layer is used to obtain the detection result of the image training sample based on the obtained compressed feature vector.
5. The method according to claim 1, characterized in that Get multiple image training samples, including: Obtain candidate image samples; Processing the candidate image samples by using a preset sample quantity expansion method to obtain processed candidate image samples; The candidate image samples and the processed candidate image samples are determined as image training samples.
6. The method according to claim 1, characterized in that After obtaining the trained abnormal image detection model, the method further includes: Acquire at least one image to be detected; The at least one image to be detected is used as input data and input into the trained abnormal image detection model to obtain a detection result of the at least one image to be detected.
7. A training device for an abnormal image detection model, characterized in that: The device comprises: An acquisition unit, used for acquiring a plurality of image training samples and corresponding sample labels; An input unit is used to input each image training sample as input data into a preset improved abnormal image detection network model, wherein the preset improved abnormal image detection network model includes an input network structure, a residual network structure and an output network structure connected in sequence; the residual network structure configured in the improved abnormal image detection network model extracts an image feature vector from the image information output by the input network structure; the output network structure of the improved abnormal image detection network model detects the extracted image feature vector to obtain the output detection result of the image training sample; wherein the initial network weight value of the improved abnormal image detection network model is a network weight value pre-trained based on a sample training data set in the ImageNet database of a computer vision system recognition project; A training unit, configured to iteratively train the improved abnormal image detection network model based on the detection result of each image training sample and the sample label of the corresponding sample to obtain a trained abnormal image detection model; Among them, the input network structure of the improved abnormal image detection network model includes 1 convolution layer, 1 maximum pooling layer and 1 channel attention mechanism module; The residual network structure configured in the improved abnormal image detection network model includes a plurality of configured residual units connected in sequence; Each configured residual unit includes an initial residual unit and a channel attention mechanism module; the channel attention mechanism module is embedded before the last convolutional layer in the initial residual unit; The output network structure of the improved abnormal image detection network model includes 1 channel attention mechanism module, 1 average pooling layer and 1 fully connected layer.
8. An electronic device, characterized in that: The electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 6 when executing a program stored in a memory.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Image identification method and system for identifying abnormal label of electric energy meter
CN113627553A