WO2023184918A1 - Image anomaly detection method, apparatus and system, and readable storage medium - Google Patents

Image anomaly detection method, apparatus and system, and readable storage medium Download PDF

Info

Publication number
WO2023184918A1
WO2023184918A1 PCT/CN2022/123403 CN2022123403W WO2023184918A1 WO 2023184918 A1 WO2023184918 A1 WO 2023184918A1 CN 2022123403 W CN2022123403 W CN 2022123403W WO 2023184918 A1 WO2023184918 A1 WO 2023184918A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
sample
anomaly detection
abnormal
samples
Prior art date
Application number
PCT/CN2022/123403
Other languages
French (fr)
Chinese (zh)
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 WO2023184918A1 publication Critical patent/WO2023184918A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning

Definitions

  • the present application relates to the field of image technology, and in particular to an image anomaly detection method, device, system and non-volatile readable storage medium.
  • Anomaly detection in the image field refers to identifying images that may contain abnormalities relative to normal images.
  • Anomaly detection tasks generally assume that normal images have a large amount of data, while abnormal data have a small amount of data. It is impossible to collect enough abnormal data to carry out supervised learning to distinguish the two. Therefore, anomaly detection is often considered to comply with the single-class learning hypothesis, that is, the detection of abnormal samples is achieved only by learning from normal samples.
  • Anomaly detection is widely used in practice. For example, the analysis of surveillance videos in highway scenarios is a very potential application scenario. The amount of surveillance video data in highway scenarios is very large, and there are various potential abnormal behaviors.
  • the purpose of the embodiments of the present application is to provide an image anomaly detection method, device, system and non-volatile readable storage medium, which can improve the accuracy of image anomaly detection during use.
  • an image anomaly detection method including:
  • the image to be detected is an abnormal image;
  • the image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on original abnormal samples and original normal samples.
  • the pre-established image anomaly detection model is used to detect the image to be detected, and the anomaly score obtained includes:
  • the image anomaly detection model is obtained by training based on the sample set.
  • the created sample set includes:
  • the sample set is established based on the original normal samples, the original abnormal samples and the simulated abnormal samples.
  • the simulated abnormal samples in the sample set are obtained based on the original abnormal samples and the original normal samples, including:
  • pasting the first copied image and the second copied image onto the target original normal sample to obtain a simulated abnormal sample includes:
  • the preset area is an area centered on the center point of the target original normal sample;
  • the first replicated image and the second replicated image are respectively scaled to obtain simulated abnormal samples.
  • the shape of the preset area is any one of the following shape areas:
  • scaling the first copied image and the second copied image respectively includes:
  • the copied image and the second copied image are respectively randomly deformed and scaled according to different aspect ratios.
  • selecting the target original abnormal sample from each original abnormal sample, and selecting the target original normal sample from each original normal sample includes:
  • the target original abnormal sample is randomly selected from each original abnormal sample, and the target original normal sample is randomly selected from each original normal sample.
  • the image anomaly detection model is trained based on a pre-established sample set and includes:
  • An image anomaly detection model is constructed based on the feature extraction network of the optimal weight parameters and the classifier of the optimal parameters.
  • the classifier is a KDE classifier.
  • the feature extraction network is trained using a pre-established sample set, and the optimal weight parameters of the feature extraction network include:
  • the first enhanced sample is processed through the first feature extraction network to obtain the first encoding vector corresponding to the first enhanced sample
  • the second enhanced sample is processed through the second feature extraction network to obtain the first encoding vector corresponding to the first enhanced sample.
  • the second encoding vector corresponding to the second enhanced sample; the first feature extraction network and the second feature extraction network are the same;
  • first projection network to process the first encoding vector to obtain a first projection vector
  • second projection network to process the second encoding vector to obtain a second projection vector
  • the method ends, and the optimal weight parameters of the first feature extraction network and the second feature extraction network are obtained.
  • the contrast loss is calculated through the following formula (1):
  • the method further includes:
  • the weight parameters of the first feature extraction network and the second feature extraction network are updated, and the next round of training is entered.
  • the image to be detected is an abnormal image, including:
  • the image to be detected is determined to be an abnormal image.
  • the pre-established image anomaly detection model is used to detect the image to be detected and the anomaly score is obtained, it also includes:
  • the image to be detected is determined to be a normal image.
  • An embodiment of the present application also provides an image anomaly detection device, including:
  • the detection module is used to detect the image to be detected using a pre-established image anomaly detection model and obtain an anomaly score
  • An analysis module configured to determine that the image to be detected is an abnormal image when the abnormality score satisfies a preset condition;
  • the image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on original abnormal samples and original normal samples.
  • Embodiments of the present application also provide an image anomaly detection system, including:
  • Memory used to store computer programs
  • a processor configured to implement the steps of the above-mentioned image anomaly detection method when executing the computer program.
  • Embodiments of the present application also provide a non-volatile readable storage medium.
  • a computer program is stored on the non-volatile readable storage medium.
  • the computer program is executed by a processor, the above-mentioned image abnormality is realized. Steps of the detection method.
  • An embodiment of the present application also provides a computing processing device, including:
  • a memory having computer readable code stored therein;
  • One or more processors when the computer readable code is executed by the one or more processors, the computing processing device performs the steps of the image anomaly detection method described above.
  • Embodiments of the present application also provide a computer program product, which includes computer readable code.
  • the computer readable code When the computer readable code is run on a computing processing device, it causes the computing processing device to execute the above-mentioned image anomaly detection method. step.
  • Embodiments of the present application provide an image anomaly detection method, device, system and non-volatile readable storage medium.
  • the method includes: using a pre-established image anomaly detection model to detect the image to be detected, and obtaining an anomaly score; When the anomaly score meets the preset conditions, the image to be detected is an abnormal image; where: the image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on the original abnormal samples and the original normal samples. of.
  • simulated abnormal samples are obtained based on original abnormal samples and original normal samples, and the image anomaly detection model is trained based on the sample set including simulated abnormal samples, original normal samples and original abnormal samples, which improves the accuracy of the image anomaly detection model.
  • the image anomaly detection model uses the image anomaly detection model to detect the image to be detected, obtain the anomaly score, and when the anomaly score meets the preset conditions, determine that the image to be detected is an abnormal image, thereby realizing image anomaly detection; during the use of this application It can improve the accuracy of image anomaly detection.
  • Figure 1 is a schematic flow chart of an image anomaly detection method provided by an embodiment of the present application.
  • Figure 2 is a schematic diagram of a simulated abnormal sample acquisition process provided by an embodiment of the present application.
  • Figure 3 is a schematic diagram of an abnormal score acquisition process provided by an embodiment of the present application.
  • Figure 4 is a schematic diagram of a comparative loss acquisition process provided by an embodiment of the present application.
  • Figure 5 is a schematic structural diagram of an image anomaly detection device provided by an embodiment of the present application.
  • Figure 6 schematically illustrates a block diagram of a computing processing device for performing a method according to the present application.
  • Figure 7 schematically shows a storage unit for holding or carrying program code for implementing the method according to the present application.
  • Embodiments of the present application provide an image anomaly detection method, device, system and computer-readable storage medium, which can improve image anomaly detection accuracy during use.
  • FIG. 1 is a schematic flow chart of an image anomaly detection method provided by an embodiment of the present application.
  • the method includes:
  • S110 Use the pre-established image anomaly detection model to detect the image to be detected and obtain an anomaly score
  • a sample set can be established first, and then the image anomaly detection model can be trained based on the sample set.
  • the amount of surveillance video data in the highway scene is very large, the probability of abnormal occurrence is small, and the differences between various abnormal behaviors are large and the probability of occurrence is different, which makes it impossible to collect reasonable data sets. Therefore, simulated abnormal samples can be constructed to Increase the number of abnormal samples in the sample set.
  • the simulated abnormal samples in the sample set in the embodiment of the present application are obtained based on the original abnormal samples and the original normal samples.
  • massive monitoring videos can be collected in advance and extracted by video frames. Convert the surveillance video into an image, and label the image as normal/abnormal according to the frame rate, that is, label each image with a category.
  • the image to be detected is collected, and the image anomaly detection model is used to detect anomalies in the image to be detected, and the anomaly score is obtained.
  • the image to be detected is determined to be an abnormal image.
  • a threshold can be set in advance. When the anomaly score is less than or equal to the threshold, the image to be detected can be determined to be a normal image. When the anomaly score is greater than the threshold, the image to be detected can be determined to be an abnormal image.
  • the simulated abnormal samples in the above sample set are obtained based on the original abnormal samples and the original normal samples, and may specifically include:
  • the target original abnormal sample can be randomly selected from each original abnormal sample, and the target original normal sample can also be randomly selected from each original normal sample, such as the target original abnormal sample in Figure 2
  • the target original normal sample is B
  • (randomly) select a target area specifically, it can be a rectangular area) from the target original abnormal sample, copy the target area, obtain the first copied image a
  • the first copied image and the second copied image are pasted onto the target original normal sample to obtain the process of simulating the abnormal sample, which may include:
  • the preset area is an area centered on the center point of the target original normal sample;
  • the first replicated image and the second replicated image are respectively scaled to obtain simulated abnormal samples.
  • a preset area (border c in Figure 2) can be selected in advance from the target original normal sample.
  • the preset area can be centered on the center point of the target original normal sample.
  • the shape of the preset area can be a circular area or a rectangular area, and the first copied image and the second copied image are pasted to the preset area on the target original normal sample, and then the two pasted
  • the images are scaled accordingly.
  • random deformation and scaling of different length-to-width ratios can be performed. For example, deformation and scaling can be randomly performed according to ratios of 1:2, 1:3, or 1:4. After the scaling is completed, the deformed and scaled images a are obtained. ' and b', thereby obtaining the final simulated anomaly sample.
  • the above image anomaly detection model is trained based on a pre-established sample set, which may include:
  • the classifier is trained using each original normal sample in the sample set and the feature extraction network based on the optimal weight parameters to obtain the optimal parameters of the classifier;
  • An image anomaly detection model is constructed based on the feature extraction network with optimal weight parameters and the classifier with optimal parameters.
  • the above-mentioned pre-established sample sets can be used to train the feature extraction network to obtain the optimal weight parameters of the feature extraction network, and then the feature extraction network is fixed based on the optimal weight network parameters.
  • the feature extraction network is followed by a classifier, and then each original normal sample in the sample set is sequentially input to the feature extraction network with fixed weight parameters for feature extraction.
  • the output of the feature extraction network is used as the input of the classifier to obtain the anomaly score.
  • the parameters of the classifier are updated and the next round of training is entered.
  • the number of training times can be preset. When the number of training times is reached, the training is stopped and the optimal parameters of the classifier are obtained.
  • the feature extraction network with optimal weight parameters and the classifier with optimal parameters construct an image anomaly detection model.
  • the classifier in the embodiment of the present application can specifically be a KDE (kernel density estimation, kernel density estimation) classifier, where KDE is used to estimate unknown density functions in probability theory, and the output result of the KDE classifier can be used as the current The degree of difference between the sample and the kernel density.
  • KDE kernel density estimation, kernel density estimation
  • the image anomaly detection model in the embodiment of the present application finally outputs an anomaly score, and further determines whether the image to be detected is an abnormal image through the anomaly score and the preset threshold.
  • KDE is calculated as follows:
  • n the total number of normal samples
  • j the jth normal sample
  • x a specific distribution sample
  • x j the jth real sample point
  • K(.) the kernel function
  • h the bandwidth.
  • the Gaussian distribution probability density function can be selected as the kernel function.
  • the Gaussian distribution probability density function is as follows:
  • represents the standard deviation
  • e represents the natural logarithm
  • represents the expectation
  • the above-mentioned process of using a pre-established sample set to train the feature extraction network and obtain the optimal weight parameters of the feature extraction network may include:
  • the first enhanced sample is processed through the first feature extraction network to obtain the first encoding vector corresponding to the first enhanced sample
  • the second enhanced sample is processed through the second feature extraction network to obtain the third encoding vector corresponding to the second enhanced sample.
  • Two encoding vectors; the first feature extraction network and the second feature extraction network are the same;
  • the first projection network is used to process the first encoding vector to obtain the first projection vector
  • the second projection network is used to process the second encoding vector to obtain the second projection vector; the first projection network and the second projection network are the same;
  • the weight parameters of the first feature extraction network and the second feature extraction network are updated, and the next round of training is entered.
  • comparative SSL Self-supervised learning, self-supervised learning
  • SSL training is a special unsupervised learning method.
  • the agent task automatically generates labels for unlabeled images, thereby achieving feature learning for unlabeled data.
  • data enhancement processing is performed on each sample X to obtain the first enhanced sample v and the second enhanced sample v'.
  • the first enhanced sample v is input into the first feature extraction network f to obtain the first Encoding vector y
  • input the first encoding vector y into the first Projection processing is performed in the projection network g to obtain the first projection vector z
  • the second encoding vector y' is input to the second projection network g' for projection processing to obtain the second projection vector z' (where g and g' are completely Same)
  • a contrast loss is obtained for each sample.
  • the total contrast loss can be obtained based on each contrast loss.
  • the end condition can be that the number of training times reaches the preset number of training times, or the total contrast loss is less than the preset value.
  • x represents the distribution to which x and x + belong
  • x represents the sample
  • x + represents the data enhancement of sample x
  • p represents distribution
  • f(x) T represents the transposition after extracting features for x
  • f(x + ) represents extracting features for x +
  • i represents the sample label
  • N represents the total sample size.
  • simulated abnormal samples are obtained based on original abnormal samples and original normal samples, and the image anomaly detection model is trained based on the sample set including simulated abnormal samples, original normal samples and original abnormal samples, which improves the accuracy of the image anomaly detection model.
  • the image anomaly detection model uses the image anomaly detection model to detect the image to be detected, obtain the anomaly score, and when the anomaly score meets the preset conditions, determine that the image to be detected is an abnormal image, thereby realizing image anomaly detection; during the use of this application It can improve the accuracy of image anomaly detection.
  • inventions of the present application also provide an image anomaly detection device. Please refer to Figure 5.
  • the device includes:
  • the detection module 21 is used to detect the image to be detected using a pre-established image anomaly detection model and obtain an anomaly score;
  • the analysis module 22 is used to determine that the image to be detected is an abnormal image when the abnormality score meets the preset conditions; where:
  • the image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on the original abnormal samples and the original normal samples.
  • the image anomaly detection device provided in the embodiments of the present application has the same beneficial effects as the image anomaly detection method involved in the above embodiments, and is more effective for the image anomaly detection involved in the embodiments of the present application. Please refer to the above embodiments for specific introduction of the method, which will not be described again in this application.
  • embodiments of the present application also provide an image anomaly detection system, which includes:
  • Memory used to store computer programs
  • a processor is used to implement the steps of the above image anomaly detection method when executing a computer program.
  • the processor in the embodiment of the present application can be used to detect the image to be detected using a pre-established image anomaly detection model to obtain an abnormality score; when the abnormality score meets the preset conditions, the image to be detected is abnormal.
  • Image where: the image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on the original abnormal samples and the original normal samples.
  • embodiments of the present application also provide a non-volatile readable storage medium.
  • the non-volatile readable storage medium stores a computer program.
  • the computer program is executed by the processor, the above-mentioned implementation is implemented. Steps of image anomaly detection method.
  • the non-volatile readable storage medium can include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk, etc.
  • U disk mobile hard disk
  • read-only memory Read-Only Memory
  • RAM random access memory
  • magnetic disk or optical disk etc.
  • Various component embodiments of the present application may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof.
  • a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components in the computing processing device according to embodiments of the present application.
  • DSP digital signal processor
  • the present application may also be implemented as an apparatus or device program (eg, computer program and computer program product) for performing part or all of the methods described herein.
  • Such a program implementing the present application may be stored on a computer-readable medium, or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, or provided on a carrier signal, or in any other form.
  • Figure 6 shows a computing processing device that may implement methods according to the present application.
  • the computing processing device includes a processor 610 and a computer program product in the form of a memory 620 or a non-volatile readable storage medium.
  • Memory 620 may be electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • the memory 620 has a storage space 630 for program code 631 for executing any method steps in the above-described methods.
  • the storage space 630 for program codes may include individual program codes 631 respectively used to implement various steps in the above method. These program codes can be read from or written into one or more computer program products.
  • Such computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
  • Such a computer program product is typically a portable or fixed storage unit as described with reference to FIG. 7 .
  • the storage unit may have storage segments, storage spaces, etc. arranged similarly to the memory 620 in the computing processing device of FIG. 6 .
  • the program code may, for example, be compressed in a suitable form.
  • the storage unit includes computer readable code 631', ie code that can be read by, for example, a processor such as 610, which code, when executed by a computing processing device, causes the computing processing device to perform the methods described above. various steps.
  • RAM random access memory
  • ROM read-only memory
  • electrically programmable ROM electrically erasable programmable ROM
  • registers hard disks, removable disks, CD-ROMs, or anywhere in the field of technology. any other known form of storage media.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Analysis (AREA)

Abstract

Disclosed in the present application are an image anomaly detection method, apparatus and system, and a non-volatile readable storage medium, which are applied to the technical field of images. With regard to the problem of the accuracy of image anomaly detection being low, the method is provided, which comprises: by using a pre-established image anomaly detection model, detecting an image to be detected, so as to obtain an anomaly score; and said image being an anomalous image when the anomaly score meets a preset condition, wherein the image anomaly detection model is obtained by means of training on the basis of a pre-established sample set, and simulated anomalous samples in the sample set are obtained on the basis of an original anomalous sample and an original normal sample. Therefore, the present application can improve the accuracy of image anomaly detection during use.

Description

一种图像异常检测方法、装置、系统及可读存储介质An image anomaly detection method, device, system and readable storage medium
本申请要求于2022年03月31日提交中国专利局,申请号为202210331065.9,申请名称为“一种图像异常检测方法、装置、系统及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application submitted to the China Patent Office on March 31, 2022, with the application number 202210331065.9, and the application title is "an image anomaly detection method, device, system and readable storage medium", all of which The contents are incorporated into this application by reference.
技术领域Technical field
本申请涉及图像技术领域,特别是涉及一种图像异常检测方法、装置、系统及非易失性可读存储介质。The present application relates to the field of image technology, and in particular to an image anomaly detection method, device, system and non-volatile readable storage medium.
背景技术Background technique
异常检测在图像领域是指相对于正常的图像,识别出可能存在异常的图像。异常检测任务一般假设正常图像的数据量较大,而异常数据的数据量较小,无法收集足够的异常数据开展监督型学习区分二者。故异常检测常被认为符合单分类学习假设,即仅通过对正常样本的学习,实现对于异常样本的检测。异常检测在实际中的应用非常广泛,例如在高速公路场景下对监控视频的分析便是非常有潜力的一个应用场景,高速公路场景下的监控视频数据量非常巨大,潜在的异常行为多种多样,但是由于异常的发生概率较小,并且各种异常行为间差异较大并且发生概率不同,导致无法收集合理的数据集进行监督型学习,通过非监督,特别是自监督学习解决高速公路监控视频场景下的异常检测任务应用前景巨大。Anomaly detection in the image field refers to identifying images that may contain abnormalities relative to normal images. Anomaly detection tasks generally assume that normal images have a large amount of data, while abnormal data have a small amount of data. It is impossible to collect enough abnormal data to carry out supervised learning to distinguish the two. Therefore, anomaly detection is often considered to comply with the single-class learning hypothesis, that is, the detection of abnormal samples is achieved only by learning from normal samples. Anomaly detection is widely used in practice. For example, the analysis of surveillance videos in highway scenarios is a very potential application scenario. The amount of surveillance video data in highway scenarios is very large, and there are various potential abnormal behaviors. , however, due to the small probability of occurrence of anomalies and the large differences between various abnormal behaviors and the different occurrence probabilities, it is impossible to collect reasonable data sets for supervised learning. Solve the problem of highway surveillance video through unsupervised, especially self-supervised learning. The application prospects of anomaly detection tasks in scenarios are huge.
现有的基于自监督学习的异常检测方法通常通过对正常图像进行数据增强处理,得到模拟的异常图像的,但是这种方法一般仅能拉远增强样本与正常样本的相似度,无法很好的模拟异常样本,影响基于这些图像训练而成的检测模型识别的精确度。Existing anomaly detection methods based on self-supervised learning usually obtain simulated abnormal images by performing data enhancement on normal images. However, this method can only further enhance the similarity between samples and normal samples, and cannot achieve a good result. Simulating abnormal samples affects the recognition accuracy of the detection model trained based on these images.
发明内容Contents of the invention
本申请实施例的目的是提供一种图像异常检测方法、装置、系统及非易失性可读存储介质,在使用过程中能够提高图像异常检测精确度。The purpose of the embodiments of the present application is to provide an image anomaly detection method, device, system and non-volatile readable storage medium, which can improve the accuracy of image anomaly detection during use.
为解决上述技术问题,本申请实施例提供了一种图像异常检测方法,包括:In order to solve the above technical problems, embodiments of the present application provide an image anomaly detection method, including:
采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分;Use a pre-established image anomaly detection model to detect the image to be detected and obtain an anomaly score;
在所述异常得分满足预设条件的情况下,所述待检测图像为异常图像;其中:When the abnormality score meets the preset conditions, the image to be detected is an abnormal image; where:
所述图像异常检测模型为基于预先建立的样本集训练得到的,所述样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的。The image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on original abnormal samples and original normal samples.
可选的,在所述采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分包括:Optionally, the pre-established image anomaly detection model is used to detect the image to be detected, and the anomaly score obtained includes:
建立样本集;Create a sample set;
基于所述样本集训练得到所述图像异常检测模型。The image anomaly detection model is obtained by training based on the sample set.
可选的,所述建立样本集包括:Optionally, the created sample set includes:
获取预设数量的视频;Get a preset number of videos;
采用视频抽帧的方式将所述视频转换为图像;Convert the video into an image by extracting video frames;
根据帧率对所述图像进行类别标注,以得到原始正常样本和原始异常样本;Classify the image according to the frame rate to obtain original normal samples and original abnormal samples;
基于所述原始正常样本和所述原始异常样本构建模拟异常样本;Construct simulated abnormal samples based on the original normal samples and the original abnormal samples;
基于所述原始正常样本、所述原始异常样本和所述模拟异常样本,建立所述样本集。The sample set is established based on the original normal samples, the original abnormal samples and the simulated abnormal samples.
可选的,所述样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的包括:Optionally, the simulated abnormal samples in the sample set are obtained based on the original abnormal samples and the original normal samples, including:
从各个原始异常样本中选取出目标原始异常样本,从各个原始正常样本中选取出目标原始正常样本;Select the target original abnormal sample from each original abnormal sample, and select the target original normal sample from each original normal sample;
获取与所述目标原始异常样本中的目标区域对应的第一复制图像,以及与所述目标原始正常样本中的目标区域对应的第二复制图像;Obtaining a first replica image corresponding to the target area in the target original abnormal sample, and a second replica image corresponding to the target area in the target original normal sample;
将所述第一复制图像和所述第二复制图像粘贴至所述目标原始正常样本上,得到模拟异常样本。Paste the first copied image and the second copied image onto the target original normal sample to obtain a simulated abnormal sample.
可选的,所述将所述第一复制图像和所述第二复制图像粘贴至所述目标原始正常样本上,得到模拟异常样本,包括:Optionally, pasting the first copied image and the second copied image onto the target original normal sample to obtain a simulated abnormal sample includes:
将所述第一复制图像和所述第二复制图像粘贴至所述目标原始正常样本上的预设区域处;所述预设区域为以所述目标原始正常样本中心点为中心的区域;Paste the first copied image and the second copied image to a preset area on the target original normal sample; the preset area is an area centered on the center point of the target original normal sample;
将所述第一复制图像和所述第二复制图像分别进行缩放,以得到模拟异常样本。The first replicated image and the second replicated image are respectively scaled to obtain simulated abnormal samples.
可选的,所述预设区域的形状为以下形状区域中的任意一种:Optionally, the shape of the preset area is any one of the following shape areas:
圆形区域和矩形区域。circular area and rectangular area.
可选的,所述将所述第一复制图像和所述第二复制图像分别进行缩放,包括:Optionally, scaling the first copied image and the second copied image respectively includes:
根据不同的长宽比例将所述复制图像和所述第二复制图像分别进行随机变形缩放。The copied image and the second copied image are respectively randomly deformed and scaled according to different aspect ratios.
可选的,所述从各个原始异常样本中选取出目标原始异常样本,从各个原始正常样本中选取出目标原始正常样本包括:Optionally, selecting the target original abnormal sample from each original abnormal sample, and selecting the target original normal sample from each original normal sample includes:
随机从各个原始异常样本中选取出目标原始异常样本,随机从各个原始正常样本中选取出目标原始正常样本。The target original abnormal sample is randomly selected from each original abnormal sample, and the target original normal sample is randomly selected from each original normal sample.
可选的,所述图像异常检测模型为基于预先建立的样本集训练得到的包括:Optionally, the image anomaly detection model is trained based on a pre-established sample set and includes:
采用预先建立的样本集对特征提取网络进行训练,得到所述特征提取网络 的最优权重参数;Use a pre-established sample set to train the feature extraction network to obtain the optimal weight parameters of the feature extraction network;
采用所述样本集中的各个原始正常样本以及基于所述最优权重参数的特征提取网络对分类器进行训练,得到所述分类器的最优参数;Using each original normal sample in the sample set and the feature extraction network based on the optimal weight parameters to train the classifier to obtain the optimal parameters of the classifier;
基于所述最优权重参数的特征提取网络及所述最优参数的分类器构建图像异常检测模型。An image anomaly detection model is constructed based on the feature extraction network of the optimal weight parameters and the classifier of the optimal parameters.
可选的,所述分类器为KDE分类器。Optionally, the classifier is a KDE classifier.
可选的,所述采用预先建立的样本集对特征提取网络进行训练,得到所述特征提取网络的最优权重参数包括:Optionally, the feature extraction network is trained using a pre-established sample set, and the optimal weight parameters of the feature extraction network include:
针对所述样本集中的每个样本,对所述样本进行数据增强处理,得到第一增强样本和第二增强样本;For each sample in the sample set, perform data enhancement processing on the sample to obtain a first enhanced sample and a second enhanced sample;
通过第一特征提取网络对所述第一增强样本进行处理,得到与所述第一增强样本对应的第一编码向量,通过第二特征提取网络对所述第二增强样本进行处理,得到与所述第二增强样本对应的第二编码向量;所述第一特征提取网络和所述第二特征提取网络相同;The first enhanced sample is processed through the first feature extraction network to obtain the first encoding vector corresponding to the first enhanced sample, and the second enhanced sample is processed through the second feature extraction network to obtain the first encoding vector corresponding to the first enhanced sample. The second encoding vector corresponding to the second enhanced sample; the first feature extraction network and the second feature extraction network are the same;
采用第一投影网络对所述第一编码向量进行处理,得到第一投影向量,采用第二投影网络对所述第二编码向量进行处理,得到第二投影向量;所述第一投影网络和所述第二投影网络相同;Using a first projection network to process the first encoding vector to obtain a first projection vector, using a second projection network to process the second encoding vector to obtain a second projection vector; the first projection network and the The second projection network is the same;
计算所述第一投影向量和所述第二投影向量的对比损失;Calculate the contrast loss of the first projection vector and the second projection vector;
根据与每个样本对应的对比损失,计算出总对比损失;Based on the contrast loss corresponding to each sample, the total contrast loss is calculated;
判断所述总对比损失是否满足结束条件;Determine whether the total comparative loss meets the ending condition;
响应于所述总对比损失满足结束条件,结束,并得到所述第一特征提取网络和所述第二特征提取网络的最优权重参数。In response to the total contrast loss satisfying the end condition, the method ends, and the optimal weight parameters of the first feature extraction network and the second feature extraction network are obtained.
可选的,通过下述公式(1)计算得到所述对比损失:Optionally, the contrast loss is calculated through the following formula (1):
Figure PCTCN2022123403-appb-000001
Figure PCTCN2022123403-appb-000001
上述公式(1)中,
Figure PCTCN2022123403-appb-000002
表示x和x +所属分布,x表示样本,x +表示样本x的数据增强,
Figure PCTCN2022123403-appb-000003
表示负样本的数据增强,p表示分布,f(x) T表示对x提取特征后的转置,f(x +)表示对x +提取特征,
Figure PCTCN2022123403-appb-000004
表示对
Figure PCTCN2022123403-appb-000005
提取特征,i表示样本标号,N表示总样本量。
In the above formula (1),
Figure PCTCN2022123403-appb-000002
represents the distribution to which x and x + belong, x represents the sample, x + represents the data enhancement of sample x,
Figure PCTCN2022123403-appb-000003
Represents the data enhancement of negative samples, p represents distribution, f(x) T represents the transposition after extracting features for x, f(x + ) represents extracting features for x + ,
Figure PCTCN2022123403-appb-000004
expresses right
Figure PCTCN2022123403-appb-000005
Extract features, i represents the sample label, and N represents the total sample size.
可选地,在所述判断所述总对比损失是否满足结束条件之后,还包括:Optionally, after determining whether the total contrast loss meets the end condition, the method further includes:
响应于所述总对比损失不满足结束条件,对所述第一特征提取网络和所述第二特征提取网络的权重参数进行更新,并进入下一轮训练。In response to the total contrast loss not meeting the end condition, the weight parameters of the first feature extraction network and the second feature extraction network are updated, and the next round of training is entered.
可选的,所述在所述异常得分满足预设条件的情况下,所述待检测图像为异常图像,包括:Optionally, when the anomaly score meets a preset condition, the image to be detected is an abnormal image, including:
在所述异常得分大于预先设置的阈值的情况下,判定所述待检测图像为异常图像。When the abnormality score is greater than a preset threshold, the image to be detected is determined to be an abnormal image.
可选的,在所述采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分之后,还包括:Optionally, after the pre-established image anomaly detection model is used to detect the image to be detected and the anomaly score is obtained, it also includes:
在所述异常得分小于等于所述阈值的情况下,判定所述待检测图像为正常图像。When the abnormality score is less than or equal to the threshold, the image to be detected is determined to be a normal image.
本申请实施例还提供了一种图像异常检测装置,包括:An embodiment of the present application also provides an image anomaly detection device, including:
检测模块,用于采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分;The detection module is used to detect the image to be detected using a pre-established image anomaly detection model and obtain an anomaly score;
分析模块,用于在所述异常得分满足预设条件的情况下,所述待检测图像为异常图像;其中:An analysis module configured to determine that the image to be detected is an abnormal image when the abnormality score satisfies a preset condition; wherein:
所述图像异常检测模型为基于预先建立的样本集训练得到的,所述样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的。The image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on original abnormal samples and original normal samples.
本申请实施例还提供了一种图像异常检测系统,包括:Embodiments of the present application also provide an image anomaly detection system, including:
存储器,用于存储计算机程序;Memory, used to store computer programs;
处理器,用于执行所述计算机程序时实现如上述所述图像异常检测方法的 步骤。A processor, configured to implement the steps of the above-mentioned image anomaly detection method when executing the computer program.
本申请实施例还提供了一种非易失性可读存储介质,所述非易失性可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述所述图像异常检测方法的步骤。Embodiments of the present application also provide a non-volatile readable storage medium. A computer program is stored on the non-volatile readable storage medium. When the computer program is executed by a processor, the above-mentioned image abnormality is realized. Steps of the detection method.
本申请实施例还提供了一种计算处理设备,包括:An embodiment of the present application also provides a computing processing device, including:
存储器,其中存储有计算机可读代码;A memory having computer readable code stored therein;
一个或多个处理器,当所述计算机可读代码被所述一个或多个处理器执行时,所述计算处理设备执行上述所述的图像异常检测方法的步骤。One or more processors, when the computer readable code is executed by the one or more processors, the computing processing device performs the steps of the image anomaly detection method described above.
本申请实施例还提供了一种计算机程序产品,包括计算机可读代码,当所述计算机可读代码在计算处理设备上运行时,导致所述计算处理设备执行上述所述的图像异常检测方法的步骤。Embodiments of the present application also provide a computer program product, which includes computer readable code. When the computer readable code is run on a computing processing device, it causes the computing processing device to execute the above-mentioned image anomaly detection method. step.
本申请实施例提供了一种图像异常检测方法、装置、系统及非易失性可读存储介质,该方法包括:采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分;在异常得分满足预设条件的情况下,待检测图像为异常图像;其中:图像异常检测模型为基于预先建立的样本集训练得到的,样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的。Embodiments of the present application provide an image anomaly detection method, device, system and non-volatile readable storage medium. The method includes: using a pre-established image anomaly detection model to detect the image to be detected, and obtaining an anomaly score; When the anomaly score meets the preset conditions, the image to be detected is an abnormal image; where: the image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on the original abnormal samples and the original normal samples. of.
可见,本申请中基于原始异常样本与原始正常样本得到模拟异常样本,并基于包括模拟异常样本、原始正常样本和原始异常样本的样本集训练图像异常检测模型,提高了图像异常检测模型的精确度,然后采用该图像异常检测模型对待检测图像进行检测,得到异常得分,并且在异常得分满足预设条件的情况下,确定出待检测图像为异常图像,从而实现图像异常检测;本申请在使用过程中能够提高图像异常检测精确度。It can be seen that in this application, simulated abnormal samples are obtained based on original abnormal samples and original normal samples, and the image anomaly detection model is trained based on the sample set including simulated abnormal samples, original normal samples and original abnormal samples, which improves the accuracy of the image anomaly detection model. , and then use the image anomaly detection model to detect the image to be detected, obtain the anomaly score, and when the anomaly score meets the preset conditions, determine that the image to be detected is an abnormal image, thereby realizing image anomaly detection; during the use of this application It can improve the accuracy of image anomaly detection.
附图说明Description of drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对现有技术和实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是 本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the prior art and the drawings required to be used in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some of the drawings of the present application. Embodiments, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without exerting creative efforts.
图1为本申请实施例提供的一种图像异常检测方法的流程示意图;Figure 1 is a schematic flow chart of an image anomaly detection method provided by an embodiment of the present application;
图2为本申请实施例提供的一种模拟异常样本获取流程的示意图;Figure 2 is a schematic diagram of a simulated abnormal sample acquisition process provided by an embodiment of the present application;
图3为本申请实施例提供的一种异常分数获取流程的示意图;Figure 3 is a schematic diagram of an abnormal score acquisition process provided by an embodiment of the present application;
图4为本申请实施例提供的一种对比损失获取流程的示意图;Figure 4 is a schematic diagram of a comparative loss acquisition process provided by an embodiment of the present application;
图5为本申请实施例提供的一种图像异常检测装置的结构示意图;Figure 5 is a schematic structural diagram of an image anomaly detection device provided by an embodiment of the present application;
图6示意性地示出了用于执行根据本申请的方法的计算处理设备的框图;以及Figure 6 schematically illustrates a block diagram of a computing processing device for performing a method according to the present application; and
图7示意性地示出了用于保持或者携带实现根据本申请的方法的程序代码的存储单元。Figure 7 schematically shows a storage unit for holding or carrying program code for implementing the method according to the present application.
具体实施方式Detailed ways
本申请实施例提供了一种图像异常检测方法、装置、系统及计算机可读存储介质,在使用过程中能够提高图像异常检测精确度。Embodiments of the present application provide an image anomaly detection method, device, system and computer-readable storage medium, which can improve image anomaly detection accuracy during use.
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments These are part of the embodiments of this application, but not all of them. Based on the embodiments in this application, other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.
请参照图1,图1为本申请实施例提供的一种图像异常检测方法的流程示意图。该方法包括:Please refer to FIG. 1 , which is a schematic flow chart of an image anomaly detection method provided by an embodiment of the present application. The method includes:
S110:采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分;S110: Use the pre-established image anomaly detection model to detect the image to be detected and obtain an anomaly score;
需要说明的是,本申请实施例中的可以先建立样本集,然后基于该样本集训练图像异常检测模型。在高速公路场景下的监控视频数据量非常巨大,异常 的发生概率较小,并且各种异常行为间差异较大并且发生概率不同,导致无法收集合理的数据集,因此可以构建模拟异常样本,从而提高样本集中异常样本数量。It should be noted that in the embodiment of the present application, a sample set can be established first, and then the image anomaly detection model can be trained based on the sample set. The amount of surveillance video data in the highway scene is very large, the probability of abnormal occurrence is small, and the differences between various abnormal behaviors are large and the probability of occurrence is different, which makes it impossible to collect reasonable data sets. Therefore, simulated abnormal samples can be constructed to Increase the number of abnormal samples in the sample set.
具体的,本申请实施例中的样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的,在实际应用中对于高速公路监控场景,可以预先收集海量监控视频,通过视频抽帧的方式将监控视频转换为图像,对图像根据帧率进行正常/异常标注,也即对每一张图像进行类别标注,具体可以添加类别标签,类别为正常或异常,从而得到各个原始正常样本和各个原始正常样本,然后再基于原始异常样本和原始正常样本构建模拟异常样本,从而得到由原始正常样本、原始异常样本和模拟异常样本构成的样本集,并基于该样本集训练图像异常检测模型。Specifically, the simulated abnormal samples in the sample set in the embodiment of the present application are obtained based on the original abnormal samples and the original normal samples. In practical applications, for highway monitoring scenarios, massive monitoring videos can be collected in advance and extracted by video frames. Convert the surveillance video into an image, and label the image as normal/abnormal according to the frame rate, that is, label each image with a category. Specifically, you can add a category label, and the category is normal or abnormal, so as to obtain each original normal sample and each original normal samples, and then construct simulated abnormal samples based on the original abnormal samples and original normal samples, thereby obtaining a sample set composed of original normal samples, original abnormal samples and simulated abnormal samples, and train the image anomaly detection model based on this sample set.
在实际应用中,采集待检测图像,并采用该图像异常检测模型对待检测图像进行异常检测,得到异常得分。In practical applications, the image to be detected is collected, and the image anomaly detection model is used to detect anomalies in the image to be detected, and the anomaly score is obtained.
S120:在异常得分满足预设条件的情况下,待检测图像为异常图像。S120: When the abnormality score meets the preset conditions, the image to be detected is an abnormal image.
具体的,本申请实施例中具体可以根据异常得到进一步判断是否满足预设条件,在满足的情况下,确定出待检测图像为异常图像。例如,可以预先设置阈值,在异常得分小于等于阈值的情况下可以判定出待检测图像为正常图像,在异常得分大于阈值的情况下可以判定出待检测图像为异常图像。Specifically, in the embodiment of the present application, it can be further determined whether the preset conditions are met based on the abnormality. If the preset conditions are met, the image to be detected is determined to be an abnormal image. For example, a threshold can be set in advance. When the anomaly score is less than or equal to the threshold, the image to be detected can be determined to be a normal image. When the anomaly score is greater than the threshold, the image to be detected can be determined to be an abnormal image.
进一步的,上述样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的,具体可以包括:Furthermore, the simulated abnormal samples in the above sample set are obtained based on the original abnormal samples and the original normal samples, and may specifically include:
从各个原始异常样本中选取出目标原始异常样本,从各个原始正常样本中选取出目标原始正常样本;Select the target original abnormal sample from each original abnormal sample, and select the target original normal sample from each original normal sample;
获取与目标原始异常样本中的目标区域对应的第一复制图像,以及与目标原始正常样本中的目标区域对应的第二复制图像;Obtaining a first replica image corresponding to the target area in the target original abnormal sample, and a second replica image corresponding to the target area in the target original normal sample;
将第一复制图像和第二复制图像粘贴至目标原始正常样本上,得到模拟异常样本。Paste the first copied image and the second copied image onto the target original normal sample to obtain a simulated abnormal sample.
可以理解的是,本申请实施例中具体可以从各个原始异常样本中随机选取出目标原始异常样本,从各个原始正常样本中也随机选取出目标原始正常样本,例如图2中的目标原始异常样本为A和目标原始正常样本为B,从目标原始异常样本上(随机)选择一个目标区域(具体可以为矩形区域),对该目标区域进行复制,得到第一复制图像a,然后从目标原始正常样本上(随机)选择一个目标区域,并对该目标区域进行复制,得到第二复制图像b,将该第一复制图像a和第二复制图像b均粘贴至目标原始正常样本上,从而得到模拟异常样本。It can be understood that in the embodiment of the present application, the target original abnormal sample can be randomly selected from each original abnormal sample, and the target original normal sample can also be randomly selected from each original normal sample, such as the target original abnormal sample in Figure 2 For A and the target original normal sample is B, (randomly) select a target area (specifically, it can be a rectangular area) from the target original abnormal sample, copy the target area, obtain the first copied image a, and then select the target original normal sample from (Randomly) select a target area on the sample and copy the target area to obtain the second copy image b. Paste both the first copy image a and the second copy image b onto the target original normal sample to obtain the simulation Abnormal samples.
更进一步的,将第一复制图像和第二复制图像粘贴至目标原始正常样本上,得到模拟异常样本的过程,具体可以包括:Furthermore, the first copied image and the second copied image are pasted onto the target original normal sample to obtain the process of simulating the abnormal sample, which may include:
将第一复制图像和第二复制图像粘贴至目标原始正常样本上的预设区域处;预设区域为以目标原始正常样本中心点为中心的区域;Paste the first copied image and the second copied image to a preset area on the target original normal sample; the preset area is an area centered on the center point of the target original normal sample;
将第一复制图像和第二复制图像分别进行缩放,以得到模拟异常样本。The first replicated image and the second replicated image are respectively scaled to obtain simulated abnormal samples.
需要说明的是,本申请实施例中可以预先从目标原始正常样本上选择一个预设区域(如图2中的边框c),该预设区域具体可以为以目标原始正常样本中心点为中心的区域,该预设区域的形状具体可以为圆形区域或矩形区域,并且在将第一复制图像和第二复制图像粘贴至目标原始正常样本上的预设区域处,然后对粘贴后的两个图像分别进行相应的缩放,具体可以进行不同长宽比例的随机变形缩放,例如可以随机按照1:2、1:3或1:4等比例进行变形缩放,缩放完成后,分别得到变形缩放图像a’和b’,从而得到最终的模拟异常样本。It should be noted that in the embodiment of the present application, a preset area (border c in Figure 2) can be selected in advance from the target original normal sample. Specifically, the preset area can be centered on the center point of the target original normal sample. area, the shape of the preset area can be a circular area or a rectangular area, and the first copied image and the second copied image are pasted to the preset area on the target original normal sample, and then the two pasted The images are scaled accordingly. Specifically, random deformation and scaling of different length-to-width ratios can be performed. For example, deformation and scaling can be randomly performed according to ratios of 1:2, 1:3, or 1:4. After the scaling is completed, the deformed and scaled images a are obtained. ' and b', thereby obtaining the final simulated anomaly sample.
进一步的,上述图像异常检测模型为基于预先建立的样本集训练得到的,具体可以包括:Furthermore, the above image anomaly detection model is trained based on a pre-established sample set, which may include:
采用预先建立的样本集对特征提取网络进行训练,得到特征提取网络的最优权重参数;Use the pre-established sample set to train the feature extraction network and obtain the optimal weight parameters of the feature extraction network;
采用样本集中的各个原始正常样本以及基于最优权重参数的特征提取网络对分类器进行训练,得到分类器的最优参数;The classifier is trained using each original normal sample in the sample set and the feature extraction network based on the optimal weight parameters to obtain the optimal parameters of the classifier;
基于最优权重参数的特征提取网络及最优参数的分类器构建图像异常检测模型。An image anomaly detection model is constructed based on the feature extraction network with optimal weight parameters and the classifier with optimal parameters.
具体的,在实际应用中可以采用预先建立的上述样本集对特征提取网络进行训练,得到特征提取网络的最优权重参数,然后基于该最优权重网络参数将特征提取网络固定后,请参照图3,在特征提取网络后接分类器,然后采用样本集中的各个原始正常样本依次输入至固定权重参数后的特征提取网络进行特征提取,特征提取网络的输出作为分类器的输入,得到异常得分,当异常得分没有达到预设要求时,对分类器的参数进行更新,进入下一轮训练,具体可以预设训练次数,当达到训练次数后,停止训练,得到分类器的最优参数,从而基于最优权重参数的特征提取网络及最优参数的分类器构建图像异常检测模型。Specifically, in practical applications, the above-mentioned pre-established sample sets can be used to train the feature extraction network to obtain the optimal weight parameters of the feature extraction network, and then the feature extraction network is fixed based on the optimal weight network parameters. Please refer to the figure. 3. The feature extraction network is followed by a classifier, and then each original normal sample in the sample set is sequentially input to the feature extraction network with fixed weight parameters for feature extraction. The output of the feature extraction network is used as the input of the classifier to obtain the anomaly score. When the anomaly score does not meet the preset requirements, the parameters of the classifier are updated and the next round of training is entered. Specifically, the number of training times can be preset. When the number of training times is reached, the training is stopped and the optimal parameters of the classifier are obtained. The feature extraction network with optimal weight parameters and the classifier with optimal parameters construct an image anomaly detection model.
其中,本申请实施例中的分类器具体可以为KDE(kernel density estimation,核密度估计)分类器,其中,KDE是在概率论中用来估计未知的密度函数,KDE分类器输出结果可以作为当前样本与核密度的差异程度,差异越小,样本属于同一分布的,差异越大,样本属于不同分布。也即,本申请实施例中的图像异常检测模型最终输出的是异常得分,并通过异常得分与预设阈值进一步确定待检测图像是否为异常图像。Among them, the classifier in the embodiment of the present application can specifically be a KDE (kernel density estimation, kernel density estimation) classifier, where KDE is used to estimate unknown density functions in probability theory, and the output result of the KDE classifier can be used as the current The degree of difference between the sample and the kernel density. The smaller the difference, the samples belong to the same distribution. The larger the difference, the samples belong to different distributions. That is to say, the image anomaly detection model in the embodiment of the present application finally outputs an anomaly score, and further determines whether the image to be detected is an abnormal image through the anomaly score and the preset threshold.
其中,KDE的计算方式如下:Among them, KDE is calculated as follows:
Figure PCTCN2022123403-appb-000006
其中,
Figure PCTCN2022123403-appb-000007
表示总体的概率密度函数,n表示正常样本总数,j表示第j个正常样本,x表示特定分布样本,x j表示第j个真实样本点,K(.)表示核函数,h表示带宽。其中,具体可以选择高斯分布概率密度函数为核函数,高斯分布概率密度函数如下:
Figure PCTCN2022123403-appb-000006
in,
Figure PCTCN2022123403-appb-000007
Represents the overall probability density function, n represents the total number of normal samples, j represents the jth normal sample, x represents a specific distribution sample, x j represents the jth real sample point, K(.) represents the kernel function, and h represents the bandwidth. Among them, the Gaussian distribution probability density function can be selected as the kernel function. The Gaussian distribution probability density function is as follows:
Figure PCTCN2022123403-appb-000008
其中,σ表示标准差,e表示自然对数,μ表示期望。
Figure PCTCN2022123403-appb-000008
Among them, σ represents the standard deviation, e represents the natural logarithm, and μ represents the expectation.
进一步的,上述采用预先建立的样本集对特征提取网络进行训练,得到特 征提取网络的最优权重参数的过程,可以包括:Furthermore, the above-mentioned process of using a pre-established sample set to train the feature extraction network and obtain the optimal weight parameters of the feature extraction network may include:
针对样本集中的每个样本,对样本进行数据增强处理,得到第一增强样本和第二增强样本;For each sample in the sample set, perform data enhancement processing on the sample to obtain the first enhanced sample and the second enhanced sample;
通过第一特征提取网络对第一增强样本进行处理,得到与第一增强样本对应的第一编码向量,通过第二特征提取网络对第二增强样本进行处理,得到与第二增强样本对应的第二编码向量;第一特征提取网络和第二特征提取网络相同;The first enhanced sample is processed through the first feature extraction network to obtain the first encoding vector corresponding to the first enhanced sample, and the second enhanced sample is processed through the second feature extraction network to obtain the third encoding vector corresponding to the second enhanced sample. Two encoding vectors; the first feature extraction network and the second feature extraction network are the same;
采用第一投影网络对第一编码向量进行处理,得到第一投影向量,采用第二投影网络对第二编码向量进行处理,得到第二投影向量;第一投影网络和第二投影网络相同;The first projection network is used to process the first encoding vector to obtain the first projection vector, and the second projection network is used to process the second encoding vector to obtain the second projection vector; the first projection network and the second projection network are the same;
计算第一投影向量和第二投影向量的对比损失;Calculate the contrast loss between the first projection vector and the second projection vector;
根据与每个样本对应的对比损失,计算出总对比损失;Based on the contrast loss corresponding to each sample, the total contrast loss is calculated;
判断总对比损失是否满足结束条件;Determine whether the total comparative loss meets the ending conditions;
在总对比损失满足结束条件时,则结束,并得到第一特征提取网络和第二特征提取网络的最优权重参数;When the total contrast loss meets the end condition, it ends, and the optimal weight parameters of the first feature extraction network and the second feature extraction network are obtained;
在总对比损失不满足结束条件时,则对第一特征提取网络和第二特征提取网络的权重参数进行更新,并进入下一轮训练。When the total comparison loss does not meet the end condition, the weight parameters of the first feature extraction network and the second feature extraction network are updated, and the next round of training is entered.
需要说明的是,如图4所示,可以对样本集中的样本进行对比式SSL(Self-supervised learning,自监督学习)训练,其中,SSL训练为一种特殊的无监督学习方法,通过设定代理任务为无标注的图像人为自动生成标签,从而实现对于无标注数据的特征学习。具体的,本申请实施例中对每一个样本X进行数据增强处理,得到第一增强样本v和第二增强样本v’,将第一增强样本v输入至第一特征提取网络f中得到第一编码向量y,将第二增强样本v’输入至第二特征提取网络f’中,得到第二编码向量y’(其中,f和f’完全相同),将第一编码向量y输入至第一投影网络g中进行投影处理,得到第一投影向量z,将第二编码向量y’输入至第二投影网络g’中进行投影处理,得 到第二投影向量z’(其中,g和g’完全相同),并计算第一投影向量z和第二投影向量z’的对比损失,针对每个样本均得到一个对比损失,根据各个对比损失即可得到总对比损失,具体可以通过求平均等方法计算得出总对比损失,然后判断总对比损失是否满足结束条件,在满足时结束训练,将当前的权重参数作为特征提取网络的最优权重参数;若不满足结束条件,则对第一特征提取网络f和第二特征提取网络f’的权重参数进行更新,并进入下一轮训练,直至结束训练,确定出最优权重参数。其中,结束条件可以为训练次数达到预设训练次数,或总对比损失小于预设值。It should be noted that, as shown in Figure 4, comparative SSL (Self-supervised learning, self-supervised learning) training can be performed on the samples in the sample set. SSL training is a special unsupervised learning method. By setting The agent task automatically generates labels for unlabeled images, thereby achieving feature learning for unlabeled data. Specifically, in the embodiment of the present application, data enhancement processing is performed on each sample X to obtain the first enhanced sample v and the second enhanced sample v'. The first enhanced sample v is input into the first feature extraction network f to obtain the first Encoding vector y, input the second enhanced sample v' into the second feature extraction network f' to obtain the second encoding vector y' (where f and f' are exactly the same), input the first encoding vector y into the first Projection processing is performed in the projection network g to obtain the first projection vector z, and the second encoding vector y' is input to the second projection network g' for projection processing to obtain the second projection vector z' (where g and g' are completely Same), and calculate the contrast loss of the first projection vector z and the second projection vector z'. A contrast loss is obtained for each sample. The total contrast loss can be obtained based on each contrast loss. Specifically, it can be calculated by averaging and other methods. Obtain the total contrast loss, and then determine whether the total contrast loss meets the end condition. When it is satisfied, the training ends, and the current weight parameters are used as the optimal weight parameters of the feature extraction network; if the end condition is not met, the first feature extraction network The weight parameters of f and the second feature extraction network f' are updated, and the next round of training is entered until the training is completed and the optimal weight parameters are determined. Among them, the end condition can be that the number of training times reaches the preset number of training times, or the total contrast loss is less than the preset value.
还需要说明的是,本申请实施例中假设数据增强为a,则v=a(x),y=f(v),z=g(y)。其中,本申请实施例中的对比损失函数具体如下:It should also be noted that in the embodiment of the present application, it is assumed that the data enhancement is a, then v=a(x), y=f(v), z=g(y). Among them, the contrast loss function in the embodiment of this application is as follows:
Figure PCTCN2022123403-appb-000009
其中,
Figure PCTCN2022123403-appb-000010
表示x和x +所属分布,x表示样本,x +表示样本x的数据增强,
Figure PCTCN2022123403-appb-000011
表示负样本的数据增强,p表示分布,f(x) T表示对x提取特征后的转置,f(x +)表示对x +提取特征,
Figure PCTCN2022123403-appb-000012
表示对
Figure PCTCN2022123403-appb-000013
提取特征,i表示样本标号,N表示总样本量。
Figure PCTCN2022123403-appb-000009
in,
Figure PCTCN2022123403-appb-000010
represents the distribution to which x and x + belong, x represents the sample, x + represents the data enhancement of sample x,
Figure PCTCN2022123403-appb-000011
Represents the data enhancement of negative samples, p represents distribution, f(x) T represents the transposition after extracting features for x, f(x + ) represents extracting features for x + ,
Figure PCTCN2022123403-appb-000012
expresses right
Figure PCTCN2022123403-appb-000013
Extract features, i represents the sample label, and N represents the total sample size.
可见,本申请中基于原始异常样本与原始正常样本得到模拟异常样本,并基于包括模拟异常样本、原始正常样本和原始异常样本的样本集训练图像异常检测模型,提高了图像异常检测模型的精确度,然后采用该图像异常检测模型对待检测图像进行检测,得到异常得分,并且在异常得分满足预设条件的情况下,确定出待检测图像为异常图像,从而实现图像异常检测;本申请在使用过程中能够提高图像异常检测精确度。It can be seen that in this application, simulated abnormal samples are obtained based on original abnormal samples and original normal samples, and the image anomaly detection model is trained based on the sample set including simulated abnormal samples, original normal samples and original abnormal samples, which improves the accuracy of the image anomaly detection model. , and then use the image anomaly detection model to detect the image to be detected, obtain the anomaly score, and when the anomaly score meets the preset conditions, determine that the image to be detected is an abnormal image, thereby realizing image anomaly detection; during the use of this application It can improve the accuracy of image anomaly detection.
在上述实施例的基础上,本申请实施例还提供了一种图像异常检测装置,请参照图5,该装置包括:Based on the above embodiments, embodiments of the present application also provide an image anomaly detection device. Please refer to Figure 5. The device includes:
检测模块21,用于采用预先建立的图像异常检测模型对待检测图像进行检 测,得出异常得分;The detection module 21 is used to detect the image to be detected using a pre-established image anomaly detection model and obtain an anomaly score;
分析模块22,用于在异常得分满足预设条件的情况下,待检测图像为异常图像;其中:The analysis module 22 is used to determine that the image to be detected is an abnormal image when the abnormality score meets the preset conditions; where:
图像异常检测模型为基于预先建立的样本集训练得到的,样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的。The image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on the original abnormal samples and the original normal samples.
需要说明的是,本申请实施例中所提供的图像异常检测装置具有与上述实施例中所涉及到的图像异常检测方法相同的有益效果,并且对于本申请实施例中所涉及到的图像异常检测方法的具体介绍请参照上述实施例,本申请在此不再赘述。It should be noted that the image anomaly detection device provided in the embodiments of the present application has the same beneficial effects as the image anomaly detection method involved in the above embodiments, and is more effective for the image anomaly detection involved in the embodiments of the present application. Please refer to the above embodiments for specific introduction of the method, which will not be described again in this application.
在上述实施例的基础上,本申请实施例还提供了一种图像异常检测系统,该系统包括:Based on the above embodiments, embodiments of the present application also provide an image anomaly detection system, which includes:
存储器,用于存储计算机程序;Memory, used to store computer programs;
处理器,用于执行计算机程序时实现如上述图像异常检测方法的步骤。A processor is used to implement the steps of the above image anomaly detection method when executing a computer program.
例如,本申请实施例中的处理器具体可以用于实现采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分;在异常得分满足预设条件的情况下,待检测图像为异常图像;其中:图像异常检测模型为基于预先建立的样本集训练得到的,样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的。For example, the processor in the embodiment of the present application can be used to detect the image to be detected using a pre-established image anomaly detection model to obtain an abnormality score; when the abnormality score meets the preset conditions, the image to be detected is abnormal. Image; where: the image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on the original abnormal samples and the original normal samples.
在上述实施例的基础上,本申请实施例还提供了一种非易失性可读存储介质,非易失性可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现如上述图像异常检测方法的步骤。On the basis of the above embodiments, embodiments of the present application also provide a non-volatile readable storage medium. The non-volatile readable storage medium stores a computer program. When the computer program is executed by the processor, the above-mentioned implementation is implemented. Steps of image anomaly detection method.
该非易失性可读存储介质可以包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The non-volatile readable storage medium can include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk, etc. The medium on which program code is stored.
本申请的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器 上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本申请实施例的计算处理设备中的一些或者全部部件的一些或者全部功能。本申请还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本申请的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。Various component embodiments of the present application may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will understand that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components in the computing processing device according to embodiments of the present application. The present application may also be implemented as an apparatus or device program (eg, computer program and computer program product) for performing part or all of the methods described herein. Such a program implementing the present application may be stored on a computer-readable medium, or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, or provided on a carrier signal, or in any other form.
例如,图6示出了可以实现根据本申请的方法的计算处理设备。该计算处理设备上包括处理器610和以存储器620形式的计算机程序产品或者非易失性可读存储介质。存储器620可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器620具有用于执行上述方法中的任何方法步骤的程序代码631的存储空间630。例如,用于程序代码的存储空间630可以包括分别用于实现上面的方法中的各种步骤的各个程序代码631。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图7的便携式或者固定存储单元。该存储单元可以具有与图6的计算处理设备中的存储器620类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括计算机可读代码631’,即可以由例如诸如610之类的处理器读取的代码,这些代码当由计算处理设备运行时,导致该计算处理设备执行上面所描述的方法中的各个步骤。For example, Figure 6 shows a computing processing device that may implement methods according to the present application. The computing processing device includes a processor 610 and a computer program product in the form of a memory 620 or a non-volatile readable storage medium. Memory 620 may be electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM. The memory 620 has a storage space 630 for program code 631 for executing any method steps in the above-described methods. For example, the storage space 630 for program codes may include individual program codes 631 respectively used to implement various steps in the above method. These program codes can be read from or written into one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such a computer program product is typically a portable or fixed storage unit as described with reference to FIG. 7 . The storage unit may have storage segments, storage spaces, etc. arranged similarly to the memory 620 in the computing processing device of FIG. 6 . The program code may, for example, be compressed in a suitable form. Typically, the storage unit includes computer readable code 631', ie code that can be read by, for example, a processor such as 610, which code, when executed by a computing processing device, causes the computing processing device to perform the methods described above. various steps.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on its differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. As for the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple. For relevant details, please refer to the description in the method section.
还需要说明的是,在本说明书中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。It should also be noted that in this specification, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that these entities or operations There is no such actual relationship or sequence between operations. Furthermore, the terms "comprises," "comprises," or any other variations thereof are intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus that includes a list of elements includes not only those elements, but also those not expressly listed other elements, or elements inherent to the process, method, article or equipment. Without further limitation, an element qualified by the statement "comprises a..." does not exclude the presence of additional identical elements in the process, method, article, or device that includes the element.
专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those skilled in the art may further realize that the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. In order to clearly illustrate the possible functions of hardware and software, Interchangeability, in the above description, the composition and steps of each example have been generally described according to functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered beyond the scope of this application.
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其他形式的存储介质中。The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly in hardware, in software modules executed by a processor, or in a combination of both. Software modules may be located in random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or anywhere in the field of technology. any other known form of storage media.
对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其他实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be practiced in other embodiments without departing from the spirit or scope of the application. Therefore, the present application is not to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (20)

  1. 一种图像异常检测方法,其特征在于,包括:An image anomaly detection method, characterized by including:
    采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分;Use a pre-established image anomaly detection model to detect the image to be detected and obtain an anomaly score;
    在所述异常得分满足预设条件的情况下,所述待检测图像为异常图像;其中:When the abnormality score meets the preset conditions, the image to be detected is an abnormal image; where:
    所述图像异常检测模型为基于预先建立的样本集训练得到的,所述样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的。The image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on original abnormal samples and original normal samples.
  2. 根据权利要求1所述的图像异常检测方法,其特征在于,在所述采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分包括:The image anomaly detection method according to claim 1, wherein the step of using a pre-established image anomaly detection model to detect the image to be detected and obtaining the anomaly score includes:
    建立样本集;Create a sample set;
    基于所述样本集训练得到所述图像异常检测模型。The image anomaly detection model is obtained by training based on the sample set.
  3. 根据权利要求2所述的方法,其特征在于,所述建立样本集包括:The method according to claim 2, characterized in that establishing the sample set includes:
    获取预设数量的视频;Get a preset number of videos;
    采用视频抽帧的方式将所述视频转换为图像;Convert the video into an image by extracting video frames;
    根据帧率对所述图像进行类别标注,以得到原始正常样本和原始异常样本;Classify the image according to the frame rate to obtain original normal samples and original abnormal samples;
    基于所述原始正常样本和所述原始异常样本构建模拟异常样本;Construct simulated abnormal samples based on the original normal samples and the original abnormal samples;
    基于所述原始正常样本、所述原始异常样本和所述模拟异常样本,建立所述样本集。The sample set is established based on the original normal samples, the original abnormal samples and the simulated abnormal samples.
  4. 根据权利要求1所述的图像异常检测方法,其特征在于,所述样本集中的模拟异常样本为基于原始异常样本与原始正常样本得到的包括:The image anomaly detection method according to claim 1, characterized in that the simulated abnormal samples in the sample set are obtained based on original abnormal samples and original normal samples and include:
    从各个原始异常样本中选取出目标原始异常样本,从各个原始正常样本中选取出目标原始正常样本;Select the target original abnormal sample from each original abnormal sample, and select the target original normal sample from each original normal sample;
    获取与所述目标原始异常样本中的目标区域对应的第一复制图像,以及 与所述目标原始正常样本中的目标区域对应的第二复制图像;Obtain a first replica image corresponding to the target area in the target original abnormal sample, and a second replica image corresponding to the target area in the target original normal sample;
    将所述第一复制图像和所述第二复制图像粘贴至所述目标原始正常样本上,得到模拟异常样本。Paste the first copied image and the second copied image onto the target original normal sample to obtain a simulated abnormal sample.
  5. 根据权利要求4所述的图像异常检测方法,其特征在于,所述将所述第一复制图像和所述第二复制图像粘贴至所述目标原始正常样本上,得到模拟异常样本,包括:The image anomaly detection method according to claim 4, wherein pasting the first copied image and the second copied image onto the target original normal sample to obtain a simulated abnormal sample includes:
    将所述第一复制图像和所述第二复制图像粘贴至所述目标原始正常样本上的预设区域处;所述预设区域为以所述目标原始正常样本中心点为中心的区域;Paste the first copied image and the second copied image to a preset area on the target original normal sample; the preset area is an area centered on the center point of the target original normal sample;
    将所述第一复制图像和所述第二复制图像分别进行缩放,以得到模拟异常样本。The first replicated image and the second replicated image are respectively scaled to obtain simulated abnormal samples.
  6. 根据权利要求5所述的图像异常检测方法,其特征在于,所述预设区域的形状为以下形状区域中的任意一种:The image anomaly detection method according to claim 5, wherein the shape of the preset area is any one of the following shape areas:
    圆形区域和矩形区域。Circular area and rectangular area.
  7. 根据权利要求5所述的图像异常检测方法,其特征在于,所述将所述第一复制图像和所述第二复制图像分别进行缩放,包括:The image anomaly detection method according to claim 5, wherein scaling the first copied image and the second copied image respectively includes:
    根据不同的长宽比例将所述复制图像和所述第二复制图像分别进行随机变形缩放。The copied image and the second copied image are respectively randomly deformed and scaled according to different aspect ratios.
  8. 根据权利要求4所述的图像异常检测方法,其特征在于,所述从各个原始异常样本中选取出目标原始异常样本,从各个原始正常样本中选取出目标原始正常样本包括:The image anomaly detection method according to claim 4, wherein selecting the target original abnormal sample from each original abnormal sample and selecting the target original normal sample from each original normal sample includes:
    随机从各个原始异常样本中选取出目标原始异常样本,随机从各个原始正常样本中选取出目标原始正常样本。The target original abnormal sample is randomly selected from each original abnormal sample, and the target original normal sample is randomly selected from each original normal sample.
  9. 根据权利要求1-8任意一项所述的图像异常检测方法,其特征在于,所述图像异常检测模型为基于预先建立的样本集训练得到的包括:The image anomaly detection method according to any one of claims 1 to 8, characterized in that the image anomaly detection model is trained based on a pre-established sample set and includes:
    采用预先建立的样本集对特征提取网络进行训练,得到所述特征提取网络的最优权重参数;Using a pre-established sample set to train the feature extraction network, obtain the optimal weight parameters of the feature extraction network;
    采用所述样本集中的各个原始正常样本以及基于所述最优权重参数的特征提取网络对分类器进行训练,得到所述分类器的最优参数;Using each original normal sample in the sample set and the feature extraction network based on the optimal weight parameters to train the classifier to obtain the optimal parameters of the classifier;
    基于所述最优权重参数的特征提取网络及所述最优参数的分类器构建图像异常检测模型。An image anomaly detection model is constructed based on the feature extraction network of the optimal weight parameters and the classifier of the optimal parameters.
  10. 根据权利要求9所述的图像异常检测方法,其特征在于,所述分类器为KDE分类器。The image anomaly detection method according to claim 9, wherein the classifier is a KDE classifier.
  11. 根据权利要求9所述的图像异常检测方法,其特征在于,所述采用预先建立的样本集对特征提取网络进行训练,得到所述特征提取网络的最优权重参数包括:The image anomaly detection method according to claim 9, characterized in that, using a pre-established sample set to train a feature extraction network, obtaining the optimal weight parameters of the feature extraction network includes:
    针对所述样本集中的每个样本,对所述样本进行数据增强处理,得到第一增强样本和第二增强样本;For each sample in the sample set, perform data enhancement processing on the sample to obtain a first enhanced sample and a second enhanced sample;
    通过第一特征提取网络对所述第一增强样本进行处理,得到与所述第一增强样本对应的第一编码向量,通过第二特征提取网络对所述第二增强样本进行处理,得到与所述第二增强样本对应的第二编码向量;所述第一特征提取网络和所述第二特征提取网络相同;The first enhanced sample is processed through the first feature extraction network to obtain the first encoding vector corresponding to the first enhanced sample, and the second enhanced sample is processed through the second feature extraction network to obtain the first encoding vector corresponding to the first enhanced sample. The second encoding vector corresponding to the second enhanced sample; the first feature extraction network and the second feature extraction network are the same;
    采用第一投影网络对所述第一编码向量进行处理,得到第一投影向量,采用第二投影网络对所述第二编码向量进行处理,得到第二投影向量;所述第一投影网络和所述第二投影网络相同;Using a first projection network to process the first encoding vector to obtain a first projection vector, using a second projection network to process the second encoding vector to obtain a second projection vector; the first projection network and the The second projection network is the same;
    计算所述第一投影向量和所述第二投影向量的对比损失;Calculate the contrast loss of the first projection vector and the second projection vector;
    根据与每个样本对应的对比损失,计算出总对比损失;Based on the contrast loss corresponding to each sample, the total contrast loss is calculated;
    判断所述总对比损失是否满足结束条件;Determine whether the total comparative loss meets the ending condition;
    响应于所述总对比损失满足结束条件,结束,并得到所述第一特征提取网络和所述第二特征提取网络的最优权重参数。In response to the total contrast loss satisfying the end condition, the method ends, and the optimal weight parameters of the first feature extraction network and the second feature extraction network are obtained.
  12. 根据权利要求11所述的方法,其特征在于,通过下述公式(1)计算得到所述对比损失:The method according to claim 11, characterized in that the contrast loss is calculated by the following formula (1):
    Figure PCTCN2022123403-appb-100001
    Figure PCTCN2022123403-appb-100001
    上述公式(1)中,
    Figure PCTCN2022123403-appb-100002
    表示x和x +所属分布,x表示样本,x +表示样本x的数据增强,x i -表示负样本的数据增强,p表示分布,f(x) T表示对x提取特征后的转置,f(x +)表示对x +提取特征,f(x i -)表示对x i -提取特征,i表示样本标号,N表示总样本量。
    In the above formula (1),
    Figure PCTCN2022123403-appb-100002
    represents the distribution to which x and x + belong, x represents the sample, x + represents the data enhancement of the sample x, xi - represents the data enhancement of the negative sample, p represents the distribution, f(x) T represents the transpose of x after extracting features, f(x + ) means extracting features for x + , f( xi - ) means extracting features for x i - , i represents the sample label, and N represents the total sample size.
  13. 根据权利要求11所述的图像异常检测方法,其特征在于,在所述判断所述总对比损失是否满足结束条件之后,还包括:The image anomaly detection method according to claim 11, characterized in that after determining whether the total contrast loss satisfies the end condition, it further includes:
    响应于所述总对比损失不满足所述结束条件,对所述第一特征提取网络和所述第二特征提取网络的权重参数进行更新,并进入下一轮训练。In response to the total contrast loss not meeting the end condition, the weight parameters of the first feature extraction network and the second feature extraction network are updated, and the next round of training is entered.
  14. 根据权利要求1所述的图像异常检测方法,其特征在于,所述在所述异常得分满足预设条件的情况下,所述待检测图像为异常图像,包括:The image anomaly detection method according to claim 1, characterized in that, when the anomaly score meets a preset condition, the image to be detected is an abnormal image, including:
    在所述异常得分大于预先设置的阈值的情况下,判定所述待检测图像为异常图像。When the abnormality score is greater than a preset threshold, the image to be detected is determined to be an abnormal image.
  15. 根据权利要求14所述的图像异常检测方法,其特征在于,在所述采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分之后,还包括:The image anomaly detection method according to claim 14, characterized in that after using a pre-established image anomaly detection model to detect the image to be detected and obtaining the anomaly score, it also includes:
    在所述异常得分小于等于所述阈值的情况下,判定所述待检测图像为正常图像。When the abnormality score is less than or equal to the threshold, the image to be detected is determined to be a normal image.
  16. 一种图像异常检测装置,其特征在于,包括:An image anomaly detection device, characterized by including:
    检测模块,用于采用预先建立的图像异常检测模型对待检测图像进行检测,得出异常得分;The detection module is used to detect the image to be detected using a pre-established image anomaly detection model and obtain an anomaly score;
    分析模块,用于在所述异常得分满足预设条件的情况下,所述待检测图像为异常图像;其中:An analysis module configured to determine that the image to be detected is an abnormal image when the abnormality score satisfies a preset condition; wherein:
    所述图像异常检测模型为基于预先建立的样本集训练得到的,所述样本 集中的模拟异常样本为基于原始异常样本与原始正常样本得到的。The image anomaly detection model is trained based on a pre-established sample set, and the simulated abnormal samples in the sample set are obtained based on original abnormal samples and original normal samples.
  17. 一种图像异常检测系统,其特征在于,包括:An image anomaly detection system, characterized by including:
    存储器,用于存储计算机程序;Memory, used to store computer programs;
    处理器,用于执行所述计算机程序时实现如权利要求1至15任一项所述图像异常检测方法的步骤。A processor, configured to implement the steps of the image anomaly detection method according to any one of claims 1 to 15 when executing the computer program.
  18. 一种非易失性可读存储介质,其特征在于,所述非易失性可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至15任一项所述图像异常检测方法的步骤。A non-volatile readable storage medium, characterized in that a computer program is stored on the non-volatile readable storage medium, and when the computer program is executed by a processor, it implements any one of claims 1 to 15 The steps of the image anomaly detection method.
  19. 一种计算处理设备,其特征在于,包括:A computing processing device, characterized by including:
    存储器,其中存储有计算机可读代码;A memory having computer readable code stored therein;
    一个或多个处理器,当所述计算机可读代码被所述一个或多个处理器执行时,所述计算处理设备执行权利要求1-15任意一项所述的图像异常检测方法的步骤。One or more processors, when the computer readable code is executed by the one or more processors, the computing processing device performs the steps of the image anomaly detection method described in any one of claims 1-15.
  20. 一种计算机程序产品,其特征在于,包括计算机可读代码,当所述计算机可读代码在计算处理设备上运行时,导致所述计算处理设备执行根据权利要求1-15任意一项所述的图像异常检测方法的步骤。A computer program product, comprising computer readable code that, when run on a computing processing device, causes the computing processing device to perform a process according to any one of claims 1-15 Steps of image anomaly detection method.
PCT/CN2022/123403 2022-03-31 2022-09-30 Image anomaly detection method, apparatus and system, and readable storage medium WO2023184918A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210331065.9 2022-03-31
CN202210331065.9A CN114627102B (en) 2022-03-31 2022-03-31 Image anomaly detection method, device and system and readable storage medium

Publications (1)

Publication Number Publication Date
WO2023184918A1 true WO2023184918A1 (en) 2023-10-05

Family

ID=81904565

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/123403 WO2023184918A1 (en) 2022-03-31 2022-09-30 Image anomaly detection method, apparatus and system, and readable storage medium

Country Status (2)

Country Link
CN (1) CN114627102B (en)
WO (1) WO2023184918A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117077066A (en) * 2023-10-17 2023-11-17 合肥联宝信息技术有限公司 Waveform abnormality detection method, waveform abnormality detection device, electronic device and storage medium
CN117152459A (en) * 2023-10-30 2023-12-01 腾讯科技(深圳)有限公司 Image detection method, device, computer readable medium and electronic equipment
CN117648632A (en) * 2024-01-29 2024-03-05 杭州海康威视数字技术股份有限公司 Method, device, equipment and computer program product for identifying optical fiber vibration abnormality

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114627102B (en) * 2022-03-31 2024-02-13 苏州浪潮智能科技有限公司 Image anomaly detection method, device and system and readable storage medium
CN116246114B (en) * 2023-03-14 2023-10-10 哈尔滨市科佳通用机电股份有限公司 Method and device for detecting pull ring falling image abnormality of self-supervision derailment automatic device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109584221A (en) * 2018-11-16 2019-04-05 聚时科技(上海)有限公司 A kind of abnormal image detection method generating confrontation network based on supervised
CN111275129A (en) * 2020-02-17 2020-06-12 平安科技(深圳)有限公司 Method and system for selecting image data augmentation strategy
CN113255738A (en) * 2021-05-06 2021-08-13 武汉象点科技有限公司 Abnormal image detection method based on self-attention generation countermeasure network
CN113688889A (en) * 2021-08-13 2021-11-23 上海商汤智能科技有限公司 Abnormality detection method, abnormality detection device, electronic apparatus, and computer-readable storage medium
CN114627102A (en) * 2022-03-31 2022-06-14 苏州浪潮智能科技有限公司 Image anomaly detection method, device and system and readable storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111680614B (en) * 2020-06-03 2023-04-14 安徽大学 Abnormal behavior detection method based on video monitoring
CN113222983A (en) * 2021-06-03 2021-08-06 北京有竹居网络技术有限公司 Image processing method, image processing device, readable medium and electronic equipment
CN113723527A (en) * 2021-09-01 2021-11-30 重庆赛迪奇智人工智能科技有限公司 Classification model training method, flaw detection device and electronic equipment
CN113778719B (en) * 2021-09-16 2024-02-02 北京中科智眼科技有限公司 Anomaly detection algorithm based on copy and paste

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109584221A (en) * 2018-11-16 2019-04-05 聚时科技(上海)有限公司 A kind of abnormal image detection method generating confrontation network based on supervised
CN111275129A (en) * 2020-02-17 2020-06-12 平安科技(深圳)有限公司 Method and system for selecting image data augmentation strategy
CN113255738A (en) * 2021-05-06 2021-08-13 武汉象点科技有限公司 Abnormal image detection method based on self-attention generation countermeasure network
CN113688889A (en) * 2021-08-13 2021-11-23 上海商汤智能科技有限公司 Abnormality detection method, abnormality detection device, electronic apparatus, and computer-readable storage medium
CN114627102A (en) * 2022-03-31 2022-06-14 苏州浪潮智能科技有限公司 Image anomaly detection method, device and system and readable storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117077066A (en) * 2023-10-17 2023-11-17 合肥联宝信息技术有限公司 Waveform abnormality detection method, waveform abnormality detection device, electronic device and storage medium
CN117077066B (en) * 2023-10-17 2024-03-12 合肥联宝信息技术有限公司 Waveform abnormality detection method, waveform abnormality detection device, electronic device and storage medium
CN117152459A (en) * 2023-10-30 2023-12-01 腾讯科技(深圳)有限公司 Image detection method, device, computer readable medium and electronic equipment
CN117648632A (en) * 2024-01-29 2024-03-05 杭州海康威视数字技术股份有限公司 Method, device, equipment and computer program product for identifying optical fiber vibration abnormality
CN117648632B (en) * 2024-01-29 2024-05-03 杭州海康威视数字技术股份有限公司 Method, device, equipment and computer program product for identifying optical fiber vibration abnormality

Also Published As

Publication number Publication date
CN114627102A (en) 2022-06-14
CN114627102B (en) 2024-02-13

Similar Documents

Publication Publication Date Title
WO2023184918A1 (en) Image anomaly detection method, apparatus and system, and readable storage medium
Selvaraju et al. Casting your model: Learning to localize improves self-supervised representations
US11741693B2 (en) System and method for semi-supervised conditional generative modeling using adversarial networks
CN109086811B (en) Multi-label image classification method and device and electronic equipment
CN109918539B (en) Audio and video mutual retrieval method based on user click behavior
CN109977895B (en) Wild animal video target detection method based on multi-feature map fusion
CN113554129B (en) Scene graph generation method and generation device
US20220092407A1 (en) Transfer learning with machine learning systems
WO2023206944A1 (en) Semantic segmentation method and apparatus, computer device, and storage medium
CN110175657B (en) Image multi-label marking method, device, equipment and readable storage medium
CN112862093A (en) Graph neural network training method and device
CN109271957B (en) Face gender identification method and device
US11410016B2 (en) Selective performance of deterministic computations for neural networks
CN115100717A (en) Training method of feature extraction model, and cartoon object recognition method and device
CN111310516B (en) Behavior recognition method and device
CN114998679A (en) Online training method, device and equipment for deep learning model and storage medium
CN113920382A (en) Cross-domain image classification method based on class consistency structured learning and related device
CN112257689A (en) Training and recognition method of face recognition model, storage medium and related equipment
CN115035463B (en) Behavior recognition method, behavior recognition device, behavior recognition equipment and storage medium
CN115063858A (en) Video facial expression recognition model training method, device, equipment and storage medium
WO2022237065A1 (en) Classification model training method, video classification method, and related device
CN111695526B (en) Network model generation method, pedestrian re-recognition method and device
CN110827261B (en) Image quality detection method and device, storage medium and electronic equipment
CN114638304A (en) Training method of image recognition model, image recognition method and device
CN112949344B (en) Characteristic autoregression method for anomaly detection

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: 22934736

Country of ref document: EP

Kind code of ref document: A1