Abnormality detection method and device

By separating the semantic segmentation map of the object to be detected from the image to be detected and generating feature data, the problem of difficulty in detecting structural relationship abnormalities in image recognition in the existing technology is solved, and higher detection precision and accuracy are achieved.

CN118644437APending Publication Date: 2024-09-13HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310261362.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-13
Publication Date
2024-09-13

AI Technical Summary

Technical Problem

When the existing technology uses image recognition for anomaly detection, it is difficult to accurately detect abnormal structural relationships in the image. Especially when there are abnormal structural relationships between multiple targets in the image, the detection accuracy is insufficient.

Method used

By separating the semantic segmentation map of the object to be detected from the image to be detected, the first feature data reflecting the structural relationship of the target elements is generated, and compared with the second feature data of the standard object to determine whether the object to be detected is abnormal. The method includes obtaining an image to be detected, cropping the image to remove interference parts, using a semantic segmentation and feature extraction model to generate first feature data, and comparing it with standard feature data to determine anomalies.

Benefits of technology

It improves the accuracy and precision of anomaly detection, can more effectively identify structural anomalies between multiple targets in images, reduces the interference of other image content on detection results, and improves detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118644437A
    Figure CN118644437A
Patent Text Reader

Abstract

The invention provides an anomaly detection method and device, and relates to the field of image processing. The method is used for improving the detection precision in the process of performing anomaly detection by using an image recognition technology. The method comprises the following steps: acquiring a to-be-detected image containing a to-be-detected object; and separating a to-be-detected object from the to-be-detected image, and generating first feature data of the to-be-detected object. Comparing the first feature data with second feature data of a standard object corresponding to the to-be-detected object; and determining whether the to-be-detected object is abnormal according to a result of the comparison operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to an anomaly detection method and device. Background Art

[0002] At present, with the development of image recognition technology, many application scenarios have begun to apply image recognition technology to perform anomaly detection on objects to be detected.

[0003] For example, in the production line of traditional manufacturing, you can collect images of products, and then use image recognition technology to input the collected images into a pre-trained artificial intelligence (AI) model, and then judge whether the product is abnormal based on the output results of the AI ​​model.

[0004] Among them, how to improve the detection accuracy in the process of using image recognition technology for anomaly detection is a problem that needs to be solved at present. Summary of the invention

[0005] The present application provides an anomaly detection method and device for improving detection accuracy in the process of performing anomaly detection using image recognition technology.

[0006] In a first aspect, an abnormality detection method is provided, the method comprising: obtaining an image to be detected containing an object to be detected; separating the object to be detected from the image to be detected, and generating first feature data of the object to be detected; performing a comparison operation on the first feature data and second feature data of a standard object corresponding to the object to be detected; and determining whether the object to be detected is abnormal according to the result of the comparison operation.

[0007] In the abnormality detection method provided by the present application, after acquiring the image to be detected, the object to be detected can be separated from the image to be detected, and the first feature data of the object to be detected can be generated. In this way, the influence of the features of other image contents in the image on the above-mentioned first feature data is avoided, so that the first feature data can more accurately reflect the features of the object to be detected. Thereby, the first feature data is used to perform a comparison operation with the second feature data of the standard object, and according to the result of the comparison operation, it can be determined whether the object to be detected is abnormal, so that a more accurate detection result can be obtained.

[0008] In one implementation, the object to be detected includes a structural relationship between at least two targets, and the above-mentioned abnormality is an abnormality in the structural relationship between at least two targets. Through the above-mentioned implementation, the method provided by the present application can separate the structural relationship between at least two targets from the image to be detected, and then generate first feature data that can reflect the structural relationship between at least two targets. In this way, the structural abnormality can be detected more accurately, thereby further improving the detection accuracy.

[0009] In one implementation, the method further includes: inputting a plurality of sample images containing a standard object into an AI model to obtain second feature data of the standard object. In the above implementation, by using an AI model for extracting feature data to extract feature data of a plurality of sample images containing a standard object, and then obtaining the above second feature data, the effect of accurately and efficiently determining the second feature data can be achieved.

[0010] In one implementation, the method further includes: inputting the object to be detected into the AI ​​model to obtain first feature data of the object to be detected. In the above implementation, by using the AI ​​model for extracting feature data to extract feature data, the feature data of the object to be detected is extracted, and then the above first feature data is obtained, thereby achieving the effect of accurately and efficiently determining the first feature data.

[0011] In one implementation, separating the object to be detected from the image to be detected includes: determining a semantic segmentation map of at least two targets based on the image to be detected, wherein the semantic segmentation map includes a structural relationship between the at least two targets. Generating first feature data of the object to be detected includes: generating first feature data of the semantic segmentation map of at least two targets. In the above implementation, the structural relationship between the at least two targets is represented by using the semantic segmentation map of at least two targets, and then the first feature data of the object to be detected can be generated by extracting features from the semantic segmentation map.

[0012] In one implementation, generating first feature data of a semantic segmentation map of at least two targets includes: dividing the semantic segmentation map into n image blocks, where n is a positive integer greater than 1. Performing feature extraction on the n image blocks to obtain feature data of each of the n image blocks. Merging the feature data of each of the n image blocks to obtain first feature data. Through the above implementation, by dividing the semantic segmentation map into multiple image blocks, and performing feature extraction on each image block to obtain feature data, and then merging each feature data to obtain the first feature data, the first feature data that can reflect the structural features of the target element can be obtained.

[0013] In one implementation, obtaining an image to be detected that includes an object to be detected includes: obtaining an original image that includes the object to be detected. Cropping the original image to obtain an image to be detected of a preset size. In the above implementation, it is considered that the size of the original image captured by the camera device is usually large, and the part involved in the abnormality detection process may only occupy a part of the original image. In the above implementation, on the one hand, the image to be detected is obtained by cropping the original image, thereby avoiding interference of other parts of the original image on the inspection result; on the other hand, in the process of cropping the original image, the image to be detected is obtained by cropping it according to a preset size, thereby standardizing the size of the image to be detected, so as to facilitate the subsequent processing of the image to be detected.

[0014] In a second aspect, an abnormality detection device is provided, comprising: an acquisition unit, configured to acquire an image to be detected containing an object to be detected; a feature extraction unit, configured to separate the object to be detected from the image to be detected and generate first feature data of the object to be detected; a determination unit, configured to compare the first feature data with second feature data of a standard object corresponding to the object to be detected; and determine whether the object to be detected is abnormal according to the result of the comparison operation.

[0015] In one implementation, the object to be detected includes a structural relationship between at least two targets, and the anomaly is an abnormality in the structural relationship between the at least two targets.

[0016] In one implementation, the feature extraction unit is further used to input multiple sample images containing the standard object into the AI ​​model to obtain second feature data of the standard object.

[0017] In one implementation, the feature extraction unit is further used to input the object to be detected into the AI ​​model to obtain first feature data of the object to be detected.

[0018] In one implementation, separating the object to be detected from the image to be detected includes: determining a semantic segmentation map of at least two targets based on the image to be detected, wherein the semantic segmentation map includes a structural relationship between the at least two targets. Generating first feature data of the object to be detected includes: generating first feature data of the semantic segmentation map of at least two targets.

[0019] In a third aspect, an anomaly detection device is provided, comprising a memory and a processor, wherein the memory is used to store computer instructions, and the processor is used to call and execute computer instructions from the memory to implement the method described in the first aspect or any implementation method of the first aspect.

[0020] In a fourth aspect, an abnormality detection system is provided, comprising: the abnormality detection device as described in the second aspect or any implementation of the second aspect or the third aspect. The abnormality detection system also includes: at least one of a camera device, a display device, and an alarm device.

[0021] According to a fifth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a processor, the method described in the first aspect or any implementation method of the first aspect is implemented.

[0022] According to a sixth aspect, a computer program product is provided, the computer program product comprising instructions, which, when executed on a processor, implement the method as described in the first aspect or any implementation of the first aspect.

[0023] The technical effects produced by any implementation method in the above-mentioned second to sixth aspects and each aspect can refer to the above-mentioned first aspect and the corresponding implementation method in the first aspect, and the repetitive parts will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 One of the flowcharts of an anomaly detection method provided in an embodiment of the present application;

[0025] Figure 2 A schematic diagram of bundling electric wires with a cable tie provided in an embodiment of the present application;

[0026] Figure 3 A schematic diagram of bundling electric wires using a spherical twist tie provided in an embodiment of the present application;

[0027] Figure 4 A second flowchart of an anomaly detection method provided in an embodiment of the present application;

[0028] Figure 5 A schematic diagram of the structure of an anomaly detection system provided in an embodiment of the present application;

[0029] Figure 6 A third flowchart of an anomaly detection method provided in an embodiment of the present application;

[0030] Figure 7 A schematic diagram of cutting out an abnormal image to be detected from an original image provided in an embodiment of the present application;

[0031] Figure 8 A schematic diagram of an abnormal image to be detected and a semantic segmentation map provided in an embodiment of the present application;

[0032] Fig. 9 A fourth flowchart of an anomaly detection method provided in an embodiment of the present application;

[0033] Fig.10 A schematic diagram of a process for training a semantic segmentation model provided in an embodiment of the present application;

[0034] Fig.11 A schematic diagram of a process of training a feature extractor provided in an embodiment of the present application;

[0035] Fig.12 One of the structural schematic diagrams of an abnormality detection device provided in an embodiment of the present application;

[0036] Fig.13 The second structural schematic diagram of an abnormality detection device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0037] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0038] To facilitate understanding of the technical solutions provided by the embodiments of the present application, the technical terms involved in the embodiments of the present application are first introduced:

[0039] The semantics of an image is a common concept in the field of image recognition. The semantics of an image can be understood as the information contained in the image when it is parsed from the perspective of natural language. Specifically, the semantics of an image can usually be divided into three parts: the visual layer, the object layer, and the conceptual layer. Among them, the visual layer is the underlying features that are usually understood, that is, the color, texture, and shape of the image, etc.; the object layer usually contains the attribute characteristics of each object in the image, that is, the state of a certain object at this moment; the conceptual layer is the image that expresses the closest thing to human understanding. In layman's terms, for example, if there are sand, blue sky, sea water, etc. on a picture, the visual layer is the distinction between color blocks, the object layer is sand, blue sky, and sea water, and the conceptual layer is the beach. This is the semantics expressed in this picture.

[0040] Usually, for the convenience of description, the underlying features of an image, such as color, texture, and shape, which cannot express the concept of the entire image, are called "low-level semantics". In addition, the image features such as the meaning contained in the image as a whole and the artificially assigned concepts (for example, concepts such as "cat", "dog" or "lawn") are called "high-level semantics". Compared with low-level semantics, high-level semantics are characterized by abstraction, complexity, and ambiguity. For example, compared with the "object layer" and "concept layer" semantics, the "visual layer" semantics is low-level semantics; compared with the "visual layer" and "object layer" semantics, the "concept layer" semantics is high-level semantics.

[0041] To facilitate understanding of the technical solution provided by the embodiments of the present application, the following is an introduction to the method of using image recognition technology to perform abnormality detection in the related art. Figure 1 As shown, the method specifically comprises the following steps:

[0042] S101. Train a semantic segmentation model for identifying abnormal regions in an image.

[0043] For example, multiple sample images containing abnormal products can be obtained, and the abnormal areas in each sample image can be annotated. Then, the semantic segmentation model can be trained using the sample images and annotations.

[0044] Taking the desk as an example, an abnormal product may be a desk with scratches on the desktop. You can first obtain multiple images of scratched desktops (i.e., multiple sample images of abnormal products) and mark the abnormal areas (i.e., scratched areas) in the sample images. Then, use these sample images and annotations to train a semantic segmentation model. In this way, you can get a semantic segmentation model that can identify scratched areas on the desktop.

[0045] S102: Input the image of the product to be detected into a trained semantic segmentation model, and the semantic segmentation model outputs information about abnormal areas in the image of the product to be detected.

[0046] For example, an image of a desk to be inspected is input into a semantic segmentation model, which can output information about the scratched area on the desk (e.g., location or size, etc.). In this way, based on the information about the abnormal area, it can be determined whether the product is abnormal.

[0047] However, in the embodiments of the present application, it is considered that the above-mentioned related technologies can usually only detect abnormal regions that are different from the low-level semantics (color, texture, shape, etc.) of normal regions in the image. In actual applications, there may be other types of abnormalities.

[0048] For example, take the scenario of bundling and arranging the wires in the electrical equipment during the production process as an example:

[0049] For example, when using cable ties to bundle wires, the image after normal bundling is as follows: Figure 2 If there is a mistake in the bundling process, the following may occur: Figure 2 (b) shows that part of the wire is not wrapped inside the cable tie (i.e., there is an abnormality in the structural relationship). Figure 2 In (a) or (b), the elements in the image include: wires and cable ties. That is, in Figure 2 The low-level semantics (i.e., color, texture, and shape) of the image in the abnormal case shown in (b) are different from Figure 2 In the normal case shown in (a), the low-level semantics of the image do not have significant differences. Therefore, if the technical solutions provided by the above-mentioned related technologies are used, it is difficult to detect such abnormal situations.

[0050] For another example, when using a ball-shaped twist tie to bundle wires, the image after normal bundling is as follows: Figure 3 If there is a mistake in the bundling process, the following may occur: Figure 3 As shown in (b) above, some wires are not wrapped in the cable tie, or Figure 3 (c) shows the situation where the ball twist buckle is not fastened. Figure 2 The same is true for the scene shown. It can be seen that Figure 3 (a) shows the normal situation and Figure 3 In the abnormal cases shown in (b) and (c), there is no significant difference in the low-level semantics of the image. Therefore, it is difficult to detect such abnormal cases using the technical solutions provided by the above-mentioned related technologies.

[0051] In response to the above problems, the embodiments of the present application take into account that: usually, in addition to the object to be detected, the image to be detected may also include other image contents, and these other image contents may not only be of no help in accurately judging whether the object to be detected is abnormal, but may increase the error of the detection result.

[0052] For example, in Figure 3 In the scenario shown, in order to determine whether the spherical twist buckle is fastened, the structural relationship between the two small balls on the spherical twist buckle in the image to be detected can be used to determine whether the spherical twist buckle is fastened. Specifically, when it can be determined that the two small balls are in a state of separation from each other based on the structural relationship between the two small balls in the image to be detected, it can be determined that the spherical twist buckle is not fastened. At this time, the image content of other elements in the image to be detected (such as the wires in the figure and the twisted wire part of the spherical twist buckle) in the image to be detected will have no effect on the determination of whether the spherical twist buckle is fastened, and may even interfere with the determination.

[0053] For example, in Figure 2 In the scenario shown, in order to determine whether all the wires are wrapped by cable ties, the structural relationship between each wire and cable ties in the image to be detected can be used to determine whether all the wires are wrapped by cable ties. For example, when it can be determined that there are wires that are not blocked by cable ties based on the structural relationship between each wire and cable ties in the image to be detected, it can be determined that there are wires that are not wrapped by cable ties. At this time, the image content of other elements in the image to be detected (for example, if the background of the image also includes other components such as the product's housing, circuit board, etc., these components are other elements) in the image to be detected has no effect on the determination of whether all the wires are wrapped by cable ties, and may even interfere with the determination.

[0054] Therefore, an abnormality detection method and device are provided in the embodiments of the present application. Figure 4As shown, in this method, after obtaining an image to be detected containing an object to be detected (S201), the object to be detected can be separated from the image to be detected (S202), and first feature data of the object to be detected can be generated (S203), and then the first feature data can be compared with the second feature data of a standard object corresponding to the object to be detected, and whether the object to be detected is abnormal can be determined based on the comparison result (S204).

[0055] Compared with the related art, which usually uses the semantics of the entire image to be detected as a basis to detect whether there is an abnormal area in the image (such as the above Figure 1 In the technical solution shown, the entire image to be detected is input into the semantic segmentation model to detect the abnormal area in the image), and then determine whether the object to be detected is abnormal. In the abnormality detection method provided in the embodiment of the present application, after the image to be detected is obtained, the object to be detected is separated from the image to be detected, and the first feature data of the object to be detected is generated. In this way, the influence of the features of other image contents in the image on the above-mentioned first feature data is avoided, so that the first feature data can more accurately reflect the features of the object to be detected. Thereby, the first feature data is used to compare with the second feature data of the standard object, and it is determined whether the object to be detected is abnormal based on the result of the comparison operation, so that a more accurate detection result can be obtained.

[0056] The following is a detailed introduction to the anomaly detection method provided in the embodiments of the present application with reference to examples.

[0057] First, the application scenarios of the anomaly detection method provided in the embodiment of the present application are introduced:

[0058] The anomaly detection method provided in the embodiment of the present application can be applied to various anomaly detection devices, so that the anomaly detection device can operate according to the method provided in the embodiment of the present application during operation, thereby determining whether the product to be detected is abnormal. In actual application, the function of the above-mentioned anomaly detection device can be implemented by a personal computer (including desktop computers, laptop computers, handheld computers and notebook computers, etc.), an ultra-mobile personal computer (UMPC), or a smart phone, server and other electronic devices; or, the function of the above-mentioned anomaly detection device can also be implemented by some hardware / software devices in the above-mentioned electronic devices. The embodiment of the present application does not impose any special restrictions on the specific form of the anomaly detection device.

[0059] like Figure 5As shown, it is a schematic diagram of the structure of an abnormality detection system provided in an embodiment of the present application. The abnormality detection system 30 can be used to detect abnormalities in the production process of consumer electronics, servers, automobiles, chemical fiber products, printed circuit boards (PCB) / printed circuit board assemblies (PCBA) and steel products; or the abnormality detection system 30 can also be used to detect abnormalities in wafer inspection or semiconductor packaging and testing.

[0060] The anomaly detection system 30 includes an anomaly detection device 301 that can be operated according to the method provided in the embodiment of the present application. In addition, the anomaly detection system 30 may also include: a camera device 302, a display device 303 and an alarm device 304 connected to the anomaly detection device 301.

[0061] The camera device 302 can be used to capture images of products on the production line and transmit the images to the anomaly detection device 301, so that the anomaly detection device 301 can determine whether the object to be detected in the image is abnormal according to the method provided in the embodiment of the present application. Specifically, the camera device 302 can be a camera, or the camera device 302 can also be other devices with a shooting function (such as a camera, a video camera, or a smart phone, etc.).

[0062] The display device 303 can be used to output the detection result of the abnormality detection device 301 on a display interface. Specifically, the display device 303 can be a display screen, a touch screen, or other devices that can output information on a display interface (for example, the display device 303 can be a personal computer, a smart phone, or a tablet computer, etc.).

[0063] The alarm device 304 can be used to send out an alarm signal after the abnormality detection device 301 detects an abnormality. Specifically, the alarm device 304 can be a buzzer, a sound, or a warning light.

[0064] The following is a detailed introduction to the anomaly detection method provided by the embodiment of the present application in conjunction with the operation process of the anomaly detection device 301. Specifically, the method may include:

[0065] S41. The abnormality detection device 301 obtains an image to be detected including an object to be detected.

[0066] For example, after the camera device 302 captures an image of the product, the image can be transmitted to the abnormality detection device 301. The abnormality detection device 301 can use the received image as an image to be detected for subsequent processing. Part or all of the components on the product can be selected as the object to be detected as needed.

[0067] In one implementation, considering that the size of the original image captured by the camera device 302 is usually large, and the part involved in the abnormality detection process may only occupy a part of the original image. Therefore, S41 may specifically include:

[0068] S411 . The abnormality detection device 301 obtains an original image including an object to be detected.

[0069] like Figure 6 As shown, the abnormality detection device 301 can receive an original image from the camera device 302, and the original image includes an object to be detected.

[0070] S412: The anomaly detection device 301 crops the original image to obtain an image to be detected of a preset size.

[0071] Through the above implementation method, on the one hand, the image to be detected is obtained by cropping the original image, thereby avoiding interference of other parts of the original image on the inspection result; on the other hand, in the process of cropping the original image, the image to be detected is obtained by cropping it according to a preset size, thereby standardizing the size of the image to be detected, so as to facilitate subsequent processing of the image to be detected.

[0072] by Figure 3 Taking the scene shown in the figure as an example, checking whether the spherical twist buckle is fastened, the original image obtained by the abnormality detection device 301 is as follows: Figure 7 As shown in (a), it can be seen that the image of the bundled wires only occupies a part of the lower right corner of the original image (it should be noted that Figure 7 (a) is a schematic diagram of the original image. Except for the image of the bundled wires, other parts of the image are not shown and replaced by shadows. Then, through the contents of S411-S412 above, the image to be detected of a preset size can be cropped from the original image, such as Figure 7 As shown in (b).

[0073] In this case, it is considered that when the camera 302 shoots the product from a fixed angle, the position of the target element in the original image is also fixed. For example, when the camera 302 shoots the product from a fixed angle, the structure of the original image shot by the camera 302 for different products can be as follows: Figure 7 As shown in (a), the bundled wires are all in the lower right corner of the original image. Therefore, in a possible design, S412 may specifically include:

[0074] S412a, the abnormality detection device 301 cuts out an image to be detected of a preset size with a preset coordinate position in the original image as the center.

[0075] by Figure 7 For example, the preset coordinate position can be a point in the lower right corner of the original image. By taking this point as the center, you can crop Figure 7 The image to be detected is shown in (b).

[0076] In another possible design, considering that when determining the position of the image to be detected in the original image, an easily identifiable object can be first identified from the original image, and then the relative position between the object and the image to be detected is used to determine the position of the image to be detected in the original image. Therefore, S412 may further specifically include:

[0077] S412b: The abnormality detection device 301 cuts out the image to be detected of a preset size according to the relative position between the preset object and the image to be detected.

[0078] For example, suppose the original image includes a screw with a unique shape (i.e., a preset object), and the relative position between the screw and the image to be detected is fixed. Then, the image recognition technology can be used to identify the position of the screw in the original image, and then the position of the image to be detected in the original image can be determined based on the relative position between the screw and the image to be detected, and then cropped.

[0079] After the abnormality detection device 301 acquires the image to be detected, the method further includes:

[0080] S42: The abnormality detection device 301 separates the object to be detected from the image to be detected.

[0081] In the actual application process, the object to be detected can be set according to actual needs. For example, the object to be detected can include one or more elements in the image. Figure 3 In the scenario shown, when it is necessary to determine whether the product is abnormal by judging whether the spherical twist buckle is fastened, the two small balls on the spherical twist buckle can be selected as the objects to be detected. Figure 2 In the scenario shown, when it is necessary to determine whether the product is abnormal by determining whether all wires are wrapped with cable ties, each wire and cable tie can be used as the object to be detected.

[0082] In addition, in one implementation, the above-mentioned object to be detected may specifically include a structural relationship between at least two targets. Furthermore, the abnormality of the object to be detected may specifically be reflected as a structural abnormality between the above-mentioned at least two targets.

[0083] Among them, each "target" in the at least two "targets" referred to in the embodiments of the present application may be any element in the image to be detected. The structural relationship between the at least two targets may include the mutual relationship between the at least two targets in terms of position, size, level, shape, etc. The abnormality of the object to be detected may be reflected in the abnormality of the at least two targets in terms of position, size, level, shape, etc.

[0084] For example, in Figure 3 In the scenario shown, when it is necessary to determine whether the product is abnormal by determining whether the spherical twist buckle is fastened, the two balls on the spherical twist buckle are the two targets, and the structural relationship between the two balls is the structural relationship between the two targets. Specifically, the structural relationship between the two targets may include: the distance between the two balls, the size relationship between the two balls, whether the two balls cover each other (i.e., the level of the two balls), whether the two balls are complete in shape, etc.

[0085] For example, in Figure 2 In the scenario shown, when it is necessary to determine whether the product is abnormal by determining whether all the wires are wrapped by cable ties, the objects to be detected include each wire and cable tie, each of which is taken as a target; the structural relationship between each wire and cable tie is the structural relationship between at least two targets. Specifically, the structural relationship between at least two targets may include: the distance between any two targets in each wire and cable tie, the size relationship between each wire, whether the targets overlap each other (i.e., the hierarchy of each target), whether the shape of each target is complete, etc.

[0086] Specifically, in a possible design, considering that the semantic segmentation maps of at least two targets can be used to represent the structural relationship between the at least two targets, the process of separating the object to be detected from the image to be detected can be specifically implemented by determining the semantic segmentation maps of at least two targets.

[0087] Therefore, if Figure 6 As shown, S42 may specifically include: the anomaly detection device 301 determines semantic segmentation maps of at least two targets (hereinafter referred to as semantic segmentation maps s for ease of distinction) according to the image to be detected.

[0088] For example, semantic segmentation may be performed on at least two targets in the image to be detected, thereby obtaining a semantic segmentation map s.

[0089] Specifically, the semantic segmentation map s can be an image of the same size as the image to be detected (for example, if the image to be detected is a pixels long and b pixels wide, then the semantic segmentation map s can also be a pixel long and b pixels wide), or the semantic segmentation map s can also be an image that is proportionally reduced (or enlarged) in length and width of the image to be detected (for example, if the image to be detected is a pixels long and b pixels wide, then the semantic segmentation map s can be 2a pixels long and 2b pixels wide; or the semantic segmentation map s can be a / 2 pixels long and b / 2 pixels wide).

[0090] by Figure 3 Take the scene shown in the figure for example to check whether the ball twist buckle is fastened. Figure 8 (a) is a schematic diagram of four images to be detected. After semantic segmentation of the two balls (i.e., two targets) in the image to be detected, the semantic segmentation map is as follows: Figure 8 As shown in (b).

[0091] In practical applications, the semantic segmentation map s may be a grayscale image. For example, the semantic segmentation map s may be an image of size (h, w, 1). h indicates that the length of the semantic segmentation map is h pixels, w indicates that the width of the semantic segmentation map is w pixels, and 1 indicates that the semantic segmentation map has only one color channel (i.e., a grayscale image). Each of the at least two targets may correspond to a grayscale value in the color channel.

[0092] In addition, the semantic segmentation map s can be a color image. For example, the semantic segmentation map s can be an image of size (h, w, 3). Among them, h means that the length of the semantic segmentation map is h pixels, w means that the width of the semantic segmentation map is w pixels, and 3 means that the semantic segmentation map has three color channels, such as red, green, and blue (RGB). Among them, each of the at least two targets can correspond to different RGB values. In addition, in addition to the three color channels, the semantic segmentation map s can also be a color image including other numbers of color channels. There is no limitation on this in the embodiments of the present application.

[0093] In a possible design, the embodiment of the present application can also use an artificial intelligence model for segmenting semantics to perform semantic segmentation on at least two targets in the image to be detected. Figure 6 As shown, the anomaly detection device 301 includes a semantic segmentation model 3011. The semantic segmentation model 3011 can be run as a software module in the anomaly detection device 301. The semantic segmentation model 3011 is used to semantically segment the target elements in the product image after inputting the product image, and output a semantic segmentation map. Therefore, S42 can specifically include: inputting the image to be detected into the semantic segmentation model 3011 to obtain a semantic segmentation map s.

[0094] The process of training the semantic segmentation model 3011 will be described in the following S501-S502, but will not be described here.

[0095] After separating the object to be detected from the image to be detected, the method further includes:

[0096] S43. The abnormality detection device 301 generates first feature data of the object to be detected.

[0097] In one implementation, when the semantic segmentation map s of at least two targets is used to represent the structural relationship between at least two targets in the object to be detected, S43 may include: the anomaly detection device 301 extracts features from the semantic segmentation map s to obtain first feature data.

[0098] Exemplarily, the anomaly detection device 301 can use various types of feature extraction models to extract features from the semantic segmentation map s to obtain first feature data. For example, the feature extraction model can include: a masked auto encoder (MAE), a convolutional neural network model, a cross-modal model, or various network models based on a visual transformer, etc.

[0099] In one possible design, Figure 6 As shown, S43 may specifically include:

[0100] S431, the anomaly detection device 301 divides the semantic segmentation map s into n image blocks, where n is a positive integer greater than 1.

[0101] For example, the anomaly detection device 301 can divide the semantic segmentation map s into 64 image blocks by dividing it into 8 blocks horizontally and vertically respectively; for another example, the anomaly detection device 301 can divide the semantic segmentation map s into 256 image blocks by dividing it into 16 blocks horizontally and vertically respectively.

[0102] S432. The abnormality detection device 301 performs feature extraction on the n image blocks to obtain feature data of each of the n image blocks (hereinafter referred to as feature data F1-Fn).

[0103] In one possible implementation, Figure 6As shown, the abnormality detection device 301 includes a feature extractor 3012. The feature extractor 3012 can be run as a software module in the abnormality detection device 301. The feature extractor 3012 is used to output feature data of each image block in the n image blocks after inputting content information and position information of each image block in the n image blocks included in an image. For example, the feature extractor 3012 can be a masked autoencoder. Furthermore, S4312 can specifically include:

[0104] The anomaly detection device 301 inputs the content of each image block in the n image blocks and the position in the semantic segmentation map into the feature extractor 3012 to obtain feature data F1-Fn of each image block in the n image blocks.

[0105] The feature data F1-Fn of each image block among the n image blocks may be used to reflect the relationship between the content and position of the image block and the content and position of other image blocks.

[0106] The process of training the feature extractor 3012 will be described in the following S601-S602, but will not be described here.

[0107] S433 , the abnormality detection device 301 combines the feature data F1 -Fn of each image block in the n image blocks to obtain first feature data.

[0108] Exemplarily, the abnormality detection device 301 may obtain the first feature data by averaging the feature data F1-Fn of each image block in the n image blocks.

[0109] S44. The abnormality detection device 301 compares the first characteristic data with the second characteristic data, and determines whether the object to be detected is abnormal according to the result of the comparison operation.

[0110] Whether the object to be detected is abnormal may specifically include whether the structural relationship between target objects is abnormal.

[0111] The second characteristic data is characteristic data of a standard object corresponding to the object to be detected.

[0112] The standard object may be a normal object (such as a normal product) or an abnormal object (such as an abnormal product). The second feature data may be obtained by extracting features from multiple sample images of the normal object or multiple sample images of the abnormal object.

[0113] In one implementation, considering that in the field of anomaly detection, sample images including normal products are easier to obtain than sample images including abnormal products, the second feature data may specifically be feature data of a normal object corresponding to the object to be detected.

[0114] Specifically, S44 may include:

[0115] S44a, the abnormality detection device 301 compares the first characteristic data with the second characteristic data. If the difference between the first characteristic data and the second characteristic data is greater than a preset condition, it is determined that the object to be detected is abnormal.

[0116] In addition, the method may further include: if the difference between the first characteristic data and the second characteristic data is less than a preset condition, the abnormality detection device 301 determines that the object to be detected is normal.

[0117] For example, the difference between the first feature data and the second feature data is greater than a preset condition, which may specifically be: the distance between the vector corresponding to the first feature data and the vector corresponding to the second feature data exceeds a threshold.

[0118] In one possible design, in order to determine the second characteristic data, the method may further include:

[0119] S45. The anomaly detection device 301 inputs a plurality of sample images containing the standard object into the AI ​​model to obtain second feature data of the standard object.

[0120] For example Figure 6 In the example, the anomaly detection device 301 inputs a plurality of sample images containing a standard object into a feature extractor 3012 (i.e., an AI model). Corresponding to each sample image, the feature extractor 3012 can output feature data F1-Fn respectively. Then, by merging the feature data F1-Fn of each sample image, the second feature data is obtained.

[0121] In addition, it can be understood that the above mainly introduces the method of determining whether the object to be detected is abnormal by comparing the first characteristic data with the second characteristic data through the content of S44 and S45. In the specific implementation process, other methods can also be used to determine whether the object to be detected is abnormal. For example, Fig. 9 As shown, after the abnormality detection device 301 determines the first characteristic data, the method may further include:

[0122] S46. The abnormality detection device 301 compares the first feature data with the feature data in the feature data set, and determines whether the object to be detected is abnormal based on whether the products corresponding to the k feature data in the feature data set that are closest to the first feature data are abnormal.

[0123] The feature data set includes feature data corresponding to multiple normal objects and feature data corresponding to multiple abnormal objects. The acquisition process of each feature data in the feature data set can refer to the process of determining the first feature data in S431-S433 above, which will not be repeated here.

[0124] For example, when the number of normal products corresponding to the k feature data closest to the first feature data in the feature data set exceeds a certain threshold, the object to be detected is determined to be normal. Conversely, when the number of abnormal products corresponding to the k feature data closest to the first feature data in the feature data set exceeds a certain threshold, the object to be detected is determined to be abnormal.

[0125] In addition, after determining whether the object to be detected is abnormal or normal, the abnormality detection device 301 can also output the detection result through the display device 303 or the alarm device 304. The specific method of outputting the detection result is not limited in the embodiment of the present application.

[0126] The following is an introduction to the training process of the semantic segmentation model 3011. It is understandable that, in practical applications, the process of training the semantic segmentation model 3011 can be performed by the above-mentioned anomaly detection device 301, or by other devices outside the anomaly detection device 301, and there is no limitation on this in the embodiment of the present application. For ease of description, the following will take the anomaly detection device 301 as an example of the execution subject of training the semantic segmentation model 3011, and introduce the process of training the semantic segmentation model 3011 by example.

[0127] Specifically, Fig.10 As shown, the method provided in the embodiment of the present application also includes:

[0128] S501 . The anomaly detection device 301 obtains p first sample images and semantic annotations corresponding to each first sample image.

[0129] Wherein, p is a positive integer.

[0130] Wherein, each of the p first sample images includes the target element. Taking the target element as a small ball on a spherical twisted wire buckle as an example, each first sample image can be an image of the spherical twisted wire buckle collected in advance.

[0131] The semantic annotations corresponding to each first sample image are used to mark the target elements in each first sample image. Specifically, the semantic annotations corresponding to each first sample image acquired by the anomaly detection device 301 can be semantic segmentation maps of the target elements in each first sample image. For example, a technician can use a semantic segmentation annotation tool to manually annotate each first sample image to obtain a semantic segmentation map of the target element in each first sample image.

[0132] S502 , the anomaly detection device 301 uses the p first sample images and the semantic annotations corresponding to each first sample image to train an artificial intelligence model to obtain a semantic segmentation model 3011 .

[0133] For example, the artificial intelligence model used by the semantic segmentation model 3011 may be a DeepLabV3+ model or other models. Specifically, the anomaly detection device 301 may train the DeepLabV3+ model using p first sample images and semantic annotations corresponding to each first sample image to obtain the semantic segmentation model 3011.

[0134] The following is an introduction to the training process of the feature extractor 3012. It is understandable that, in practical applications, the process of training the feature extractor 3012 can be performed by the above-mentioned anomaly detection device 301, or by other devices outside the anomaly detection device 301, and this may not be limited in the embodiments of the present application. For ease of description, the following will take the anomaly detection device 301 as an example of the execution subject of the training feature extractor 3012, and introduce the process of training the feature extractor 3012 by example.

[0135] Specifically, Fig.11 As shown, the method provided in the embodiment of the present application also includes:

[0136] S601. The anomaly detection device 301 obtains q sample semantic segmentation maps.

[0137] Among them, each sample semantic segmentation map in the q sample semantic segmentation maps is used to indicate the layout of the target elements in the image of the normal product.

[0138] Exemplarily, the above-mentioned sample semantic segmentation maps can be sample semantic segmentation maps that are automatically generated using program rules and can indicate the layout of target elements in an image of a normal product. After each sample semantic segmentation map is automatically generated using program rules, each sample semantic segmentation map can be stored in a sample library so that the abnormality detection device 301 can read it.

[0139] In addition, the above-mentioned semantic segmentation maps of each sample can also be drawn manually by a technician, or generated by using artificial intelligence models such as generative adversarial neural networks and autoencoders. There is no restriction on the method of obtaining the semantic segmentation maps of each sample in the embodiments of the present application.

[0140] S602, the anomaly detection device 301 uses q sample semantic segmentation maps to perform mask self-supervisory training on the artificial intelligence model to obtain a feature extractor 3012.

[0141] For example, the anomaly detection device 301 can use q sample semantic segmentation maps to perform mask self-supervision training on the mask autoencoder to obtain the feature extractor 3012. The type of artificial intelligence model used by the feature extractor 3012 may not be limited in the embodiment of the present application.

[0142] Combined with the above Figure 4-Figure 11 , describes in detail the anomaly detection method provided according to this embodiment, and various devices corresponding to the anomaly detection method provided by this embodiment will be described below.

[0143] like Fig.12 , which is a schematic diagram of the structure of an abnormality detection device provided in this embodiment. Specifically, the abnormality detection device 70 may include a desktop computer, a tablet computer, a desktop, a laptop, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a cellular phone, a personal digital assistant (PDA), an augmented reality (AR)\virtual reality (VR) device, and various artificial intelligence (AI) hardware accelerators and other devices that can perform image processing, or the abnormality detection device 70 may also be software running on the above devices.

[0144] The abnormality detection device 70 can be used to perform the above Figure 4 , Figure 6 , Fig. 9 , Fig.10 and Fig.11 All or part of the steps performed by the abnormality detection device 301. Specifically, the abnormality detection device 70 includes:

[0145] The acquisition unit 701 is used to acquire an image to be detected containing an object to be detected.

[0146] The feature extraction unit 702 is used to separate the object to be detected from the image to be detected and generate first feature data of the object to be detected.

[0147] The determination unit 703 is used to compare the first characteristic data with the second characteristic data of the standard object corresponding to the object to be detected, and determine whether the object to be detected is abnormal according to the result of the comparison operation.

[0148] In one implementation, the object to be detected includes a structural relationship between at least two targets, and the above-mentioned abnormality is an abnormality in the structural relationship between the at least two targets.

[0149] In one implementation, the feature extraction unit 702 is further configured to input a plurality of sample images containing the standard object into the AI ​​model to obtain second feature data of the standard object.

[0150] In one implementation, the feature extraction unit 702 is further used to input the object to be detected into the AI ​​model to obtain first feature data of the object to be detected.

[0151] In one implementation, separating the object to be detected from the image to be detected includes: determining a semantic segmentation map of at least two targets based on the image to be detected, wherein the semantic segmentation map includes a structural relationship between the at least two targets. Generating first feature data of the object to be detected includes: generating first feature data of the semantic segmentation map of the at least two targets.

[0152] For a more detailed description of the acquisition unit 701, the feature extraction unit 702 and the determination unit 703, please refer to Figure 4 , Figure 6 , Fig. 9 , Fig.10 and Fig.11 The relevant description in the method shown will not be repeated here.

[0153] Fig.13 This is a schematic diagram of the structure of another abnormality detection device provided in this embodiment. The abnormality detection device 80 can be a chip or a system on a chip. Specifically, the abnormality detection device 80 can include all or part of the hardware in a desktop computer, a tablet computer, a desktop, a laptop, a handheld computer, a notebook computer, a super mobile personal computer, a netbook, and a cellular phone, a personal digital assistant, an augmented reality\virtual reality device, etc. that can perform abnormality detection.

[0154] The abnormality detection device 80 may include: a processor 801 , a communication line 802 , a memory 803 , and part or all of at least one communication interface 804 .

[0155] The processor 801 is used to execute the Figure 4 , Figure 6 , Fig. 9 , Fig.10 and Fig.11 All or part of the steps performed by the anomaly detection device 301 in the provided method.

[0156] Specifically, the processor 801 may include a general-purpose central processing unit (CPU), and the processor 801 may also include a microprocessor, a field programmable gate array (Field Programmable Gate Array, FPGA), a digital signal processor (digital signal processing, DSP) or an application-specific integrated circuit (application-specific integrated circuit, ASIC), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0157] In a specific implementation, as an embodiment, the processor 801 may include one or more CPUs, such as Fig.13 CPU0 and CPU1 in.

[0158] In a specific implementation, as an embodiment, the device 80 may include multiple processors, such as Fig.13 801 and processor 808 in the embodiment of the present invention. Each of these processors can be a single-CPU processor or a multi-CPU processor. The processor here can refer to one or more devices, circuits, and / or processing cores for processing, for example, computer data (computer program instructions).

[0159] In addition, the memory 803 may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. Among them, the nonvolatile memory may be a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM). Memory 803 can be independent and connected to processor 801 via communication line 802. Memory 803 can also be integrated with processor 801.

[0160] The memory 803 stores computer instructions. The processor 801 can execute all or part of the steps in the abnormality detection method provided in this embodiment by executing the computer instructions stored in the memory 803. Fig.13 As shown, the computer instructions stored in the memory 803 may include software modules for implementing the functions of the acquisition unit 701, the feature extraction unit 702, and the determination unit 703. The processor 801 may execute the abnormality detection method provided in this embodiment by executing the computer instructions stored in the memory 803.

[0161] Optionally, the computer-executable instructions in this embodiment may also be referred to as application program codes, which is not specifically limited in this embodiment.

[0162] In addition, the communication interface 804 uses any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.

[0163] In addition, the communication line 802 is used to connect the various components in the abnormality detection device 80. Specifically, the communication line 802 may include a data bus, a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are marked as communication lines 802 in the figure.

[0164] In a specific implementation, as an embodiment, the data processing device 80 may further include an output device 807 and an input device 806. The output device 807 may communicate with the processor 801 and may display information in a variety of ways. For example, the output device 807 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 806 may communicate with the processor 801 and may receive user input in a variety of ways. For example, the input device 806 may be a mouse, a keyboard, a touch screen device, or a sensor device.

[0165] In addition, the anomaly detection device 80 may further include a storage medium 805. The storage medium 805 is used to store computer instructions and various data for implementing the technical solution of this embodiment. When the anomaly detection device 80 executes the above-mentioned anomaly detection method of this embodiment, the computer instructions and various data stored in the storage medium 805 are loaded into the memory 803, so that the processor 801 can execute the computer instructions stored in the memory 803 to execute the anomaly detection method provided by this embodiment.

[0166] The method steps in this embodiment can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in RAM, flash memory, ROM, PROM, EPROM, EEPROM, registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in an anomaly detection device. Of course, the processor and the storage medium can also be present in the anomaly detection device as discrete components.

[0167] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in this embodiment is executed in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a communication device, a user device or other programmable device. The computer program or instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer program or instruction can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, a hard disk, or a tape; it can also be an optical medium, such as a digital video disc (DVD); it can also be a semiconductor medium, such as an SSD.

[0168] In this embodiment, unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different implementations are consistent and can be referenced to each other, and the technical features in different embodiments can be combined to form a new embodiment based on their internal logical relationships.

[0169] In this embodiment, "at least one" means one or more, "more than one" means two or more, and other quantifiers are similar. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, for elements (element) in the singular form "a", "an" and "the", unless the context clearly stipulates otherwise, it does not mean "one or only one", but means "one or more than one". For example, "a device" means one or more such devices. Furthermore, at least one (at least one of) ......." means one or any combination of subsequent associated objects, for example, "at least one of A, B and C" includes A, B, C, AB, AC, BC, or ABC. In the text description of this embodiment, the character " / " generally indicates that the previous and next associated objects are in an "or" relationship; in the formula of this embodiment, the character " / " indicates that the previous and next associated objects are in a "division" relationship.

Claims

1. An anomaly detection method, characterized in that: include: Acquire an image to be detected containing an object to be detected; Separating the object to be detected from the image to be detected, and generating first feature data of the object to be detected; The first characteristic data is compared with the second characteristic data of a standard object corresponding to the object to be detected; and whether the object to be detected is abnormal is determined according to the result of the comparison operation.

2. The method according to claim 1, characterized in that The object to be detected includes a structural relationship between at least two targets, and the anomaly is an abnormality in the structural relationship between the at least two targets.

3. The method according to claim 1 or 2, characterized in that: The method also includes: inputting a plurality of sample images containing the standard object into an artificial intelligence (AI) model to obtain second feature data of the standard object.

4. The method according to claim 3, characterized in that The method also includes: inputting the object to be detected into the AI ​​model to obtain first feature data of the object to be detected.

5. The method according to claims 2 to 4, characterized in that The step of separating the object to be detected from the image to be detected comprises: Determine, according to the image to be detected, a semantic segmentation map of the at least two targets, wherein the semantic segmentation map includes a structural relationship between the at least two targets; The generating the first characteristic data of the object to be detected comprises: Generate first feature data of the semantic segmentation map of the at least two objects.

6. An abnormality detection device, characterized in that: include: An acquisition unit, used for acquiring an image to be detected containing an object to be detected; A feature extraction unit, used to separate the object to be detected from the image to be detected and generate first feature data of the object to be detected; The determination unit is used to compare the first characteristic data with the second characteristic data of a standard object corresponding to the object to be detected; and determine whether the object to be detected is abnormal according to the result of the comparison operation.

7. The abnormality detection device according to claim 6, characterized in that: The object to be detected includes a structural relationship between at least two targets, and the anomaly is an abnormality in the structural relationship between the at least two targets.

8. The abnormality detection device according to claim 6 or 7, characterized in that: The feature extraction unit is further used to input multiple sample images containing the standard object into an artificial intelligence AI model to obtain second feature data of the standard object.

9. The abnormality detection device according to claim 8, characterized in that: The feature extraction unit is also used to input the object to be detected into the AI ​​model to obtain first feature data of the object to be detected.

10. The abnormality detection device according to claims 7 to 9, characterized in that: The step of separating the object to be detected from the image to be detected comprises: Determine, according to the image to be detected, a semantic segmentation map of the at least two targets, wherein the semantic segmentation map includes a structural relationship between the at least two targets; The generating the first characteristic data of the object to be detected comprises: The first feature data of the semantic segmentation map of the at least two targets is generated.

11. An anomaly detection system, characterized in that: include: The abnormality detection device as claimed in any one of claims 6 to 10; The abnormality detection system further includes: at least one of a camera device, a display device, and an alarm device.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a processor, the method according to any one of claims 1 to 5 is implemented.

13. A computer program product, characterized in that The computer program product comprises instructions, which, when executed on a processor, implement the method according to any one of claims 1 to 5.