WO2021114896A1 - 一种基于计算机视觉的异常检测方法、装置及电子设备 - Google Patents

一种基于计算机视觉的异常检测方法、装置及电子设备 Download PDF

Info

Publication number
WO2021114896A1
WO2021114896A1 PCT/CN2020/123475 CN2020123475W WO2021114896A1 WO 2021114896 A1 WO2021114896 A1 WO 2021114896A1 CN 2020123475 W CN2020123475 W CN 2020123475W WO 2021114896 A1 WO2021114896 A1 WO 2021114896A1
Authority
WO
WIPO (PCT)
Prior art keywords
tested
target
picture
diversity
difference
Prior art date
Application number
PCT/CN2020/123475
Other languages
English (en)
French (fr)
Inventor
谢馥励
张一凡
刘杰
田继锋
Original Assignee
歌尔股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 歌尔股份有限公司 filed Critical 歌尔股份有限公司
Priority to US17/309,306 priority Critical patent/US12002195B2/en
Publication of WO2021114896A1 publication Critical patent/WO2021114896A1/zh

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
    • G06T7/0004Industrial image inspection
    • G06T7/001Industrial image inspection using an image reference approach
    • 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
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • 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/20021Dividing image into blocks, subimages or windows
    • 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
    • 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/20084Artificial neural networks [ANN]

Definitions

  • the present invention relates to the technical field of abnormality detection, in particular to an abnormality detection method, device and electronic equipment based on computer vision.
  • Computer vision refers to the use of cameras and computers instead of human eyes to perform operations such as recognition, tracking, and measurement of targets. It can also be seen as the science of studying how to make artificial systems perceive from images or multi-dimensional data.
  • Anomaly detection refers to the identification of items, events, or observations that do not conform to expected patterns or other items in the data set. Commonly used fields include data mining and structural defect detection. In industrial production, some products that need to be detected have different characteristics. Based on this, an anomaly detection algorithm can be used to perform anomaly detection based on computer vision.
  • the existing research and application of anomaly detection algorithms are mainly aimed at semantic-level anomaly detection such as security screening machines, that is, it can be judged when there is a semantic-level anomaly in the image, and the semantic level is to divide the pixels according to the image
  • the difference in semantic meaning is grouped or divided. For example, when the prohibited items (guns) are detected in the security check machine, the abnormal contraband usually accounts for a higher proportion of the screen, and there is a semantic difference from other components in the screen (such as other normal bags) .
  • the application of existing detection methods cannot achieve better results.
  • an anomaly detection method, device and electronic device based on computer vision of the present invention are proposed to overcome the above-mentioned problems.
  • an abnormality detection method based on computer vision including:
  • the generated image and the target image to be tested are pixel-based Value difference detection.
  • an anomaly detection device based on computer vision, the device including: a training set generation module, a training module, and a detection module;
  • the training set generation module is used to divide the target picture into at least two feature regions according to different regional features of the target picture, and use the feature regions corresponding to each target picture to form a training set;
  • the training module is used to select the antagonistic generative network GAN as the network model used, and use the training sets of different feature regions to train the GAN network model to obtain each GAN network model corresponding to different feature regions;
  • the detection module is used to divide the same feature area of the target image to be tested, and input the different feature regions of the target image to be tested into the corresponding GAN network model to obtain the generated image.
  • the generated image and the target image to be tested are pixel-based Value difference detection.
  • an electronic device including a processor; and a memory arranged to store computer-executable instructions, which when executed, cause the processor to perform the above-mentioned method.
  • This application obtains the training set by dividing the different feature regions of the target picture, and trains the GAN network model corresponding to each feature region. With the trained GAN network model, you can input each feature region of the target picture to be tested to obtain the generated picture, and then generate the generated picture by pairing The difference between the picture and the target picture to be tested is detected based on the pixel value to determine whether the target to be tested is normal. Since this application divides the target picture into different feature areas and detects the difference in pixel level, it improves the judgment of whether the target is normal or not. Accuracy.
  • FIG. 1 is a schematic flowchart of an abnormality detection method based on computer vision provided by an embodiment of the present invention
  • Figure 2 is a schematic diagram of a WGAN network model training process provided by an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of cutting a grid-shaped target image according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram showing the division of the central area and the edge area of the cutting diagram shown in FIG. 3 of the present invention.
  • FIG. 5 is a schematic diagram of a WGAN network model detection process based on a central area and an edge area provided by an embodiment of the present invention
  • FIG. 6 is a flowchart of abnormality detection judgment of a computer vision-based abnormality detection method according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of an abnormality detection device based on computer vision provided by an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of an abnormality detection device based on computer vision provided by another embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of an electronic device provided by another embodiment of the present invention.
  • connection should be understood in a broad sense, unless otherwise clearly specified and limited.
  • it can be a fixed connection or a detachable connection.
  • Connected or integrally connected it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the internal communication between two components.
  • connection should be understood in a broad sense, unless otherwise clearly specified and limited.
  • it can be a fixed connection or a detachable connection.
  • Connected or integrally connected it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the internal communication between two components.
  • the specific meanings of the above terms in this application can be understood under specific circumstances.
  • the technical idea of the present invention is to obtain a training set by dividing different feature regions of the target picture, and train to obtain a GAN network model corresponding to each feature region.
  • each feature region of the target picture to be tested can be input and generated Image, and then through the difference detection based on the pixel value of the generated image and the target image to be tested, it is determined whether the target to be tested is normal. Because the target image is divided into different feature regions and the pixel level difference detection is performed on the target image, it improves The accuracy of judging whether the target is normal or not.
  • FIG. 1 is a schematic flowchart of an abnormality detection method based on computer vision provided by an embodiment of the present invention. As shown in Figure 1, an abnormality detection method based on computer vision includes:
  • Step S110 Divide the target picture into at least two feature regions according to different regional features of the target picture, and use the feature regions corresponding to each target picture to form a training set.
  • this application first divides the target image into different characteristic areas, processes each characteristic area separately, and comprehensively judges the target product according to whether the characteristic difference is normal. Is it normal?
  • Step S120 Select the confrontation generation network GAN as the network model to be used, and train the GAN network model using the training sets of different feature regions, respectively, to obtain each GAN network model corresponding to different feature regions.
  • GAN Geneative Adversarial Network
  • generator G First reconstructs the generated image (such as the generated image G(z)) according to the original input image (real image x), and then sends the generated image to the discriminator D for judgment. If the difference between the image and the reconstructed generated image is large, the original image can be judged to be abnormal, that is, the difference between the original image and the reconstructed generated image can be used to determine whether the target is normal or not.
  • the corresponding GAN network model is trained separately for two or more feature regions after the target is divided, so that each feature region of the target image to be tested can be comprehensively detected for differences.
  • Step S130 When performing anomaly detection, perform the same feature region division on the target image to be tested, and input different feature regions of the target image to be tested into the corresponding GAN network model to obtain the generated image, and compare the generated image and the target image to be tested Perform difference detection based on pixel value.
  • this application performs the same feature area division for the target image to be tested, and uses the corresponding GAN network model obtained by training to perform pixel-level difference detection for each feature region of the target image to be tested, each feature of the target image to be tested can be fully detected. Whether there is an abnormality in the area, according to the results of whether each characteristic area is normal or not, comprehensively judge whether the target to be tested is normal or not, thus improving the accuracy of judging whether the target is normal or not.
  • step S110 using feature regions corresponding to each target picture to form a training set respectively includes: using each feature region of the target picture in a normal state to form a training set respectively.
  • step S120 the confrontation generation network GAN is selected as the network model used, and the training set of different feature regions is used to train the GAN network model, including: selecting the GAN network based on the wasserstein distance (ie WGAN) as the network model used, using the training set
  • the WGAN network model is trained, and the WGAN network model can generate pictures with normal target characteristics according to the input pictures.
  • each feature region of the normal target image is selected to form a training set, and the WGAN network model is generated by training. Since the WGAN network model has not been trained for abnormal images, it can only generate normal target features during abnormal detection. Therefore, when the input target image is abnormal, the generated image is very different from the input original image of the target target. According to the difference detection between the two based on the pixel value, the abnormality of the target target can be accurately determined.
  • the target picture is divided into at least two feature regions according to different regional characteristics of the target picture, including: dividing the target picture into a low-diversity region and a high-diversity region according to the diversity of the content of the target picture Sexual area.
  • the low-diversity region and the high-diversity region of the target picture are respectively divided according to the diversity of the content of the target picture, and the number of the low-diversity region and the high-diversity region may be one or more respectively.
  • the patterns in the central part of the grid are generally more uniform, while the edge patterns are deformed. Therefore, this embodiment divides the central area of the target into low diversity Area, the edge area of the target is divided into high-diversity areas, the complexity of the image information covered by the high-diversity area is greater than the complexity of the image information covered by the low-diversity area.
  • the outermost circle in the segmentation diagram of FIG. 3 is divided into a high diversity area, and the inside is divided into a low diversity area.
  • the WGAN network model trained in this embodiment also includes the central area WGAN model and the edge area WGAN model.
  • the target The image is also divided into the central area and the edge area, and the corresponding WGAN model is used to detect the central area and the edge area of the target image. After the detection results are comprehensively processed, the final judgment of whether the target is normal or not is realized. .
  • the method further includes image preprocessing to deal with the size limitation of the GAN model to process the image, including: before the target image is input into the GAN network model, the resolution of the target image is reset to make the target image Adjust to an integer multiple of the preset pixel size, and divide the target picture into multiple pictures according to the preset pixel size.
  • the GAN network is subject to the generation space cannot be too large, otherwise it will cause network instability, so the generated image size is stable at most 64X64 size, and most of the images in the actual detection are much larger than this value. Therefore, in this application, before inputting the target image into the GAN network model, the original image is integerized and cut, and the resolution of the original image is first reset to an integer multiple of 64, and then cut into several small images of 64X64 size. (See Figures 3 and 4), after cutting, each small image is enough to be fully displayed in a size of 64X64.
  • the size of 64X64 here is only an exemplary embodiment, and in actual applications, different preset pixel sizes can also be selected according to needs, which will not be repeated here.
  • performing pixel value-based difference detection on the generated picture and the target picture to be tested includes:
  • this implementation For example, first detect the difference in the low-diversity area. If it is judged that the low-diversity area is abnormal, it will directly judge the object to be tested as abnormal and stop the calculation. If it is judged that the low-diversity area is normal, then further detect the difference in the high diversity area. The anomaly detection process can be made simpler and more accurate.
  • this embodiment inputs the image to be tested into the GAN network model, and after generating the reconstructed image, first determine whether the central area (low diversity area) is normal. Then directly judge that the target to be tested is abnormal and stop the calculation; if it is determined that the central area is normal, then further determine whether the edge area (high-diversity area) is normal, if the high-diversity area is also normal, then it can be determined that the target to be tested is normal, if it is high and diverse If the sexual area is abnormal, the target to be tested is determined to be abnormal.
  • the central area low diversity area
  • the edge area high-diversity area
  • performing pixel value-based difference detection on the generated picture and the target picture to be tested includes:
  • performing pixel value-based difference detection on the generated picture and the target picture to be tested includes: calculating the average value of the second-order norm squared of each pixel value difference between the target picture to be tested and the generated picture, and The average value is used as a calculation result indicating regional differences in low diversity.
  • the following first formula can be used to calculate the average value of the second-order norm squared of each pixel value difference:
  • n is the total number of pixels in the low diversity area
  • x is the pixel value of the target picture to be tested
  • G(x) is the pixel value of the generated picture.
  • this embodiment uses another evaluation system to calculate the pixel value difference of the high-diversity region.
  • the second threshold is a set of values .
  • the maximum pixel value difference and the cumulative pixel value difference are not less than the corresponding value in the second threshold, the calculation result is considered to be not less than the second threshold, and it is judged that the high diversity area of the target image to be tested is abnormal.
  • the maximum pixel value difference It indicates the maximum value of the difference in pixel values between a single target picture to be tested and the corresponding generated picture;
  • the cumulative difference in pixel values indicates the cumulative value of the difference in pixel values between all target pictures belonging to the same target picture and the corresponding generated pictures.
  • the following second formula is used to calculate the maximum pixel value difference between the target picture to be tested and the generated picture:
  • the following third formula is used to calculate the cumulative difference in pixel values between the target image to be tested and the generated image:
  • (i, j) represents the coordinates of each pixel in each picture in the high-diversity area
  • M is the total number of pictures in the high-diversity area.
  • Combining the second formula and the third formula can determine whether the high diversity area is abnormal.
  • L bmax can reflect the maximum difference in pixel values of a single picture in the high diversity area
  • L bsum can reflect the cumulative difference in pixel values of the entire high diversity area. Since the generated pictures of the high-diversity area are not as accurate as the low-diversity area, if the same determination method as the low-diversity area is still used, it will cause too many misjudgments, and the normal picture will be judged as abnormal.
  • this embodiment designs this double loss function superposition method, and only when the cumulative difference in pixel values of the high-diversity area and the maximum difference in pixel values of a single picture reach the corresponding threshold, it is determined that the target to be tested is abnormal. It can ensure that the largest anomaly of each small image after the target image is segmented and the small anomalies that continuously span multiple small images can be identified.
  • the second threshold is a set of values, and two thresholds are respectively set for L bmax and L bsum . When both L bmax and L bsum are not less than the corresponding threshold, it is determined that the high diversity area is abnormal.
  • the method further includes the step of determining the first threshold and the second threshold by using a training set of pictures in a normal state, including:
  • the value at the preset position above the median of the calculation result is used as the first threshold; the maximum pixel value difference and the cumulative difference in pixel value of the high diversity area are calculated, and the values at the preset position above the median of the calculation result are selected to form the first threshold.
  • Two thresholds Preferably, in this embodiment, a value at 15%, 20%, or 25% above the median of the calculation result is selected as the corresponding threshold (the first threshold or the second threshold).
  • the device includes: a training set generation module 710, a training module 720 and a detection module 730.
  • the training set generating module 710 is configured to divide the target picture into at least two feature regions according to different regional features of the target picture, and use the feature regions corresponding to each target picture to form a training set.
  • the training module 720 is used to select the confrontation generation network GAN as the network model to be used, and train the GAN network model using the training sets of different feature regions to obtain each GAN network model corresponding to different feature regions.
  • the detection module 730 is used to divide the same feature area of the target image to be tested, input different feature regions of the target image to be tested into the corresponding GAN network model, obtain the generated image, and base the generated image and the target image to be tested. Detection of differences in pixel values.
  • the training set generating module 710 is configured to divide the target picture into a low-diversity area and a high-diversity area according to the diversity of the content of the target picture.
  • the detection module 730 is used to detect the difference between the generated image and the low-diversity area corresponding to the target image to be tested. When the detection result is abnormal, stop the calculation and directly determine the abnormality of the target to be tested; when the detection result is normal, continue to The generated image and the high-diversity area corresponding to the target image to be tested are generated for difference detection.
  • the training set generating module 710 is specifically configured to use each feature region of the target picture in a normal state to form a training set.
  • the training module 720 is specifically configured to select the GAN network WGAN based on the wasserstein distance as the network model used, and use the training set to train to obtain the WGAN network model.
  • the WGAN network model can generate pictures with normal target characteristics according to the input pictures.
  • the training set generating module 710 is configured to divide the target picture into a low-diversity area and a high-diversity area according to the diversity of the content of the target picture.
  • the training set generation module 710 and the detection module 730 are also used to reset the resolution of the target picture before inputting the target picture into the GAN network model, so that the target picture is adjusted to the preset pixel size. Integer multiples, and divide the target picture into multiple pictures according to the preset pixel size.
  • the detection module 730 is specifically configured to: calculate the difference in pixel values between the target picture to be tested and the low-diversity region of the generated picture, and if the calculation result is not less than the first threshold, determine that the target picture to be tested is low The diversity area is abnormal, and the calculation is stopped. If the calculation result is less than the first threshold, it is determined that the low diversity area of the target image to be tested is normal, and the pixel value difference between the target image to be tested and the high diversity area of the generated image is continued to be calculated. If the calculation result is If it is not less than the second threshold, it is determined that the high diversity area of the target image to be tested is abnormal, and if the calculation result is less than the second threshold, it is determined that the target image to be tested is normal.
  • the detection module 730 is specifically configured to: calculate the average value of the second-order norm squared of each pixel value difference between the target picture to be tested and the generated picture, and use the average value as an indicator of low diversity. The results of the calculation of regional differences. And, calculate the maximum pixel value difference and the cumulative pixel value difference between the target image to be tested and the generated picture; where the second threshold is a set of values, when the maximum pixel value difference and the cumulative pixel value difference are not less than the corresponding ones in the second threshold Value, the calculation result is considered to be not less than the second threshold, and it is judged that the high diversity area of the target image to be tested is abnormal.
  • the maximum pixel value difference indicates the maximum value of the difference between the pixel value of a single target image to be tested and the corresponding generated image; pixels;
  • the value cumulative difference indicates the cumulative value of the pixel value difference between all target pictures belonging to the same target to be tested and the corresponding generated pictures.
  • the detection module 730 may use the following first formula to calculate the average value of the second-order norm squared of each pixel value difference:
  • n is the total number of pixels in the low diversity area
  • x is the pixel value of the target picture to be tested
  • G(x) is the pixel value of the generated picture.
  • the detection module 730 may use the following second formula to calculate the maximum pixel value difference between the target picture to be tested and the generated picture:
  • the following third formula is used to calculate the cumulative difference in pixel values between the target image to be tested and the generated image:
  • (i, j) represents the coordinates of each pixel in each picture in the high-diversity area
  • M is the total number of pictures in the high-diversity area.
  • FIG. 8 shows another embodiment of an abnormality detection device based on computer vision of the present application.
  • the device includes: a training set generation module 810, a training module 820, a detection module 830, and a threshold determination module 840.
  • the threshold determination module 840 is used to input the training set of each feature area of the target picture in a normal state into the trained GAN network model to obtain the generated picture, and calculate the second-order norm square of the difference of each pixel value in the low diversity area
  • the value at the preset position above the median of the calculation result is selected as the first threshold; the maximum pixel value difference and the cumulative difference in pixel value of the high-diversity area are calculated, and the prediction values above the median of the calculation result are selected respectively.
  • values at 20% positions above the median of the calculation result are selected as the corresponding thresholds (first threshold or second threshold).
  • the working principle of the computer vision-based abnormality detection device provided in this embodiment is the same as the above-mentioned computer vision-based abnormality detection method.
  • Fig. 9 shows a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • the electronic device 900 includes a processor 910 and a memory 920 arranged to store computer-executable instructions (computer-readable program code).
  • the memory 920 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • the memory 920 has a storage space 930 for storing computer-readable program codes 931 for executing any method steps in the foregoing methods.
  • the storage space 930 for storing computer-readable program codes may include various computer-readable program codes 931 respectively used to implement various steps in the above method.
  • the computer-readable program code 931 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 computer program products are usually computer-readable storage media.
  • the executable instructions stored in the memory 920 cause the processor to execute the following methods when executed:
  • the target picture into at least two feature regions according to the characteristics of different regions of the target picture, and use the feature regions corresponding to each target picture to form a training set; select the adversarial generation network GAN as the network model used, and use different feature regions for training. Collect training GAN network models, and get each GAN network model corresponding to different feature regions;
  • the generated image and the target image to be tested are pixel-based Value difference detection.
  • the processor when the executable instruction is executed, the processor also executes the following methods:
  • the target picture is divided into a low-diversity area and a high-diversity area.
  • the processor when the executable instruction is executed, the processor also executes the following methods:
  • Yet another embodiment of the present invention provides a computer-readable storage medium.
  • the computer-readable storage medium stores computer-readable program codes for executing the steps of the method according to the present invention, which can be read by the processor of the electronic device, and when the computer-readable program code is run by the electronic device, it causes the electronic device to execute Each step in the method described above, specifically, the computer readable program code stored in the computer readable storage medium can execute the method shown in any of the above embodiments.
  • the computer readable program code can be compressed in an appropriate form.

Landscapes

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

Abstract

一种基于计算机视觉的异常检测方法、装置和电子设备。该方法包括:S110根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集;S120选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型;S130执行异常检测时,对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。

Description

一种基于计算机视觉的异常检测方法、装置及电子设备 技术领域
本发明涉及异常检测技术领域,特别涉及一种基于计算机视觉的异常检测方法、装置及电子设备。
发明背景
计算机视觉(computer vision)是指用摄影机和计算机代替人眼对目标进行识别、跟踪、测量等操作,也可以看作是研究如何使人工***从图像或多维数据中感知的科学。异常检测(anomaly detection)是指对不符合预期模式或数据集中的其他项目的项目、事件或观测的识别,常用的领域包括数据挖掘和结构缺陷检测等。在工业生产中,一些需要检测的产品具备不同的特征,基于此,可以利用异常检测算法,对其进行基于计算机视觉的异常检测。
然而,现有的异常检测算法研究及应用中,主要是针对安检机之类的语义级别的异常检测,即当图片中出现了语义级别的异常时才能判断,而语义级别是将像素按照图像中表达语义含义的不同进行分组或分割的,比如安检机中检测违禁物品(***)时,违禁品异常通常占画面比例较高,且与画面中其他成分(如其他正常箱包)存在语义级的区别。而工业产品中的异常产品与正常产品不存在语义级别的差别,因而应用现有检测方法不能取得较好的效果。
发明内容
鉴于现有技术异常检测算法不能很好应用于工业产品检测的问题,提出了本发明的一种基于计算机视觉的异常检测方法、装置及电子设备,以便克服上述问题。
为了实现上述目的,本发明实施例采用了如下技术方案:
依据本发明的一个方面,提供了一种基于计算机视觉的异常检测方法,该方法包括:
根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集;
选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型;
执行异常检测时,对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。
依据本发明实施例的另一个方面,提供了一种基于计算机视觉的异常检测装置,该装置包括:训练集生成模块、训练模块和检测模块;
训练集生成模块,用于根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集;
训练模块,用于选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型;
检测模块,用于对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。
依据本发明实施例的又一个方面,提供了一种电子设备,包括处理器;以及被安排成存储计算机可执行指令的存储器,可执行指令在被执行时使处理器执行上述方法。
综上所述,本发明的有益效果是:
本申请通过划分目标图片的不同特征区域获得训练集,训练得到对应各特征区域的GAN网络模型,借助训练后的GAN网络模型,可以输入待测目标图片各特征区域得到生成图片,继而通过对生成图片和待测目标图片进行基于像素值的差异检测,判断待测目标是否正常,由于本申请对目标图片进行了不同特征区域的划分和像素级别的差异检测,因而提高了判断目标正常与否的准确度。
附图简要说明
图1为本发明一个实施例提供的基于计算机视觉的异常检测方法的流程示意图;
图2为本发明一个实施例提供的WGAN网络模型训练流程示意图;
图3为本发明一个实施例提供的网格状目标图片切割示意图;
图4为本发明图3所示切割示意图的中央区域和边缘区域划分示意图;
图5为本发明一个实施例提供的基于中央区域和边缘区域的WGAN网络模 型检测流程示意图;
图6为本发明一个实施例提供的基于计算机视觉的异常检测方法的异常检测判定流程图;
图7为本发明一个实施例提供的基于计算机视觉的异常检测装置的结构示意图;
图8为本发明另一个实施例提供的基于计算机视觉的异常检测装置的结构示意图。
图9为本发明另一个实施例提供的电子设备的结构示意图。
具体实施方式
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。
在本申请的描述中,需要说明的是,术语“中心”、“上”、“下”、“左”、“右”、“竖直”、“水平”、“内”、“外”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本申请和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本申请的限制。此外,术语“第一”、“第二”、“第三”仅用于描述目的,而不能理解为指示或暗示相对重要性。
在本申请的描述中,需要说明的是,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本申请中的具体含义。
本发明的技术构思是:通过划分目标图片的不同特征区域来获得训练集,训练得到对应各特征区域的GAN网络模型,借助训练后的GAN网络模型,可以输入待测目标图片各特征区域得到生成图片,继而通过对生成图片和待测目标图片进行基于像素值的差异检测,判断待测目标是否正常,由于本申请对目标图片进行了不同特征区域的划分和像素级别的差异检测,因而提高了判断目标正常与否的准确度。
图1为本发明一个实施例提供的基于计算机视觉的异常检测方法的流程示意图。如图1所示,一种基于计算机视觉的异常检测方法,该方法包括:
步骤S110:根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集。
由于工业生产中,需要检测的产品不同区域具有不同的特征,基于此,本申请首先将目标图片划分成不同的特征区域,对各特征区域分别处理,根据各特征区别是否正常来综合判断目标产品是否正常。
步骤S120:选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型。
基于对抗生成网络GAN(Generative Adversarial Network),包括生成器G和鉴别器D(见图2)。训练完成后的GAN网络模块中,生成器G首先根据输入原图(真实图片x)重建获得生成图片(如生成图片G(z)),然后将生成图片送入鉴别器D中进行判断,若原图和重建的生成图片差别很大,则可以判断原图异常,也就是说,通过计算原图和重建的生成图片的差异即可判定目标正常与否。本申请针对目标划分后的两个以上特征区域,分别训练得到对应的GAN网络模型,从而可以对待测目标图片的各特征区域分别进行全面的差异检测。
步骤S130:执行异常检测时,对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。
由于本申请对待测目标图片进行了同样的特征区域划分,并且利用训练得到的对应GAN网络模型分别对待测目标图片的各特征区域进行像素级别的差异检测,从而可以充分检测待测目标图片各个特征区域是否存在异常,根据各个特征区域正常与否的结果,综合判断待测目标是否正常,因而提高了判断目标正常与否的准确度。
在本申请的一个实施例中,步骤S110中,利用各个目标图片对应的特征区域分别组成训练集,包括:利用状态正常的目标图片的各特征区域分别组成训练集。
步骤S120中,选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,包括:选取基于wasserstein距离的GAN网络(即WGAN)作为使用的网络模型,利用训练集训练得到WGAN网络模型,该WGAN网络模型能够依据输入图片生成具有正常目标特征的图片。
本实施例中,选择状态正常的目标图片的各特征区域构成训练集,以此训 练生成WGAN网络模型,由于WGAN网络模型没有经过异常图片的训练,因此异常检测时就只能生成具有正常目标特征的生产图片,从而当输入的待测目标图片异常时,生成图片与输入的待测目标原图差别很大,根据对二者基于像素值的差异检测就可以准确判断待测目标异常。
在本申请的一个实施例中,根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,包括:根据目标图片内容的多样性,将目标图片划分为低多样性区域和高多样性区域。
本实施例中,根据目标图片内容的多样性不同,分别划分目标图片的低多样性区域和高多样性区域,低多样性区域和高多样性区域的数量可以分别为一个或多个。参考图3所示,以网布等网格状产品为例,通常网格中央部分的图案较为均匀一致,而边缘图案则存在变形,因此,本实施例将目标的中央区域划分为低多样性区域,将目标的边缘区域划分为高多样性区域,高多样性区域涵盖的图像信息的复杂度大于低多样性区域涵盖的图像信息的复杂度。参考图4所示,图3分割示意图中最外侧一圈划分为高多样性区域,内部划分为低多样性区域。
继而,如本申请图5所示,本实施例训练得到的WGAN网络模型也对应包括中央区域WGAN模型和边缘区域WGAN模型,在对待测目标图片进行基于计算机视觉的异常检测时,将待测目标图片也进行中央区域和边缘区域的划分,并分别使用对应的WGAN模型对待测目标图片的中央区域和边缘区域进行异常检测,其检测结果经过综合处理后,实现对待测目标正常与否的最终判断。
在本申请的一个实施例中,该方法还包括图片预处理,以应对GAN模型处理图片的尺寸限制,包括:在将目标图片输入GAN网络模型之前,重置目标图片的分辨率,使目标图片调整至预设像素尺寸的整数倍,并按照预设像素尺寸将目标图片分割成多张图片。
GAN网络受制于生成空间不能过大,否则会造成网络不稳定,因此生成的图片大小最多稳定在64X64尺寸大小,而实际检测中的图片多数远大于这个数值。因此,本申请在将目标图片输入GAN网络模型前,对原图片进行整数化和切割处理,首先将原图的分辨率重置为64的整数倍,然后裁切成数个64X64尺寸的小图(见图3、4所示),经过切割后每张小图足以采用64X64的大小完整显示。当然,这里的64X64尺寸仅是示意性实施例,实际应用中,也可根据需要,选择不同的预设像素尺寸,在此不再赘述。
在本申请的一个实施例中,对生成图片和待测目标图片进行基于像素值的差异检测,包括:
对生成图片和待测目标图片对应的低多样性区域进行差异检测,当检测结果为异常时,停止计算,直接判定待测目标异常;当检测结果为正常时,继续对生成图片和待测目标图片对应的高多样性区域进行差异检测。也就是说,在本实施例中,优先检测待测目标图片的低多样性区域正常与否,在检测确认低多样性区域正常后,才进行高多样性区域的检测。
由于低多样性区域中,目标图片的变化不多,多样性不高,因此即使是极细微的异常也会引起GAN模型重构生成图片与输入原图之间的显著差异,因此,因此本实施例首先对低多样性区域进行差异检测,若判断低多样性区域异常,则直接判断待测目标异常,停止计算,若判断低多样性区域正常,再进一步对高多样性区域进行差异检测,这样可以使异常检测过程更加简单和准确。
如图6所示,仍以中央-边缘划分的特征区域为例,本实施例输入待测图到GAN网络模型,生成重建图后,首先判定中央区域(低多样性区域)是否正常,若异常则直接判断待测目标异常,停止计算;若判定中央区域正常,再进一步判定边缘区域(高多样性区域)是否正常,若高多样性区域也正常,则可以判定待测目标正常,若高多样性区域异常,则判定待测目标异常。
在本申请的一个实施例中,对生成图片和待测目标图片进行基于像素值的差异检测,包括:
计算待测目标图片和生成图片低多样性区域的像素值差异,若计算结果不小于第一阈值,则判断待测目标图片低多样性区域异常,并停止计算,若计算结果小于第一阈值,则判断待测目标图片低多样性区域正常;继续计算待测目标图片和生成图片高多样性区域的像素值差异,若计算结果不小于第二阈值,则判断待测目标图片高多样性区域异常,若计算结果小于第二阈值,则判断待测目标图片正常。
在优选实施例中,对生成图片和待测目标图片进行基于像素值的差异检测,包括:计算待测目标图片与生成图片的每个像素值差值的二阶范数平方的平均值,将该平均值作为指示低多样性区域差异的计算结果。
具体地,针对低多样性区域,可以采用如下第一公式计算每个像素值差值的二阶范数平方的平均值:
Figure PCTCN2020123475-appb-000001
其中,n为低多样性区域总像素数,x为待测目标图片的像素值,G(x)为生成图片的像素值。通常情况下,当待测目标图片正常时,计算结果Lc的值会比较低,而当待测目标图片为异常图片时,计算结果Lc的值会远高于正常图片,通过设置合适的第一阈值即可判定待测目标图片的异常,实现待测目标的差异检测。
由于高多样性区域具有更高的多样性,因此生成图片的重构精度不如低多样性区域,对此,本实施例采用另一种评价体系计算高多样性区域的像素值差异。
优选地,继续对生成图片和待测目标图片对应的高多样性区域进行差异检测,包括:计算待测目标图片与生成图片的最大像素值差异和像素值累积差异;第二阈值为一组值,当最大像素值差异和像素值累积差异均不小于第二阈值中的对应值时,才认为计算结果不小于第二阈值,判断待测目标图片高多样性区域异常,其中,最大像素值差异指示了单张待测目标图片与对应的生成图片的像素值差异的最大值;像素值累积差异指示了属于同一待测目标的所有目标图片与对应的生成图片的像素值差异的累积值。
具体地,针对高多样性区域,采用如下第二公式计算待测目标图片与生成图片的最大像素值差异:
Figure PCTCN2020123475-appb-000002
m∈[1,M];第二公式
采用如下第三公式计算待测目标图片与生成图片的像素值累积差异:
Figure PCTCN2020123475-appb-000003
在第二公式和第三公式中,(i,j)代表高多样性区域每张图片中各像素的坐标,M为高多样性区域总的图片张数。
综合第二公式和第三公式即可判定高多样性区域是否为异常。其中,L bmax可以体现高多样性区域内,单张图片的像素值最大差异,L bsum可以体现整个高多样性区域的像素值累积差异。由于高多样性区域的生成图片精确程度不如低多样性区域,因此如果仍采用与低多样性区域同一判定方式会造成过多的误判,将正常的图片判为异常。所以,本实施例设计这种双重损失函数叠加的方式,仅有当高多样性区域的像素值累积差异和单张图片的像素值最大差异均达到对应阈值时,才判定待测目标异常,这样可以保证目标图片分割后每张小图的最 大异常和连续跨越多张小图的微小异常均能够被识别。对应地,第二阈值为一组值,分别针对L bmax和L bsum设置两个阈值,当L bmax和L bsum全都不小于对应阈值时即判定高多样性区域为异常。
在本申请的一个实施例中,方法还包括利用状态正常的图片训练集确定第一阈值和第二阈值的步骤,包括:
将状态正常的目标图片各特征区域训练集分别输入到训练后的GAN网络模型,得到生成图片,计算低多样性区域中每个像素值差值的二阶范数平方的平均值,选取计算结果的中位数以上预设位置处的数值作为第一阈值;计算高多样性区域的最大像素值差异和像素值累积差异,分别选取计算结果的中位数以上的预设位置处的数值组成第二阈值。优选地,在本实施例中,分别选取计算结果的中位数以上的15%或者20%或者25%位置处的数值作为对应阈值(第一阈值或第二阈值)。
本申请还公开了一种基于计算机视觉的异常检测装置,如图7所示,该装置包括:训练集生成模块710、训练模块720和检测模块730。
训练集生成模块710,用于根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集。
训练模块720,用于选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型。
检测模块730,用于对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。
在本申请的一个实施例中,训练集生成模块710,用于根据目标图片内容的多样性,将目标图片划分为低多样性区域和高多样性区域。
检测模块730,用于对生成图片和待测目标图片对应的低多样性区域进行差异检测,当检测结果为异常时,停止计算,直接判定待测目标异常;当检测结果为正常时,继续对生成图片和待测目标图片对应的高多样性区域进行差异检测。
在本申请的一个实施例中,训练集生成模块710,具体用于利用状态正常的目标图片的各特征区域分别组成训练集。
训练模块720,具体用于选取基于wasserstein距离的GAN网络WGAN作为使用的网络模型,利用训练集训练得到WGAN网络模型,该WGAN网络模型能够依据输入图片生成具有正常目标特征的图片。
在本申请的一个实施例中,训练集生成模块710,用于根据目标图片内容的多样性,将目标图片划分为低多样性区域和高多样性区域。
在本申请的一个实施例中,训练集生成模块710以及检测模块730,还用于在将目标图片输入GAN网络模型之前,重置目标图片的分辨率,使目标图片调整至预设像素尺寸的整数倍,并按照预设像素尺寸将目标图片分割成多张图片。
在本申请的一个实施例中,检测模块730,具体用于:计算待测目标图片和生成图片低多样性区域的像素值差异,若计算结果不小于第一阈值,则判断待测目标图片低多样性区域异常,并停止计算,若计算结果小于第一阈值,则判断待测目标图片低多样性区域正常,继续计算待测目标图片和生成图片高多样性区域的像素值差异,若计算结果不小于第二阈值,则判断待测目标图片高多样性区域异常,若计算结果小于第二阈值,则判断待测目标图片正常。
在本申请的一个实施例中,检测模块730,具体用于:计算待测目标图片与生成图片的每个像素值差值的二阶范数平方的平均值,将该平均值作为指示低多样性区域差异的计算结果。以及,计算待测目标图片与生成图片的最大像素值差异和像素值累积差异;其中,第二阈值为一组值,当最大像素值差异和像素值累积差异均不小于第二阈值中的对应值时,才认为计算结果不小于第二阈值,判断待测目标图片高多样性区域异常,最大像素值差异指示了单张待测目标图片与对应的生成图片的像素值差异的最大值;像素值累积差异指示了属于同一待测目标的所有目标图片与对应的生成图片的像素值差异的累积值。
具体地,针对低多样性区域,检测模块730可以采用如下第一公式计算每个像素值差值的二阶范数平方的平均值:
Figure PCTCN2020123475-appb-000004
其中,n为低多样性区域总像素数,x为待测目标图片的像素值,G(x)为生成图片的像素值。
针对高多样性区域,检测模块730可以采用如下第二公式计算待测目标图片与生成图片的最大像素值差异:
Figure PCTCN2020123475-appb-000005
m∈[1,M];
采用如下第三公式计算待测目标图片与生成图片的像素值累积差异:
Figure PCTCN2020123475-appb-000006
在第二公式和第三公式中,(i,j)代表高多样性区域每张图片中各像素的坐标,M为高多样性区域总的图片张数。
图8示出了本申请基于计算机视觉的异常检测装置的另一个实施例,如图8所示,该装置包括:训练集生成模块810、训练模块820、检测模块830以及阈值确定模块840。
阈值确定模块840,用于将状态正常的目标图片各特征区域训练集分别输入到训练后的GAN网络模型,得到生成图片,计算低多样性区域中每个像素值差值的二阶范数平方的平均值,选取计算结果的中位数以上预设位置处的数值作为第一阈值;计算高多样性区域的最大像素值差异和像素值累积差异,分别选取计算结果的中位数以上的预设位置处的数值组成第二阈值。优选地,在本实施例中,分别选取计算结果的中位数以上的20%位置处的数值作为对应阈值(第一阈值或第二阈值)。
本实施例提供的基于计算机视觉的异常检测装置的工作原理,与上述基于计算机视觉的异常检测方法对应相同,具体使用的公式以及参数选择,可以参考上述方法实施例的介绍,在此不再赘述。
图9示出了根据本发明一个实施例的电子设备的结构示意图。该电子设备900包括处理器910和被安排成存储计算机可执行指令(计算机可读程序代码)的存储器920。存储器920可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器920具有存储用于执行上述方法中的任何方法步骤的计算机可读程序代码931的存储空间930。例如,用于存储计算机可读程序代码的存储空间930可以包括分别用于实现上面的方法中的各种步骤的各个计算机可读程序代码931。计算机可读程序代码931可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为计算机可读存储介质。
具体的,存储器920存储的可执行指令在被执行时使处理器执行如下方法:
根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集;选取对抗生成网络GAN作为 使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型;
执行异常检测时,对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。
进一步的,可执行指令在被执行时使处理器还执行如下方法:
根据目标图片内容的多样性,将目标图片划分为低多样性区域和高多样性区域。
对生成图片和待测目标图片对应的低多样性区域进行差异检测,当检测结果为异常时,停止计算,直接判定待测目标异常;
当检测结果为正常时,继续对生成图片和待测目标图片对应的高多样性区域进行差异检测。
进一步的,可执行指令在被执行时使处理器还执行如下方法:
计算待测目标图片和生成图片低多样性区域的像素值差异,若计算结果不小于第一阈值,则判断待测目标图片低多样性区域异常,并停止计算,若计算结果小于第一阈值,则判断待测目标图片低多样性区域正常,继续计算待测目标图片和生成图片高多样性区域的像素值差异,若计算结果不小于第二阈值,则判断待测目标图片高多样性区域异常,若计算结果小于第二阈值,则判断待测目标图片正常。
本发明又一个实施例提供了一种计算机可读存储介质。该计算机可读存储介质存储有用于执行根据本发明的方法步骤的计算机可读程序代码,可以被电子设备的处理器读取,当计算机可读程序代码由电子设备运行时,导致该电子设备执行上面所描述的方法中的各个步骤,具体来说,该计算机可读存储介质存储的计算机可读程序代码可以执行上述任一实施例中示出的方法。计算机可读程序代码可以以适当形式进行压缩。
本实施例提供的电子设备和计算机可读存储介质中代码执行的具体功能,与上述基于计算机视觉的异常检测方法对应,具体内容可以参考上述方法实施例的介绍,在此不再赘述。
以上所述,仅为本发明的具体实施方式,在本发明的上述教导下,本领域技术人员可以在上述实施例的基础上进行其他的改进或变形。本领域技术人员 应该明白,上述的具体描述只是更好的解释本发明的目的,本发明的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种基于计算机视觉的异常检测方法,其中,该方法包括:
    根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集;
    选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型;
    执行异常检测时,对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。
  2. 根据权利要求1所述的基于计算机视觉的异常检测方法,其中,所述利用各个目标图片对应的特征区域分别组成训练集,包括:
    利用状态正常的目标图片的各特征区域分别组成训练集;
    所述选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,包括:
    选取基于wasserstein距离的GAN网络WGAN作为使用的网络模型,利用训练集训练得到WGAN网络模型,该WGAN网络模型能够依据输入图片生成具有正常目标特征的图片。
  3. 根据权利要求1或2所述的基于计算机视觉的异常检测方法,其中,所述根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,包括:
    根据目标图片内容的多样性,将目标图片划分为低多样性区域和高多样性区域。
  4. 根据权利要求3所述的基于计算机视觉的异常检测方法,其中,对生成图片和待测目标图片进行基于像素值的差异检测,包括:
    对生成图片和待测目标图片对应的低多样性区域进行差异检测,当检测结果为异常时,停止计算,直接判定待测目标异常;
    当检测结果为正常时,继续对生成图片和待测目标图片对应的高多样性区域进行差异检测。
  5. 根据权利要求4所述的基于计算机视觉的异常检测方法,其中,所述对生成图片和待测目标图片进行基于像素值的差异检测,包括:
    计算待测目标图片和生成图片低多样性区域的像素值差异,若计算结果不 小于第一阈值,则判断待测目标图片低多样性区域异常,并停止计算,若计算结果小于第一阈值,则判断待测目标图片低多样性区域正常;
    继续计算待测目标图片和生成图片高多样性区域的像素值差异,若计算结果不小于第二阈值,则判断待测目标图片高多样性区域异常,若计算结果小于第二阈值,则判断待测目标图片正常。
  6. 根据权利要求4所述的基于计算机视觉的异常检测方法,其中,所述对生成图片和待测目标图片进行基于像素值的差异检测,包括:计算待测目标图片与生成图片的每个像素值差值的二阶范数平方的平均值,将该平均值作为指示低多样性区域差异的计算结果。
  7. 根据权利要求6所述的基于计算机视觉的异常检测方法,其中,针对低多样性区域,采用如下第一公式计算每个像素值差值的二阶范数平方的平均值:
    Figure PCTCN2020123475-appb-100001
    其中,n为低多样性区域总像素数,x为待测目标图片的像素值,G(x)为生成图片的像素值。
  8. 根据权利要求6所述的基于计算机视觉的异常检测方法,其中,所述方法还包括:
    将状态正常的目标图片各特征区域训练集分别输入到训练后的GAN网络模型,得到生成图片,计算低多样性区域中每个像素值差值的二阶范数平方的平均值,选取计算结果的中位数以上预设位置处的数值作为所述第一阈值;计算高多样性区域的最大像素值差异和像素值累积差异,分别选取计算结果的中位数以上的预设位置处的数值组成所述第二阈值。
  9. 根据权利要求1所述的基于计算机视觉的异常检测方法,其中,该方法还包括:
    在将目标图片输入GAN网络模型之前,重置目标图片的分辨率,使目标图片调整至预设像素尺寸的整数倍,并按照预设像素尺寸将目标图片分割成多张图片。
  10. 根据权利要求6所述的基于计算机视觉的异常检测方法,其中,针对高多样性区域,采用如下第二公式计算待测目标图片与生成图片的最大像素值差异:
    Figure PCTCN2020123475-appb-100002
    其中,(i,j)代表高多样性区域每张图片中各像素的坐标,M为高多样性区域总的图片张数。
  11. 根据权利要求4所述的基于计算机视觉的异常检测方法,其中,所述对生成图片和待测目标图片对应的高多样性区域进行差异检测,包括:计算待测目标图片与生成图片的最大像素值差异和像素值累积差异;当所述最大像素值差异和所述像素值累积差异均不小于第二阈值中的对应值时,才认为计算结果不小于第二阈值,判断待测目标图片高多样性区域异常,其中,
    第二阈值为一组值;
    最大像素值差异指示了单张待测目标图片与对应的生成图片的像素值差异的最大值;
    像素值累积差异指示了属于同一待测目标的所有目标图片与对应的生成图片的像素值差异的累积值。
  12. 根据权利要求11所述的基于计算机视觉的异常检测方法,其中,采用如下第三公式计算待测目标图片与生成图片的像素值累积差异:
    Figure PCTCN2020123475-appb-100003
    其中,(i,j)代表高多样性区域每张图片中各像素的坐标,M为高多样性区域总的图片张数。
  13. 根据权利要求8所述的基于计算机视觉的异常检测方法,其中,
    分别选取计算结果的中位数以上的15%或者20%或者25%位置处的数值作为第一阈值或第二阈值。
  14. 一种基于计算机视觉的异常检测装置,其中,该装置包括:训练集生成模块、训练模块和检测模块;
    所述训练集生成模块,用于根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集;
    所述训练模块,用于选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型;
    所述检测模块,用于对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。
  15. 根据权利要求14所述的基于计算机视觉的异常检测装置,其中,所述训练集生成模块,用于根据目标图片内容的多样性,将目标图片划分为低多样性 区域和高多样性区域;
    所述检测模块,用于对生成图片和待测目标图片对应的低多样性区域进行差异检测,当检测结果为异常时,停止计算,直接判定待测目标异常;当检测结果为正常时,继续对生成图片和待测目标图片对应的高多样性区域进行差异检测。
  16. 根据权利要求15所述的基于计算机视觉的异常检测装置,其中,所述检测模块,具体用于:计算待测目标图片和生成图片低多样性区域的像素值差异,若计算结果不小于第一阈值,则判断待测目标图片低多样性区域异常,并停止计算,若计算结果小于第一阈值,则判断待测目标图片低多样性区域正常,继续计算待测目标图片和生成图片高多样性区域的像素值差异,若计算结果不小于第二阈值,则判断待测目标图片高多样性区域异常,若计算结果小于第二阈值,则判断待测目标图片正常。
  17. 根据权利要求16所述的基于计算机视觉的异常检测装置,其中,所述装置还包括阈值确定模块,用于将状态正常的目标图片各特征区域训练集分别输入到训练后的GAN网络模型,得到生成图片,计算低多样性区域中每个像素值差值的二阶范数平方的平均值,选取计算结果的中位数以上预设位置处的数值作为第一阈值;计算高多样性区域的最大像素值差异和像素值累积差异,分别选取计算结果的中位数以上的预设位置处的数值组成第二阈值。
  18. 一种电子设备,包括:处理器;以及被安排成存储计算机可执行指令的存储器,可执行指令在被执行时使处理器执行如下方法:
    根据目标图片的不同区域特征,将目标图片划分为至少两个特征区域,利用各个目标图片对应的特征区域分别组成训练集;
    选取对抗生成网络GAN作为使用的网络模型,分别使用不同特征区域的训练集训练GAN网络模型,得到对应不同特征区域的各GAN网络模型;
    执行异常检测时,对待测目标图片进行同样的特征区域划分,将待测目标图片的不同特征区域分别输入到对应的GAN网络模型中,获得生成图片,对生成图片和待测目标图片进行基于像素值的差异检测。
  19. 如权利要求18所述的电子设备,其中,可执行指令在被执行时使处理器还执行如下方法:
    根据目标图片内容的多样性,将目标图片划分为低多样性区域和高多样性区域。
    对生成图片和待测目标图片对应的低多样性区域进行差异检测,当检测结果为异常时,停止计算,直接判定待测目标异常;
    当检测结果为正常时,继续对生成图片和待测目标图片对应的高多样性区域进行差异检测。
  20. 如权利要求18所述的电子设备,其中,可执行指令在被执行时使处理器还执行如下方法:
    计算待测目标图片和生成图片低多样性区域的像素值差异,若计算结果不小于第一阈值,则判断待测目标图片低多样性区域异常,并停止计算,若计算结果小于第一阈值,则判断待测目标图片低多样性区域正常,继续计算待测目标图片和生成图片高多样性区域的像素值差异,若计算结果不小于第二阈值,则判断待测目标图片高多样性区域异常,若计算结果小于第二阈值,则判断待测目标图片正常。
PCT/CN2020/123475 2019-12-10 2020-10-24 一种基于计算机视觉的异常检测方法、装置及电子设备 WO2021114896A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/309,306 US12002195B2 (en) 2019-12-10 2020-10-24 Computer vision-based anomaly detection method, device and electronic apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911258334.8A CN111062918B (zh) 2019-12-10 2019-12-10 一种基于计算机视觉的异常检测方法及装置
CN201911258334.8 2019-12-10

Publications (1)

Publication Number Publication Date
WO2021114896A1 true WO2021114896A1 (zh) 2021-06-17

Family

ID=70300371

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/123475 WO2021114896A1 (zh) 2019-12-10 2020-10-24 一种基于计算机视觉的异常检测方法、装置及电子设备

Country Status (3)

Country Link
US (1) US12002195B2 (zh)
CN (1) CN111062918B (zh)
WO (1) WO2021114896A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111062918B (zh) 2019-12-10 2023-11-21 歌尔股份有限公司 一种基于计算机视觉的异常检测方法及装置
CN114078108B (zh) * 2020-08-11 2023-12-22 北京阅影科技有限公司 图像中异常区域的处理方法、装置和图像分割方法、装置
CN113554605B (zh) * 2021-07-07 2023-09-26 常州大学 一种基于特征匹配的织物异常区域检测方法
CN114596308A (zh) * 2022-04-02 2022-06-07 卡奥斯工业智能研究院(青岛)有限公司 基于5g网络的信息处理方法、装置、设备及介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101996308A (zh) * 2009-08-19 2011-03-30 北京中星微电子有限公司 人脸认证方法及***、人脸模型训练方法及***
CN102609680A (zh) * 2011-12-22 2012-07-25 中国科学院自动化研究所 一种基于三维深度图像信息的并行统计学习人体部位检测方法
CN103226616A (zh) * 2013-05-16 2013-07-31 南京龙渊微电子科技有限公司 一种图像内容检索***及其图像内容稀疏学习方法
US8705866B2 (en) * 2010-12-07 2014-04-22 Sony Corporation Region description and modeling for image subscene recognition
CN109461458A (zh) * 2018-10-26 2019-03-12 合肥工业大学 一种基于生成对抗网络的音频异常检测方法
CN110211114A (zh) * 2019-06-03 2019-09-06 浙江大学 一种基于深度学习的装箱缺条视觉检测方法
CN111062918A (zh) * 2019-12-10 2020-04-24 歌尔股份有限公司 一种基于计算机视觉的异常检测方法及装置

Family Cites Families (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104458748B (zh) * 2013-09-25 2017-02-08 中国科学院沈阳自动化研究所 基于机器视觉的铝型材表面缺陷检测方法
JP6642161B2 (ja) * 2016-03-18 2020-02-05 株式会社リコー 検査装置、検査方法及びプログラム
US10624558B2 (en) * 2017-08-10 2020-04-21 Siemens Healthcare Gmbh Protocol independent image processing with adversarial networks
CN108009628B (zh) * 2017-10-30 2020-06-05 杭州电子科技大学 一种基于生成对抗网络的异常检测方法
CN108961272B (zh) * 2018-07-02 2021-10-26 浙江工业大学 一种基于深度卷积对抗生成网络的皮肤病图像的生成方法
CN109447895B (zh) * 2018-09-03 2021-06-08 腾讯科技(武汉)有限公司 图片生成方法和装置、存储介质及电子装置
CN109584221B (zh) * 2018-11-16 2020-07-28 聚时科技(上海)有限公司 一种基于监督式生成对抗网络的异常图像检测方法
CN109583364A (zh) * 2018-11-27 2019-04-05 上海鹰瞳医疗科技有限公司 图像识别方法及设备
CN109829895B (zh) * 2019-01-09 2021-08-17 武汉精立电子技术有限公司 一种基于gan的aoi缺陷检测方法
CN109872313A (zh) * 2019-02-15 2019-06-11 苏州晓创光电科技有限公司 一种基于深度卷积自编码器的产品表面缺陷检测方法
CN109949305B (zh) * 2019-03-29 2021-09-28 北京百度网讯科技有限公司 产品表面缺陷检测方法、装置及计算机设备
CN110135273B (zh) * 2019-04-19 2020-05-22 中铁第一勘察设计院集团有限公司 接触网视频图像云端智能监测与故障识别方法
CN110097543B (zh) * 2019-04-25 2023-01-13 东北大学 基于生成式对抗网络的热轧带钢表面缺陷检测方法
CN110349135A (zh) * 2019-06-27 2019-10-18 歌尔股份有限公司 目标检测方法和装置
CN110490858B (zh) * 2019-08-21 2022-12-13 西安工程大学 一种基于深度学习的织物缺陷像素级分类方法

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101996308A (zh) * 2009-08-19 2011-03-30 北京中星微电子有限公司 人脸认证方法及***、人脸模型训练方法及***
US8705866B2 (en) * 2010-12-07 2014-04-22 Sony Corporation Region description and modeling for image subscene recognition
CN102609680A (zh) * 2011-12-22 2012-07-25 中国科学院自动化研究所 一种基于三维深度图像信息的并行统计学习人体部位检测方法
CN103226616A (zh) * 2013-05-16 2013-07-31 南京龙渊微电子科技有限公司 一种图像内容检索***及其图像内容稀疏学习方法
CN109461458A (zh) * 2018-10-26 2019-03-12 合肥工业大学 一种基于生成对抗网络的音频异常检测方法
CN110211114A (zh) * 2019-06-03 2019-09-06 浙江大学 一种基于深度学习的装箱缺条视觉检测方法
CN111062918A (zh) * 2019-12-10 2020-04-24 歌尔股份有限公司 一种基于计算机视觉的异常检测方法及装置

Also Published As

Publication number Publication date
CN111062918A (zh) 2020-04-24
CN111062918B (zh) 2023-11-21
US12002195B2 (en) 2024-06-04
US20220309635A1 (en) 2022-09-29

Similar Documents

Publication Publication Date Title
WO2021114896A1 (zh) 一种基于计算机视觉的异常检测方法、装置及电子设备
EP3674852B1 (en) Method and apparatus with gaze estimation
CN109076198B (zh) 基于视频的对象跟踪遮挡检测***、方法和设备
CN105095905B (zh) 目标识别方法和目标识别装置
CN105243395B (zh) 一种人体图像比对方法和装置
CN108090458A (zh) 人体跌倒检测方法和装置
RU2607774C2 (ru) Способ управления в системе захвата изображения, устройство управления и машиночитаемый носитель данных
WO2017163955A1 (ja) 監視システム、画像処理装置、画像処理方法およびプログラム記録媒体
EP2983131A1 (en) Method and device for camera calibration
CN108564010A (zh) 一种安全帽佩戴的检测方法、装置、电子设备及存储介质
US9947164B2 (en) Automatic fault diagnosis method and device for sorting machine
CN111898486B (zh) 监控画面异常的检测方法、装置及存储介质
KR20140045854A (ko) 단일객체에 대한 기울기를 추정하는 영상을 감시하는 장치 및 방법
JP2015041164A (ja) 画像処理装置、画像処理方法およびプログラム
WO2011148439A1 (ja) 動作解析装置および動作解析方法
CN110287791A (zh) 一种用于人脸图片的筛选方法和***
CN108875474A (zh) 评估人脸识别算法的方法、装置及计算机存储介质
JP2018026115A (ja) 火炎検出方法、火炎検出装置及び電子機器
JP2011210054A (ja) 対象物検知装置及びその学習装置
CN111915541B (zh) 基于人工智能的图像增强处理方法、装置、设备及介质
CN115171218A (zh) 一种基于图像识别技术的物资送样异常行为识别***
CN116310568A (zh) 图像异常的识别方法、装置、计算机可读存储介质及设备
KR101581162B1 (ko) 실시간 영상 기반의 화염, 연기 및 물체 움직임 자동 감지 방법, 장치 및 시스템
CN111753587A (zh) 一种倒地检测方法及装置
CN109858319A (zh) 图像处理设备及控制方法和非暂时性计算机可读存储介质

Legal Events

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

Ref document number: 20898623

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20898623

Country of ref document: EP

Kind code of ref document: A1