WO2023040510A1 - 图像异常检测模型训练方法、图像异常检测方法和装置 - Google Patents

图像异常检测模型训练方法、图像异常检测方法和装置 Download PDF

Info

Publication number
WO2023040510A1
WO2023040510A1 PCT/CN2022/110998 CN2022110998W WO2023040510A1 WO 2023040510 A1 WO2023040510 A1 WO 2023040510A1 CN 2022110998 W CN2022110998 W CN 2022110998W WO 2023040510 A1 WO2023040510 A1 WO 2023040510A1
Authority
WO
WIPO (PCT)
Prior art keywords
label
training
image
loss
model
Prior art date
Application number
PCT/CN2022/110998
Other languages
English (en)
French (fr)
Inventor
张博深
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2023040510A1 publication Critical patent/WO2023040510A1/zh
Priority to US18/141,011 priority Critical patent/US20230267730A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/98Detection or correction of errors, e.g. by rescanning the pattern or by human intervention; Evaluation of the quality of the acquired patterns
    • G06V10/993Evaluation of the quality of the acquired pattern
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/774Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/764Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/776Validation; Performance evaluation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks

Definitions

  • the present application relates to the field of computer technology, in particular to a method for training an image anomaly detection model, an image anomaly detection method, a device, computer equipment, a storage medium, and a computer program product.
  • Machine learning models can be trained to detect abnormalities in images, thereby filtering out abnormal and low-quality images.
  • model training is usually performed on machine learning models based on training images.
  • the training images are usually simple binary classification images, that is, the training images are divided into normal images and abnormal images.
  • abnormal images usually correspond to various degrees of abnormal situations.
  • Simple binary classification labels may have a lot of subjectivity, which may lead to noise in the training labels of training images.
  • the accuracy of the model trained based on such training images is low. The problem.
  • the present application provides an image anomaly detection model training method, an image anomaly detection method, a device, a computer device, a storage medium, and a computer program product.
  • An image abnormality detection model training device comprising:
  • the training data acquisition module is used to obtain the initial mapping label corresponding to the training label, and use the initial mapping label as the current mapping label;
  • the model prediction module is used to input the training images in the current training image set into the initial image anomaly detection model to obtain the target prediction labels corresponding to the training images;
  • a model feedback data determination module configured to generate model feedback data based on the current mapping label and the target prediction label corresponding to the training label of the training image
  • a label adjustment module configured to generate a label loss based on the data change reference information corresponding to the model feedback data, adjust the current mapping label based on the label loss to obtain an updated mapping label, and use the updated mapping label as the current mapping label;
  • a model adjustment module configured to adjust the model parameters of the initial image anomaly detection model based on the model feedback data to obtain an updated image anomaly detection model, and use the updated image anomaly detection model as the initial image anomaly detection model to obtain the next training image set As the current training image set, return to the step of inputting the training images in the current training image set into the initial image anomaly detection model until the training end condition is satisfied, and the target image anomaly detection model is obtained.
  • a computer device comprising a memory and one or more processors, the memory storing computer readable instructions which, when executed by the one or more processors, cause the one or more The processor executes the steps of the above-mentioned image abnormality detection model training method.
  • One or more non-transitory computer-readable storage media on which are stored computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the above-mentioned Steps of a method for training an image anomaly detection model.
  • a computer program product or computer program comprising computer readable instructions stored on a computer readable storage medium for one or more processors of a computer device to read from the The computer-readable storage medium reads the computer-readable instructions, and the one or more processors execute the computer-readable instructions, so that the computer device executes the steps of the above-mentioned image abnormality detection model training method.
  • a method for detecting an image abnormality, performed by a computer device comprising:
  • the training process of the target image abnormality detection model includes:
  • An image abnormality detection device comprising:
  • An image acquisition module configured to acquire an image to be detected
  • a label prediction module configured to input the image to be detected into a target image anomaly detection model to obtain a model prediction label corresponding to the image to be detected;
  • a detection result determination module configured to determine an abnormal image detection result corresponding to the image to be detected based on the model prediction label
  • the training process of the target image abnormality detection model includes:
  • a computer device comprising a memory and one or more processors, the memory storing computer readable instructions which, when executed by the one or more processors, cause the one or more The processor executes the steps of the above image anomaly detection method.
  • One or more non-transitory computer-readable storage media on which are stored computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the above-mentioned Steps of an image anomaly detection method.
  • a computer program product or computer program comprising computer readable instructions stored on a computer readable storage medium for one or more processors of a computer device to read from the The computer-readable storage medium reads the computer-readable instructions, and the one or more processors execute the computer-readable instructions, so that the computer device executes the steps of the above image anomaly detection method.
  • Fig. 1 is an application environment diagram of an image anomaly detection model training method and an image anomaly detection method in an embodiment
  • Fig. 2 is a schematic flow chart of an image abnormality detection model training method in an embodiment
  • Fig. 3 is a schematic flow chart of an image abnormality detection model training method in another embodiment
  • FIG. 4 is a schematic flow diagram of a method for training an image abnormality detection model in yet another embodiment
  • FIG. 5 is a schematic flow chart of an image abnormality detection method in an embodiment
  • Fig. 6 is a schematic diagram of a blurry image in an embodiment
  • Fig. 7 is a schematic flow chart of a method for training an image blurring detection model in an embodiment
  • Fig. 8 is a schematic diagram of image blurring detection results in an embodiment
  • Fig. 9 is a structural block diagram of an image abnormality detection model training device in an embodiment
  • Fig. 10 is a structural block diagram of an image abnormality detection device in an embodiment
  • Figure 11 is an internal structural diagram of a computer device in one embodiment
  • Figure 12 is a diagram of the internal structure of a computer device in one embodiment.
  • the image anomaly detection model training method and the image anomaly detection method provided in this application can be applied to the application environment shown in FIG. 1 .
  • the terminal 102 communicates with the server 104 through the network.
  • the terminal 102 can be, but not limited to, various desktop computers, notebook computers, smart phones, tablet computers, IoT devices and portable wearable devices, and the IoT devices can be smart speakers, smart TVs, smart air conditioners, smart vehicle devices, etc.
  • Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, and the like.
  • the server 104 may be implemented by an independent server or a server cluster composed of multiple servers or a cloud server.
  • Both the terminal 102 and the server 104 can be independently used to execute the image anomaly detection model training method and the image anomaly detection method provided in the embodiment of the present application.
  • the server obtains the initial mapping label corresponding to the training label, uses the initial mapping label as the current mapping label, inputs the training images in the current training image set into the initial image anomaly detection model, and obtains the target prediction label corresponding to the training image.
  • the server generates model feedback data based on the current mapping label and target prediction label corresponding to the training label of the training image, generates label loss based on the data change reference information corresponding to the model feedback data, adjusts the current mapping label based on the label loss to obtain an updated mapping label, and updates the mapping label as the current map label.
  • the server adjusts the model parameters of the initial image anomaly detection model based on the model feedback data to obtain an updated image anomaly detection model, uses the updated image anomaly detection model as the initial image anomaly detection model, obtains the next training image set as the current training image set, and returns the current
  • the step of inputting the training images in the training image set into the initial image anomaly detection model is performed until the training end condition is met, and the target image anomaly detection model is obtained.
  • the server obtains the image to be detected, inputs the image to be detected into the target image anomaly detection model, obtains the model prediction label corresponding to the image to be detected, and determines the image anomaly detection result corresponding to the image to be detected based on the model prediction label.
  • the terminal 102 and the server 104 can also cooperate to execute the image anomaly detection model training method and the image anomaly detection method provided in the embodiment of the present application.
  • the server fetches the training image set from the terminal.
  • the server obtains the initial mapping label corresponding to the training label, uses the initial mapping label as the current mapping label, inputs the training image into the initial image anomaly detection model, and obtains the target prediction label corresponding to the training image.
  • the server generates model feedback data based on the current mapping label and target prediction label corresponding to the training label of the training image, generates label loss based on the data change reference information corresponding to the model feedback data, adjusts the current mapping label based on the label loss to obtain an updated mapping label, and updates the mapping label as the current map label.
  • the server adjusts the model parameters of the initial image anomaly detection model based on the model feedback data to obtain an updated image anomaly detection model, uses the updated image anomaly detection model as the initial image anomaly detection model, obtains the next training image set as the current training image set, and returns the current
  • the step of inputting the training images in the training image set into the initial image anomaly detection model is performed until the training end condition is met, and the target image anomaly detection model is obtained.
  • the server sends the target image anomaly detection model to the terminal.
  • the terminal acquires the image to be detected, and the terminal inputs the image to be detected into the target image anomaly detection model to obtain the model prediction label corresponding to the image to be detected, and the terminal determines the image anomaly detection result corresponding to the image to be detected based on the model prediction label.
  • a method for training an image abnormality detection model is provided.
  • the method is applied to the computer in FIG. 1 as an example for illustration.
  • the computer device can be the terminal 102, It may also be a server 104 .
  • the image abnormality detection model training method includes the following steps:
  • step S202 the initial mapping label corresponding to the training label is obtained, and the initial mapping label is used as the current mapping label.
  • the training label is a manually marked label, which is used to identify the image abnormality determination result of the training image.
  • Training images refer to images used for model training.
  • An image can be a picture or a video frame in a video.
  • the training label can be a binary classification label.
  • the training label corresponding to an abnormal image is a negative label, which is represented by 1
  • the training label corresponding to an image without abnormality is a positive label, which is represented by 0.
  • the training label can also be a multi-category label.
  • the training label corresponding to the image without abnormality is the first label, which is represented by 0, and the training label corresponding to the image with obvious abnormality is the second label, which is represented by 1.
  • the training label corresponding to the image is the third label, denoted by 2.
  • the initial mapping label is obtained by performing mapping transformation on the training label, and the mapping transformation is used to convert the discrete training label into data that is easy for the model to learn and calculate.
  • a training label is usually represented by a constant value, and after mapping conversion, the initial mapping label corresponding to the training label can be represented by a vector. In one embodiment, the distances between various initial mapping labels are consistent.
  • the computer device may obtain training samples of the image anomaly detection model locally or from other terminals or servers, and the training samples include training images and training labels corresponding to the training images.
  • the computer device can perform mapping transformation on the training labels to obtain the initial mapping labels. It can be understood that the computer device may use a self-defined algorithm or formula to perform mapping conversion.
  • the training samples can also directly include training images, corresponding training labels and initial mapping labels.
  • the training label is a label marked manually, which has a certain degree of human subjectivity, which leads to noise in the training label.
  • the feature learning ability of the neural network can be used to identify and correct the noisy training labels. Therefore, during model training, in addition to adjusting the model parameters, the training labels can also be adjusted synchronously.
  • Model training adopts iterative training. In the first round of iterative training, the initial mapping label is used as the current mapping label, and the current mapping label is used as the supervision signal of the model for model training. In the first round of iterative training, the initial Mapping labels are adjusted to get updated mapping labels.
  • the updated mapping label obtained in the previous round is used as the new current mapping label, and the new current mapping label is used as the supervision signal of the model for model training.
  • the previous The updated map label obtained in rounds is adjusted again to obtain a new updated map label.
  • model training samples may be set for different types of image abnormalities, and each model training sample is used to specifically train a corresponding image abnormality detection model.
  • image abnormalities include image blur, image blur, image mosaic, and image smear.
  • image blurring and image blurring you can specially train an image blurring detection model, and the training label of the training image in the training sample corresponding to the image blurring detection model is used to identify whether there is blurring in the image.
  • image blurring an image blurring detection model can be specially trained, and the training label of the training image in the training sample corresponding to the image blurring detection model is used to identify whether there is blurring in the image.
  • Step S204 input the training images in the current training image set into the initial image anomaly detection model, and obtain the target prediction labels corresponding to the training images.
  • the current training image set refers to the currently used training image set.
  • the current set of training images includes at least one training image.
  • the initial image anomaly detection model refers to the image anomaly detection model to be trained.
  • the image anomaly detection model is a machine learning model, specifically a convolutional neural network, a deep neural network, and other types of models.
  • the input data of the image anomaly detection model is the image, and the output data is the predicted label.
  • the predicted label is used to identify the probability that the input image is abnormal. Predicted labels can also be represented as vectors.
  • the computer device can input the training image into the initial image anomaly detection model, and after the initial image anomaly detection model processes the input data, it can output the target prediction label corresponding to the training image.
  • the initial image anomaly detection model may be an original image anomaly detection model, and the model parameters in the original image anomaly detection model are randomly initialized, that is, the initial image anomaly detection model may not be trained by any model original model.
  • the initial image anomaly detection model may also be a pre-trained image anomaly detection model, that is, the initial image anomaly detection model may be obtained by pre-training the original image anomaly detection model.
  • Step S206 generating model feedback data based on the current mapping label and the target prediction label corresponding to the training label of the training image.
  • the model feedback data is used to characterize the data difference between the current mapped label and the target predicted label.
  • adjusting model parameters based on model feedback data can make the output data of the model closer to the current mapping label and closer to the real result.
  • the computer device can calculate the model feedback data based on the data distribution difference between the current mapping label corresponding to the training label of the training image and the target prediction label corresponding to the training image. For example, the distance between the current mapping label corresponding to the training label of the training image and the target prediction label can be calculated to obtain the classification loss, and the classification loss can be used as the model feedback data.
  • the prior loss can also be obtained based on the training label and the target prediction label, and the model feedback data can be obtained based on the classification loss and the prior loss.
  • the self-entropy loss can also be obtained based on the target prediction label
  • the model feedback data can be obtained based on the classification loss, prior loss and self-entropy loss
  • the model feedback data can also be obtained based on the classification loss and self-entropy loss.
  • the classification loss, prior loss and self-entropy loss can be obtained by calculating the divergence of the data, or by calculating the cross-entropy of the data, or by using custom formulas, algorithms, etc. .
  • Step S208 generate a label loss based on the data change reference information corresponding to the model feedback data, adjust the current mapped label based on the label loss to obtain an updated mapped label, and use the updated mapped label as the current mapped label.
  • the data change reference information is used to measure the data change speed of the model feedback data along the direction of the current mapping label.
  • the model feedback data is obtained based on the current mapping label and the target prediction label.
  • the current mapping label and the target prediction label are variables. Since the label loss is used to adjust the current mapping label corresponding to the training label, Therefore, the computer device can generate data change reference information based on the change speed of the model feedback data in the direction of the current mapping label, and then generate label loss based on the data change reference information, adjust the current mapping label based on the label loss to obtain an updated mapping label, and update the mapping label as the new current mapping label.
  • the gradient can be used to measure the speed of change of a function along a certain direction.
  • the computer device can calculate the gradient of the model feedback data to the current mapping label to obtain the loss gradient, use the loss gradient as the reference information of the data change, and obtain the label loss based on the loss gradient , adjust the current map label based on the label loss to get the updated map label.
  • the computer device can use the updated mapping label as the current mapping label in the next round of model training, and continuously identify and correct the noisy training labels through model iteration.
  • the computer device can also calculate the data change reference information by using a custom formula or algorithm.
  • generating the label loss based on the data change reference information may be to use the data change reference information as the label loss, or to fuse the data change reference information and hyperparameters, and use the fused data as the label loss.
  • Hyperparameters can be preset fixed values, and hyperparameters can also be used as a model parameter to be adjusted and learned during model training.
  • Step S210 adjust the model parameters of the initial image anomaly detection model based on the model feedback data to obtain an updated image anomaly detection model, use the updated image anomaly detection model as the initial image anomaly detection model, obtain the next training image set as the current training image set, and return
  • the step of inputting the training images in the current training image set into the initial image anomaly detection model is executed until the training end condition is satisfied, and the target image anomaly detection model is obtained.
  • the updated image anomaly detection model refers to a model obtained by adjusting model parameters of the initial image anomaly detection model.
  • the target image anomaly detection model refers to the trained image anomaly detection model.
  • the computer device in addition to adjusting the current mapping label based on the model feedback data, the computer device also needs to synchronously adjust model parameters based on the model feedback data.
  • the computer device can perform backpropagation based on the model feedback data to update model parameters of the initial image anomaly detection model, thereby obtaining an updated image anomaly detection model.
  • the computer device can use the updated image anomaly detection model as a new initial image anomaly detection model, use the updated mapping label as a new current mapping label, and obtain the next training image set as a new current training image set, based on the new current training image set , the current mapping label and the initial image anomaly detection model start a new round of model iterative training.
  • the computer device can input the training images in the new current training image set into the updated initial image anomaly detection model to obtain an updated target prediction label, based on the updated current mapping label and the updated target prediction label Generate updated model feedback data, and readjust the current mapped labels and model parameters of the initial image anomaly detection model based on the updated model feedback data.
  • the above steps are repeated until the training end condition is satisfied, the training is stopped, and the abnormal detection model of the target image is obtained.
  • the training end condition includes at least one of the number of model iterations being greater than the preset number of iterations, the value of the model feedback data being less than a preset target value, the rate of change of the model feedback data being less than a preset rate of change, and the minimization of the model feedback data.
  • the preset number of iterations, the preset target value, and the preset change rate are all preset data, which can be set according to actual needs.
  • the initial mapping label is used as the current mapping label
  • the initial image anomaly detection model is trained based on the current mapping label and the training image set A1 to adjust the model parameters to obtain an updated image anomaly detection model A2, Synchronously adjust the initial mapping label to obtain the updated mapping label A3.
  • the updated mapping label A3 obtained in the first round is used as the new current mapping label
  • the updated image anomaly detection model A2 obtained in the first round is used as the new initial image anomaly detection model, based on the current mapping label
  • the updated mapping label B3 obtained in the second round is used as the new current mapping label
  • the updated image anomaly detection model B2 obtained in the second round is used as the new initial image anomaly detection model, based on the current mapping label
  • the updated image anomaly detection model obtained from the latest round of iterative training is used as the target image anomaly detection model.
  • each set of training images may include the same training images.
  • Each set of training images may also include different training images.
  • the computer device can adjust the model parameters of the initial image anomaly detection model through a gradient descent algorithm based on the model feedback data.
  • the computer device can train the current mapping label and the initial image anomaly detection model based on the model feedback data until the first training end condition is satisfied, and the intermediate image anomaly detection model and target mapping label can be obtained, and the intermediate image can be directly
  • the anomaly detection model serves as an anomaly detection model for target images.
  • the computer device can also keep the target mapping label unchanged, train the intermediate image anomaly detection model based on the training image set, fine-tune the model parameters of the intermediate image anomaly detection model, and obtain the target image anomaly detection model.
  • the training images in the training image set can be input into the intermediate image anomaly detection model to obtain an updated prediction label
  • the update loss is calculated based on the update prediction label and the target mapping label
  • the model parameters of the intermediate image anomaly detection model are adjusted based on the update loss until the second
  • the training end condition is to obtain the target image anomaly detection model.
  • the first training end condition and the second training end condition can be the same training end condition, for example, the number of model iterations is greater than the preset iteration number, or different training end conditions, for example, the first training end condition is model feedback data
  • the value of is less than the preset target value
  • the second training end condition is that the number of model iterations is greater than the preset number of iterations.
  • the target image abnormality detection model is any one of image blurring detection model, image blur detection model and image mosaic detection model.
  • the image blurring detection model is used to detect whether there is a blurring phenomenon in the input image.
  • the blurred screen phenomenon is an abnormal image caused by problems in the encoding and decoding process of the image.
  • the image blur detection model is used to detect whether the input image is blurred or not.
  • the blur phenomenon is an image abnormality caused by shooting parameters or shooting angles of the shooting device when the image is taken.
  • the image mosaic detection model is used to detect whether there is a mosaic phenomenon in the input image.
  • the mosaic phenomenon is an image abnormality caused by the deterioration of the gradation details in a local area of the image.
  • the image anomaly detection model training method of the present application is applicable to various image anomaly detection models, and can effectively improve the efficiency and accuracy of image anomaly detection.
  • the image anomaly detection model by obtaining the initial mapping label corresponding to the training label, using the initial mapping label as the current mapping label, inputting the training images in the current training image set into the initial image anomaly detection model, and obtaining the target prediction corresponding to the training image label, based on the current mapping label corresponding to the training label of the training image and the target prediction label to generate model feedback data, generate label loss based on the data change reference information corresponding to the model feedback data, adjust the current mapping label based on the label loss to obtain an updated mapping label, and update
  • the mapping label is used as the current mapping label, and the model parameters of the initial image anomaly detection model are adjusted based on the model feedback data to obtain an updated image anomaly detection model.
  • the updated image anomaly detection model is used as the initial image anomaly detection model, and the next training image set is obtained as the current training Image set, return to the step of inputting the training images in the current training image set into the initial image anomaly detection model until the training end condition is satisfied, and the target image anomaly detection model is obtained.
  • the current mapping label and model parameters are adjusted synchronously, and the feature learning ability of the model is used to self-correct the current mapping label corresponding to the noisy training label, which can effectively filter the impact of noisy data on the performance of the model, greatly Improve the performance of the model, and finally train an image anomaly detection model with high accuracy.
  • the image anomaly detection results with high accuracy can be obtained, which effectively improves the detection accuracy and detection efficiency of image anomaly detection.
  • obtaining the initial mapping label corresponding to the training label includes:
  • label encoding is performed on the training label to obtain the initial mapping label.
  • the number of label categories refers to the number of label categories of the training labels. For example, if the training label is a binary classification label, then the number of label categories is 2, and if the training label is a four-category label, then the number of label categories is 4. Label encoding is used to convert training labels into data represented by binary.
  • the computer device may perform label encoding on the training label based on the number of label categories corresponding to the training label, and convert the training label mapping into the initial mapping label.
  • the computer device can determine the number of vector dimensions corresponding to the initial mapping label based on the number of label categories, and the initial vector value on each vector dimension defaults to the first preset value, and sequentially converts the initial vector values on each vector dimension to the second preset value respectively. Set the value to get the initial mapping label corresponding to the training label of each label category.
  • a vector dimension corresponds to a label category, and the vector value on each vector dimension represents the probability that the image belongs to the corresponding label category.
  • the training label is a binary classification label and the number of label categories is 2, then the number of vector dimensions corresponding to the initial mapping label is 2, that is, the initial mapping label is a two-dimensional vector.
  • the initial shape of the two-dimensional vector may be [0, 0], that is, the first preset value is 0, and the second preset value is 1. Convert the initial values on each vector dimension to the second preset value in turn, then the initial mapping label corresponding to the positive label in the binary classification label is [0, 1], and the initial mapping label corresponding to the negative label is [1, 0 ].
  • 0 represents the probability that the image belongs to the negative label
  • 1 represents the probability that the image belongs to the positive label.
  • the initial mapping label is a three-dimensional vector.
  • the initial shape of the three-dimensional vector can be [0, 0, 0], the initial mapping label corresponding to the first label in the three-category label is [0, 0, 1], and the initial mapping label corresponding to the second label is [0, 1 , 0], the initial mapping label corresponding to the third label is [1, 0, 0].
  • the distance between each pair of initially mapped labels is the same.
  • the first preset value may also be 1, and the second preset value may be 0. It can be understood that with the update of the model and network, the initial mapping label will be gradually softened. For example, the initial mapping label [1, 0] corresponding to the negative label will be adjusted to [0.8, 0.2].
  • the training labels are coded based on the number of label categories corresponding to the training labels to obtain the initial mapping labels.
  • the initial mapping labels are composed of binary data, and the distance between each pair is the same, which is easy to be learned and calculated by the model.
  • the method before inputting the training images in the current training image set into the initial image anomaly detection model, and obtaining the target prediction labels corresponding to the training images, the method further includes:
  • Step S302 input the training images in the candidate training image set into the candidate image anomaly detection model, and obtain the initial prediction labels corresponding to the training images.
  • Step S304 based on the label difference between the training label corresponding to the training image in the candidate training image set and the initial prediction label, adjust the model parameters of the candidate image anomaly detection model until the first convergence condition is met, and obtain the initial image anomaly detection model.
  • the candidate image anomaly detection model is an original image anomaly detection model, and the model parameters in the candidate image anomaly detection model may be initialized randomly, or may be artificially set initial values.
  • the candidate training image set refers to the training image set used to train the candidate image anomaly detection model, and the candidate training image set may include at least one training image.
  • the candidate training image set and the current training image set may be the same training image set or different training image sets, that is, the candidate training image set and the current training image set may include the same training image or different training images.
  • the computer device can also pre-train the candidate image anomaly detection model, and use the trained candidate image anomaly detection model as the initial image anomaly detection model.
  • the candidate image anomaly detection model only the model parameters are adjusted, and the training labels are not adjusted, so that the subsequent model training for the initial image anomaly detection model can converge faster than training from scratch.
  • the computer device inputs the training images in the candidate training image set into the candidate image anomaly detection model, and after the candidate image anomaly detection model processes the input data, it can output the initial prediction label corresponding to the training image.
  • the computer device can generate a training loss based on the label difference between the training label corresponding to the training image and the initial prediction label, and perform backpropagation based on the training loss to update the model parameters of the candidate image anomaly detection model until the first convergence condition is met, and the initial Image anomaly detection model.
  • the distance between the training label and the initial prediction label can be calculated to obtain the training loss, for example, the divergence calculation is performed on the initial prediction label and the training label to obtain the training loss; the cross-entropy calculation is performed on the initial prediction label and the training label to obtain the training loss; etc.
  • the first convergence condition may be at least one of the number of model iterations reaching a first preset threshold, the value of the training loss being smaller than a preset training value, and the like.
  • the initial image anomaly detection model is obtained by pre-training the candidate image anomaly detection model, which can reduce the training difficulty of the initial image anomaly detection model and improve the training speed.
  • the candidate image anomaly detection model is directly obtained as the initial image anomaly detection model, since the model parameters are randomly initialized, it is difficult to update the model parameters and the current mapping label at the same time, and the training may be unstable. Therefore, at the beginning, the current mapping label is fixed, only the network parameters are updated, and the model training is performed on the candidate image anomaly detection model to obtain the initial image anomaly detection model. Later, when the initial image anomaly detection model is trained, the model parameters and the current mapping label are updated at the same time. , which can effectively reduce the training difficulty.
  • model feedback data is generated based on current mapped labels and target predicted labels, including:
  • the divergence calculation is a calculation method to measure the distribution difference between two data.
  • the label distribution scale is used to represent the distribution of training images among the various label categories.
  • the computer device can calculate the divergence of the current mapping label and the target prediction label to obtain the first loss.
  • the first loss is used to measure the difference between the prediction probability output by the current model and the manually labeled data.
  • the first loss can also be called classification loss.
  • the computer device can also obtain the label distribution ratio corresponding to the training label, calculate the second loss based on the label distribution ratio and the target prediction label, and the second loss is used to measure the predicted probability of the current model output and the prior label distribution ratio
  • the second loss can also be called the prior loss.
  • the purpose of the prior loss is to make the predicted probability not too far from the label distribution ratio.
  • the computer device fuses the calculated first loss and the second loss to obtain the model feedback data, for example, the first loss and the second loss are added to obtain the model feedback data, and the weighted sum of the first loss and the second loss is used as Model feedback data, etc.
  • the first loss is obtained by performing divergence calculation on the current mapping label and the target prediction label
  • the second loss is obtained based on the label distribution ratio and the target prediction label
  • the model feedback data is obtained based on the first loss and the second loss.
  • Model feedback data consists of different types of losses. Adjusting model parameters and current mapping labels based on such model feedback data to train the model can improve the accuracy of model training.
  • the divergence calculation is performed on the current mapping label and the target prediction label to obtain the first loss, including:
  • Logarithmic transformation is performed on the ratio of the current mapping label and the target prediction label to obtain the label transformation ratio; the label transformation ratio and the target prediction label are fused to obtain the first loss.
  • the computer device may calculate a ratio between the current mapped label and the target predicted label, and logarithmically transform the ratio, so as to obtain a label conversion ratio for calculating the first loss.
  • the preset value can be used as the base number, and the ratio of the current mapping label and the target prediction label can be used as a real number to perform logarithmic transformation to obtain the label transformation ratio, or the preset value can be used as the base number, and the fusion value of the ratio and the constant value can be used as The real number is logarithmically transformed to obtain the label transformation ratio.
  • the preset value and the constant value can be set as required, for example, the preset value and the constant value are data greater than 1.
  • the fusion value can be the sum of the ratio of the current mapping label and the target prediction label and a constant value, or the product of the ratio of the current mapping label and the target prediction label and a constant value, etc.
  • the computer device can fuse the target predicted label and the label transformation ratio to obtain the first loss, for example, the product of the target prediction label and the label transformation ratio is used as the first loss, and the weighted product of the target prediction label and the label transformation ratio is used as first loss.
  • the optimization direction of the first loss is that the closer the current mapping label and the target prediction label are, the better.
  • the calculation formula of the first loss is as follows:
  • Lc represents the first loss
  • p represents the target prediction label
  • the ratio of the current mapped label and the target predicted label is logarithmically transformed to obtain the label transformation ratio, and the first loss can be quickly obtained by fusing the label transformation ratio with the target predicted label. The closer and more similar the current mapped label and target predicted label are, the closer the first loss is to zero.
  • the divergence calculation is performed on the current mapping label and the target prediction label to obtain the first loss, including:
  • the computer device can perform statistics on the current mapping label and the target prediction label, and use the statistical results as label statistics, for example, use the mean value of the current mapping label and the target prediction label as the label statistics information, and use the current mapping label and the target prediction label and as label statistics. Furthermore, the computer device performs logarithmic transformation on the ratio of the label statistical information and the target predicted label to obtain the first transformation ratio, and performs logarithmic transformation on the ratio of the label statistical information and the current mapped label to obtain the second transformation ratio.
  • the preset value For example, use the preset value as the base, and use the ratio of the label statistics and the target predicted label as the real number to perform logarithmic transformation to obtain the first transformation ratio, use the preset value as the base, and take the ratio of the label statistics and the current mapped label as Logarithmic transformation is performed on the real number to obtain the second transformation ratio.
  • the computer device fuses the target prediction label and the first transformation scale to obtain the first sub-loss, and fuses the current mapping label and the second transformation scale to obtain the second sub-loss.
  • the product of the target prediction label and the first transformation scale is used as The first sub-loss takes the product of the current mapping label and the second transformation scale as the second sub-loss.
  • the computer device can obtain the first loss based on the first sub-loss and the second sub-loss, for example, the first loss is obtained by adding the first sub-loss and the second sub-loss, and the first sub-loss and the second sub-loss Weighted sum as first loss.
  • the calculation formula of the first loss is as follows:
  • Lc represents the first loss
  • p represents the target prediction label
  • the label statistical information is obtained, and the ratio of the label statistical information and the target predicted label is logarithmically transformed to obtain the first conversion ratio, and the label statistical information and the current mapping
  • the ratio of the label is logarithmically transformed to obtain the second transformation ratio.
  • the target prediction label is fused with the first transformation ratio to obtain the first sub-loss.
  • the second transformation ratio is fused with the current mapping label to obtain the second sub-loss.
  • the first loss can be quickly obtained based on the first sub-loss and the second sub-loss. The closer and more similar the current mapping label and the target prediction label are, the closer the first sub-loss and the second sub-loss are to zero, and the closer the first loss is to zero.
  • the label distribution ratio corresponding to the training label is obtained, and the second loss is obtained based on the label distribution ratio and the target prediction label, including:
  • the label distribution ratio is vectorized to obtain the label distribution vector; the cross-entropy calculation is performed on the label distribution vector and the target prediction label to obtain the second loss.
  • cross-entropy calculation is a calculation method to measure the distribution difference between two data. The closer the target predicted label and label distribution vector are, the smaller the second loss is.
  • the label distribution ratio is used to represent the comparative relationship between the number of training images of each label category.
  • the label distribution vector has the same vector dimension as the target prediction label, and the number of vector dimensions of the label distribution vector is the number of label categories.
  • the computer device can perform cross-entropy calculation on the label distribution vector and the target prediction label to obtain the second loss.
  • the preset value can be used as the base number
  • the target prediction label can be used as the real number to perform logarithmic transformation, and the label distribution vector and the pair The target prediction label after numerical transformation is fused, and the fusion result is reversed to obtain the second loss.
  • the calculation formula of the second loss is as follows;
  • L p represents the second loss
  • p prior represents the label distribution vector
  • p represents the target prediction label
  • the label distribution vector is obtained by vectorizing the label distribution ratio, and the cross-entropy calculation is performed on the label distribution vector and the target prediction label, so that the second loss can be quickly obtained.
  • the second loss is used to characterize the data difference between the target prediction label and the label distribution vector, and the closer the target prediction label and the label distribution vector are, the smaller the second loss is.
  • the model feedback data is obtained based on the first loss and the second loss, including:
  • information entropy calculation is a calculation method to measure the amount of information in data. Performing information entropy calculation on a piece of data is equivalent to performing cross-entropy calculation on the data and itself. The closer the target predicted label is to the current mapped label obtained by label encoding the training label, the smaller the third loss is.
  • the third loss is used to constrain the first loss to prevent the model from falling into local optimum. It can be understood that during the update process of the network, the information of the manual label is also updated synchronously (that is, the current mapping label is also updated synchronously), and the purpose of network learning is to make the model output and label information as close as possible, so obviously, It is only necessary to update the artificial label information to be exactly the same as the model output. In this case, the first loss is equal to 0. However, the model output at this time may be out of order, because the model parameters are randomly initialized when the training starts. Therefore, in order to avoid this situation, the third loss is introduced, and the third loss is used as a positive term to constrain the first loss.
  • the computer device can calculate the information entropy of the target prediction label to obtain the third loss.
  • the preset value can be used as the base number
  • the target prediction label can be used as the real number to perform logarithmic transformation, and the target prediction label and the logarithmically transformed target prediction
  • the labels are fused, and the fusion result is reversed to obtain the third loss.
  • the optimization direction of the third loss is to make the model output as close as possible to the current mapped label obtained by label encoding the training label.
  • the calculation formula of the third loss is as follows:
  • the information entropy calculation of the target prediction label can quickly obtain the third loss, and the model feedback data obtained based on the first loss, the second loss, and the third loss help to ensure the training quality of the model.
  • the model feedback data is obtained based on the first loss, the second loss and the third loss, including:
  • the loss weights corresponding to the first loss, the second loss and the third loss respectively; the loss weight corresponding to the second loss decreases as the proportion of the noise image corresponding to the noise image in the current training image set increases; based on the loss weight, the first loss , the second loss and the third loss are fused to obtain model feedback data.
  • the noisy image refers to the training image with noise.
  • a noisy image is an image for which it is difficult to determine its corresponding accurate label category from multiple label categories, that is, the label accuracy of the training label corresponding to the noisy image is lower than the preset accuracy.
  • the training label is a binary classification label
  • the positive label represents a normal image
  • the negative training label represents a blurred image.
  • the labeling information of multiple users on the same training image perform statistical analysis on each labeling information, and determine the label accuracy corresponding to the training image based on the statistical analysis results, for example, calculate the labeling ratio corresponding to each label category, from which The largest labeling ratio is selected as the label accuracy, and the label category corresponding to the largest labeling ratio is selected as the training label.
  • the preset accuracy can be set as required, for example, set to 0.8.
  • the label information given by 3 users is a positive label
  • the label information given by 3 users is a negative label.
  • the training label corresponding to training image A is a positive label or a negative label, and the label is accurate
  • the computer device when obtaining model feedback data based on the first loss, the second loss, and the third loss, can obtain the loss weights corresponding to the first loss, the second loss, and the third loss respectively, and based on the loss weights corresponding to each loss Each loss is weighted and fused to obtain model feedback data.
  • each loss weight can be a preset fixed value, or can be used as a model parameter to be adjusted and learned during the model training process.
  • the loss weight corresponding to the second loss may decrease as the proportion of the noise image corresponding to the noise image in the training image increases.
  • the calculation formula of the model feedback data is as follows:
  • L represents the model feedback data (also called loss function)
  • L c represents the first loss
  • L p represents the second loss
  • L e represents the third loss.
  • the loss weight corresponding to the first loss is 1
  • the loss weight corresponding to the second loss is ⁇
  • the loss weight corresponding to the third loss is ⁇ .
  • decreases as the proportion of noise images corresponding to noise images in the current training image set increases.
  • the loss weights corresponding to the first loss, the second loss, and the third loss are obtained, and the first loss, the second loss, and the third loss are fused based on the loss weights to obtain model feedback data.
  • the loss weight corresponding to the second loss decreases as the proportion of the noise image corresponding to the noise image in the training image increases, thereby preventing the second loss from affecting the training effect of the model training when there are many noise data.
  • the label loss is generated based on the data change reference information corresponding to the model feedback data, and the current mapping label is adjusted based on the label loss to obtain an updated mapping label, including:
  • the model learning rate is a hyperparameter, which can be a preset fixed value, or can be used as a model parameter to be adjusted and learned during the model training process.
  • the computer device may calculate the gradient of the model feedback data to the current mapping label, and use the calculation result as data change reference information, that is, calculate the gradient of the current mapping label based on the model feedback data to obtain the data change reference information.
  • data change reference information that is, calculate the gradient of the current mapping label based on the model feedback data to obtain the data change reference information.
  • the product of the model learning rate and the data change reference information is used as the label loss
  • the model learning rate and data change reference information The weighted product of information is used as label loss etc.
  • the computer device calculates the distance between the current mapped label and the label loss, and uses the calculated distance as an updated updated mapped label. For example, take the difference between the current map label and the label loss as the updated map label. Subsequently, the updated mapping label will be used as the new current mapping label to participate in the next round of model iterative training.
  • the current mapping label can be adjusted by the following formula:
  • L represents the model feedback data (also known as the loss function)
  • l r indicates the model learning rate.
  • the gradient calculation of the current mapping label based on the model feedback data is performed to obtain the data change reference information, the data change reference information is adjusted based on the model learning rate to obtain the label loss, and the updated mapping label is obtained based on the distance between the current mapping label and the label loss .
  • adjusting the current mapping label based on the loss gradient of the model feedback data to the current mapping label can update the current mapping label along the direction of gradient descent, so that the target mapping label can be quickly adjusted.
  • the model parameters of the initial image anomaly detection model are adjusted based on the model feedback data to obtain an updated image anomaly detection model, and the updated image anomaly detection model is used as the initial image anomaly detection model to obtain the next training
  • the image set is used as the current training image set, and returns to the step of inputting the training images in the current training image set into the initial image anomaly detection model until the training end condition is satisfied, and the target image anomaly detection model is obtained, including:
  • Step S402 adjust the model parameters of the initial image anomaly detection model based on the model feedback data to obtain an updated image anomaly detection model, use the updated image anomaly detection model as the initial image anomaly detection model, obtain the next training image set as the current training image set, and return
  • the step of inputting the training images in the current training image set into the initial image anomaly detection model is performed until the second convergence condition is met, and the intermediate image anomaly detection model and target mapping labels are obtained.
  • the intermediate image anomaly detection model is a model finally obtained by synchronously adjusting model parameters and current mapping labels during model training.
  • the target mapping label is the final mapping label obtained by synchronously adjusting the model parameters and the current mapping label during model training, which can be considered as the mapping label obtained after the initial image anomaly detection model converges.
  • the initial image anomaly detection model can be directly initialized, or can be obtained through pre-training. For example, directly obtain the candidate image anomaly detection model as the initial image anomaly detection model; pre-train the candidate image anomaly detection model, and use the trained candidate image anomaly detection model as the initial image anomaly detection model; and so on.
  • the computer device when training the initial image anomaly detection model, can simultaneously update model parameters and current mapping labels.
  • the computer equipment can adjust the model parameters of the initial image anomaly detection model based on the model feedback data through backpropagation to obtain a new initial image anomaly detection model, and input the training images in the next training image set into the new initial image anomaly detection model to obtain New target prediction label, get new model feedback data based on the new current mapping label and new target prediction label, adjust the current mapping label and model parameters again based on the new model feedback data, and so on, loop training for multiple iterations times until the second convergence condition is met, and the intermediate image anomaly detection model and object mapping label are obtained.
  • the second convergence condition may be at least one of the number of model iterations reaching the second number of iterations, the value of the model feedback data being less than a preset target value, the rate of change of the model feedback data being less than a preset rate of change, the minimization of the model feedback data, etc.
  • Step S404 input the training images in the target training image set into the intermediate image anomaly detection model, and obtain the updated prediction labels corresponding to the training images.
  • Step S406 generate an update loss based on the update prediction labels and target mapping labels corresponding to the training images in the target training image set, adjust the model parameters of the intermediate image anomaly detection model based on the update loss, until the third convergence condition is met, and obtain the target image anomaly detection model .
  • the target training image set refers to the training image set used to train the intermediate image abnormality detection model, and the target training image set may include at least one training image.
  • the target training image set and the current training image set may be the same training image set or different training image sets, that is, the target training image set and the current training image set may include the same training images or different training images.
  • the computer device can fix the target mapping label, perform further model training on the anomaly detection model of the intermediate image, fine-tune the model parameters, and obtain the anomaly detection model of the target image.
  • the computer device can input the training image into the intermediate image anomaly detection model to obtain the updated prediction label corresponding to the training image, and generate an update loss based on the data distribution difference between the updated prediction label and the target mapping label, based on The update loss is backpropagated to adjust the model parameters of the intermediate image anomaly detection model until the third convergence condition is met, and the target image anomaly detection model is obtained.
  • the third convergence condition may be at least one of the number of model iterations reaching the third number of iterations, the value of the update loss being smaller than a preset update value, and the like.
  • the update loss can be obtained based on at least one loss.
  • the update loss includes the classification loss calculated based on the target map label and the update prediction label, the prior loss calculated based on the training label and the update prediction label; the update loss includes the classification loss calculated based on the target map label and the update prediction label, The prior loss calculated based on the training labels and the updated predicted labels and the self-entropy loss calculated based on the updated predicted labels.
  • the update loss includes the classification loss calculated based on the target map label and the update prediction label, the prior loss calculated based on the training labels and the updated predicted labels and the self-entropy loss calculated based on the updated predicted labels.
  • the current mapping label and model parameters are updated synchronously until the second convergence condition is met, and the intermediate image anomaly detection model and target mapping label are obtained, and then the target mapping label is fixed for further update
  • the model parameters of the intermediate image anomaly detection model are obtained until the third convergence condition is reached, and the target image anomaly detection model is obtained.
  • the update loss is generated based on the update prediction label and the target map label, including:
  • the update loss can be obtained based on classification loss, prior loss and self-entropy loss.
  • the classification loss can be obtained by calculating the divergence of the updated prediction labels and target mapping labels corresponding to each training image in the target training image set, that is, the computer device can calculate the divergence of the updated prediction labels and target mapping labels to obtain the fourth loss .
  • the prior loss may be obtained by calculating the information entropy of the updated prediction labels corresponding to each training image in the target training image set, that is, the computer device may perform information entropy calculation on the updated prediction labels to obtain the fifth loss.
  • the prior loss can be obtained by performing cross-entropy calculation on the training labels and updated prediction labels corresponding to each training image in the target training image set, that is, the computer device can perform cross-entropy calculation based on the training labels and updated prediction labels to obtain the sixth loss.
  • the computer device can obtain the update loss based on the fourth loss, the fifth loss and the sixth loss, for example, the update loss is obtained by adding the fourth loss, the fifth loss and the sixth loss, and the fourth loss, the fifth loss and The sixth loss is weighted and fused to obtain an update loss.
  • the fourth loss is obtained by performing divergence calculation on the update prediction label and the target mapping label
  • the fifth loss is obtained by performing information entropy calculation on the update prediction label, based on the training label corresponding to the target training image set and the update prediction label.
  • the sixth loss is obtained by cross-entropy calculation, and the update loss is obtained based on the fourth loss, fifth loss and sixth loss.
  • the update loss is composed of many different types of losses. Adjusting model parameters based on such update loss to train the model can improve the accuracy of model training.
  • an image anomaly detection method is provided.
  • the method is applied to the computer in FIG. is the server 104 .
  • the image anomaly detection method includes the following steps:
  • Step S502 acquiring an image to be detected.
  • Step S504 input the image to be detected into the target image anomaly detection model, and obtain the model prediction label corresponding to the image to be detected.
  • the image to be detected refers to an image to be detected whether there is an abnormality.
  • the image to be detected can be a picture, or a video frame in a video.
  • the model predicted label refers to the predicted label corresponding to the image to be detected.
  • the computer device can obtain the image to be detected and the abnormality detection model of the target image locally or from other terminals or servers, input the image to be detected into the abnormality detection model of the target image, and obtain the model prediction label corresponding to the image to be detected.
  • the training process of the target image anomaly detection model includes: obtaining the initial mapping label corresponding to the training label, and using the initial mapping label as the current mapping label; inputting the training images in the current training image set into the initial image anomaly detection model, and obtaining the corresponding Target prediction label; generate model feedback data based on the current mapping label and target prediction label corresponding to the training label of the training image; generate label loss based on the data change reference information corresponding to the model feedback data, adjust the current mapping label based on the label loss to obtain an updated mapping label, Use the updated mapping label as the current mapping label; adjust the model parameters of the initial image anomaly detection model based on the model feedback data to obtain an updated image anomaly detection model, use the updated image anomaly detection model as the initial image anomaly detection model, and obtain the next training image set as
  • the current training image set returns to the step of inputting the training images in the current training image set into the initial image anomaly detection model until the training end condition is satisfied, and the target image anomaly detection model is obtained.
  • Step S506 determine the abnormality detection result of the image corresponding to the image to be detected based on the model prediction label.
  • the computer device may determine an image abnormality detection result corresponding to the image to be detected based on the model prediction label.
  • the computer device can set the target image anomaly detection model to output complete data, that is, the model prediction label is a prediction vector, and each vector value in the prediction vector represents the probability that the image to be detected belongs to the corresponding label category.
  • the computer device can use the probability corresponding to the normal label category from the prediction vector as the target confidence degree, if the target confidence degree is greater than the preset confidence degree, then determine that the image to be detected is a normal image, and the image abnormality detection result of the image to be detected is that the image has no abnormality , if the target confidence is less than or equal to the preset confidence, it is determined that the image to be detected is an abnormal image, and the image anomaly detection result of the image to be detected is an image anomaly.
  • the computer device can also use the vector value greater than the preset vector value in the prediction vector as the target confidence, if the target confidence is greater than the preset confidence, then determine the image abnormality detection result of the image to be detected as The label category corresponding to the target confidence.
  • the computer device can also set the target image anomaly detection model to only output the probability corresponding to the normal label category as the model prediction label. If the model prediction label is greater than the preset reliability, it is determined that the image to be detected is a normal image. If the model prediction label is less than or is equal to the preset reliability, then it is determined that the image to be detected is an abnormal image.
  • the preset reliability can be set as required, for example, set to 0.5.
  • the image anomaly detection method of the present application can be applied to image or video quality analysis tasks.
  • a computer device obtains a picture to be shared uploaded by a user, and performs image anomaly detection on the picture to be shared based on the target image anomaly detection model. Then, the pictures to be shared are published in social applications for other users to browse. If the image anomaly detection result shows that the image is abnormal, the user can be prompted that the picture quality is not good, and the user is prompted to re-upload the picture.
  • the computer device acquires the video to be shared uploaded by the user, and performs image anomaly detection on the video frames in the video to be shared based on the target image anomaly detection model.
  • the computer equipment can obtain the surrounding environment video collected by the vehicle terminal, and perform image anomaly detection on the video frames in the surrounding environment video based on the target image anomaly detection model. If the image anomaly detection result is a video with no abnormal image If the frame ratio is greater than the preset ratio, store the surrounding environment video or perform further data analysis on the surrounding environment video to determine the environmental state of the vehicle. Instruct the vehicle-mounted terminal to re-collect the surrounding environment video.
  • the initial mapping label is used as the current mapping label;
  • the training image in the current training image set is input into the initial image anomaly detection model, and the target prediction label corresponding to the training image is obtained;
  • Generate model feedback data based on the current mapping label and target prediction label corresponding to the training label of the training image; generate label loss based on the data change reference information corresponding to the model feedback data, adjust the current mapping label based on the label loss to obtain an updated mapping label, and update the mapping label
  • adjust the model parameters of the initial image anomaly detection model based on the model feedback data to obtain an updated image anomaly detection model, use the updated image anomaly detection model as the initial image anomaly detection model, and obtain the next training image set as the current training image set , return to the step of inputting the training images in the current training image set into the initial image anomaly detection model until the training end condition is met, and the target image anomaly detection model is obtained.
  • the current mapping label and model parameters are adjusted synchronously, and the feature learning ability of the model is used to self-correct the current mapping label corresponding to the noisy training label, which can effectively filter the impact of noisy data on the performance of the model, greatly Improve the performance of the model, and finally train an image anomaly detection model with high accuracy. Therefore, when the model is applied, the image anomaly detection based on the image anomaly detection model with high accuracy can obtain the image anomaly detection result with high accuracy, which effectively improves the detection accuracy and detection efficiency of image anomaly detection.
  • image anomaly detection model training method and image anomaly detection method can be applied to image artifact detection tasks.
  • Image blurring detection refers to detecting whether there is blurring in a picture.
  • the image blur detection task is an essential step in the quality analysis of pictures and videos, and can be used to evaluate the quality of the current picture or video.
  • blurred images are not a simple binary classification, and many blurred images are only slightly blurred or partially blurred. Therefore, simple binary labels may have human subjectivity, which will lead to noise in the artificially labeled information corresponding to such blurred images. Training the model in such noisy labels will reduce the performance of the model.
  • the feature learning ability of the model can be used to identify and correct the artificial label data containing noise, thereby greatly improving the performance of the model, and the final trained model can output more in the blurred screen detection task. for accurate predictions.
  • the image is input into the image blurring detection model, and the predicted probability (that is, the prediction label) of whether the input image is blurred can be obtained through the data calculation of the deep learning model.
  • the artificial labels corresponding to the input images are transformed into mapped labels through label encoding.
  • the manual label refers to a label marked manually, which may be a 0/1 binary label, which indicates the artificial judgment result of the presence or absence of blurring in the image.
  • the loss function of the image blurring detection model includes three kinds of losses, specifically self-entropy loss, classification loss and prior loss. The self-entropy loss is calculated based on the predicted probability. It is the result of the predicted probability and the entropy value calculated by itself.
  • This loss is a regular term, and the purpose is to prevent the model from falling into a local optimum.
  • the classification loss is obtained based on the predicted probability and the mapped label, which is used to measure the distance between the predicted probability of the model and the artificial label.
  • the prior loss is based on the predicted probability and the distribution ratio of positive and negative labels in artificial labels, and this loss is also a regularization term.
  • the updated mapping label is used as the calculation data corresponding to the loss function of the next round of model iteration. After multiple rounds of model iteration , and finally obtain the trained image blurring detection model and the corrected manual label result (ie, the target mapping label).
  • Step 1 uses the original human-labeled labels for training without updating the labels.
  • the purpose of this step is to randomly initialize the model parameters in the early stage of model training. It is difficult to update the model parameters and label distribution at the same time, and the training may be unstable. Therefore, at the beginning, the mapping label is fixed, and only the model parameters are updated.
  • the loss function of this stage can only include classification loss, and this stage can be trained for K1 iteration rounds.
  • Step 2 updates model parameters and mapping labels at the same time.
  • the loss function of this stage can include three kinds of losses. This stage can be trained for K2 iteration rounds.
  • Step 3 fixes the mapping label obtained by the previous step 2 iteration, no longer updates the mapping label, only updates the model parameters, and updates the model for K3 iteration rounds again.
  • the loss function in this stage includes three kinds of losses.
  • the entire training process needs to consume K1+K2+K3 iteration rounds, and after the training is completed, the trained image blurring detection model is obtained.
  • the training process of the model may not use the three-step training method of K1+K2+K3, for example, use the training method of K1+K2.
  • the image artifact detection model that has been trained can be used to predict the artifact probability (ie artifact confidence) of the input image.
  • the confidence degree of artifacts predicted by the model is greater than the preset reliability, it is determined that the input image has artifacts and is a blurred image; when the confidence degree of artifacts predicted by the model is less than or equal to the preset confidence, it is determined that the input image does not have artifacts , for a normal image.
  • the preset threshold can be set as required, for example, set to 0.5.
  • the image blurring detection model based on the training can accurately detect the blurring degree of the image.
  • the model training by self-correcting the artificial labels with noise, the impact of noise data on the performance of the model is effectively filtered, so as to train an accurate image blurring detection model.
  • the accurate image artifact detection model can output stable and reliable artifact detection results, thus providing reliable technical support for video quality assessment.
  • model training method can be applied to image blur detection models, image mosaic detection models and other image anomaly detection models in addition to being applied to image blurred screen detection models.
  • FIGS. 2-5 may include multiple steps or stages. These steps or stages are not necessarily executed at the same time, but may be executed at different times. These steps or stages The order of execution is not necessarily performed sequentially, but may be performed alternately or alternately with other steps or at least a part of steps or stages in other steps.
  • an image abnormality detection model training device is provided.
  • the device can use software modules or hardware modules, or a combination of both to become a part of computer equipment.
  • the device specifically includes: Training data acquisition module 902, model prediction module 904, model feedback data determination module 906, label adjustment module 908 and model adjustment module 910, wherein:
  • the training data acquiring module 902 is configured to acquire an initial mapping label corresponding to the training label, and use the initial mapping label as a current mapping label.
  • the model prediction module 904 is configured to input the training images in the current training image set into the initial image anomaly detection model to obtain target prediction labels corresponding to the training images.
  • the model feedback data determination module 906 is configured to generate model feedback data based on the current mapping label and the target prediction label corresponding to the training label of the training image.
  • the label adjustment module 908 is configured to generate a label loss based on the data change reference information corresponding to the model feedback data, adjust the current mapping label based on the label loss to obtain an updated mapping label, and use the updated mapping label as the current mapping label.
  • the model adjustment module 910 is used to adjust the model parameters of the initial image anomaly detection model based on the model feedback data, obtain an updated image anomaly detection model, use the updated image anomaly detection model as the initial image anomaly detection model, and obtain the next training image set as the current training Image set, return to the step of inputting the training images in the current training image set into the initial image anomaly detection model until the training end condition is satisfied, and the target image anomaly detection model is obtained.
  • the training data acquisition module is further configured to perform label encoding on the training labels based on the number of label categories corresponding to the training labels to obtain initial mapping labels.
  • the image abnormality detection model training device also includes:
  • the model pre-training module is used to input the training images in the candidate training image set into the candidate image anomaly detection model to obtain the initial prediction label corresponding to the training image; based on the training label corresponding to the training image in the candidate training image set and the initial prediction label label difference, adjust the model parameters of the candidate image anomaly detection model until the first convergence condition is met, and obtain the initial image anomaly detection model.
  • the model feedback data determination module includes:
  • the first loss determination unit is configured to perform divergence calculation on the current mapped label and the target predicted label to obtain the first loss.
  • the second loss determination unit is used to obtain the label distribution ratio corresponding to the training label, and obtain the second loss based on the label distribution ratio and the target prediction label; the label distribution ratio is determined based on the number of training images of each label category in the current training image set.
  • a model feedback data determining unit configured to obtain model feedback data based on the first loss and the second loss.
  • the first loss determining unit is further configured to logarithmically transform the ratio of the current mapped label to the target predicted label to obtain a label transformation ratio; to fuse the label transformation ratio with the target prediction label to obtain the first loss.
  • the first loss determination unit is also used to perform statistics on the current mapped label and the target predicted label to obtain label statistical information; logarithmically transform the ratio of the label statistical information to the target predicted label to obtain the first transformation ratio , logarithmically transform the ratio of the label statistics and the current mapping label to obtain the second transformation ratio; fuse the target prediction label with the first transformation ratio to obtain the first sub-loss, and perform the current mapping label and the second transformation ratio Fusion to obtain the second sub-loss; based on the first sub-loss and the second sub-loss to obtain the first loss.
  • the second loss determination unit is further configured to vectorize the label distribution ratio to obtain a label distribution vector; perform cross-entropy calculation on the label distribution vector and the target predicted label to obtain the second loss.
  • the model feedback data determining unit is further configured to perform information entropy calculation on the target prediction label to obtain a third loss; obtain model feedback data based on the first loss, the second loss and the third loss.
  • the model feedback data determination unit is also used to obtain the loss weights corresponding to the first loss, the second loss and the third loss respectively; The increase of the image scale decreases; the first loss, the second loss and the third loss are fused based on the loss weight to obtain the model feedback data.
  • the label adjustment module is also used to calculate the gradient of the current mapping label based on the model feedback data to obtain data change reference information; obtain the model learning rate, adjust the data change reference information based on the model learning rate, and obtain the label loss; The distance between the current map label and the label loss gets updated with the current map label.
  • the model adjustment module includes:
  • the first adjustment unit is configured to adjust the model parameters of the initial image anomaly detection model based on the model feedback data to obtain an updated image anomaly detection model, use the updated image anomaly detection model as the initial image anomaly detection model, and acquire the next training image set as the current training
  • the image set returns to the step of inputting the training images in the current training image set into the initial image anomaly detection model until the second convergence condition is satisfied, and the intermediate image anomaly detection model and the target mapping label are obtained.
  • the prediction unit is configured to input the training images in the target training image set into the intermediate image anomaly detection model to obtain updated prediction labels corresponding to the training images.
  • the second adjustment unit is used to generate an update loss based on the update prediction label and target mapping label corresponding to the training image in the target training image set, adjust the model parameters of the intermediate image anomaly detection model based on the update loss, until the third convergence condition is met, and the target is obtained Image anomaly detection model.
  • the second adjustment unit is also used to calculate the divergence of the updated prediction label and the target mapping label to obtain the fourth loss; perform information entropy calculation on the updated prediction label to obtain the fifth loss; based on the target training image set The corresponding training label and update prediction label are calculated by cross entropy to obtain the sixth loss; the update loss is obtained based on the fourth loss, fifth loss and sixth loss.
  • the target image abnormality detection model is any one of image blurring detection model, image blur detection model and image mosaic detection model.
  • the above-mentioned image anomaly detection model training device during model training, synchronously adjusts the training label and the current mapping label, and uses the feature learning ability of the model to self-correct the current mapping label corresponding to the training label with noise, which can effectively filter noise data pairs.
  • the performance of the model is greatly improved, and the performance of the model is greatly improved, and finally an image anomaly detection model with high accuracy is trained.
  • the image anomaly detection results with high accuracy can be obtained, which effectively improves the detection accuracy and detection efficiency of image anomaly detection.
  • an image anomaly detection device is provided.
  • the device may adopt a software module or a hardware module, or a combination of the two becomes a part of computer equipment.
  • the device specifically includes: image acquisition Module 1002, label prediction module 1004 and detection result determination module 1006, wherein:
  • An image acquisition module 1002 configured to acquire an image to be detected.
  • the label prediction module 1004 is configured to input the image to be detected into the target image anomaly detection model, and obtain a model prediction label corresponding to the image to be detected.
  • the detection result determination module 1006 is configured to determine the image abnormality detection result corresponding to the image to be detected based on the model prediction label.
  • the training process of the target image anomaly detection model includes:
  • the step of inputting the training images in the image set into the initial image anomaly detection model is performed until the training end condition is met, and the target image anomaly detection model is obtained.
  • the above-mentioned image anomaly detection device during model training, synchronously adjusts the training label and the current mapping label, and uses the feature learning ability of the model to self-correct the current mapping label corresponding to the training label with noise, which can effectively filter the impact of noise data on the model. Performance impact, greatly improving the performance of the model, and finally training an image anomaly detection model with high accuracy. Therefore, when the model is applied, based on the image anomaly detection model with high accuracy, the image anomaly detection result with high accuracy can be obtained, which effectively improves the detection accuracy and detection efficiency of image anomaly detection.
  • each module in the above-mentioned image anomaly detection model training device and image anomaly detection device can be fully or partially realized by software, hardware and combinations thereof.
  • the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, and can also be stored in the memory of the computer device in the form of software, so that the processor can invoke and execute the corresponding operations of the above-mentioned modules.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure may be as shown in FIG. 11 .
  • the computer device includes a processor, memory and a network interface connected by a system bus. Wherein, the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer equipment includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer readable instructions and a database.
  • the internal memory provides an environment for the execution of the operating system and computer readable instructions in the non-volatile storage medium.
  • the database of the computer device is used to store data such as training images, candidate image anomaly detection models, initial image anomaly detection models, intermediate image anomaly detection models, and target image anomaly detection models.
  • the network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer readable instructions are executed by the processor, an image abnormality detection model training method and an image abnormality detection method are realized.
  • a computer device is provided.
  • the computer device may be a terminal, and its internal structure may be as shown in FIG. 12 .
  • the computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Wherein, the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system and computer readable instructions.
  • the internal memory provides an environment for the execution of the operating system and computer readable instructions in the non-volatile storage medium.
  • the communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, an operator network, NFC (Near Field Communication) or other technologies.
  • WIFI Wireless Fidelity
  • NFC Near Field Communication
  • the computer readable instructions are executed by the processor, an image abnormality detection model training method and an image abnormality detection method are realized.
  • the display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen
  • the input device of the computer device may be a touch layer covered on the display screen, or a button, a trackball or a touch pad provided on the casing of the computer device , and can also be an external keyboard, touchpad, or mouse.
  • FIGS 11 and 12 are only block diagrams of partial structures related to the solution of this application, and do not constitute a limitation to the computer equipment on which the solution of this application is applied.
  • the specific computer Devices may include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.
  • a computer device including a memory and one or more processors, where computer-readable instructions are stored in the memory, and the above-mentioned methods are implemented when the one or more processors execute the computer-readable instructions Steps in the examples.
  • a computer-readable storage medium which stores computer-readable instructions and computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the steps in the above-mentioned method embodiments are implemented. .
  • a computer program product or computer program comprising computer readable instructions stored in a computer readable storage medium.
  • One or more processors of the computer device read the computer-readable instructions from the computer-readable storage medium, and one or more processors execute the computer-readable instructions, so that the computer device executes the steps in the foregoing method embodiments.
  • Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory or optical memory, etc.
  • Volatile memory can include Random Access Memory (RAM) or external cache memory.
  • RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Databases & Information Systems (AREA)
  • Medical Informatics (AREA)
  • Quality & Reliability (AREA)
  • Molecular Biology (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Image Analysis (AREA)

Abstract

本申请涉及一种图像异常检测模型训练方法、图像异常检测方法、装置、计算机设备和存储介质。本发明实施例可应用于云技术、人工智能、智慧交通等各种场景。该方法包括:获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签(步骤S202);将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签(步骤S204);基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据(步骤S206);基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签(步骤S208);基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型(步骤S210)。

Description

图像异常检测模型训练方法、图像异常检测方法和装置
本申请要求于2021年09月15日提交中国专利局,申请号为2021110796510,申请名称为“图像异常检测模型训练方法、图像异常检测方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,特别是涉及一种图像异常检测模型训练方法、图像异常检测方法、装置、计算机设备、存储介质和计算机程序产品。
背景技术
随着计算机技术的进步,图像被广泛应用在各行各业,对于图像质量的要求也是越来越高。可以通过训练机器学习模型来检测图像是否出现异常,从而筛选出有异常、质量较低的图像。
传统技术中,通常是基于训练图像对机器学习模型进行模型训练。训练图像通常是简单的二分类图像,即训练图像分为正常图像和异常图像。然而,异常图像通常对应各种不同程度的异常情况,简单的二分类标签可能带有很多主观性,进而导致训练图像的训练标签带有噪声,基于这样的训练图像训练得到的模型存在准确性低的问题。
发明内容
本申请提供了提供一种图像异常检测模型训练方法、图像异常检测方法、装置、计算机设备、存储介质和计算机程序产品。
一种图像异常检测模型训练方法,由计算机设备执行,所述方法包括:
获取训练标签对应的初始映射标签,将所述初始映射标签作为当前映射标签;
将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签;
基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;
基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将所述更新映射标签作为当前映射标签;
基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
一种图像异常检测模型训练装置,所述装置包括:
训练数据获取模块,用于获取训练标签对应的初始映射标签,将所述初始映射标签作为当前映射标签;
模型预测模块,用于将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签;
模型反馈数据确定模块,用于基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;
标签调整模块,用于基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将所述更新映射标签作为当前映射标签;
模型调整模块,用于基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入 初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
一种计算机设备,包括存储器和一个或多个处理器,所述存储器存储有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时,使得所述一个或多个处理器执行上述图像异常检测模型训练方法的步骤。
一个或多个非易失性计算机可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行上述图像异常检测模型训练方法的步骤。
一种计算机程序产品或计算机程序,所述计算机程序产品或计算机程序包括计算机可读指令,所述计算机可读指令存储在计算机可读存储介质中,计算机设备的一个或多个处理器从所述计算机可读存储介质读取所述计算机可读指令,所述一个或多个处理器执行所述计算机可读指令,使得所述计算机设备执行上述图像异常检测模型训练方法的步骤。
一种图像异常检测方法,由计算机设备执行,所述方法包括:
获取待检测图像;
将所述待检测图像输入目标图像异常检测模型,得到所述待检测图像对应的模型预测标签;
基于所述模型预测标签确定所述待检测图像对应的图像异常检测结果;
其中,所述目标图像异常检测模型的训练过程包括:
获取训练标签对应的初始映射标签,将所述初始映射标签作为当前映射标签;
将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签;
基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;
基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将所述更新映射标签作为当前映射标签;
基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
一种图像异常检测装置,所述装置包括:
图像获取模块,用于获取待检测图像;
标签预测模块,用于将所述待检测图像输入目标图像异常检测模型,得到所述待检测图像对应的模型预测标签;
检测结果确定模块,用于基于所述模型预测标签确定所述待检测图像对应的图像异常检测结果;
其中,所述目标图像异常检测模型的训练过程包括:
获取训练标签对应的初始映射标签,将所述初始映射标签作为当前映射标签;
将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签;
基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;
基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将所述更新映射标签作为当前映射标签;
基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模 型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
一种计算机设备,包括存储器和一个或多个处理器,所述存储器存储有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时,使得所述一个或多个处理器执行上述图像异常检测方法的步骤。
一个或多个非易失性计算机可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行上述图像异常检测方法的步骤。
一种计算机程序产品或计算机程序,所述计算机程序产品或计算机程序包括计算机可读指令,所述计算机可读指令存储在计算机可读存储介质中,计算机设备的一个或多个处理器从所述计算机可读存储介质读取所述计算机可读指令,所述一个或多个处理器执行所述计算机可读指令,使得所述计算机设备执行上述图像异常检测方法的步骤。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为一个实施例中图像异常检测模型训练方法、图像异常检测方法的应用环境图;
图2为一个实施例中图像异常检测模型训练方法的流程示意图;
图3为另一个实施例中图像异常检测模型训练方法的流程示意图;
图4为又一个实施例中图像异常检测模型训练方法的流程示意图;
图5为一个实施例中图像异常检测方法的流程示意图;
图6为一个实施例中花屏图像的示意图;
图7为一个实施例中图像花屏检测模型训练方法的流程示意图;
图8为一个实施例中图像花屏检测结果的示意图;
图9为一个实施例中图像异常检测模型训练装置的结构框图;
图10为一个实施例中图像异常检测装置的结构框图;
图11为一个实施例中计算机设备的内部结构图;
图12为一个实施例中计算机设备的内部结构图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请实施例提供的方案涉及人工智能的计算机视觉技术、自然语言处理、机器学习等技术,具体通过如下实施例进行说明:
本申请提供的图像异常检测模型训练方法、图像异常检测方法,可以应用于如图1所示的应用环境中。其中,终端102通过网络与服务器104进行通信。终端102可以但不限于是各种台式计算机、笔记本电脑、智能手机、平板电脑、物联网设备和便携式可穿戴设备,物联网设备可为智能音箱、智能电视、智能空调、智能车载设备等。便携式可穿戴设备可为智能手表、智能手环、头戴设备等。服务器104可以用独立的服务器或者是多个服务器组成的服务器集群或者云服务器来实现。
终端102和服务器104均可单独用于执行本申请实施例中提供的图像异常检测模型训练方法、图像异常检测方法。
例如,服务器获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签, 将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签。服务器基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据,基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签。服务器基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
服务器获取待检测图像,将待检测图像输入目标图像异常检测模型,得到待检测图像对应的模型预测标签,基于模型预测标签确定待检测图像对应的图像异常检测结果。
终端102和服务器104也可协同用于执行本申请实施例中提供的图像异常检测模型训练方法、图像异常检测方法。
例如,服务器从终端获取训练图像集。服务器获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签,将训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签。服务器基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据,基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签。服务器基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。服务器将目标图像异常检测模型发送至终端。
终端获取待检测图像,终端将待检测图像输入目标图像异常检测模型,得到待检测图像对应的模型预测标签,终端基于模型预测标签确定待检测图像对应的图像异常检测结果。
在一个实施例中,如图2所示,提供了一种图像异常检测模型训练方法,以该方法应用于图1中的计算机为例进行说明,可以理解的是,计算机设备可以是终端102,也可以是服务器104。本实施例中,图像异常检测模型训练方法包括以下步骤:
步骤S202,获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签。
其中,训练标签是人工标注的标签,用于标识训练图像的图像异常判定结果。训练图像是指用于模型训练的图像。图像可以是图片,也可以是视频中的视频帧。训练标签可以是二分类标签,例如存在异常的图像对应的训练标签为负标签,用1表示,没有异常的图像对应的训练标签为正标签,用0表示。训练标签也可以是多分类标签,例如,没有异常的图像对应的训练标签为第一标签,用0表示,存在明显异常的图像对应的训练标签为第二标签,用1表示,存在轻微异常的图像对应的训练标签为第三标签,用2表示。
初始映射标签是对训练标签进行映射转换得到的,映射转换用于将离散的训练标签转换为模型易于学习、计算的数据。一种训练标签通常是用一个常数值来表示,经过映射转换后,该训练标签对应的初始映射标签可以用向量来表示。在一个实施例中,各种初始映射标签之间的距离是一致的。
具体地,计算机设备可以在本地、或从其他终端、服务器获取图像异常检测模型的训练样本,训练样本包括训练图像和训练图像对应的训练标签。计算机设备可以对训练标签进行映射转换得到初始映射标签。可以理解,计算机设备可以采用自定义的算法或公式进行映射转换。当然,训练样本也可以直接包括训练图像、对应的训练标签和初始映射标签。
训练标签是人工标注的标签,带有一定的人为主观性,从而导致训练标签带有噪声。为了减少训练标签中的噪声,可以利用神经网络的特征学习能力对含有噪声的训练标签进行辨别与纠正,因此,在进行模型训练时,除了调整模型参数,也可以同步对训练标签进 行调整。模型训练采用迭代训练的方式,在第一轮迭代训练中,将初始映射标签作为当前映射标签,将当前映射标签作为模型的监督信号进行模型训练,在第一轮迭代训练中,也可以对初始映射标签进行调整得到更新映射标签。在下一轮迭代训练中,将上一轮得到的更新映射标签作为新的当前映射标签,将新的当前映射标签作为模型的监督信号进行模型训练,在下一轮迭代训练中,也可以将上一轮得到的更新映射标签再次进行调整得到新的更新映射标签。以此类推,经过多轮迭代训练,利用神经网络的特征学习能力对含有噪声的训练标签不断进行辨别与纠正,进而大幅提升模型的性能,最终训练得到表现优异的图像异常检测模型。
进一步的,针对不同类型的图像异常可以设置不同的模型训练样本,各个模型训练样本用于专门训练对应的图像异常检测模型。例如,图像异常包括图像花屏、图像模糊、图像马赛克、图像拖影等类型。以图像花屏和图像模糊为例,针对图像花屏,可以专门训练图像花屏检测模型,图像花屏检测模型对应的训练样本中训练图像的训练标签用于标识图像中是否存在花屏。针对图像模糊,可以专门训练图像模糊检测模型,图像模糊检测模型对应的训练样本中训练图像的训练标签用于标识图像中是否存在模糊。
步骤S204,将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签。
其中,当前训练图像集是指当前使用的训练图像集。当前训练图像集包括至少一个训练图像。
初始图像异常检测模型是指待训练的图像异常检测模型。图像异常检测模型是机器学习模型,具体可以是卷积神经网络、深度神经网络等类型的模型。图像异常检测模型的输入数据为图像,输出数据为预测标签。预测标签用于标识输入图像是否异常的概率。预测标签也可以用向量来表示。
具体地,计算机设备可以将训练图像输入初始图像异常检测模型,经过初始图像异常检测模型对输入数据的数据处理,可以输出训练图像对应的目标预测标签。
在一个实施例中,初始图像异常检测模型可以是原始的图像异常检测模型,原始的图像异常检测模型中模型参数是随机初始化的,也就是,初始图像异常检测模型可以是没有经过任何模型训练的原始模型。初始图像异常检测模型也可以是经过预训练的图像异常检测模型,也就是,初始图像异常检测模型可以是对原始的图像异常检测模型进行预训练得到的。
步骤S206,基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据。
其中,模型反馈数据用于表征当前映射标签和目标预测标签之间的数据差异。在模型训练时,基于模型反馈数据调整模型参数,可以使得模型的输出数据越来越接近当前映射标签,越来越接近真实结果。
具体地,计算机设备基于训练图像的训练标签对应的当前映射标签和训练图像对应的目标预测标签之间的数据分布差异可以计算得到模型反馈数据。例如,可以计算训练图像的训练标签对应的当前映射标签和目标预测标签之间的距离得到分类损失,将分类损失作为模型反馈数据。也可以基于训练标签和目标预测标签得到先验损失,基于分类损失和先验损失得到模型反馈数据。也可以基于目标预测标签得到自熵损失,基于分类损失、先验损失和自熵损失得到模型反馈数据,也可以基于分类损失和自熵损失得到模型反馈数据。其中,分类损失、先验损失和自熵损失均可以采用对数据进行散度计算的方式得到,也可以采用对数据进行交叉熵计算的方式得到,还可以采用自定义公式、算法等方式计算得到。
步骤S208,基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签。
具体地,数据变化参考信息用于衡量模型反馈数据沿当前映射标签方向上的数据变化 速度。可以理解,模型反馈数据是基于当前映射标签和目标预测标签得到的,对于模型反馈数据来说,当前映射标签和目标预测标签都是变量,由于标签损失用于调整训练标签对应的当前映射标签,因此,计算机设备可以基于模型反馈数据在当前映射标签方向上的变化速度生成数据变化参考信息,进而基于数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为新的当前映射标签。例如,梯度可以用于衡量函数沿某一方向的变化速度,因此,计算机设备可以计算模型反馈数据对当前映射标签的梯度得到损失梯度,将损失梯度作为数据变化参考信息,基于损失梯度得到标签损失,基于标签损失调整当前映射标签得到更新映射标签。计算机设备可以将更新映射标签作为下一轮模型训练中的当前映射标签,通过模型迭代来对含有噪声的训练标签不断进行辨别与纠正。当然,计算机设备也可以采用自定义公式或算法计算数据变化参考信息。
其中,基于数据变化参考信息生成标签损失可以是将数据变化参考信息作为标签损失,也可以是将数据变化参考信息和超参数进行融合,将融合后的数据作为标签损失。超参数可以是预设的固定值,超参数也可以作为一种模型参数,在模型训练过程中调整和学习。
步骤S210,基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
其中,更新图像异常检测模型是指对初始图像异常检测模型进行模型参数调整得到的模型。目标图像异常检测模型是指训练完成的图像异常检测模型。
具体地,除了基于模型反馈数据调整当前映射标签,计算机设备还需要基于模型反馈数据同步调整模型参数。计算机设备可以基于模型反馈数据进行反向传播来更新初始图像异常检测模型的模型参数,从而得到更新图像异常检测模型。计算机设备可以将更新图像异常检测模型作为新的初始图像异常检测模型,将更新映射标签作为新的当前映射标签,获取下一训练图像集作为新的当前训练图像集,基于新的当前训练图像集、当前映射标签和初始图像异常检测模型开启新一轮模型迭代训练。在新一轮模型迭代训练中,计算机设备可以将新的当前训练图像集中的训练图像输入更新的初始图像异常检测模型,得到更新的目标预测标签,基于更新的当前映射标签和更新的目标预测标签生成更新的模型反馈数据,基于更新的模型反馈数据再次调整当前映射标签和初始图像异常检测模型的模型参数。以此类推,重复上述步骤,直至满足训练结束条件,停止训练,得到目标图像异常检测模型。
其中,训练结束条件包括模型迭代次数大于预设迭代次数、模型反馈数据的数值小于预设目标数值、模型反馈数据的变化率小于预设变化率、模型反馈数据最小化等中的至少一种。预设迭代次数、预设目标数值、预设变化率都是预设设置的数据,具体可以根据实际需要进行设置。
举例说明,在第一轮迭代训练中,将初始映射标签作为当前映射标签,基于当前映射标签和训练图像集A1对初始图像异常检测模型进行模型训练以调整模型参数得到更新图像异常检测模型A2,同步对初始映射标签进行调整得到更新映射标签A3。在第二轮迭代训练中,将第一轮得到的更新映射标签A3作为新的当前映射标签,将第一轮得到的更新图像异常检测模型A2作为新的初始图像异常检测模型,基于当前映射标签和训练图像集B1对初始图像异常检测模型进行模型训练以调整模型参数得到更新图像异常检测模型B2,同步对初始映射标签进行调整得到更新映射标签B3。在第三轮迭代训练中,将第二轮得到的更新映射标签B3作为新的当前映射标签,将第二轮得到的更新图像异常检测模型B2作为新的初始图像异常检测模型,基于当前映射标签和训练图像集C1对初始图像异常检测模型进行模型训练以调整模型参数得到更新图像异常检测模型C2,同步对初始映射标 签进行调整得到更新映射标签C3。以此类推,经过多轮迭代训练,若模型迭代次数大于预设迭代次数,则将最新一轮迭代训练得到的更新图像异常检测模型作为目标图像异常检测模型。
可以理解,各个训练图像集可以包括相同的训练图像。各个训练图像集也可以包括不同的训练图像。
在一个实施例中,计算机设备可以基于模型反馈数据通过梯度下降算法来调整初始图像异常检测模型的模型参数。
在一个实施例中,计算机设备可以基于模型反馈数据对当前映射标签和初始图像异常检测模型进行训练,直至满足第一训练结束条件,得到中间图像异常检测模型和目标映射标签,可以直接将中间图像异常检测模型作为目标图像异常检测模型。进一步的,计算机设备还可以保持目标映射标签不变,基于训练图像集对中间图像异常检测模型进行训练,微调中间图像异常检测模型的模型参数,得到目标图像异常检测模型。例如,可以将训练图像集中的训练图像输入中间图像异常检测模型得到更新预测标签,基于更新预测标签和目标映射标签计算更新损失,基于更新损失调整中间图像异常检测模型的模型参数,直至满足第二训练结束条件,得到目标图像异常检测模型。第一训练结束条件和第二训练结束条件可以是相同的训练结束条件,例如,模型迭代次数大于预设迭代次数,也可以是不同的训练结束条件,例如,第一训练结束条件为模型反馈数据的数值小于预设目标数值,第二训练结束条件为模型迭代次数大于预设迭代次数。
在一个实施例中,目标图像异常检测模型为图像花屏检测模型、图像模糊检测模型和图像马赛克检测模型中的任意一种。
其中,图像花屏检测模型用于检测输入图像是否存在花屏现象。花屏现象是由于图像在编解码过程中出现问题而造成的图像异常。图像模糊检测模型用于检测输入图像是否存在模糊现象。模糊现象是在图像拍摄时,由于拍摄装置的拍摄参数或拍摄角度而造成的图像异常。图像马赛克检测模型用于检测输入图像是否存在马赛克现象。马赛克现象是由于图像局部区域的色阶细节劣化而造成的图像异常。本申请的图像异常检测模型训练方法适用于各种图像异常检测模型,可以有效提高图像异常检测效率和准确性。
上述图像异常检测模型训练方法中,通过获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签,将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签,基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据,基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签,基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。这样,在模型训练时,同步调整当前映射标签和模型参数,利用模型的特征学习能力对带有噪声的训练标签对应的当前映射标签进行自纠正,可以有效过滤噪声数据对模型的性能影响,大幅提升模型的性能,最终训练得到准确性较高的图像异常检测模型。后续在模型应用时,基于准确性较高的图像异常检测模型可以得到准确性较高的图像异常检测结果,有效提高了图像异常检测的检测准确性和检测效率。
在一个实施例中,获取训练标签对应的初始映射标签,包括:
基于训练标签对应的标签类别数量,对训练标签进行标签编码,得到初始映射标签。
其中,标签类别数量是指训练标签的标签类别个数。例如,若训练标签为二分类标签,那么标签类别数量为2,若训练标签为四分类标签,那么标签类别数量为4。标签编码用于将训练标签转换为由二进制来表示的数据。
具体地,计算机设备可以基于训练标签对应的标签类别数量对训练标签进行标签编码,将训练标签映射转换为初始映射标签。计算机设备具体可以基于标签类别数量确定初始映射标签对应的向量维度数量,各个向量维度上的初始向量值默认为第一预设值,依次将各个向量维度上的初始向量值分别转换为第二预设值,从而得到各个标签类别的训练标签对应的初始映射标签。一个向量维度对应一种标签类别,各个向量维度上的向量值表示图像属于对应标签类别的概率。例如,若训练标签为二分类标签,标签类别数量为2,那么初始映射标签对应的向量维度数量为2,即初始映射标签为二维向量。二维向量的初始形态可以是[0,0],即第一预设值为0,第二预设值为1。依次将各个向量维度上的初始值分别转换为第二预设值,那么二分类标签中的正标签对应的初始映射标签为[0,1],负标签对应的初始映射标签为[1,0]。以[0,1]为例,0表示图像属于负标签的概率,1表示图像属于正标签的概率。若训练标签为三分类标签,标签类别数量为3,那么初始映射标签对应的向量维度数量为3,即初始映射标签为三维向量。三维向量的初始形态可以是[0,0,0],三分类标签中的第一标签对应的初始映射标签为[0,0,1],第二标签对应的初始映射标签为[0,1,0],第三标签对应的初始映射标签为[1,0,0]。初始映射标签两两之间的距离相同。当然,第一预设值也可以为1,第二预设值为0。可以理解,后续随着模型、网络的更新,初始映射标签会逐渐被软化,例如,负标签对应的初始映射标签[1,0]会调整为[0.8,0.2]。
本实施例中,基于训练标签对应的标签类别数量对训练标签进行标签编码,得到初始映射标签,初始映射标签由二进制数据组成,并且两两之间的距离相同,易于被模型学习和计算。
在一个实施例中,如图3所示,将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签之前,所述方法还包括:
步骤S302,将候选训练图像集中的训练图像输入候选图像异常检测模型,得到训练图像对应的初始预测标签。
步骤S304,基于候选训练图像集中的训练图像对应的训练标签和初始预测标签之间的标签差异,调整候选图像异常检测模型的模型参数,直至满足第一收敛条件,得到初始图像异常检测模型。
其中,候选图像异常检测模型为原始的图像异常检测模型,候选图像异常检测模型中的模型参数可以是随机初始化的,也可以是人为设置的初始值。候选训练图像集是指用于训练候选图像异常检测模型的训练图像集,候选训练图像集可以包括至少一个训练图像。候选训练图像集和当前训练图像集可以是同一训练图像集,也可以是不同的训练图像集,即候选训练图像集和当前训练图像集可以包括相同的训练图像,也可以包括不同的训练图像。
具体地,除了直接获取候选图像异常检测模型作为初始图像异常检测模型,计算机设备还可以对候选图像异常检测模型进行预训练,将训练后的候选图像异常检测模型作为初始图像异常检测模型。在训练候选图像异常检测模型时,只调整模型参数,不调整训练标签,使得后续针对初始图像异常检测模型的模型训练可以比从头开始训练更快地收敛。
在训练时,计算机设备将候选训练图像集中的训练图像输入候选图像异常检测模型,经过候选图像异常检测模型对输入数据的数据处理,可以输出训练图像对应的初始预测标签。计算机设备可以基于训练图像对应的训练标签和初始预测标签之间的标签差异生成训练损失,基于训练损失进行反向传播来更新候选图像异常检测模型的模型参数,直至满足第一收敛条件,得到初始图像异常检测模型。其中,可以计算训练标签和初始预测标签之间的距离得到训练损失,例如,对初始预测标签和训练标签进行散度计算得到训练损失;对初始预测标签和训练标签进行交叉熵计算得到训练损失;等等。第一收敛条件可以是模型迭代次数达到第一预设阈值,训练损失的数值小于预设训练数值等中的至少一种。
本实施例中,对候选图像异常检测模型进行预训练得到初始图像异常检测模型,能够降低初始图像异常检测模型的训练难度,提高训练速度。可以理解,若直接获取候选图像异常检测模型作为初始图像异常检测模型,由于模型参数随机初始化,同时更新模型参数和当前映射标签的话难度较大,训练可能出现不稳定的情况。因此一开始先固定住当前映射标签,只更新网络参数,对候选图像异常检测模型进行模型训练得到初始图像异常检测模型,后续在训练初始图像异常检测模型时,再同时更新模型参数和当前映射标签,这样可以有效降低训练难度。
在一个实施例中,基于当前映射标签和目标预测标签生成模型反馈数据,包括:
对当前映射标签和目标预测标签进行散度计算,得到第一损失;获取训练标签对应的标签分布比例,基于标签分布比例和目标预测标签得到第二损失;标签分布比例是基于当前训练图像集中各个标签类别分别对应的训练图像数量确定的;基于第一损失和第二损失得到模型反馈数据。
其中,散度计算是一种度量两个数据之间分布差异的计算方式。标签分布比例用于表示各个标签类别之间的训练图像分布情况。标签分布比例是基于当前训练图像集中各个标签类别的训练图像数量确定的,具体可以是将各个标签类别的训练图像数量之间的比值作为标签分布比例。例如,若训练标签为二分类标签,在当前训练图像集中,具备正标签的图像有30个,具备负标签的图像有30个,那么标签分布比例为30:30=1:1。若训练标签为三分类标签,在当前训练图像集中,具备第一标签的图像有30个,具备第二标签的图像有30个,具备第三标签的图像有60个,那么标签分布比例为30:30:60=1:1:2。
具体地,计算机设备可以对当前映射标签和目标预测标签进行散度计算得到第一损失,第一损失用于衡量当前模型输出的预测概率与人工标注数据的差异,第一损失也可以称为分类损失。除了第一损失,计算机设备还可以获取训练标签对应的标签分布比例,基于标签分布比例和目标预测标签计算第二损失,第二损失用于衡量当前模型输出的预测概率与先验的标签分布比例的距离,第二损失也可以称为先验损失。先验损失的目的是让预测概率不要和标签分布比例相差的太远。计算机设备将计算得到的第一损失和第二损失进行融合可以得到模型反馈数据,例如,将第一损失和第二损失相加得到模型反馈数据,将第一损失和第二损失的加权和作为模型反馈数据等。
可以理解,人工标注标签虽然带有噪声,但是通常情况下,大部分人工标注标签的准确性还是比较高的,即大部分人工标注标签是正确的,只有少部分人工标注标签带有噪声,因此,引入第二损失,希望目标预测标签和标签分布比例不要相差太大,以此来提高模型反馈数据的准确性。本实施例中,通过对当前映射标签和目标预测标签进行散度计算,得到第一损失,基于标签分布比例和目标预测标签得到第二损失,基于第一损失和第二损失得到模型反馈数据。模型反馈数据由不同类型的损失组成,基于这样的模型反馈数据调整模型参数和当前映射标签来训练模型,可以提高模型训练的准确性。
在一个实施例中,对当前映射标签和目标预测标签进行散度计算,得到第一损失,包括:
对当前映射标签和目标预测标签的比值进行对数变换,得到标签变换比例;将标签变换比例和目标预测标签进行融合,得到第一损失。
具体地,计算机设备可以计算当前映射标签和目标预测标签的比值,对该比值进行对数变换,从而得到用于计算第一损失的标签变换比例。具体可以将预设值作为底数,以当前映射标签和目标预测标签的比值作为真数进行对数变换得到标签变换比例,也可以将预设值作为底数,以该比值与常量值的融合值作为真数进行对数变换得到标签变换比例。其中,预设值和常量值可以根据需要进行设置,例如,预设值和常量值为大于1的数据。融合值可以是当前映射标签和目标预测标签的比值与常量值的和,也可以是当前映射标签和目标预测标签的比值与常量值的乘积等。进而,计算机设备可以将目标预测标签和标签变 换比例进行融合,得到第一损失,例如,将目标预测标签和标签变换比例的乘积作为第一损失,将目标预测标签和标签变换比例的加权乘积作为第一损失。
可以理解,当前映射标签和目标预测标签越接近,标签变换比例越接近于零。第一损失的优化方向为当前映射标签和目标预测标签越接近越好。
在一个实施例中,第一损失的计算公式如下:
Figure PCTCN2022110998-appb-000001
其中,L c表示第一损失,p表示目标预测标签,
Figure PCTCN2022110998-appb-000002
表示当前映射标签。
Figure PCTCN2022110998-appb-000003
表示标签变换比例。p和
Figure PCTCN2022110998-appb-000004
为向量,在计算L c时,p和
Figure PCTCN2022110998-appb-000005
中同一向量维度的向量值基于上述公式进行计算,基于各个向量维度的计算结果最终得到L c
本实施例中,通过对当前映射标签和目标预测标签的比值进行对数变换,得到标签变换比例,将标签变换比例和目标预测标签进行融合可以快速得到第一损失。当前映射标签和目标预测标签越接近、越相似,第一损失越接近于零。
在一个实施例中,对当前映射标签和目标预测标签进行散度计算,得到第一损失,包括:
对当前映射标签和目标预测标签进行统计,得到标签统计信息;对标签统计信息和目标预测标签的比值进行对数变换,得到第一变换比例,对标签统计信息和当前映射标签的比值进行对数变换,得到第二变换比例;将目标预测标签和第一变换比例进行融合,得到第一子损失,将第二变换比例和当前映射标签进行融合,得到第二子损失;基于第一子损失和第二子损失得到第一损失。
具体地,计算机设备可以对当前映射标签和目标预测标签进行统计,将统计结果作为标签统计信息,例如,将当前映射标签和目标预测标签的均值作为标签统计信息,将当前映射标签和目标预测标签的和作为标签统计信息。进而,计算机设备对标签统计信息和目标预测标签的比值进行对数变换得到第一变换比例,对标签统计信息和当前映射标签的比值进行对数变换,得到第二变换比例。例如,将预设值作为底数,以标签统计信息和目标预测标签的比值作为真数进行对数变换得到第一变换比例,将预设值作为底数,以标签统计信息和当前映射标签的比值作为真数进行对数变换得到第二变换比例。计算机设备将目标预测标签和第一变换比例进行融合得到第一子损失,将当前映射标签和第二变换比例进行融合得到第二子损失,例如,将目标预测标签和第一变换比例的乘积作为第一子损失,将当前映射标签和第二变换比例的乘积作为第二子损失。最终,计算机设备基于第一子损失和第二子损失可以得到第一损失,例如,将第一子损失和第二子损失相加得到第一损失,将第一子损失和第二子损失的加权和作为第一损失。
可以理解,当前映射标签和目标预测标签越接近,第一变换比例和第二变换比例越接近于零。当前映射标签和目标预测标签越接近,第一损失越小。
在一个实施例中,第一损失的计算公式如下:
Figure PCTCN2022110998-appb-000006
其中,L c表示第一损失,p表示目标预测标签,
Figure PCTCN2022110998-appb-000007
表示当前映射标签。
Figure PCTCN2022110998-appb-000008
表示标签统计信息,
Figure PCTCN2022110998-appb-000009
表示第一变换比例,
Figure PCTCN2022110998-appb-000010
表示第二变换比例。
Figure PCTCN2022110998-appb-000011
表示第一子损失,
Figure PCTCN2022110998-appb-000012
表示第二子损失。
本实施例中,通过对当前映射标签和目标预测标签进行统计,得到标签统计信息,对标签统计信息和目标预测标签的比值进行对数变换,得到第一变换比例,对标签统计信息和当前映射标签的比值进行对数变换,得到第二变换比例,将目标预测标签和第一变换比例进行融合,得到第一子损失,将第二变换比例和当前映射标签进行融合,得到第二子损失,基于第一子损失和第二子损失可以快速得到第一损失。当前映射标签和目标预测标签越接近、越相似,第一子损失、第二子损失越接近于零,进而,第一损失越接近于零。
在一个实施例中,获取训练标签对应的标签分布比例,基于标签分布比例和目标预测标签得到第二损失,包括:
对标签分布比例进行向量化处理,得到标签分布向量;对标签分布向量和目标预测标签进行交叉熵计算,得到第二损失。
其中,交叉熵计算是一种度量两个数据之间分布差异的计算方式。目标预测标签和标签分布向量越接近,第二损失越小。
具体地,标签分布比例用于表示各个标签类别的训练图像数量之间的对比关系,为了便于和目标预测标签进行计算,需要对标签分布比例进行向量化处理,将标签分布比例转换为标签分布向量。标签分布向量与目标预测标签的向量维度相同,标签分布向量的向量维度数量为标签类别数量。计算机设备可以将各个标签类别对应的训练图像数量和训练图像总数量的比值作为标签分布向量中各个向量维度对应的向量值。例如,训练标签为二分类标签,标签分布比例为30:30=1:1,那么标签分布向量可以是[1/2,1/2],即[0.5,0.5]。进而,计算机设备可以对标签分布向量和目标预测标签进行交叉熵计算得到第二损失,具体可以是将预设值作为底数,以目标预测标签作为真数进行对数变换,将标签分布向量和对数变换后的目标预测标签进行融合,将融合结果取相反数得到第二损失。
在一个实施例中,第二损失的计算公式如下;
L p=-p prior*logp
其中,L p表示第二损失,p prior表示标签分布向量,p表示目标预测标签。
本实施例中,通过对标签分布比例进行向量化处理得到标签分布向量,对标签分布向量和目标预测标签进行交叉熵计算,可以快速得到第二损失。第二损失用于表征目标预测标签和标签分布向量之间的数据差异,目标预测标签和标签分布向量越接近,第二损失越小。
在一个实施例中,基于第一损失和第二损失得到模型反馈数据,包括:
对目标预测标签进行信息熵计算,得到第三损失;基于第一损失、第二损失和第三损失得到模型反馈数据。
其中,信息熵计算是一种度量数据中信息量的计算方式。对一个数据进行信息熵计算相当于将该数据和自身进行交叉熵计算。目标预测标签和对训练标签进行标签编码得到的当前映射标签越接近,第三损失越小。
具体地,第三损失用于约束第一损失,避免模型陷入局部最优。可以理解,网络的更新过程中由于人工标注标签的信息也在同步更新(即当前映射标签也在同步更新),而网络学习的目的是使得模型输出与标签信息越接近越好,那么显而易见的,只需要将人工标签信息更新到和模型输出完全一致,这种情况下第一损失就等于0了,然而此时的模型输出可能是乱序的,因为训练开始的时候模型参数是随机初始化的。因此,为了避免这种情况的发生,引入第三损失,将第三损失作为正向项,来约束第一损失。
计算机设备可以对目标预测标签进行信息熵计算得到第三损失,具体可以是将预设值作为底数,以目标预测标签作为真数进行对数变换,将目标预测标签和对数变换后的目标预测标签进行融合,将融合结果取相反数得到第三损失。第三损失的优化方向是使得模型输出尽可能接近于对训练标签进行标签编码得到的当前映射标签。在一个实施例中,第三 损失的计算公式如下:
L e=-p*logp
其中,L e表示第三损失,p表示目标预测标签。
本实施例中,对目标预测标签进行信息熵计算,可以快速得到第三损失,基于第一损失、第二损失和第三损失得到的模型反馈数据有助于保障模型的训练质量。
在一个实施例中,基于第一损失、第二损失和第三损失得到模型反馈数据,包括:
获取第一损失、第二损失和第三损失分别对应的损失权重;第二损失对应的损失权重随着当前训练图像集中噪声图像对应的噪声图像比例的增加而减少;基于损失权重对第一损失、第二损失和第三损失进行融合,得到模型反馈数据。
其中,噪声图像是指带有噪声的训练图像。噪声图像是从多个标签类别中难以确定其对应的准确标签类别的图像,也就是,噪声图像对应的训练标签的标签准确度低于预设准确度。例如,训练标签为二分类标签,正标签表示正常图像,负训练标签表示花屏图像,对于只有轻微花屏或局部花屏的图像,难以确定其对应的准确标签,有些人会将其标注为对应正标签,有些人会将其标注为对应负标签。因此,可以收集多个用户对同一训练图像的标签标注信息,对各个标签标注信息进行统计分析,基于统计分析结果确定训练图像对应的标签准确度,例如,计算各个标签类别对应的标注比例,从中选取最大的标注比例作为标签准确度,从中选取最大的标注比例对应的标签类别作为训练标签。而预设准确度可以根据需要进行设置,例如,设置为0.8。举例说明,针对训练图像A,3个用户给出的标签标注信息为正标签,3个用户给出的标签标注信息为负标签,训练图像A对应的训练标签为正标签或负标签,标签准确度为3/6=0.5<0.8,因此训练图像A为噪声图像。
噪声图像比例是指噪声图像的数量占当前训练图像集中训练图像总数量的比例。例如,在当前训练图像集中,训练图像有100个,其中的噪声图像有20个,那么噪声图像比例为20/100=0.2。
具体地,在基于第一损失、第二损失和第三损失得到模型反馈数据时,计算机设备可以获取第一损失、第二损失和第三损失分别对应的损失权重,基于各个损失对应的损失权重对各个损失进行加权融合,从而得到模型反馈数据。其中,各个损失权重可以是预设的固定值,也可以作为一种模型参数,在模型训练过程中调整和学习。
进一步的,由于第二损失的目的是让模型输出不要和标签分布比例相差的太远,若训练图像中噪声图像占的比例较多,那么可以适当减少第二损失对应的损失权重,避免噪声图像对模型训练造成不好的影响。因此,第二损失对应的损失权重可以随着训练图像中噪声图像对应的噪声图像比例的增加而减少。
在一个实施例中,模型反馈数据的计算公式如下:
L=L c+αL e+βL p
其中,L表示模型反馈数据(也可以称为损失函数),L c表示第一损失,L p表示第二损失,L e表示第三损失。第一损失对应的损失权重为1,第二损失对应的损失权重为β,第三损失对应的损失权重为α。α随着当前训练图像集中噪声图像对应的噪声图像比例的增加而减少。
本实施例中,通过获取第一损失、第二损失和第三损失分别对应的损失权重,基于损失权重对第一损失、第二损失和第三损失进行融合得到模型反馈数据。其中,第二损失对应的损失权重随着训练图像中噪声图像对应的噪声图像比例的增加而减少,进而能够避免在噪声数据较多的情况下第二损失影响模型训练的训练效果。
在一个实施例中,基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,包括:
基于模型反馈数据对当前映射标签进行梯度计算,得到数据变化参考信息;获取模型 学习率,基于模型学习率调整数据变化参考信息,得到标签损失;基于当前映射标签和标签损失之间的距离得到更新映射标签。
其中,模型学习率是一种超参数,可以是预设的固定值,也可以作为一种模型参数,在模型训练过程中调整和学习。
具体地,计算机设备可以计算模型反馈数据对当前映射标签的梯度,将计算结果作为数据变化参考信息,也就是,基于模型反馈数据对当前映射标签进行梯度计算得到数据变化参考信息。可以理解,由于自熵损失是基于目标预测标签得到的,与当前映射标签无关,即使模型反馈数据包括自熵损失,基于该模型反馈数据对当前映射标签进行梯度计算得到的数据变化参考信息也不会受自熵损失的影响。进而,计算机设备可以获取模型学习率,将模型学习率和数据变化参考信息进行融合得到标签损失,例如,将模型学习率和数据变化参考信息的乘积作为标签损失,将模型学习率和数据变化参考信息的加权乘积作为标签损失等。然后,计算机设备计算当前映射标签和标签损失之间的距离,将计算得到的距离作为更新的更新映射标签。例如,将当前映射标签和标签损失的差值作为更新映射标签。后续,将更新映射标签作为新的当前映射标签,参与下一轮的模型迭代训练。
在一个实施例中,可以通过以下公式调整当前映射标签:
Figure PCTCN2022110998-appb-000013
Figure PCTCN2022110998-appb-000014
其中,
Figure PCTCN2022110998-appb-000015
表示数据变化参考信息,是通过计算损失函数L对
Figure PCTCN2022110998-appb-000016
的梯度得到,L表示模型反馈数据(也可以称为损失函数),
Figure PCTCN2022110998-appb-000017
表示t时刻(t模型迭代轮次)对应的当前映射标签,
Figure PCTCN2022110998-appb-000018
表示t+1时刻(t+1模型迭代轮次)对应的当前映射标签,即对当前映射标签进行调整得到的更新映射标签,l r表示模型学习率。
本实施例中,基于模型反馈数据对当前映射标签进行梯度计算得到数据变化参考信息,基于模型学习率调整数据变化参考信息得到标签损失,基于当前映射标签和标签损失之间的距离得到更新映射标签。这样,基于模型反馈数据对当前映射标签的损失梯度调整当前映射标签,可以沿梯度下降方向更新当前映射标签,从而可以快速调整得到目标映射标签。
在一个实施例中,如图4所示,基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型,包括:
步骤S402,基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足第二收敛条件,得到中间图像异常检测模型和目标映射标签。
其中,中间图像异常检测模型为在模型训练时通过同步调整模型参数和当前映射标签最终得到的模型。目标映射标签为在模型训练时通过同步调整模型参数和当前映射标签最终得到的映射标签,可以认为是初始图像异常检测模型收敛后得到的映射标签。
可以理解,初始图像异常检测模型可以是直接初始化得到的,也可以是经过预训练得到的。例如,直接获取候选图像异常检测模型作为初始图像异常检测模型;对候选图像异常检测模型进行预训练,将训练后的候选图像异常检测模型作为初始图像异常检测模型;等等。
具体地,在训练初始图像异常检测模型时,计算机设备可以同时更新模型参数和当前映射标签。计算机设备可以基于模型反馈数据进行反向传播来调整初始图像异常检测模型的模型参数,得到新的初始图像异常检测模型,将下一训练图像集中的训练图像输入新的 初始图像异常检测模型,得到新的目标预测标签,基于新的当前映射标签和新的目标预测标签得到新的模型反馈数据,基于新的模型反馈数据再次调整当前映射标签和模型参数,以此类推,循环训练多个迭代轮次,直至满足第二收敛条件,得到中间图像异常检测模型和目标映射标签。其中,第二收敛条件可以是模型迭代次数达到第二迭代次数、模型反馈数据的数值小于预设目标数值、模型反馈数据的变化率小于预设变化率、模型反馈数据最小化等中的至少一者。
步骤S404,将目标训练图像集中的训练图像输入中间图像异常检测模型,得到训练图像对应的更新预测标签。
步骤S406,基于目标训练图像集中的训练图像对应的更新预测标签和目标映射标签生成更新损失,基于更新损失调整中间图像异常检测模型的模型参数,直至满足第三收敛条件,得到目标图像异常检测模型。
其中,目标训练图像集是指用于训练中间图像异常检测模型的训练图像集,目标训练图像集可以包括至少一个训练图像。目标训练图像集和当前训练图像集可以是同一训练图像集,也可以是不同的训练图像集,即目标训练图像集和当前训练图像集可以包括相同的训练图像,也可以包括不同的训练图像。
具体地,在得到中间图像异常检测模型后,计算机设备可以固定目标映射标签,对中间图像异常检测模型进行进一步的模型训练,微调模型参数,得到目标图像异常检测模型。在训练中间图像异常检测模型时,计算机设备可以将训练图像输入中间图像异常检测模型,得到训练图像对应的更新预测标签,基于更新预测标签和目标映射标签之间的数据分布差异生成更新损失,基于更新损失进行反向传播来调整中间图像异常检测模型的模型参数,直至满足第三收敛条件,得到目标图像异常检测模型。其中,第三收敛条件可以是模型迭代次数达到第三迭代次数、更新损失的数值小于预设更新数值等中的至少一者。
可以理解,与模型反馈数据类似,更新损失可以是基于至少一种损失得到的。例如,更新损失包括基于目标映射标签和更新预测标签计算得到的分类损失、基于训练标签和更新预测标签计算得到的先验损失;更新损失包括基于目标映射标签和更新预测标签计算得到的分类损失、基于训练标签和更新预测标签计算得到的先验损失和基于更新预测标签计算得到的自熵损失。各种损失的计算可以参考前述各个相关实施例所述的方法,此处不再赘述。
本实施例中,在训练初始图像异常检测模型时,先同步更新当前映射标签和模型参数,直至满足第二收敛条件,得到中间图像异常检测模型和目标映射标签,然后固定目标映射标签,进一步更新中间图像异常检测模型的模型参数,直至达到第三收敛条件,得到目标图像异常检测模型。上述训练过程可以进一步提高模型训练的准确性。
在一个实施例中,基于更新预测标签和目标映射标签生成更新损失,包括:
对更新预测标签和目标映射标签进行散度计算,得到第四损失;对更新预测标签进行信息熵计算,得到第五损失;基于目标训练图像集对应的训练标签和更新预测标签进行交叉熵计算,得到第六损失;基于第四损失、第五损失和第六损失得到更新损失。
具体地,更新损失可以是基于分类损失、先验损失和自熵损失得到的。分类损失可以是对目标训练图像集中各个训练图像对应的更新预测标签和目标映射标签进行散度计算得到的,也就是,计算机设备可以对更新预测标签和目标映射标签进行散度计算得到第四损失。先验损失可以是对目标训练图像集中各个训练图像对应的更新预测标签进行信息熵计算得到的,也就是,计算机设备可以对更新预测标签进行信息熵计算得到第五损失。先验损失可以是对目标训练图像集中各个训练图像对应的训练标签和更新预测标签进行交叉熵计算得到的,也就是,计算机设备可以基于训练标签和更新预测标签进行交叉熵计算得到第六损失。最终,计算机设备可以基于第四损失、第五损失和第六损失得到更新损失,例如,将第四损失、第五损失和第六损失相加得到更新损失,将第四损失、第五损失和第 六损失进行加权融合得到更新损失。各种损失的具体计算过程可以参考前述各个相关实施例所述的方法,此处不再赘述。
本实施例中,通过对更新预测标签和目标映射标签进行散度计算得到第四损失,对更新预测标签进行信息熵计算得到第五损失,基于目标训练图像集对应的训练标签和更新预测标签进行交叉熵计算得到第六损失,基于第四损失、第五损失和第六损失得到更新损失。更新损失由多种不同类型的损失组成,基于这样的更新损失调整模型参数来训练模型,可以提高模型训练的准确性。
在一个实施例中,如图5所示,提供了一种图像异常检测方法,以该方法应用于图1中的计算机为例进行说明,可以理解的是,计算机设备可以是终端102,也可以是服务器104。本实施例中,图像异常检测方法包括以下步骤:
步骤S502,获取待检测图像。
步骤S504,将待检测图像输入目标图像异常检测模型,得到待检测图像对应的模型预测标签。
其中,待检测图像是指待检测是否存在异常的图像。待检测图像可以是图片,也可以是视频中的视频帧。模型预测标签是指待检测图像对应的预测标签。
具体地,计算机设备可以在本地、或从其他终端、服务器获取待检测图像和目标图像异常检测模型,将待检测图像输入目标图像异常检测模型,得到待检测图像对应的模型预测标签。
其中,目标图像异常检测模型的训练过程包括:获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签;将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签;基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签;基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
可以理解,目标图像异常检测模型的具体训练过程可以参照图像异常检测模型训练方法中各个相关实施例所述的方法,此处不再赘述。
步骤S506,基于模型预测标签确定待检测图像对应的图像异常检测结果。
具体地,在得到模型预测标签后,计算机设备可以基于模型预测标签确定待检测图像对应的图像异常检测结果。计算机设备可以设置目标图像异常检测模型输出完整的数据,即模型预测标签为预测向量,预测向量中各个向量值表示待检测图像属于对应标签类别的概率。计算机设备可以从预测向量中将正常标签类别对应的概率作为目标置信度,若目标置信度大于预设置信度,则确定待检测图像为正常图像,待检测图像的图像异常检测结果为图像无异常,若目标置信度小于或等于预设置信度,则确定待检测图像为异常图像,待检测图像的图像异常检测结果为图像异常。若模型预测标签为预测向量,计算机设备还可以将预测向量中大于预设向量值的向量值作为目标置信度,若目标置信度大于预设置信度,则确定待检测图像的图像异常检测结果为该目标置信度对应的标签类别。
当然,计算机设备也可以设置目标图像异常检测模型只输出正常标签类别对应的概率作为模型预测标签,若模型预测标签大于预设置信度,则确定待检测图像为正常图像,若模型预测标签小于或等于预设置信度,则确定待检测图像为异常图像。其中,预设置信度可以根据需要进行设置,例如,设置为0.5。
本申请的图像异常检测方法可以应用于图像或视频的质量分析任务中。例如,在社交应用中,计算机设备获取用户上传的待分享图片,基于目标图像异常检测模型对待分享图 片进行图像异常检测,若图像异常检测结果为图像无异常,则确定待分享图片满足分享条件,进而将待分享图片发布在社交应用中,以供其他用户浏览,若图像异常检测结果为图像异常,可以提示用户图片质量不佳,提示用户重新上传图片。在视频应用中,计算机设备获取用户上传的待分享视频,基于目标图像异常检测模型对待分享视频中的视频帧进行图像异常检测,若图像异常检测结果为图像无异常的视频帧比例大于预设比例,则确定待分享视频满足分享条件,进而将待分享视频发布在视频应用中,以供其他用户浏览。在车辆周边环境检测应用中,计算机设备可以获取车载终端采集的周边环境视频,基于目标图像异常检测模型对周边环境视频中的视频帧进行图像异常检测,若图像异常检测结果为图像无异常的视频帧比例大于预设比例,则存储周边环境视频或对周边环境视频进行进一步数据分析,确定车辆所处环境状态,若图像异常检测结果为图像无异常的视频帧比例小于或等于预设比例,则指示车载终端重新采集周边环境视频。
上述图像异常检测方法中,通过获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签;将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签;基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签;基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。这样,在模型训练时,同步调整当前映射标签和模型参数,利用模型的特征学习能力对带有噪声的训练标签对应的当前映射标签进行自纠正,可以有效过滤噪声数据对模型的性能影响,大幅提升模型的性能,最终训练得到准确性较高的图像异常检测模型。从而在模型应用时,基于准确性较高的图像异常检测模型对待检测图像进行图像异常检测,可以得到准确性较高的图像异常检测结果,有效提高了图像异常检测的检测准确性和检测效率。
在一个具体的实施例中,上述的图像异常检测模型训练方法、图像异常检测方法可以应用于图像花屏检测任务。图像花屏检测是指对一张图片是否存在花屏现象进行检测。图像花屏检测任务是图片以及视频的质量分析中的一个必备步骤,可以用于评估当前图片或视频的质量。
参考图6,花屏图像并不是简单的二分类,很多花屏图像只是轻微花屏或者局部花屏。因此,简单的二值标签可能带有人为主观性,进而导致这样的花屏图像对应的人工标注信息带有噪声,在这样的带噪标签中进行模型的训练,会降低模型的性能。通过本申请的图像异常检测模型训练方法,可以利用模型的特征学习能力对含有噪声的人工标签数据进行辨别与纠正,进而大幅提升模型的性能,最终训练完成的模型可以在花屏检测任务中输出更为精确的预测结果。
参考图7,在模型训练时,将图像输入图像花屏检测模型,经过深度学习模型的数据计算可以得到输入图像是否是花屏的预测概率(即预测标签)。同时,输入图像对应的人工标签经过标签编码转换为映射标签。其中,人工标签是指人工标注的标签,可以为0/1二值标签,表示图像存在花屏或者不存在花屏的人为判定结果。图像花屏检测模型的损失函数包括三种损失,具体为自熵损失、分类损失和先验损失。自熵损失是基于预测概率计算得到的,是预测概率与自身计算熵值的结果,该项损失是一个正则项,目的是防止模型陷入局部最优。分类损失是基于预测概率和映射标签得到的,用于度量模型的预测概率和人工标签二者之间的距离。先验损失是基于预测概率和人工标签中正负标签分布比例得到的,该项损失也是一个正则项。三项损失叠加之后同时指导深度学习模型的参数更新以及人工标签对应的映射标签的标签更新,更新之后的映射标签又作为下一个轮次模型迭代的 损失函数对应的计算数据,经过多轮模型迭代,最终得到训练完成的图像花屏检测模型以及纠正之后的人工标签结果(即目标映射标签)。
可以理解,图7中的实线箭头表示模型的前向传播过程,也就是推理过程,图7中的虚线箭头表示模型训练时的反向传播过程。
进一步的,模型的训练过程可以分为三个步骤。步骤1使用原始的人工标注标签进行训练,不对标签进行更新,这一步的目的是在模型训练的初期,模型参数随机初始化,同时更新模型参数和标签分布的话难度较大,训练可能出现不稳定的情况,因此一开始先固定住映射标签,只更新模型参数,该阶段的损失函数可以只包括分类损失,该阶段可以训练K1个迭代轮次。步骤2同时更新模型参数和映射标签,该阶段的损失函数可以包括三种损失,该阶段可以训练K2个迭代轮次。步骤3固定住之前步骤2迭代得到的映射标签,不再更新映射标签,只更新模型参数,再一次对模型进行K3个迭代轮次的更新,该阶段的损失函数包括三种损失。最终,整个训练过程需要消耗K1+K2+K3个迭代轮次,训练完成后得到已训练的图像花屏检测模型。
可以理解,模型的训练过程,也可以不采用K1+K2+K3的三步式训练方式,例如,采用K1+K2的训练方式。
已训练的图像花屏检测模型可以用于预测输入图像的花屏概率(即花屏置信度)。参考图8,当模型预测的花屏置信度大于预设置信度时,确定输入图像存在花屏,为花屏图像,当模型预测的花屏置信度小于或等于预设置信度时,确定输入图像不存在花屏,为正常图像。其中,预设阈值可以根据需要进行设置,例如,设置为0.5。
本实施例中,基于训练完成的图像花屏检测模型可以精准的对图像的花屏程度进行检测。在模型训练时,通过对带有噪声的人工标签进行自纠正,有效过滤噪声数据对模型的性能影响,从而训练得到准确的图像花屏检测模型。在模型应用时,基于准确的图像花屏检测模型可以输出稳定、可靠的花屏检测结果,从而为视频质量评估提供可靠的技术支撑。
可以理解,上述模型训练方法除了应用于图像花屏检测模型,还可以应用于图像模糊检测模型、图像马赛克检测模型等图像异常检测模型。
应该理解的是,虽然图2-图5的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-图5中的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者阶段的至少一部分轮流或者交替地执行。
在一个实施例中,如图9所示,提供了一种图像异常检测模型训练装置,该装置可以采用软件模块或硬件模块,或者是二者的结合成为计算机设备的一部分,该装置具体包括:训练数据获取模块902、模型预测模块904、模型反馈数据确定模块906、标签调整模块908和模型调整模块910,其中:
训练数据获取模块902,用于获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签。
模型预测模块904,用于将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签。
模型反馈数据确定模块906,用于基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据。
标签调整模块908,用于基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签。
模型调整模块910,用于基于模型反馈数据调整初始图像异常检测模型的模型参数, 得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
在一个实施例中,训练数据获取模块还用于基于训练标签对应的标签类别数量,对训练标签进行标签编码,得到初始映射标签。
在一个实施例中,图像异常检测模型训练装置还包括:
模型预训练模块,用于将候选训练图像集中的训练图像输入候选图像异常检测模型,得到训练图像对应的初始预测标签;基于候选训练图像集中的训练图像对应的训练标签和初始预测标签之间的标签差异,调整候选图像异常检测模型的模型参数,直至满足第一收敛条件,得到初始图像异常检测模型。
在一个实施例中,模型反馈数据确定模块包括:
第一损失确定单元,用于对当前映射标签和目标预测标签进行散度计算,得到第一损失。
第二损失确定单元,用于获取训练标签对应的标签分布比例,基于标签分布比例和目标预测标签得到第二损失;标签分布比例是基于当前训练图像集中各个标签类别的训练图像数量确定的。
模型反馈数据确定单元,用于基于第一损失和第二损失得到模型反馈数据。
在一个实施例中,第一损失确定单元还用于对当前映射标签和目标预测标签的比值进行对数变换,得到标签变换比例;将标签变换比例和目标预测标签进行融合,得到第一损失。
在一个实施例中,第一损失确定单元还用于对当前映射标签和目标预测标签进行统计,得到标签统计信息;对标签统计信息和目标预测标签的比值进行对数变换,得到第一变换比例,对标签统计信息和当前映射标签的比值进行对数变换,得到第二变换比例;将目标预测标签和第一变换比例进行融合,得到第一子损失,将当前映射标签和第二变换比例进行融合,得到第二子损失;基于第一子损失和第二子损失得到第一损失。
在一个实施例中,第二损失确定单元还用于对标签分布比例进行向量化处理,得到标签分布向量;对标签分布向量和目标预测标签进行交叉熵计算,得到第二损失。
在一个实施例中,模型反馈数据确定单元还用于对目标预测标签进行信息熵计算,得到第三损失;基于第一损失、第二损失和第三损失得到模型反馈数据。
在一个实施例中,模型反馈数据确定单元还用于获取第一损失、第二损失和第三损失分别对应的损失权重;第二损失对应的损失权重随着当前训练图像集中噪声图像对应的噪声图像比例的增加而减少;基于损失权重对第一损失、第二损失和第三损失进行融合,得到模型反馈数据。
在一个实施例中,标签调整模块还用于基于模型反馈数据对当前映射标签进行梯度计算,得到数据变化参考信息;获取模型学习率,基于模型学习率调整数据变化参考信息,得到标签损失;基于当前映射标签和标签损失之间的距离得到更新的当前映射标签。
在一个实施例中,模型调整模块包括:
第一调整单元,用于基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足第二收敛条件,得到中间图像异常检测模型和目标映射标签。
预测单元,用于将目标训练图像集中的训练图像输入中间图像异常检测模型,得到训练图像对应的更新预测标签。
第二调整单元,用于基于目标训练图像集中的训练图像对应的更新预测标签和目标映 射标签生成更新损失,基于更新损失调整中间图像异常检测模型的模型参数,直至满足第三收敛条件,得到目标图像异常检测模型。
在一个实施例中,第二调整单元还用于对更新预测标签和目标映射标签进行散度计算,得到第四损失;对更新预测标签进行信息熵计算,得到第五损失;基于目标训练图像集对应的训练标签和更新预测标签进行交叉熵计算,得到第六损失;基于第四损失、第五损失和第六损失得到更新损失。
在一个实施例中,目标图像异常检测模型为图像花屏检测模型、图像模糊检测模型和图像马赛克检测模型中的任意一种。
上述图像异常检测模型训练装置,在模型训练时,同步调整训练标签和当前映射标签,利用模型的特征学习能力对带有噪声的训练标签对应的当前映射标签进行自纠正,可以有效过滤噪声数据对模型的性能影响,大幅提升模型的性能,最终训练得到准确性较高的图像异常检测模型。后续在模型应用时,基于准确性较高的图像异常检测模型可以得到准确性较高的图像异常检测结果,有效提高了图像异常检测的检测准确性和检测效率。
在一个实施例中,如图10所示,提供了一种图像异常检测装置,该装置可以采用软件模块或硬件模块,或者是二者的结合成为计算机设备的一部分,该装置具体包括:图像获取模块1002、标签预测模块1004和检测结果确定模块1006,其中:
图像获取模块1002,用于获取待检测图像。
标签预测模块1004,用于将待检测图像输入目标图像异常检测模型,得到待检测图像对应的模型预测标签。
检测结果确定模块1006,用于基于模型预测标签确定待检测图像对应的图像异常检测结果。
其中,目标图像异常检测模型的训练过程包括:
获取训练标签对应的初始映射标签,将初始映射标签作为当前映射标签;
将当前训练图像集中的训练图像输入初始图像异常检测模型,得到训练图像对应的目标预测标签;
基于训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;
基于模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将更新映射标签作为当前映射标签;
基于模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
上述图像异常检测装置,在模型训练时,同步调整训练标签和当前映射标签,利用模型的特征学习能力对带有噪声的训练标签对应的当前映射标签进行自纠正,可以有效过滤噪声数据对模型的性能影响,大幅提升模型的性能,最终训练得到准确性较高的图像异常检测模型。从而在模型应用时,基于准确性较高的图像异常检测模型可以得到准确性较高的图像异常检测结果,有效提高了图像异常检测的检测准确性和检测效率。
关于图像异常检测模型训练装置、图像异常检测装置的具体限定可以参见上文中对于图像异常检测模型训练方法、图像异常检测方法的限定,在此不再赘述。上述图像异常检测模型训练装置、图像异常检测装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图11所示。该计算机设备包括通过系统总线连接的处理器、存储器和网络接口。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易 失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储训练图像、候选图像异常检测模型、初始图像异常检测模型、中间图像异常检测模型、目标图像异常检测模型等数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种图像异常检测模型训练方法、图像异常检测方法。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是终端,其内部结构图可以如图12所示。该计算机设备包括通过系统总线连接的处理器、存储器、通信接口、显示屏和输入装置。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机可读指令。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的通信接口用于与外部的终端进行有线或无线方式的通信,无线方式可通过WIFI、运营商网络、NFC(近场通信)或其他技术实现。该计算机可读指令被处理器执行时以实现一种图像异常检测模型训练方法、图像异常检测方法。该计算机设备的显示屏可以是液晶显示屏或者电子墨水显示屏,该计算机设备的输入装置可以是显示屏上覆盖的触摸层,也可以是计算机设备外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。
本领域技术人员可以理解,图11、12中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
在一个实施例中,还提供了一种计算机设备,包括存储器和一个或多个处理器,存储器中存储有计算机可读指令,该一个或多个处理器执行计算机可读指令时实现上述各方法实施例中的步骤。
在一个实施例中,提供了一种计算机可读存储介质,存储有计算机可读指令计算机可读指令,该计算机可读指令被一个或多个处理器执行时实现上述各方法实施例中的步骤。
在一个实施例中,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机可读指令,该计算机可读指令存储在计算机可读存储介质中。计算机设备的一个或多个处理器从计算机可读存储介质读取该计算机可读指令,一个或多个处理器执行该计算机可读指令,使得该计算机设备执行上述各方法实施例中的步骤。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和易失性存储器中的至少一种。非易失性存储器可包括只读存储器(Read-Only Memory,ROM)、磁带、软盘、闪存或光存储器等。易失性存储器可包括随机存取存储器(Random Access Memory,RAM)或外部高速缓冲存储器。作为说明而非局限,RAM可以是多种形式,比如静态随机存取存储器(Static Random Access Memory,SRAM)或动态随机存取存储器(Dynamic Random Access Memory,DRAM)等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范 围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (19)

  1. 一种图像异常检测模型训练方法,其特征在于,由计算机设备执行,所述方法包括:
    获取训练标签对应的初始映射标签,将所述初始映射标签作为当前映射标签;
    将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签;
    基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;
    基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将所述更新映射标签作为当前映射标签;及
    基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
  2. 根据权利要求1所述的方法,其特征在于,所述获取训练标签对应的初始映射标签,包括:
    基于所述训练标签对应的标签类别数量,对所述训练标签进行标签编码,得到所述初始映射标签。
  3. 根据权利要求1所述的方法,其特征在于,所述将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签之前,所述方法还包括:
    将候选训练图像集中的训练图像输入候选图像异常检测模型,得到训练图像对应的初始预测标签;及
    基于所述候选训练图像集中的训练图像对应的训练标签和初始预测标签之间的标签差异,调整所述候选图像异常检测模型的模型参数,直至满足第一收敛条件,得到初始图像异常检测模型。
  4. 根据权利要求1所述的方法,其特征在于,所述基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据,包括:
    对当前映射标签和目标预测标签进行散度计算,得到第一损失;
    获取所述训练标签对应的标签分布比例,基于所述标签分布比例和目标预测标签得到第二损失;所述标签分布比例是基于当前训练图像集中各个标签类别分别对应的训练图像数量确定的;及
    基于所述第一损失和所述第二损失得到所述模型反馈数据。
  5. 根据权利要求4所述的方法,其特征在于,所述对当前映射标签和目标预测标签进行散度计算,得到第一损失,包括:
    对当前映射标签和目标预测标签的比值进行对数变换,得到标签变换比例;及
    将所述标签变换比例和目标预测标签进行融合,得到所述第一损失。
  6. 根据权利要求4所述的方法,其特征在于,所述对当前映射标签和目标预测标签进行散度计算,得到第一损失,包括:
    对当前映射标签和目标预测标签进行统计,得到标签统计信息;
    对所述标签统计信息和目标预测标签的比值进行对数变换,得到第一变换比例,对所述标签统计信息和当前映射标签的比值进行对数变换,得到第二变换比例;
    将所述第一变换比例和目标预测标签进行融合,得到第一子损失,将所述第二变换比例和当前映射标签进行融合,得到第二子损失;及
    基于所述第一子损失和所述第二子损失得到所述第一损失。
  7. 根据权利要求4所述的方法,其特征在于,所述获取所述训练标签对应的标签分布比例,基于所述标签分布比例和目标预测标签得到第二损失,包括:
    对所述标签分布比例进行向量化处理,得到标签分布向量;及
    对所述标签分布向量和目标预测标签进行交叉熵计算,得到所述第二损失。
  8. 根据权利要求4所述的方法,其特征在于,所述基于所述第一损失和所述第二损失得到所述模型反馈数据,包括:
    对目标预测标签进行信息熵计算,得到第三损失;及
    基于所述第一损失、所述第二损失和所述第三损失得到所述模型反馈数据。
  9. 根据权利要求8所述的方法,其特征在于,所述基于所述第一损失、所述第二损失和所述第三损失得到所述模型反馈数据,包括:
    获取所述第一损失、所述第二损失和所述第三损失分别对应的损失权重;所述第二损失对应的损失权重随着当前训练图像集中噪声图像对应的噪声图像比例的增加而减少;及
    基于损失权重对所述第一损失、所述第二损失和所述第三损失进行融合,得到所述模型反馈数据。
  10. 根据权利要求1所述的方法,其特征在于,所述基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,包括:
    基于所述模型反馈数据对当前映射标签进行梯度计算,得到所述数据变化参考信息;
    获取模型学习率,基于所述模型学习率调整所述数据变化参考信息,得到所述标签损失;及
    基于当前映射标签和标签损失之间的距离得到所述更新映射标签。
  11. 根据权利要求1所述的方法,其特征在于,所述基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型,包括:
    基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足第二收敛条件,得到中间图像异常检测模型和目标映射标签;
    将目标训练图像集中的训练图像输入所述中间图像异常检测模型,得到训练图像对应的更新预测标签;及
    基于所述目标训练图像集中的训练图像对应的更新预测标签和所述目标映射标签生成更新损失,基于所述更新损失调整所述中间图像异常检测模型的模型参数,直至满足第三收敛条件,得到所述目标图像异常检测模型。
  12. 根据权利要求11所述的方法,其特征在于,所述基于所述目标训练图像集中的训练图像对应的更新预测标签和所述目标映射标签生成更新损失,包括:
    对所述更新预测标签和所述目标映射标签进行散度计算,得到第四损失;
    对所述更新预测标签进行信息熵计算,得到第五损失;
    基于所述目标训练图像集对应的训练标签和所述更新预测标签进行交叉熵计算,得到第六损失;及
    基于所述第四损失、所述第五损失和所述第六损失得到所述更新损失。
  13. 根据权利要求1至12任意一项所述的方法,其特征在于,所述目标图像异常检测模型为图像花屏检测模型、图像模糊检测模型和图像马赛克检测模型中的任意一种。
  14. 一种图像异常检测方法,其特征在于,由计算机设备执行,所述方法包括:
    获取待检测图像;
    将所述待检测图像输入目标图像异常检测模型,得到所述待检测图像对应的模型预测标签;及
    基于所述模型预测标签确定所述待检测图像对应的图像异常检测结果;
    其中,所述目标图像异常检测模型的训练过程包括:获取训练标签对应的初始映射标签,将所述初始映射标签作为当前映射标签;将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签;基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将所述更新映射标签作为当前映射标签;基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
  15. 一种图像异常检测模型训练装置,其特征在于,所述装置包括:
    训练数据获取模块,用于获取训练标签对应的初始映射标签,将所述初始映射标签作为当前映射标签;
    模型预测模块,用于将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签;
    模型反馈数据确定模块,用于基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;
    标签调整模块,用于基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将所述更新映射标签作为当前映射标签;及
    模型调整模块,用于基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异常检测模型。
  16. 一种图像异常检测装置,其特征在于,所述装置包括:
    图像获取模块,用于获取待检测图像;
    标签预测模块,用于将所述待检测图像输入目标图像异常检测模型,得到所述待检测图像对应的模型预测标签;及
    检测结果确定模块,用于基于所述模型预测标签确定所述待检测图像对应的图像异常检测结果;
    其中,所述目标图像异常检测模型的训练过程包括:获取训练标签对应的初始映射标签,将所述初始映射标签作为当前映射标签;将当前训练图像集中的训练图像输入初始图像异常检测模型,得到所述训练图像对应的目标预测标签;基于所述训练图像的训练标签对应的当前映射标签和目标预测标签生成模型反馈数据;基于所述模型反馈数据对应的数据变化参考信息生成标签损失,基于标签损失调整当前映射标签得到更新映射标签,将所述更新映射标签作为当前映射标签;基于所述模型反馈数据调整初始图像异常检测模型的模型参数,得到更新图像异常检测模型,将所述更新图像异常检测模型作为初始图像异常检测模型,获取下一训练图像集作为当前训练图像集,返回所述将当前训练图像集中的训练图像输入初始图像异常检测模型的步骤执行,直至满足训练结束条件,得到目标图像异 常检测模型。
  17. 一种计算机设备,包括存储器和一个或多个处理器,所述存储器存储有计算机可读指令,其特征在于,所述一个或多个处理器执行所述计算机可读指令时实现权利要求1至13或14中任一项所述的方法的步骤。
  18. 一种计算机可读存储介质,存储有计算机可读指令,其特征在于,所述计算机可读指令被一个或多个处理器执行时实现权利要求1至13或14中任一项所述的方法的步骤。
  19. 一种计算机程序产品,包括计算机可读指令,其特征在于,所述计算机可读指令被一个或多个处理器执行时实现权利要求1至13或14中任一项所述的方法的步骤。
PCT/CN2022/110998 2021-09-15 2022-08-09 图像异常检测模型训练方法、图像异常检测方法和装置 WO2023040510A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/141,011 US20230267730A1 (en) 2021-09-15 2023-04-28 Image abnormality detection model training

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111079651.0A CN114332578A (zh) 2021-09-15 2021-09-15 图像异常检测模型训练方法、图像异常检测方法和装置
CN202111079651.0 2021-09-15

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/141,011 Continuation US20230267730A1 (en) 2021-09-15 2023-04-28 Image abnormality detection model training

Publications (1)

Publication Number Publication Date
WO2023040510A1 true WO2023040510A1 (zh) 2023-03-23

Family

ID=81044893

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/110998 WO2023040510A1 (zh) 2021-09-15 2022-08-09 图像异常检测模型训练方法、图像异常检测方法和装置

Country Status (3)

Country Link
US (1) US20230267730A1 (zh)
CN (1) CN114332578A (zh)
WO (1) WO2023040510A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116993963A (zh) * 2023-09-21 2023-11-03 腾讯科技(深圳)有限公司 一种图像处理方法、装置、设备及存储介质

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114332578A (zh) * 2021-09-15 2022-04-12 广州腾讯科技有限公司 图像异常检测模型训练方法、图像异常检测方法和装置
CN115222738B (zh) * 2022-09-20 2022-12-09 合肥中科类脑智能技术有限公司 一种基于特征迁移的在线学习异常检测方法及系统
CN117148814B (zh) * 2023-07-25 2024-04-16 湖北仕上电子科技有限公司 真空镀膜设备壁板清洗控制系统的异常报警方法及系统
CN116824305A (zh) * 2023-08-09 2023-09-29 中国气象服务协会 应用于云计算的生态环境监测数据处理方法及系统
CN117710763A (zh) * 2023-11-23 2024-03-15 广州航海学院 图像噪声识别模型训练方法、图像噪声识别方法及装置
CN117409326B (zh) * 2023-12-13 2024-04-19 山东锋士信息技术有限公司 基于自适应加权损失和对抗干扰器的遥感异常检测方法
CN117523213B (zh) * 2024-01-04 2024-03-29 南京航空航天大学 一种基于元去噪和负学习的噪声标签识别方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110163234A (zh) * 2018-10-10 2019-08-23 腾讯科技(深圳)有限公司 一种模型训练方法、装置和存储介质
CN111598881A (zh) * 2020-05-19 2020-08-28 西安电子科技大学 基于变分自编码器的图像异常检测方法
CN112766244A (zh) * 2021-04-07 2021-05-07 腾讯科技(深圳)有限公司 目标对象检测方法、装置、计算机设备和存储介质
CN114332578A (zh) * 2021-09-15 2022-04-12 广州腾讯科技有限公司 图像异常检测模型训练方法、图像异常检测方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110163234A (zh) * 2018-10-10 2019-08-23 腾讯科技(深圳)有限公司 一种模型训练方法、装置和存储介质
CN111598881A (zh) * 2020-05-19 2020-08-28 西安电子科技大学 基于变分自编码器的图像异常检测方法
CN112766244A (zh) * 2021-04-07 2021-05-07 腾讯科技(深圳)有限公司 目标对象检测方法、装置、计算机设备和存储介质
CN114332578A (zh) * 2021-09-15 2022-04-12 广州腾讯科技有限公司 图像异常检测模型训练方法、图像异常检测方法和装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116993963A (zh) * 2023-09-21 2023-11-03 腾讯科技(深圳)有限公司 一种图像处理方法、装置、设备及存储介质
CN116993963B (zh) * 2023-09-21 2024-01-05 腾讯科技(深圳)有限公司 一种图像处理方法、装置、设备及存储介质

Also Published As

Publication number Publication date
US20230267730A1 (en) 2023-08-24
CN114332578A (zh) 2022-04-12

Similar Documents

Publication Publication Date Title
WO2023040510A1 (zh) 图像异常检测模型训练方法、图像异常检测方法和装置
CN109816589B (zh) 用于生成漫画风格转换模型的方法和装置
CN108229479B (zh) 语义分割模型的训练方法和装置、电子设备、存储介质
US20220012533A1 (en) Object Recognition Method and Apparatus
WO2022142009A1 (zh) 一种模糊图像修正的方法、装置、计算机设备及存储介质
CN110929780A (zh) 视频分类模型构建、视频分类的方法、装置、设备及介质
CN115082920B (zh) 深度学习模型的训练方法、图像处理方法和装置
CN113361710B (zh) 学生模型训练方法、图片处理方法、装置及电子设备
EP4068160A1 (en) Neural network training and face detection method and apparatus, and device and storage medium
CN114511041B (zh) 模型训练方法、图像处理方法、装置、设备和存储介质
CN115861462B (zh) 图像生成模型的训练方法、装置、电子设备及存储介质
CN115147680B (zh) 目标检测模型的预训练方法、装置以及设备
CN114882321A (zh) 深度学习模型的训练方法、目标对象检测方法和装置
CN116977674A (zh) 图像匹配方法、相关设备、存储介质及程序产品
WO2019234156A1 (en) Training spectral inference neural networks using bilevel optimization
CN117456236A (zh) 一种3d点云数据零样本分类方法、装置、设备及存储介质
CN114758130B (zh) 图像处理及模型训练方法、装置、设备和存储介质
CN114120423A (zh) 人脸图像检测方法、装置、电子设备和计算机可读介质
CN111680754B (zh) 图像分类方法、装置、电子设备及计算机可读存储介质
CN114820558A (zh) 汽车零件检测方法、装置、电子设备和计算机可读介质
WO2021217653A1 (zh) 视频插帧方法及装置、计算机可读存储介质
CN114241411A (zh) 基于目标检测的计数模型处理方法、装置及计算机设备
CN113139540A (zh) 背板检测方法及设备
CN115861684B (zh) 图像分类模型的训练方法、图像分类方法及装置
CN114844889B (zh) 视频处理模型的更新方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22868887

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE