Data detection method and apparatus, computer, storage medium, and program product
By extracting and classifying the image sample characteristics of the camera module connector, the problem of lack of sufficient samples in the prior art is solved, and more efficient and accurate data detection is achieved, and the accuracy and efficiency of camera module detection is improved.
Patent Information
- Application Number
- PCT/CN2024/103618
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-07-04
- Filing Date
- 2024-07-04
- Publication Date
- 2025-01-09
AI Technical Summary
In the detection of camera module connectors, the lack of sufficient defect samples leads to inaccuracy and efficiency of data detection, especially in the process of manufacturer yield control and production line optimization, it is difficult to obtain sufficient samples for model training. .
By acquiring image samples, extracting multiple first sample features, determining the target first sample feature with the largest first feature distance, and dividing (N+1) sample feature categories based on this feature distance, and training of the feature classification model is carried out based on this feature distance. and detect, realize image abnormality detection.
Improve the accuracy and efficiency of data detection, use only normal samples for model training, reduce dependence on defect samples, obtain sufficient normal samples for training, and enhance the robustness of the model and the fine-grainedness of the detection.
Smart Images

Figure CN2024103618_09012025_PF_FP_ABST
Abstract
Description
Data detection method, device, computer, storage medium and program product
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on July 4, 2023, with application number 2023108144715 and application name “Data detection method, device, computer, storage medium and program product”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a data detection method, device, computer, storage medium, and program product. Background Art
[0003] With the development of 5G and autonomous driving, industries such as consumer electronics and automotive electronics are experiencing new growth opportunities. Cameras, as the fundamental visual components of intelligent machines, play the role of human eyes, playing a crucial role in environmental perception, automated intelligence, and enhancing user experience. Camera modules have a wide range of applications, including healthcare, automated teller machines (ATMs), road inspection, and precision equipment, such as mobile phone camera modules. The increasing number of intelligent terminal devices has created a massive demand for camera modules, making their inspection extremely important. Connectors play a crucial role in camera modules, and soldering is required during assembly. This often leads to defects such as solder overflow and bent pins, which can directly impact the usability of the terminal. Currently, deep learning-based object detection methods are commonly used. These methods group all defects based on their appearance characteristics, grouping defects with similar appearance characteristics. For each defect group, relevant sample images are collected for model training. For a relatively robust deep model, the number of images required for a single defect is generally around 1,000. However, due to manufacturers' routine yield control and production line optimization and upgrades, the number of connector-related defect samples is usually small, making it difficult to obtain sufficient samples for model training, resulting in low data detection accuracy and efficiency.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide a data detection method, device, computer, storage medium and program product, which can improve the accuracy and efficiency of data detection.
[0006] On the one hand, an embodiment of the present application provides a data detection method, the method comprising:
[0007] Acquire an image sample, and extract a plurality of first sample features from the image sample;
[0008] Determine a target first sample feature having the largest first feature distance from the plurality of first sample features, where the first feature distance is the minimum value of feature distances between the first sample feature and other first sample features other than the first sample feature in the plurality of first sample features;
[0009] Based on the first feature distance, the (N+1) sample feature categories corresponding to the multiple first sample features are determined, and based on the (N+1) sample feature categories and the multiple first sample features, the initial feature classification model is trained to obtain a trained feature classification model; N is a positive integer, and the target first sample features and the trained feature classification model are jointly used to perform image anomaly detection on the image to be analyzed; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature categories are used to indicate that a secondary detection is performed on the detected data.
[0010] On the one hand, an embodiment of the present application provides a data detection method, the method comprising:
[0011] Obtain the image features to be analyzed of the image to be analyzed, and predict the image feature categories corresponding to the image features to be analyzed by using a trained feature classification model; the trained feature classification model is obtained by dividing multiple first sample features into (N+1) sample feature categories and training multiple first sample features; N is a positive integer, and the (N+1) sample feature categories are obtained by dividing multiple first sample features based on the first feature distances corresponding to the multiple first sample features; the multiple first sample features are features extracted from image samples; the target first sample feature refers to the first sample feature with the largest corresponding first feature distance among the multiple first sample features, and the first feature distance is the minimum value of the feature distances between the first sample feature and other first sample features among the multiple first sample features except the first sample feature; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature categories are used to indicate that the detected data is subjected to secondary detection;
[0012] Based on the image feature categories corresponding to the features of the image to be analyzed, image anomaly detection is performed on the image to be analyzed.
[0013] In one aspect, an embodiment of the present application provides a data detection device, the device comprising:
[0014] A sample acquisition module, used to acquire image samples;
[0015] A feature extraction module, configured to extract a plurality of first sample features from the image sample;
[0016] A feature reduction module is configured to determine a target first sample feature having a maximum first feature distance from a plurality of first sample features, where the first feature distance is a minimum value of feature distances between the first sample feature and other first sample features other than the first sample feature in the plurality of first sample features;
[0017] A model training module is used to determine the (N+1) sample feature categories corresponding to the first sample feature based on the first feature distance, and to train the initial feature classification model based on the (N+1) sample feature categories and multiple first sample features to obtain a trained feature classification model; N is a positive integer, and the target first sample feature and the trained feature classification model are jointly used to perform image anomaly detection on the image to be analyzed; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature categories are used to indicate that the detected data is subjected to secondary detection.
[0018] The sample acquisition module is specifically used to:
[0019] Capturing an image of the object to be detected and obtaining a template image corresponding to the object to be detected; the template image refers to a standard image of the object to be detected generated during design;
[0020] The template image is used to perform image registration on the image of the object to be detected to obtain a registered image. Image registration refers to the process of matching and superimposing two or more images acquired at different times, using different sensors, or under different conditions.
[0021] The area corresponding to the object to be detected is cut out from the registered image, and the area corresponding to the object to be detected is determined as an image sample.
[0022] When the template image is used to perform image registration on the image of the object to be detected to obtain the registered image, the sample acquisition module is used to:
[0023] Detecting a first object contour of the object to be detected in the image of the object to be detected, and detecting a second object contour of the object to be detected in the template image;
[0024] Acquire contour offset information of the first object contour relative to the second object contour, and perform image rotation and offset processing on the image of the object to be detected based on the contour offset information to obtain a registered image;
[0025] When intercepting the area corresponding to the object to be detected from the registered image, the sample acquisition module is used to:
[0026] The area corresponding to the first object contour in the registered image is determined as the area corresponding to the object to be detected in the registered image, and the area corresponding to the object to be detected is intercepted.
[0027] When the template image is used to perform image registration on the image of the object to be detected to obtain the registered image, the sample acquisition module can be used to:
[0028] Convolution processing is performed on the image of the object to be detected using a Gaussian kernel to obtain a feature matrix of the pixel points included in the image of the object to be detected;
[0029] Obtaining matrix parameter weights for the feature matrix, performing weighted processing on the feature matrix using the matrix parameter weights, and obtaining pixel feature values of the pixel points included in the image of the object to be detected;
[0030] Using the pixel feature values of the pixels included in the image of the object to be detected, the image of the object to be detected is subjected to non-maximum suppression processing to determine the initial feature points of the image of the object to be detected; the non-maximum suppression processing refers to the processing of suppressing non-maximum elements for performing local maximum search;
[0031] Performing extreme value detection on the initial feature points to obtain a first feature point of the image of the object to be detected, detecting the wavelet features of the first feature point, and determining the direction of the wavelet feature with the largest modulus value among the wavelet features of the first feature point as the feature main direction of the first feature point;
[0032] Constructing a first eigenvector of the first feature point according to the feature main direction of the first feature point;
[0033] Detecting a second feature point in the template image and constructing a second feature vector of the second feature point;
[0034] Performing image registration on the image of the object to be detected and the template image based on the similarity between the first eigenvector and the second eigenvector to obtain a registered image;
[0035] When intercepting the area corresponding to the object to be detected from the registered image, the sample acquisition module is used to:
[0036] Based on the object template corresponding to the template image, the area corresponding to the object to be detected is cut out from the registered image; the object template is used to represent the position information corresponding to the object to be detected in the template image.
[0037] The feature extraction module is specifically used to:
[0038] extracting initial image features from image samples;
[0039] Perform convolution processing on the initial image features to obtain residual features corresponding to the image samples, and use the initial image features to perform feature enhancement processing on the residual features to obtain initial sample features of the image samples; the initial sample features include sample block features corresponding to the M sample image blocks that constitute the image sample; M is a positive integer;
[0040] The sample block feature corresponding to the k-th sample image block is fused with the sample block features of the adjacent sample image blocks of the k-th sample image block to obtain the first sample feature of the sample image block, until the first sample features corresponding to M sample image blocks are obtained respectively; k is a positive integer less than or equal to M.
[0041] Among them, when performing convolution processing on the initial image features to obtain residual features corresponding to the image samples, and performing feature enhancement processing on the residual features using the initial image features to obtain initial sample features of the image samples, the feature extraction module is used to:
[0042] In the i-th network unit, the i-1th enhanced sample feature is subjected to channel downsampling to obtain the i-th downsampling feature; when i is the first initial value, the i-1th enhanced sample feature is the initial image feature; when i is not the first initial value, the i-1th enhanced sample feature is the output feature of the i-1th network unit;
[0043] Perform convolution on the i-th downsampled feature to obtain the i-th convolution feature of the image sample;
[0044] Perform channel upsampling on the i-th convolution feature to obtain the i-th residual feature of the image sample;
[0045] The i-1th enhanced sample feature is used to perform feature enhancement processing on the i-th residual feature to obtain the i-th enhanced sample feature of the image sample;
[0046] If the i-th network unit is the last network unit, the i-th enhanced sample feature is determined as the initial sample feature of the image sample.
[0047] Wherein, when the sample block feature corresponding to the k-th sample image block is fused with the sample block features of the adjacent sample image blocks of the k-th sample image block to obtain the first sample feature of the sample image block, until the first sample features corresponding to M sample image blocks are obtained, the feature extraction module is used to:
[0048] Obtaining sample block features of adjacent sample image blocks of the k-th sample image block, performing pooling processing on the sample block features of the adjacent sample image blocks, and obtaining an adjacent enhanced feature of the k-th sample image block;
[0049] The adjacent enhanced features of the k-th sample image block are fused with the sample block features corresponding to the k-th sample image block to obtain the first sample feature of the k-th sample image block;
[0050] When k is M, first sample features corresponding to M sample image blocks are obtained.
[0051] The first sample feature refers to the first sample features corresponding to the M sample image blocks constituting the image sample;
[0052] The feature reduction module can be used to:
[0053] Constructing an initial reference feature set, and adding the first sample feature corresponding to any sample image block to the initial reference feature set;
[0054] In the s-th set construction stage, obtain the first feature distances between the M first sample features and the first sample features in the reference feature set of the (s-1)-th set construction stage, add the first sample feature corresponding to the largest first feature distance obtained in the s-th set construction stage to the reference feature set of the (s-1)-th set construction stage, and obtain the reference feature set of the s-th set construction stage; s is a positive integer; when s is the second initial value, the reference feature set of the (s-1)-th set construction stage is the initial reference feature set;
[0055] If the reference feature set in the sth set construction stage meets the set convergence condition, the reference feature set in the sth set construction stage is determined as the target reference feature set corresponding to the image sample, and the first sample feature included in the target reference feature set is determined as the target first sample feature.
[0056] Wherein, the number of the first sample features is M; M is a positive integer;
[0057] This model training module can be used for:
[0058] In the tth iteration, based on the first feature distance between the first sample feature included in the feature set to be detected in the (t-1)th iteration and the target first sample feature included in the auxiliary feature set in the (t-1)th iteration, the associated sample features ft corresponding to the pt-1 target first sample features are determined; t is a positive integer; when t is the third initial value, the feature set to be detected in the (t-1)th iteration includes M first sample features, p t-1 is a positive integer, p t-1 It refers to the number of target first sample features included in the auxiliary feature set in the (t-1)th iteration;
[0059] Based on p t-1 The associated sample features f corresponding to the first sample features of the target t , determine p t-1 The statistical frequency information corresponding to the first sample features of the target is respectively taken as the first sample feature of the target with the largest statistical frequency information. t The corresponding associated sample feature f t, corresponding to the t-th sample feature category;
[0060] The updated feature classification model in the (t-1)th iteration is trained using the t-th sample feature category and the feature set to be detected in the (t-1)th iteration to obtain the updated feature classification model in the t-th iteration; when t is the third initial value, the updated feature classification model in the (t-1)th iteration is the initial feature classification model;
[0061] If p t-1 If the statistical frequency information corresponding to the first sample features of the target does not meet the statistical convergence condition, the feature set to be detected in the (t-1)th iteration is removed except for the first sample feature q t The corresponding associated sample feature f t The first sample features other than the first sample features constitute the feature set to be detected in the t-th iteration, and the auxiliary feature set in the t-th iteration is obtained from the feature set to be detected in the t-th iteration;
[0062] If p t-1 If the statistical frequency information corresponding to the first sample features of each target meets the statistical convergence condition, the updated feature classification model in the tth iteration is determined as the trained feature classification model.
[0063] In one aspect, an embodiment of the present application provides a data detection device, the device comprising:
[0064] A feature acquisition module, used to acquire the image features to be parsed of the image to be parsed;
[0065] A category prediction module is used to predict the image feature category corresponding to the image feature to be analyzed through a trained feature classification model; the trained feature classification model is obtained by dividing multiple first sample features into (N+1) sample feature categories and training multiple first sample features; N is a positive integer, and the (N+1) sample feature categories are obtained by dividing multiple first sample features based on the first feature distances corresponding to the multiple first sample features; the multiple first sample features are features extracted from image samples; the target first sample feature refers to the first sample feature with the largest first feature distance among the multiple first sample features, and the first feature distance is the minimum value of the feature distances between the first sample feature and other first sample features among the multiple first sample features except the first sample feature; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature categories are used to indicate that the detected data is subjected to secondary detection;
[0066] The image detection module is used to perform image anomaly detection on the image to be analyzed based on the image feature category corresponding to the image feature to be analyzed.
[0067] The image features to be analyzed include block features of multiple image blocks constituting the image to be analyzed, and the image feature categories include subcategories corresponding to the block features of the multiple image blocks. The image detection module can be used to:
[0068] If the subcategories corresponding to the block features of the plurality of image blocks all belong to the N first feature categories, then it is determined that the image to be parsed is normal data;
[0069] If there is a block feature whose subcategory is the second feature category among the block features of multiple image blocks, the second feature distance between the image feature to be analyzed and the target first sample feature is obtained, and image anomaly detection is performed on the image to be analyzed based on the second feature distance between the image feature to be analyzed and the target first sample feature.
[0070] The image features to be analyzed include block features of a plurality of image blocks constituting the image to be analyzed, and the image feature categories include subcategories corresponding to the block features of the plurality of image blocks;
[0071] If a block feature of the second feature category exists among the block features of the plurality of image blocks, a second feature distance between the feature of the image to be parsed and the target first sample feature is obtained. When performing image anomaly detection on the image to be parsed based on the second feature distance between the feature of the image to be parsed and the target first sample feature, the image detection module may be used to:
[0072] If there is a block feature of the second feature category among the block features of the multiple image blocks, obtaining the block feature to be detected whose subcategory is the second feature category, and obtaining the second feature distance between the block feature to be detected and the target first sample feature;
[0073] If the second characteristic distance is less than or equal to the normal distance threshold, the image to be analyzed is determined to be normal data;
[0074] If the second characteristic distance is greater than the normal distance threshold, the second characteristic distance is converted into the abnormality degree of the image to be analyzed.
[0075] On the one hand, an embodiment of the present application provides a computer device, including a processor, a memory, and an input and output interface;
[0076] The processor is connected to the memory and the input and output interface respectively, wherein the input and output interface is used to receive and output data, the memory is used to store the computer program, and the processor is used to call the computer program so that the computer device including the processor executes the data detection method in one aspect of the embodiment of the present application.
[0077] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program is suitable for being loaded and executed by a processor so that a computer device having the processor executes the data detection method in one aspect of the embodiment of the present application.
[0078] In one aspect, an embodiment of the present application provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional embodiments of the present application. In other words, when the computer instructions are executed by the processor, the methods provided in various optional embodiments of the present application are implemented.
[0079] Implementing the embodiments of this application will have the following beneficial effects:
[0080] In an embodiment of the present application, an image sample is obtained, and multiple first sample features are extracted from the image sample; a target first sample feature with the largest first feature distance is determined from the multiple first sample features; the first feature distance is the minimum value of the feature distances between the first sample feature and other first sample features other than the first sample feature in the multiple first sample features; based on the first feature distance between the first sample feature and the target first sample feature, the (N+1) sample feature categories corresponding to the first sample feature are determined, and based on the (N+1) sample feature categories and the first sample feature, the initial feature classification model is trained to obtain a trained feature classification model; N is a positive integer, and the target first sample feature and the trained feature classification model are used together to perform image anomaly detection on the image to be analyzed. In the above process, only normal samples (i.e., image samples) are used, that is, defective samples do not need to be used, and only normal samples are used to complete the modeling, making it easier to obtain samples for model training, which can improve the efficiency of data detection. Moreover, since a sufficient amount of normal samples can be obtained to train a model with better robustness, the accuracy of data detection is improved. At the same time, during the training process, the first sample features will be subjected to feature reduction processing to obtain more compact and fine-grained sample features (i.e., the target first sample features), so that semantic segmentation of feature distance can be performed based on the sample features before feature reduction and the sample features after feature reduction, so as to train a post-trained feature classification model for image anomaly detection of the image to be analyzed, so that the post-trained feature classification model can be directly used for image anomaly detection in the future, thereby improving the accuracy and efficiency of data detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] FIG1a is a diagram of a network interaction architecture for data detection provided by an embodiment of the present application;
[0082] FIG1b is a schematic diagram of an architecture in a sample collection scenario provided by an embodiment of the present application;
[0083] FIG2 is a schematic diagram of a data detection scenario provided in an embodiment of the present application;
[0084] FIG3 is a flow chart of a data detection method provided in an embodiment of the present application;
[0085] FIG4 is a schematic diagram of a feature detection network provided in an embodiment of the present application;
[0086] FIG5 is a schematic diagram of a process for obtaining initial sample features provided in an embodiment of the present application;
[0087] FIG6 is a schematic diagram of a feature fusion processing scenario provided in an embodiment of the present application;
[0088] FIG7 is a schematic diagram of a feature reduction process provided by an embodiment of the present application;
[0089] FIG8 is a schematic diagram of a feature reduction scenario provided by an embodiment of the present application;
[0090] FIG9 is a schematic diagram of an image detection scenario provided in an embodiment of the present application;
[0091] FIG10 is a flow chart of another data detection method provided in an embodiment of the present application;
[0092] FIG11 is a schematic diagram of a data detection device provided in an embodiment of the present application;
[0093] FIG12 is a schematic diagram of another data detection device provided in an embodiment of the present application;
[0094] FIG13 is a schematic structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0095] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0096] Among them, if it is necessary to collect object (such as user, etc.) data in this application, a prompt interface or pop-up window will be displayed before or during the collection. The prompt interface or pop-up window is used to remind the user that certain data (such as image samples, etc.) is currently being collected. Only after the user confirms the prompt interface or pop-up window, the relevant steps for data acquisition will be started, otherwise the process will end. Moreover, the acquired user data will be used in reasonable and legal scenarios or purposes. Optionally, in some scenarios where user data needs to be used but the user has not authorized it, authorization can be requested from the user, and the user data can be used when the authorization is passed. Among them, the use of user data complies with the relevant provisions of laws and regulations.
[0097] In an embodiment of the present application, referring to FIG. 1a, FIG. 1a is a network interaction architecture diagram of a data detection provided by an embodiment of the present application, and as shown in FIG. 1a, a computer device 101 can obtain an image sample for model training from any one or more business devices, such as business device 102a, business device 102b or business device 102c, etc. Wherein, multiple in this application refers to at least two. Alternatively, the computer device 101 can also obtain image samples directly from a local storage space (i.e., the storage space of the computer device 101), or obtain image samples from a cloud storage space or a blockchain network, etc., without limitation herein. Wherein, image samples refer to normal samples (i.e., positive samples), that is, images obtained by image acquisition for a normal and defect-free object to be detected, that is, image samples are samples that can be determined as normal data. Wherein, the object to be detected can be a connector in a camera module, or other objects that need to be detected, such as a lens element or other industrial components in a camera module, etc., without limitation herein. Further, the computer device 101 can use the image samples obtained to carry out model training on the initial feature classification model to obtain a feature classification model after training.
[0098] Wherein, computer equipment is when obtaining image sample, a possible way can refer to Fig. 1b, Fig. 1b is the framework schematic diagram under a kind of sample acquisition scene that embodiment of the present application provides.As shown in Figure 1b, assuming that the object to be detected is the connector in camera module 104, the camera module 104 can be collected by image acquisition device 105, and object to be detected image is obtained.Computer equipment 106 obtains the object to be detected image collected by image acquisition device 105, carries out image recognition processing to the object to be detected image, obtains image sample, specifically, the object to be detected image can be determined as image sample, or, can identify the region where the object to be detected is located from the object to be detected image, the region where the object to be detected is located is determined as image sample etc.Wherein, the image acquisition device 105 can be the component (such as but not limited to the camera in computer equipment 106 etc.) integrated in computer equipment 106, or can be the equipment (such as but not limited to camera or business equipment with camera function etc.) independent of computer equipment 106.
[0099] Specifically, please refer to Figure 2, which is a schematic diagram of a data detection scenario provided by an embodiment of the present application. As shown in Figure 2, a computer device can obtain an image sample of an object to be detected 201 and extract multiple first sample features 202 from the image sample. The first sample features 202 refer to features obtained after feature analysis of the image sample. Furthermore, a target first sample feature 203 with the largest first feature distance can be determined from the multiple first sample features 202. In other words, the multiple first sample features 202 include the target first sample feature 203. The target first sample feature 203 has the largest first feature distance, which means that the similarity between the target first sample feature 203 and the other first sample features is the smallest. The target first sample feature 203 can be considered to be the most representative first sample feature among the multiple first sample features 202. Specifically, the number of the multiple first sample features 202 is M, where M is a positive integer. The computer device can determine the target first sample feature from the M first sample features based on the first feature distance between each first sample feature and the other first sample features of the first sample feature. The target first sample feature refers to the first sample feature with the largest corresponding first feature distance among the multiple first sample features. Through the above process, resource control can be performed on multiple first sample features, so that the target first sample features constitute a compact set of normal features extracted from multiple first sample features, which can more accurately characterize the features of high confusion areas, thereby reducing the memory consumption caused by saving sample features and the time consumption during subsequent image anomaly detection. In addition, the model can be trained without the need for negative samples, thereby improving the convenience, efficiency and accuracy of sample acquisition for model training. Among them, the first feature distance refers to the minimum feature distance among the feature distances between the corresponding first sample feature and other first sample features. Specifically, please refer to the relevant description in step S302 of Figure 3 below, which will not be described here for the time being.
[0100] Furthermore, the computer device may classify the plurality of first sample features 202 into (N+1) categories based on the first feature distance, that is, determine (N+1) sample feature categories corresponding to the plurality of first sample features 202, wherein the (N+1) feature categories may include N first feature categories and second feature categories, where N is a positive integer. Furthermore, the initial feature classification model may be trained based on the plurality of first sample features 202 and the (N+1) sample feature categories corresponding to the plurality of first sample features 202 to obtain a trained feature classification model 204, thereby achieving end-to-end training of the model for subsequent anomaly detection of images, thereby improving the efficiency and accuracy of image detection.
[0101] It is understood that the business device mentioned in the embodiments of the present application may also be a computer device, and the computer device in the embodiments of the present application includes but is not limited to a terminal device or a server. In other words, the computer device may be a server or a terminal device, or a system consisting of a server and a terminal device. Among them, the terminal device mentioned above may be an electronic device, including but not limited to a mobile phone, a tablet computer, a desktop computer, a laptop computer, a PDA, a vehicle-mounted device, an augmented reality / virtual reality (AR / VR) device, a helmet display, a smart TV, a wearable device, a smart speaker, a digital camera, a camera, and other mobile internet devices (mobile internet device, MID) with network access capability, or a terminal device in scenarios such as a train, a ship, or a flight. As shown in Figure 1a, the terminal device may be a laptop computer (as shown in business device 102b), a mobile phone (as shown in business device 102c), or a vehicle-mounted device (as shown in business device 102a), etc. Figure 1a only lists some of the devices. Optionally, the business device 102a refers to a device located in a vehicle 103. Among them, the servers mentioned above can be independent physical servers, or they can be server clusters or distributed systems composed of multiple physical servers. They can also be cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, vehicle-road collaboration, content delivery networks (CDNs), as well as big data and artificial intelligence platforms.
[0102] Optionally, the data involved in the embodiments of the present application can be stored in a computer device, or the data can be stored based on cloud storage technology or a blockchain network, which is not limited here.
[0103] Further, please refer to Figure 3, which is a flow chart of a data detection method provided in an embodiment of the present application. As shown in Figure 3, the data detection process includes the following steps:
[0104] Step S301: Acquire an image sample, and extract a plurality of first sample features from the image sample.
[0105] In an embodiment of the present application, a computer device can obtain an image sample. Specifically, an image of the object to be detected can be collected for the object to be detected, and an area containing the object to be detected can be intercepted from the image of the object to be detected to obtain an image sample; or an image of the object to be detected can be collected for the object to be detected, and image registration can be performed on the image of the object to be detected to obtain a registered image, and an area containing the object to be detected can be intercepted from the registered image to obtain an image sample. Wherein, when collecting the image sample, the object to be detected is a normal and defect-free object. Specifically, the image of the object to be detected can be input into an object detection model for object detection, and the area where the object to be detected is located in the image of the object to be detected is determined, and the area where the object to be detected is located in the image of the object to be detected is intercepted as an image sample. Wherein, the object detection model can be a trained model for detecting the object to be detected. Alternatively, an image of the object to be detected can be collected for the object to be detected, and a template image corresponding to the object to be detected can be obtained. The template image refers to a standard image generated when the object to be detected is designed; the template image is used to perform image registration on the image of the object to be detected to obtain a registered image; the area corresponding to the object to be detected is intercepted from the registered image, and the area corresponding to the object to be detected is determined as an image sample. For example, the image of the object to be detected is input into an object detection model for object detection, and the area where the object to be detected is located in the registered image is determined, and the area where the object to be detected is located in the registered image is intercepted as an image sample. Among them, image registration refers to the process of matching and superimposing two or more images obtained at different times, different sensors, or under different conditions. The template image refers to a standard image generated when the object to be detected is designed. That is to say, when the object to be detected is produced, a design drawing of the object to be detected will exist, and a planar image of the design drawing of the object to be detected can be determined as a template image.
[0106] Among them, in one image registration processing method, when using a template image to perform image registration on the image of the object to be detected to obtain a registered image, the computer device can detect the first object contour of the object to be detected in the image of the object to be detected, and detect the second object contour of the object to be detected in the template image. The contour offset information of the first object contour relative to the second object contour is obtained, and the image of the object to be detected is image registered based on the contour offset information to obtain a registered image. In other words, the image of the object to be detected can be subjected to image rotation offset processing based on the contour offset information to obtain a registered image. For example, if the contour offset information of the first object contour relative to the second object contour is "5 cm to the left, 5 degrees counterclockwise offset", then based on the contour offset information, the image of the object to be detected is offset 5 cm to the left and rotated 5 degrees counterclockwise to obtain a registered image. At this time, the area corresponding to the object to be detected is cut out from the registered image. Specifically, the area corresponding to the first object contour in the registered image is determined as the area corresponding to the object to be detected in the registered image, and the area corresponding to the object to be detected is cut out; or, the area corresponding to the object to be detected can be cut out from the registered image based on the object template corresponding to the template image; the object template is used to represent the position information corresponding to the object to be detected in the template image, for example, the object template includes "(10, 20)(40, 70)", at this time, the area composed of pixel coordinates (10, 20) to pixel coordinates (40, 70) in the registered image is determined as the area corresponding to the object to be detected, or the object template can also include "(10, 20), width 30, height 50", etc., and the object template includes the position information corresponding to the object to be detected in the template image.
[0107] Alternatively, in one image registration processing method, a Gaussian kernel can be used to perform convolution processing on the image of the object to be detected to obtain a feature matrix of the pixels included in the image of the object to be detected. The Gaussian kernel can be denoted as σ, and one method for obtaining the feature matrix can be shown in formula ①:
[0108] As shown in formula ①, H(x, σ ) is used to represent the feature matrix, σ Used to represent the Gaussian kernel, where L xx , L yy and L xy They are Gaussian second-order differential operators and Convolution with the image of the object to be detected at x, where the convolution process can be shown in formula ②:
[0109] As shown in formula ②, I is used to represent the initial pixel value of the corresponding pixel point at x in the image of the object to be detected, and G(t) is used to represent the Gaussian second-order differential operator. Specifically, as shown in formulas ① to ② above, in a possible feature matrix construction method (1), the computer device can obtain the initial pixel value (i.e., I) of the pixel point in the image of the object to be detected at the first pixel dimension (such as x). Obtain the Gaussian second-order differential operator (which can be recorded as the first Gaussian second-order differential operator) of the pixel point in the image of the object to be detected at the first pixel dimension, such as Obtain the Gaussian second-order differential operator (which can be recorded as the second Gaussian second-order differential operator) of the pixel point in the image of the object to be detected in the second pixel dimension, such as Obtain the Gaussian second-order differential operator (which can be recorded as the third Gaussian second-order differential operator) of the pixel point in the image of the object to be detected in the first pixel dimension and the second pixel dimension, such as The first Gaussian second-order differential operator, the second Gaussian second-order differential operator, and the third Gaussian second-order differential operator corresponding to the pixel point in the image to be detected are convolved with the initial pixel value of the pixel point at the first pixel dimension to determine the first matrix parameter of the pixel point (such as L xx (x,σ)), the second matrix parameters (such as L yy (x,σ)) and the third matrix parameters (such as L xy (x,σ)), the first matrix parameter, the second matrix parameter and the third matrix parameter of the pixel point form the characteristic matrix of the pixel point.
[0110] Alternatively, under a possible feature matrix construction method (2), the first Gaussian second-order differential operator, the second Gaussian second-order differential operator, and the third Gaussian second-order differential operator corresponding to the pixel point in the image of the object to be detected can be obtained through the above process. The first Gaussian second-order differential operator, the second Gaussian second-order differential operator, and the third Gaussian second-order differential operator are combined to form the feature matrix of the pixel point. A method for obtaining the feature matrix can be shown in formula ③:
[0111] As shown in formula ③, H(f(x, y)) is used to represent the feature matrix. is used to represent the first Gaussian second-order differential operator, Used to represent the second Gaussian second-order differential operator, Used to represent the third Gaussian second-order differential operator. The Gaussian second-order differential operator is used to represent the second-order derivative of the image.
[0112] Of course, the above are only several possible ways of obtaining the feature matrix, and other feature matrix construction methods can also be used to construct the feature matrix of the pixels included in the image of the object to be detected.
[0113] Furthermore, the computer device can perform weighted processing on the feature matrix based on the size of the Gaussian kernel to obtain the pixel feature values of the pixel points included in the image of the object to be detected. Specifically, the matrix parameter weights for the feature matrix can be obtained, and the matrix parameter weights can be used to perform weighted processing on the feature matrix to obtain the pixel feature values of the pixel points included in the image of the object to be detected. As in the feature matrix construction method (1), the first matrix parameter, the second matrix parameter and the third matrix parameter can be used to process the size of the Gaussian kernel to determine the matrix parameter weights for the feature matrix; or, the default parameter weights can be determined as the matrix parameter weights for the feature matrix, such as 0.9 or 0.912. The matrix parameter weights are used to perform weighted processing on the feature matrix to obtain the pixel feature values of the pixel points included in the image of the object to be detected. A possible generation process of the pixel feature value can be shown in formula ④: det(H)=L xx L yy -(βL xy ) 2 ④
[0114] As shown in formula ④, β is used to represent the matrix parameter weight for the feature matrix, L xx Used to represent the first matrix parameter, L yy Used to represent the second matrix parameter, L xy Used to represent the third matrix parameter. det(H) is used to represent the pixel eigenvalue.
[0115] As in the feature matrix construction method (2), the default parameter weights can be determined as the matrix parameter weights for the feature matrix, and the matrix parameter weights are used to perform weighted processing on the feature matrix to obtain the pixel feature values of the pixels included in the image of the object to be detected. Through the above process, pixel processing of the image of the object to be detected can be implemented based on the Gaussian kernel without updating the size of the image of the object to be detected, which can improve the efficiency of data processing.
[0116] Furthermore, the pixel feature values of the pixels included in the image of the object to be detected can be used to perform non-maximum suppression processing on the image of the object to be detected to obtain the initial feature points of the image of the object to be detected. The non-maximum suppression processing refers to the processing of suppressing non-maximum elements, which is used to perform local maximum search. Specifically, the pixel feature values of the pixels included in the image of the object to be detected can be compared with the pixel feature values of the adjacent pixels of the pixel in the image of the object to be detected; if the pixel feature value of the pixel is the maximum value or minimum value among the pixel feature values of the pixel and the pixel feature values of the adjacent pixels of the pixel, the pixel is determined as the initial feature point; if the pixel feature value of the pixel is neither the maximum value nor the minimum value among the pixel feature values of the pixel and the pixel feature values of the adjacent pixels of the pixel, the pixel is not processed.
[0117] Among them, the number of pixel points is multiple. Through the above process, the pixel feature value of any pixel point can be obtained, and the initial feature point in the image of the object to be detected can be determined from the multiple pixel points that constitute the image of the object to be detected.
[0118] Furthermore, the initial feature points can be subjected to extreme value detection to obtain the first feature points of the image of the object to be detected. For example, a three-dimensional linear interpolation method can be used to perform extreme value detection on the initial feature points to obtain the first feature points of the image of the object to be detected, thereby removing some points whose pixel characteristic values are less than a certain threshold, reducing the number of feature points that need to be processed, and at the same time ensuring that a sufficient number of representative pixels are obtained, further improving the efficiency of data detection. Furthermore, the wavelet features of the first feature points can be detected, and the characteristic main direction of the first feature points can be determined based on the wavelet features of the first feature points. Specifically, the direction of the wavelet feature with the largest modulus value among the wavelet features of the first feature points can be determined as the characteristic main direction of the first feature point. Specifically, the number of the first feature points can be multiple, and a feature point area of the jth first feature point can be constructed, and the wavelet features in the feature point area of the jth first feature point can be obtained. The direction of the wavelet feature with the largest modulus value among the wavelet features in the feature point area of the jth first feature point can be determined as the characteristic main direction of the jth first feature point, where j is a positive integer and j is less than or equal to the number of the first feature points. Furthermore, the characteristic main direction of the first feature point can be used to construct the first eigenvector of the first feature point. Specifically, a feature neighborhood can be constructed with the jth first feature point, and E rectangular areas can be selected from the feature neighborhood. Based on the characteristic main direction of the jth first feature point, the Haar wavelet responses corresponding to the E rectangular areas of the jth first feature point are obtained. The E Haar wavelet responses of the jth first feature point are accumulated and determined as the first eigenvector of the jth first feature point. E is a positive integer, and the Haar wavelet response is used to represent the grayscale value difference of the corresponding rectangular area. Further, the second feature point in the template image can be detected and the second eigenvector of the second feature point can be constructed. The detection process of the second feature point can refer to the detection process of the first feature point mentioned above, and the construction process of the second eigenvector can refer to the construction process of the first eigenvector mentioned above, which will not be repeated here. Further, the first eigenvector and the second eigenvector can be used to perform image registration on the above-mentioned image of the object to be detected to obtain a registered image. For example, the similarity between the first and second eigenvectors can be used to register the image of the object to be detected with the template image to produce a registered image. In this case, the computer can extract the region corresponding to the object to be detected from the registered image based on the object template corresponding to the template image; the object template is used to represent the location information of the object to be detected in the template image.
[0119] Among them, the above image registration processing methods are only several possible image registration processing methods cited as examples, and are not limited to the above implementation process. For example, an image registration method based on template matching, an image registration method based on grayscale matching, an image registration method based on features (such as Speeded Up Robust Features, SURF feature points, etc.) or an image registration method based on domain transformation (such as Fourier transform, Walsh transform or wavelet transform, etc.) can also be used, and there is no limitation here. For example, the image features to be detected of the image of the object to be detected can be obtained, and a feature descriptor to be detected can be generated for the image features to be detected; the template image features of the template image can be obtained, and a template feature descriptor can be generated for the template image features; the feature descriptor to be detected and the template feature descriptor can be compared, and the image to be detected is subjected to image registration processing based on the comparison result to obtain a registered image. Among them, SURF feature points are a type of scale-invariant feature points. Since quality inspection equipment is often limited by various factors such as the sample placement angle and the stability of the robot arm when collecting images of the object to be inspected, the imaging results of the same point will have inconsistent angles. For some objects to be inspected (such as connectors, etc.), the neatness of their pins needs to be analyzed, and the inconsistency of the image angle will cause additional errors, resulting in missed detections and low data detection accuracy. By performing image registration on the image of the object to be inspected, the imaging of the object to be inspected in the image sample is more standardized, and the detection of the object to be inspected will not or will only cause very little additional error, which can improve the accuracy of data detection. At the same time, the image sample only captures the imaging area corresponding to the object to be inspected, and can extract the main area where the object to be inspected is distributed, which is convenient for subsequent analysis and also avoids interference from foreign objects in the surrounding background to a certain extent, thereby improving the accuracy of data detection.
[0120] Furthermore, multiple first sample features can be extracted from the image sample. Specifically, the computer device can divide the image sample into M sample image blocks, and extract the first sample features corresponding to the M sample image blocks. Among them, the computer device can extract the initial image features respectively from the M sample image blocks. Further, the M initial image features can be determined as the M first sample features of the image sample. Alternatively, the initial image features can be convolved to obtain the residual features corresponding to the image sample, and the initial image features can be used to perform feature enhancement processing on the residual features to obtain the initial sample features of the image sample. Specifically, the M initial image features can be convolved to obtain the residual features corresponding to the M sample image blocks constituting the image sample, and the initial image features of each sample image block can be used to perform feature enhancement processing on the residual features corresponding to the initial image features to obtain the initial sample features of the sample image block. At this time, the initial sample features include the sample block features corresponding to the M sample image blocks constituting the image sample, or, based on the initial sample features, the sample block features corresponding to the M sample image blocks constituting the image sample can be obtained; M is a positive integer. Specifically, the initial image features (such as denoted as ) Input the feature detection model, and in the residual network included in the feature detection model, the initial image features are convolved to obtain the residual features corresponding to the image samples The initial image features are used to enhance the residual features to obtain the initial sample features of the image samples, which are recorded as Among them, the number of the residual networks can be one or more. For example, please refer to Figure 4, which is a schematic diagram of a feature detection network provided in an embodiment of the present application. As shown in Figure 4, assuming that the feature detection model 401 includes a residual network 4011 and a residual network 4012, the computer device can input the initial image feature into the feature detection model 401, and in the residual network 4011 included in the feature detection model 401, the initial image feature is convolved to obtain a first residual feature; in the residual network 4012 included in the feature detection model 401, the first residual feature is convolved to obtain a second residual feature; the initial image feature is used to perform feature enhancement processing on the second residual feature to obtain an enhanced sample feature of the image sample, and the enhanced sample feature is determined as the initial sample feature. For the sample block feature corresponding to each sample image block, the sample block features of the adjacent sample image blocks of the sample image block are fused to obtain the first sample feature of the sample image block. Specifically, the sample block feature corresponding to the k-th sample image block is feature fused with the sample block features of the adjacent sample image blocks of the k-th sample image block to obtain the first sample feature of the sample image block, until the first sample features corresponding to M sample image blocks are obtained respectively; k is a positive integer less than or equal to M.
[0121] In which, when performing convolution processing on the initial image features to obtain the residual features corresponding to the image samples, and performing feature enhancement processing on the residual features using the initial image features to obtain the initial sample features of the image samples, specifically, in the i-th network unit, channel downsampling processing can be performed on the i-1th enhanced sample features to obtain the i-th downsampling features; when i is the first initial value, the i-1th enhanced sample features are the initial image features; when i is not the first initial value, the i-1th enhanced sample features are the output features of the i-1th network unit. Convolution processing is performed on the i-th downsampling features to obtain the i-th convolution features corresponding to the image samples; channel upsampling processing is performed on the i-th convolution features to obtain the i-th residual features corresponding to the image samples. Feature enhancement processing is performed on the i-1th enhanced sample features on the i-th residual features to obtain the i-th enhanced sample features of the image samples. If the i-th network unit is the last network unit, the i-th enhanced sample feature is determined as the initial sample feature of the image sample; if the i-th network unit is not the last network unit, i is incremented and the process of performing channel downsampling on the i-1-th enhanced sample feature in the i-th network unit to obtain the i-th downsampling feature is returned. Specifically, the process of obtaining the initial sample feature can be seen in Figure 5 below, which is a schematic diagram of an initial sample feature acquisition process provided in an embodiment of the present application, and a more detailed description is not provided here.
[0122] Among them, when the sample block features corresponding to each sample image block are fused with the sample block features of the adjacent sample image blocks of the sample image block to obtain the first sample feature of the sample image block, the sample block features of the adjacent sample image blocks of the k-th sample image block can be obtained; k is a positive integer. Further, the sample block features of the adjacent sample image blocks of the k-th sample image block can be fused with the sample block features corresponding to the k-th sample image block to obtain the first sample feature of the k-th sample image block; when k is M, the first sample features corresponding to the M sample image blocks are obtained. Alternatively, the sample block features of the adjacent sample image blocks of the k-th sample image block are subjected to feature fusion processing to obtain the adjacent enhanced features of the k-th sample image block, such as performing pooling processing on the sample block features of the adjacent sample image blocks to obtain the adjacent enhanced features of the k-th sample image block, etc. If the number of adjacent sample image blocks is k', k' is a positive integer, then the sample block features of the adjacent sample image blocks of the k-th sample image block can be recorded as f kk' , k'∈{1,2,…,k'}, assuming that the pooling process is the maximum pooling process (maxpool), then the adjacent enhanced feature can be recorded as The adjacent enhanced features of the k-th sample image block are fused with the sample block features corresponding to the k-th sample image block (such as feature splicing) to obtain the first sample feature of the k-th sample image block.
[0123] Specifically, when obtaining sample block features of adjacent sample image blocks of the kth sample image block, if the initial sample features include sample block features corresponding to the M sample image blocks that constitute the image sample, that is, if the initial sample features obtained through the above process are themselves composed of sample block features of each sample image block, the computer device can directly obtain the sample block features corresponding to the M sample image blocks. Alternatively, the computer device can divide the image sample into M sample image blocks, for example, by obtaining a region division size, and then divide the image sample into M sample image blocks based on the region division size. A default region division size can be determined as the region division size; or, performance testing can be performed on at least two candidate region division sizes to determine the size detection performance corresponding to the at least two candidate region division sizes, and the candidate region division size with the best size detection performance can be determined as the region division size. For example, assuming the region division size is 4*4, a 4*4 region in the image sample is determined as a sample image block. Similarly, the M sample image blocks that constitute the image sample can be obtained. Furthermore, unit pixel features of the characteristic pixel points constituting the image sample are obtained from the initial sample features, wherein the characteristic pixel points refer to pixel points that can be mapped to the initial sample features of the image sample; the unit pixel features of the characteristic pixel points included in the M sample image blocks are subjected to feature fusion processing to obtain sample block features corresponding to each of the M sample image blocks. For example, the unit pixel features of the characteristic pixel points included in the k-th sample image block are subjected to feature fusion processing to obtain the sample block features of the k-th sample image block. By performing block processing on the image samples, the number of features that need to be processed subsequently can be reduced, and the number of target first sample features that serve as the basis for subsequent image detection can also be further reduced, thereby improving the efficiency of data detection and, to a certain extent, reducing the resources consumed by data processing.
[0124] Specifically, when performing feature fusion processing on the unit pixel features of the characteristic pixels included in the M sample image blocks to obtain the sample block features corresponding to the M sample image blocks, the unit pixel features of the characteristic pixels included in the k-th sample image block can be pooled to obtain the sample block features of the k-th sample image block. Alternatively, feature splicing can be performed on the unit pixel features of the characteristic pixels included in the k-th sample image block to obtain the sample block features of the k-th sample image block. Alternatively, averaging processing can be performed on the unit pixel features of the characteristic pixels included in the k-th sample image block to obtain the sample block features of the k-th sample image block, etc. Alternatively, the unit pixel features of the characteristic pixels included in the kth sample image block can be sampled to obtain the pixel features to be fused of the characteristic pixels included in the kth sample image block. Specifically, the sampling size can be determined based on the region division size, and the unit pixel features of the characteristic pixels included in the kth sample image block are sampled based on the sampling size to obtain the pixel features to be fused of the characteristic pixels included in the kth sample image block. For example, assuming that the region division size is 4*4, the sampling size can be 1 / 4. Feature fusion processing is performed on the pixel features to be fused of the characteristic pixels included in the kth sample image block to obtain the sample block features of the kth sample image block. Specifically, feature splicing can be performed along the channel dimension on the pixel features to be fused of the characteristic pixels included in the kth sample image block to obtain the sample block features of the kth sample image block. Similarly, the sample block features corresponding to the M sample image blocks can be obtained, so that each sample block feature is obtained through multi-scale fusion, is a multi-scale feature, can contain more information, improve the information content of the sample block feature, and improve data processing accuracy to a certain extent.
[0125] Optionally, when constructing the first sample feature, reference may be made to FIG6 , which is a schematic diagram of a feature fusion processing scenario provided by an embodiment of the present application. As shown in FIG6 , assuming that k′ is 4, the computer device may obtain adjacent sample image blocks of the kth sample image block 6a, including adjacent sample image block (1), adjacent sample image block (2), adjacent sample image block (3) and adjacent sample image block (4), and perform feature fusion on the sample block features of the adjacent sample image blocks of the kth sample image block with the sample block features corresponding to the kth sample image block to obtain the first sample feature of the kth sample image block, such as performing feature fusion on the sample block features 6021 of the adjacent sample image block (1), the sample block features 6022 of the adjacent sample image block (2), the sample block features 6025 of the adjacent sample image block (3) and the sample block features 6024 of the adjacent sample image block (4) with the sample block features 6023 corresponding to the kth sample image block 6a to obtain the first sample feature 603 of the kth sample image block, wherein the feature fusion includes but is not limited to feature splicing. By introducing the feature information of adjacent sample image blocks on the basis of the sample image block, the first sample feature of each sample image block is made into a multi-scale feature, which contains both its own feature information and the feature information of adjacent sample image blocks, thereby increasing the information content in the feature. In this way, the context information of each sample image block can be fully considered in the subsequent processing process, thereby improving the accuracy of data processing.
[0126] Step S302 : determining a target first sample feature having the largest first feature distance from a plurality of first sample features.
[0127] In an embodiment of the present application, a computer device may perform representative feature detection processing on the first sample features to obtain a target first sample feature. Specifically, the computer device may determine the target first sample feature from M first sample features based on the first feature distance corresponding to each first sample feature. The first sample feature refers to the first sample feature corresponding to each of the M sample image blocks that constitute the image sample. Among them, the target first sample feature refers to the first sample feature with the largest corresponding first feature distance among multiple first sample features, and the first feature distance is the minimum value of the feature distances between the first sample feature and other first sample features among the multiple first sample features except the first sample feature. For example, the M first sample features are sequentially recorded as first sample feature 1, first sample feature 2, ... and first sample feature M. The first feature distance of the first sample feature 1 is the minimum value of the feature distances between the first sample feature 1 and the first sample feature 2 to the first sample feature M; the first feature distance of the first sample feature 2 is the minimum value of the feature distances between the first sample feature 2 and the first sample feature 1, the first sample feature 3 to the first sample feature M; ...; the first feature distance of the first sample feature M is the minimum value of the feature distances between the first sample feature M and the first sample feature 1 to the first sample feature M-1. In simple terms, a characteristic distance can be obtained between each first sample feature and the M-1 first sample features other than itself, that is, each first sample feature can obtain M-1 characteristic distances, and the minimum value of the M-1 characteristic distances corresponding to each first sample feature is determined as the first characteristic distance of the first sample feature. Specifically, the computer device can obtain the characteristic distance between the kth first sample feature and other first sample features except the kth first sample feature, and determine the minimum value of the characteristic distances corresponding to the kth first sample feature as the first characteristic distance of the kth first sample feature. Similarly, the first characteristic distances corresponding to multiple first sample features can be obtained; further, the first sample feature with the largest first characteristic distance can be determined as the target first sample feature. The characteristic distance between two first sample features is used to represent the similarity or difference between the two first sample features, and can be the Euclidean distance between the two first sample features.
[0128] Specifically, an initial reference feature set can be constructed, and the first sample feature corresponding to any sample image block can be added to the initial reference feature set. Furthermore, in the s-th set construction stage, the first feature distances between the M first sample features and the first sample features included in the reference feature set in the (s-1)-th set construction stage (which can be simply referred to as the reference feature set (s-1)) are obtained. The first feature distance obtained in the s-th set construction stage can be recorded as the first feature distance s. The first sample feature corresponding to the largest first feature distance obtained in the s-th set construction stage is added to the reference feature set (which can be simply referred to as the reference feature set (s-1)) to obtain the reference feature set in the s-th set construction stage (which can be referred to as the reference feature set s); s is a positive integer; when s is the second initial value, the reference feature set in the (s-1)-th set construction stage is the initial reference feature set. In other words, a suffix label can be added to the data to indicate the set construction stage in which the data is located, rather than to refer to the data. Among them, the feature distance in this application (such as the first feature distance or the second feature distance, etc.) refers to the minimum distance between the corresponding first sample feature and the sample feature for distance detection. For example, the feature distance between the first sample feature A and multiple sample features is the minimum value of the distances between the first sample feature A and multiple sample features respectively. For example, the first feature distance between the kth first sample feature and the first sample feature included in the initial reference feature set is the minimum value of the distances between the kth first sample feature and all the first sample features included in the initial reference feature set. If the reference feature set in the sth set construction stage meets the set convergence condition, the reference feature set in the sth set construction stage is determined as the target reference feature set corresponding to the image sample, and the first sample feature included in the target reference feature set is determined as the target first sample feature. The specific process of this process can be seen in Figure 7 below. Figure 7 is a schematic diagram of a feature reduction process provided in an embodiment of the present application, which will not be described here for the time being.
[0129] Step S303: Based on the first feature distance, determine (N+1) sample feature categories corresponding to the multiple first sample features, and train the initial feature classification model based on the (N+1) sample feature categories and the multiple first sample features to obtain a trained feature classification model.
[0130] In an embodiment of the present application, N is a positive integer, and the target first sample feature and the trained feature classification model are used together to perform image anomaly detection on the image to be analyzed. Specifically, the number of first sample features is M; M is a positive integer. Among them, (N+1) sample feature categories include N first feature categories and second feature categories; N first feature categories are used to indicate that the detected data is normal data, and the second feature category is used to indicate that the detected data is a secondary test. Specifically, the (N+1) sample feature categories corresponding to the multiple first sample features can be determined based on the first feature distance between the multiple first sample features and the target first sample feature. Among them, normal data is used to indicate that the detected data is accurate and meets the data standard of the data, that is, the object to be detected corresponding to the image data determined to be normal data meets the production standard of the object to be detected. For example, the object to be detected is a connector of a camera module. The production standard of the object to be detected includes straight pins without bending, no tin overflow and no pin breakage, etc. If the image data of the object to be detected is determined to be normal data, it can be considered that the object to be detected meets the production standard.
[0131] Among them, in one model training method, in the tth iteration, based on the first feature distance between the first sample feature included in the feature set to be detected in the (t-1)th iteration (which can be recorded as the feature set to be detected (t-1)) and the target first sample feature included in the auxiliary feature set in the (t-1)th iteration (which can be recorded as the auxiliary feature set (t-1)), p is determined. t-1 The associated sample features f corresponding to the first sample features of the target t ; t is a positive integer; when t is the third initial value, the feature set to be detected in the (t-1)th iteration includes M first sample features, p t-1 is a positive integer, p t-1 Refers to the number of target first sample features included in the auxiliary feature set in the (t-1)th iteration. In other words, a suffix label can be added after the data to indicate the iteration stage of the data, rather than to refer to the data. Based on p t-1 The associated sample features f corresponding to the first sample features of the target t , determine p t-1 The statistical frequency information corresponding to the first sample features of each target can be specifically based on p t-1 The associated sample features f corresponding to the first sample features of the target t , statistics p t-1 The feature histogram of the first sample feature of the target is used to represent p t-1 The statistical frequency information corresponding to each of the first sample features of the target. The first sample feature q with the largest statistical frequency information tThe corresponding associated sample feature f t , corresponding to the t-th sample feature category, that is, the more the number of associated first sample features, that is, the more the number of sample image blocks, it can be considered that the sample image block corresponding to the first sample feature is the common background area of the object to be detected, and it can be regarded as a background category (i.e., the first feature category), realizing the classification of sample features and sample generation, and realizing the generation of dependent data for image anomaly detection (such as the trained feature classification model and the target first sample feature, etc.), thereby improving the accuracy of data detection. Until p t-1 The statistical frequency information corresponding to the first sample features of the target meets the statistical convergence condition, the first sample features that are not divided into sample feature categories correspond to the second feature category, the N sample feature categories that have been determined (which can be recorded as N first feature categories) and the second feature category are composed of (N+1) sample feature categories, and the (N+1) sample feature categories and the first sample features corresponding to each sample feature category are used to train the initial feature classification model to obtain the trained feature classification model. In other words, the M first sample features can be divided into sample feature categories first, and then the model training is performed. Among them, the second feature category is used to indicate that the detected data is normal but occurs less frequently, or the data is abnormal, that is, further accurate detection is required, that is, the image to be detected needs to be subjected to secondary detection.
[0132] Alternatively, in the tth iteration, based on the first feature distance between the first sample feature included in the feature set to be detected in the (t-1)th iteration and the target first sample feature included in the auxiliary feature set in the (t-1)th iteration, p is determined. t-1 The associated sample features f corresponding to the first sample features of the target t ; t is a positive integer; when t is the third initial value, the feature set to be detected in the (t-1)th iteration includes M first sample features, p t-1 is a positive integer, p t-1 It refers to the number of target first sample features included in the auxiliary feature set in the (t-1)th iteration. t-1 The associated sample features f corresponding to the first sample features of the target t , determine p t-1 The statistical frequency information corresponding to the first sample features of the target is respectively taken as the first sample feature of the target with the largest statistical frequency information. t The corresponding associated sample feature f t, corresponding to the t-th sample feature category. Further, the t-th sample feature category and the feature set to be detected in the (t-1)-th iteration can be used to train the updated feature classification model in the (t-1)-th iteration to obtain the updated feature classification model in the t-th iteration; when t is the third initial value, the updated feature classification model in the (t-1)-th iteration is the initial feature classification model. If p t-1 If the statistical frequency information corresponding to the first sample features of each target satisfies the statistical convergence condition, the updated feature classification model in the tth iteration is determined as the trained feature classification model. In other words, model training can be performed while classifying.
[0133] Among them, in the above two methods, if p t-1 If the statistical frequency information corresponding to the first sample features of the target does not meet the statistical convergence condition, the feature set to be detected in the (t-1)th iteration is removed except for the first sample feature q t The corresponding associated sample feature f t The first sample features other than the first sample features constitute the feature set to be detected in the t-th iteration; the auxiliary feature set in the t-th iteration is obtained from the feature set to be detected in the t-th iteration, or the target first sample feature q in the auxiliary feature set in the (t-1)-th iteration can be deleted t , get the auxiliary feature set in the tth iteration. Further, update the value of t, that is, t = t + 1, and proceed to the next iteration, that is, return to execute the above process in the tth iteration. If p t-1 If the statistical frequency information corresponding to the first sample features of each target meets the statistical convergence condition, the updated feature classification model in the tth iteration is determined as the trained feature classification model.
[0134] Among them, you can get p t-1 The entropy of the statistical frequency information corresponding to the first sample features of each target is less than or equal to the entropy convergence threshold (such as 0.75), then p is determined. t-1 The statistical frequency information corresponding to the first sample features of each target satisfies the statistical convergence condition; if the entropy is greater than the entropy convergence threshold, then p is determined. t-1 The statistical frequency information corresponding to the first sample features of each target does not meet the statistical convergence conditions.
[0135] Among them, the above-mentioned suffix labels, such as (t-1), (s-1), t or s, etc., all indicate the iterative stage when the corresponding data is generated, and are not used to refer to the corresponding data. For example, the feature set to be detected (t-1) is used to indicate the feature set to be detected generated in the (t-1)th iteration, the first feature distance s is used to indicate the first feature distance generated in the sth set construction, and the reference feature set s is used to indicate the reference feature set generated in the sth set construction.
[0136] In simple terms, all the first sample features in the feature set to be detected (denoted as Q1) can be traversed, and for each first sample feature, the nearest proxy feature can be searched in the auxiliary feature set (denoted as Q2), that is, the target first sample feature corresponding to the first feature distance of each first sample feature, so that all the first sample features in Q1 can be associated with Q2. The first sample feature associated with any target first sample feature in Q2 in Q1 can be called the associated sample feature of the target first sample feature. Furthermore, a feature histogram can be statistically generated based on the associated sample features of each target first sample feature in Q2. According to the statistical frequency information of each target first sample feature in the feature histogram, the target first sample feature q with the largest statistical frequency information is selected. t The corresponding associated sample feature f t , is considered as a sample feature category, recorded as the first sample feature category, and the remaining first sample features in Q1 are considered as a separate category (recorded as the intermediate category). The first sample feature category and the intermediate category are used to train the initial feature classification model. After the model converges, an updated feature classification model is obtained. Further, all first sample features predicted as intermediate categories are re-feature reduced to obtain a new Q2. All first sample features predicted as intermediate categories are used as the new Q1. The above model training process is repeated until Q2 meets the statistical convergence condition, and the iteration is stopped. The updated feature classification model at this time is determined as the trained feature classification model.
[0137] Optionally, the p target first sample features can be directly used as sample features for subsequent image anomaly detection, that is, the p target first sample features are added to the feature memory (memory bank), where p is a positive integer and is used to uniformly refer to the number of target first sample features in any iteration; or, in the tth iteration of any of the above model training methods, the target first sample feature q t Add to the feature memory bank until p t-1The statistical frequency information corresponding to the first sample features of the target respectively meets the statistical convergence condition, and a final feature memory is obtained. The first sample features of the target included in the feature memory are used to perform image anomaly detection on the image to be analyzed.
[0138] Furthermore, the process of obtaining the above initial sample features can be referred to FIG5 . As shown in FIG5 , the process may include the following steps:
[0139] Step S501: Acquire an image sample and extract the initial image features corresponding to the image sample.
[0140] In an embodiment of the present application, a computer device may obtain an image sample, input the image sample into a feature detection model, and extract the initial image features corresponding to the image sample. Furthermore, the initial image features may be determined as the i-1th enhanced sample feature, where i is a first initial value. Furthermore, step S502 is executed.
[0141] Step S502: Input the i-1th enhanced sample feature into the i-th network unit. In the i-th network unit, perform feature processing on the i-1th enhanced sample feature to obtain the i-th residual feature.
[0142] In an embodiment of the present application, the i-th network unit may include one or more residual networks, assuming that the number of the residual networks is c, where c is a positive integer. The computer device may input the i-1th enhanced sample feature into the i-th network unit, and in the first residual network in the i-th network unit, perform convolution processing on the i-1th enhanced sample feature to obtain the i-th first residual feature; in the second residual network in the i-th network unit, perform convolution processing on the i-th first residual feature to obtain the i-th second residual feature; ...; in the c-th residual network in the i-th network unit, perform convolution processing on the i-th (c-1)th residual feature to obtain the i-th c-th residual feature, and use the i-th c-th residual feature as the i-th residual feature to execute step S503. The i-1th enhanced sample feature may be recorded as The i-th residual feature can be recorded as Wherein, F() is used to represent the i-th network unit.
[0143] In any residual network, the input features of the residual network can be subjected to channel-wise downsampling to obtain downsampled features. These input features, such as the i-1th enhanced sample feature input to the first residual network, the i-th first residual feature input to the second residual network, etc., can be subjected to channel-wise downsampling of the input features of the residual network using max pooling or a convolution kernel with a stride equal to the sampling interval. This can increase the network receptive field and local translation invariance of the obtained features, improve the feature's fault tolerance, and thereby enhance the accuracy of data detection. The sampling interval refers to the sampling interval to be achieved during the channel-wise downsampling process. The downsampled features are then convolved to obtain convolutional features corresponding to the image samples, such as convolving the downsampled features with a 3*3 convolution kernel. The convolutional features are then subjected to channel-wise upsampling to restore the feature's channels to their original channel size, thereby obtaining the output features of the residual network, such as the aforementioned residual features i. The implementation process of any of the aforementioned residual networks can be referenced in the implementation process of this section.
[0144] That is to say, when i is a first initial value (such as 1), the computer device can perform feature processing on the initial image features in the first network unit to obtain the first residual feature; when i is a positive integer greater than 1 and less than or equal to the number of network units, the computer device can perform feature processing on the i-1th enhanced sample features in the i-th network unit to obtain the i-th residual feature.
[0145] Step S503: Use the i-1th enhanced sample feature to perform feature enhancement processing on the i-th residual feature to obtain the i-th enhanced sample feature of the image sample.
[0146] In the embodiment of the present application, the i-th enhanced sample feature is The number of reference channels of each network unit will increase as the network level deepens, so that the acquired features can have richer semantic information.
[0147] Step S504: the i-th network unit is the last network unit.
[0148] In the embodiment of the present application, it is detected whether the i-th network unit is the last network unit. For example, assuming that there are a total of 5 network units (blocks), when i is 5, it indicates that the i-th network unit is the last network unit. Specifically, if the i-th network unit is not the last network unit, step S505 is executed; if the i-th network unit is the last network unit, step S506 is executed.
[0149] Step S505, i++.
[0150] In the embodiment of the present application, i is incremented, that is, the next network unit is executed, and the process returns to step S502.
[0151] Step S506: Determine the i-th enhanced sample feature as the initial sample feature of the image sample.
[0152] In the embodiment of the present application, the i-th enhanced sample feature is determined as the initial sample feature of the image sample.
[0153] Furthermore, the feature reduction process can be shown in FIG7 . As shown in FIG7 , the process may include the following steps:
[0154] Step S701: construct an initial reference feature set, and add the first sample feature corresponding to any sample image block to the initial reference feature set.
[0155] Step S702: determine the initial reference feature set as the reference feature set (s-1).
[0156] In the embodiment of the present application, at this time, s is a second initial value, such as 1.
[0157] Step S703: Obtain the first feature distances s between the M first sample features and the first sample features included in the reference feature set (s-1), add the first sample feature corresponding to the largest first feature distance s to the reference feature set (s-1), and obtain the reference feature set s.
[0158] In an embodiment of the present application, the distance between the kth first sample feature and the first sample feature included in the reference feature set (s-1) is obtained, and the minimum value of the distance between the kth first sample feature and the first sample feature included in the reference feature set (s-1) is determined as the first feature distance s corresponding to the kth first sample feature. The kth first sample feature is an associated sample feature of the first sample feature in the reference feature set (s-1) that is at the first feature distance s from the kth first sample feature. Similarly, the first feature distances s corresponding to the M first sample features can be obtained. Furthermore, the first sample feature corresponding to the largest first feature distance s among the M first sample features is added to the reference feature set (s-1) to obtain the reference feature set s, so that more representative fine-grained features can be obtained, reducing the resources consumed by feature maintenance, thereby improving the efficiency of data detection to a certain extent.
[0159] Step S704: Detect the reference feature set s based on the set convergence condition.
[0160] In an embodiment of the present application, it is detected whether the reference feature set s meets the set convergence condition. If the reference feature set does not meet the set convergence condition, step S705 is executed; if the reference feature set s meets the set convergence condition, step S706 is executed. If the reference feature set s reaches the set size threshold, it is determined that the reference feature set s meets the set convergence condition; if the reference feature set s does not reach the set size threshold, it is determined that the reference feature set s does not meet the set convergence condition. Alternatively, if the first feature distances (s+1) between the M first sample features and the first sample features included in the reference feature set s are both less than the convergence distance threshold, it is determined that the reference feature set s meets the set convergence condition; if among the first feature distances (s+1) between the M first sample features and the first sample features included in the reference feature set s, there is a first feature distance (s+1) greater than or equal to the convergence distance threshold, it is determined that the reference feature set s does not meet the set convergence condition.
[0161] Step S705, s++.
[0162] In the embodiment of the present application, s is incremented and the process returns to step S703.
[0163] Step S706: Determine the reference feature set s as the target reference feature set corresponding to the image sample, and determine the first sample feature included in the target reference feature set as the target first sample feature.
[0164] Through the above process, the memory occupied by feature maintenance is reduced, thereby reducing the resources consumed by feature maintenance and improving data detection efficiency. Specifically, as shown in Figure 8, Figure 8 is a schematic diagram of a feature reduction scenario provided by an embodiment of the present application. As shown in Figure 8, each first sample feature in the M first sample features can be traversed to obtain the distance between it and each first sample feature in the reference feature set, and the first feature distances corresponding to the M first sample features are determined. After the traversal is completed, a series of feature pairs can be obtained, each feature pair including one first sample feature in the M first sample features and one first sample feature in the reference feature set; the feature distance between each feature pair, such as the feature distance d1, feature distance d2, feature distance d3 and feature distance d4 shown in Figure 8, is the minimum distance between the first sample feature corresponding to the M first sample features and the reference feature set. And based on the maximum value of the feature distance corresponding to each feature pair, the reference feature set is updated. If the maximum value is d1, the first sample feature corresponding to d1 in the M first sample features is added to the reference feature set. Wherein, this process can be shown in formula ⑤:
[0165] As shown in formula ⑤, Q0 is used to represent the M first sample features, Q' is used to represent the reference feature set, ||f s -f q′ ||2 is used to represent the first sample feature f among the M first sample features s , and the first sample feature f in the reference feature set q' The characteristic distance between them, that is, first determine the first characteristic distance corresponding to the M first sample features, that is Then in (Q0-Q'), select the first sample feature with the largest first feature distance, that is It is used to represent the first sample feature that needs to be added to the reference feature set. Add to the reference feature set to update the reference feature set, denoted as Until the reference feature set (ie, Q') satisfies the set convergence condition, the reference feature set that satisfies the set convergence condition is determined as the target reference feature set.
[0166] In an embodiment of the present application, an image sample is obtained, and the first sample feature corresponding to the image sample is extracted; a target first sample feature with the largest first feature distance is determined from multiple first sample features; the first feature distance is the minimum value of the feature distances between the first sample feature and other first sample features other than the first sample feature; based on the first feature distance between the first sample feature and the target first sample feature, the (N+1) sample feature categories corresponding to the first sample feature are determined, and based on the (N+1) sample feature categories and the first sample feature, the initial feature classification model is trained to obtain a trained feature classification model; N is a positive integer, and the target first sample feature and the trained feature classification model are used together to perform image anomaly detection on the image to be analyzed. In the above process, only normal samples (i.e., image samples) are used, that is, defective samples do not need to be used, and only normal samples are used to complete the modeling, making it easier to obtain samples for model training, which can improve the efficiency of data detection. Moreover, since a sufficient amount of normal samples can be obtained to train a model with better robustness, the accuracy of data detection is improved. At the same time, during the training process, the first sample features will be subjected to feature reduction processing to obtain more compact and fine-grained sample features (i.e., the target first sample features), so that semantic segmentation of feature distance can be performed based on the sample features before feature reduction and the sample features after feature reduction, so as to train a post-trained feature classification model for image anomaly detection of the image to be analyzed, so that the post-trained feature classification model can be directly used for image anomaly detection in the future, thereby improving the accuracy and efficiency of data detection.
[0167] Further, see Figure 9, which is a schematic diagram of an image detection scenario provided by an embodiment of the present application. As shown in Figure 9, a computer device can capture an initial image 901 of the object to be detected, perform image registration processing on the initial image 901, and obtain an image to be analyzed 902. Image 902 to be analyzed is then detected for image anomalies, such as a bent pin anomaly shown in region 9031 or a solder overflow anomaly shown in region 9032.
[0168] Further, please refer to Figure 10, which is a flow chart of another data detection method provided by an embodiment of the present application. As shown in Figure 10, the data detection process includes the following steps:
[0169] Step S1001: Obtain the image features to be analyzed of the image to be analyzed, and predict the image feature category corresponding to the image features to be analyzed by using the trained feature classification model.
[0170] In an embodiment of the present application, the trained feature classification model is obtained by training multiple first sample features into (N+1) sample feature categories and multiple first sample features; N is a positive integer, and the (N+1) sample feature categories are obtained by dividing multiple first sample features based on the first feature distances between the multiple first sample features and the target first sample feature; the multiple first sample features are features extracted from the image sample; the target first sample feature is the first sample feature with the largest first feature distance among the multiple first sample features. The target first sample feature refers to the first sample feature with the largest corresponding first feature distance among the multiple first sample features, and the first feature distance is the minimum value of the feature distances between the first sample feature and other first sample features in the multiple first sample features except the first sample feature; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature category is used to indicate that the detected data is subjected to secondary detection.
[0171] Step S1002 : performing image anomaly detection on the image to be analyzed based on the image feature category corresponding to the image feature to be analyzed.
[0172] In an embodiment of the present application, the image features to be analyzed include block features of multiple image blocks constituting the image to be analyzed, and the image feature categories include subcategories of the block features of the multiple image blocks. If the subcategories corresponding to the block features of the multiple image blocks all belong to N first feature categories, the image to be analyzed is determined to be normal data; if there is a block feature whose subcategory is a second feature category among the block features of the multiple image blocks, the second feature distance between the image features to be analyzed and the target first sample feature is obtained, and based on the second feature distance between the image features to be analyzed and the target first sample feature, image anomaly detection is performed on the image to be analyzed. Specifically, the target first sample feature is obtained from the feature memory, and the second feature distance between the image features to be analyzed and the target first sample feature is obtained.
[0173] Specifically, the image features to be analyzed include block features of multiple image blocks that constitute the image to be analyzed. If there is a block feature with a subcategory of the second feature category among the block features of the multiple image blocks, then the second feature distance between the image feature to be analyzed and the target first sample feature is obtained, and image anomaly detection is performed on the image to be analyzed based on the second feature distance between the image feature to be analyzed and the target first sample feature. Specifically, if there is a block feature with a subcategory of the second feature category among the block features of the multiple image blocks, then the block feature to be detected with a subcategory of the second feature category is obtained, and the second feature distance between the block feature to be detected and the target first sample feature is obtained. Furthermore, if the second feature distance is less than or equal to the normal distance threshold, it means that the block feature to be detected is normal, but uncommon. During model training, it is not processed, and the image to be analyzed can be determined to be normal data; if the second feature distance is greater than the normal distance threshold, the second feature distance is converted into the degree of abnormality of the image to be analyzed. This process can be shown in formula ⑥:
[0174] As shown in formula ⑥, C0 is used to represent the features of the block to be detected, Q is used to represent the feature memory, and f a It is used to indicate a block feature to be detected among the block features to be detected. b It is used to represent the target first sample feature belonging to the feature memory. From the feature memory, the target first sample feature with the smallest distance to the feature of the block to be detected is found. At this time, multiple feature pairs to be detected can be obtained. a , f b}, the feature pair to be detected refers to the feature pair composed of the first sample feature of the target with the smallest distance to the block feature to be detected, that is, the second feature distance between the block feature to be detected and the first sample feature of the target can be obtained, and the second feature distance refers to the minimum distance between the corresponding block feature to be detected and the first sample feature of the target. Furthermore, the number of block features to be detected is one or more. If the number of block features to be detected is multiple, then the target feature pair corresponding to the largest second feature distance can be obtained from the second feature distances corresponding to the multiple block features to be detected, which can be recorded as Obtain the feature distance between the target feature pairs, i.e. S. Compare S with the normal distance threshold. If S is less than or equal to the normal distance threshold, the image to be parsed can be determined to be normal data; if S is greater than the normal distance threshold, the feature distance between the target feature pairs can be determined as the degree of abnormality of the image to be parsed.
[0175] For example, the present application can be used to perform object detection on an object to be inspected, that is, it can be used in scenarios such as industrial quality inspection. In this scenario, a computer device can capture an image of the object to be inspected, obtain an image to be analyzed, and perform image anomaly detection on the image to be analyzed through steps S1001 to S1002. Furthermore, when the image to be analyzed is determined to be normal data, it indicates that the object to be inspected meets the production standards, that is, the quality inspection of the object to be inspected has passed, and the object to be inspected can be released. When the degree of anomaly of the image to be analyzed is determined, the object to be inspected can be processed based on the degree of anomaly of the image to be analyzed. For example, if the degree of anomaly is greater than or equal to a destruction anomaly threshold, the object to be inspected can be destroyed; if the degree of anomaly is less than the destruction anomaly threshold, an object anomaly prompt message can be fed back to management personnel, so that the management personnel can repair or destroy the object to be inspected based on the object anomaly prompt message. Alternatively, the present application can be used for image classification processing to divide image data into two categories: normal data and abnormal images.
[0176] Further, please refer to Figure 11, which is a schematic diagram of a data detection device provided in an embodiment of the present application. The data detection device can be a computer program (including program code, etc.) running in a computer device. For example, the data detection device can be an application software; the device can be used to execute the corresponding steps in the method provided in an embodiment of the present application. As shown in Figure 11, the data detection device 1100 can be used for the computer device in the embodiment corresponding to Figure 3. Specifically, the device may include: a sample acquisition module 11, a feature extraction module 12, a feature reduction module 13 and a model training module 14.
[0177] The sample acquisition module 11 is used to acquire image samples;
[0178] A feature extraction module 12 is configured to extract a plurality of first sample features from the image sample;
[0179] A feature reduction module 13 is configured to determine a target first sample feature having a maximum first feature distance from a plurality of first sample features, where the first feature distance is the minimum value of feature distances between the first sample feature and other first sample features other than the first sample feature in the plurality of first sample features;
[0180] The model training module 14 is used to determine the (N+1) sample feature categories corresponding to the first sample feature based on the first feature distance, and train the initial feature classification model based on the (N+1) sample feature categories and multiple first sample features to obtain a trained feature classification model; N is a positive integer, and the target first sample feature and the trained feature classification model are jointly used to perform image anomaly detection on the image to be analyzed; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature category is used to indicate that the detected data is subjected to secondary detection.
[0181] The sample acquisition module 11 is specifically configured to:
[0182] Capturing an image of the object to be detected and obtaining a template image corresponding to the object to be detected; the template image refers to a standard image of the object to be detected generated during design;
[0183] The template image is used to perform image registration on the image of the object to be detected to obtain a registered image. Image registration refers to the process of matching and superimposing two or more images acquired at different times, using different sensors, or under different conditions.
[0184] Cut out the area corresponding to the object to be detected from the registered image;
[0185] The area corresponding to the object to be detected is determined as the image sample.
[0186] When the template image is used to perform image registration on the image of the object to be detected to obtain the registered image, the sample acquisition module 11 is used to:
[0187] Detecting a first object contour of the object to be detected in the image of the object to be detected, and detecting a second object contour of the object to be detected in the template image;
[0188] Acquiring contour offset information of the first object contour relative to the second object contour, and performing image rotation and offset processing on the image of the object to be detected based on the contour offset information to obtain a registered image;
[0189] When intercepting the area corresponding to the object to be detected from the registered image, the sample acquisition module 11 is used to:
[0190] The area corresponding to the first object contour in the registered image is determined as the area corresponding to the object to be detected in the registered image, and the area corresponding to the object to be detected is intercepted.
[0191] When the template image is used to perform image registration on the image of the object to be detected to obtain the registered image, the sample acquisition module 11 can be used to:
[0192] Convolution processing is performed on the image of the object to be detected using a Gaussian kernel to obtain a feature matrix of the pixel points included in the image of the object to be detected;
[0193] Obtaining matrix parameter weights for the feature matrix, performing weighted processing on the feature matrix using the matrix parameter weights, and obtaining pixel feature values of the pixel points included in the image of the object to be detected;
[0194] Using the pixel feature values of the pixels included in the image of the object to be detected, the image of the object to be detected is subjected to non-maximum suppression processing to determine the initial feature points of the image of the object to be detected; the non-maximum suppression processing refers to the processing of suppressing non-maximum elements for performing local maximum search;
[0195] Performing extreme value detection on the initial feature points to obtain a first feature point of the image of the object to be detected, detecting the wavelet features of the first feature point, and determining the direction of the wavelet feature with the largest modulus value among the wavelet features of the first feature point as the main feature direction of the first feature point;
[0196] Constructing a first eigenvector of the first feature point according to the feature main direction of the first feature point;
[0197] Detecting a second feature point in the template image and constructing a second feature vector of the second feature point;
[0198] Performing image registration on the image of the object to be detected and the template image based on the similarity between the first eigenvector and the second eigenvector to obtain a registered image;
[0199] When intercepting the area corresponding to the object to be detected from the registered image, the sample acquisition module 11 is used to:
[0200] Based on the object template corresponding to the template image, the area corresponding to the object to be detected is cut out from the registered image; the object template is used to represent the position information corresponding to the object to be detected in the template image.
[0201] The feature extraction module 12 is specifically configured to:
[0202] Extracting initial image features from image samples;
[0203] Perform convolution processing on the initial image features to obtain residual features corresponding to the image samples, and use the initial image features to perform feature enhancement processing on the residual features to obtain initial sample features of the image samples; the initial sample features include sample block features corresponding to the M sample image blocks that constitute the image sample; M is a positive integer;
[0204] The sample block feature corresponding to the k-th sample image block is fused with the sample block features of the adjacent sample image blocks of the k-th sample image block to obtain the first sample feature of the sample image block, until the first sample features corresponding to M sample image blocks are obtained respectively; k is a positive integer less than or equal to M.
[0205] When performing convolution processing on the initial image features to obtain residual features corresponding to the image samples, and performing feature enhancement processing on the residual features using the initial image features to obtain initial sample features of the image samples, the feature extraction module 12 is used to:
[0206] In the i-th network unit, the enhanced sample feature (i-1) is subjected to channel downsampling processing to obtain the downsampled feature i; when i is the first initial value, the enhanced sample feature (i-1) is the initial image feature; when i is not the first initial value, the enhanced sample feature (i-1) is the output feature of the (i-1)-th network unit;
[0207] In the i-th network unit, the i-1th enhanced sample feature is subjected to channel downsampling to obtain the i-th downsampling feature; when i is the first initial value, the i-1th enhanced sample feature is the initial image feature; when i is not the first initial value, the i-1th enhanced sample feature is the output feature of the i-1th network unit;
[0208] Perform convolution on the i-th downsampled feature to obtain the i-th convolution feature of the image sample;
[0209] Perform channel upsampling on the i-th convolution feature to obtain the i-th residual feature of the image sample;
[0210] The i-1th enhanced sample feature is used to perform feature enhancement processing on the i-th residual feature to obtain the i-th enhanced sample feature of the image sample;
[0211] If the i-th network unit is the last network unit, the i-th enhanced sample feature is determined as the initial sample feature of the image sample.
[0212] When the sample block feature corresponding to the k-th sample image block is fused with the sample block features of the adjacent sample image blocks of the k-th sample image block to obtain the first sample feature of the sample image block, and until the first sample features corresponding to M sample image blocks are obtained, the feature extraction module 12 is used to:
[0213] Obtain sample block features of adjacent sample image blocks of the k-th sample image block, perform pooling processing on the sample block features of the adjacent sample image blocks, and obtain adjacent enhanced features of the k-th sample image block; k is a positive integer;
[0214] Performing feature fusion on the adjacent enhanced features of the k-th sample image block and the sample block features corresponding to the k-th sample image block to obtain the first sample feature of the k-th sample image block;
[0215] When k is M, first sample features corresponding to M sample image blocks are obtained.
[0216] The first sample feature refers to the first sample features corresponding to the M sample image blocks constituting the image sample;
[0217] The feature reduction module 13 can be used to:
[0218] Constructing an initial reference feature set, and adding the first sample feature corresponding to any sample image block to the initial reference feature set;
[0219] In the s-th set construction stage, first feature distances are obtained between the M first sample features and the first sample features included in the reference feature set in the (s-1)-th set construction stage, and the first sample feature corresponding to the largest first feature distance obtained in the s-th set construction stage is added to the reference feature set obtained in the (s-1)-th set construction stage to obtain the reference feature set in the s-th set construction stage; s is a positive integer; when s is the second initial value, the reference feature set in the (s-1)-th set construction stage is the initial reference feature set;
[0220] If the reference feature set in the sth set construction stage meets the set convergence condition, the reference feature set in the sth set construction stage is determined as the target reference feature set corresponding to the image sample, and the first sample feature included in the target reference feature set is determined as the second sample feature.
[0221] Wherein, the number of first sample features is M, the number of target first sample features is p; M is a positive integer, p is a positive integer;
[0222] The model training module 14 can be used to:
[0223] In the tth iteration, based on the first feature distance between the first sample feature included in the feature set to be detected in the (t-1)th iteration and the first target sample feature included in the auxiliary feature set in the (t-1)th iteration, p is determined. t-1 The associated sample features f corresponding to the first sample features of the target t ; t is a positive integer; when t is the third initial value, the feature set to be detected in the (t-1)th iteration includes M first sample features, p t-1 is a positive integer, p t-1 It refers to the number of target first sample features included in the auxiliary feature set in the (t-1)th iteration;
[0224] Based on p t-1 The associated sample features f corresponding to the first sample features of the target t , determine p t-1 The statistical frequency information corresponding to the first sample features of the target is respectively, and the target first sample feature q with the largest statistical frequency information is selected as t The corresponding associated sample feature f t , corresponding to the t-th sample feature category;
[0225] The updated feature classification model in the (t-1)th iteration is trained using the t-th sample feature category and the feature set to be detected in the (t-1)th iteration to obtain the updated feature classification model in the t-th iteration; when t is the third initial value, the updated feature classification model in the (t-1)th iteration is the initial feature classification model;
[0226] If p t-1 If the statistical frequency information corresponding to the first sample features of the target does not meet the statistical convergence condition, the feature set to be detected in the (t-1)th iteration is removed except for the first sample feature q t The corresponding associated sample feature f t The first sample features other than the first sample features constitute the feature set to be detected in the t-th iteration, and the feature reduction process is performed on the feature set to be detected in the t-th iteration to obtain the auxiliary feature set in the t-th iteration;
[0227] If p t-1 If the statistical frequency information corresponding to the first sample features of each target meets the statistical convergence condition, the updated feature classification model in the tth iteration is determined as the trained feature classification model.
[0228] The embodiment of the present application provides a data detection device, which can obtain an image sample and extract a first sample feature corresponding to the image sample; perform feature reduction processing on the first sample feature to obtain a target first sample feature; the first sample feature includes the target first sample feature; based on the first feature distance between the first sample feature and the target first sample feature, determine the (N+1) sample feature categories corresponding to the first sample feature, and based on the (N+1) sample feature categories and the first sample feature, train the initial feature classification model to obtain a trained feature classification model; N is a positive integer, and the target first sample feature and the trained feature classification model are used to perform image anomaly detection on the image to be analyzed. In the above process, only normal samples (i.e., image samples) are used, that is, defective samples do not need to be used, and only normal samples are used to complete the modeling, so that samples used for model training are easier to obtain, which can improve the efficiency of data detection. Moreover, since a sufficient amount of normal samples can be obtained to train a model with better robustness, the accuracy of data detection is improved. At the same time, during the training process, the first sample features will be subjected to feature reduction processing to obtain more compact and fine-grained sample features (i.e., the target first sample features), so that semantic segmentation of feature distance can be performed based on the sample features before feature reduction and the sample features after feature reduction, so as to train a post-trained feature classification model for image anomaly detection of the image to be analyzed, so that the post-trained feature classification model can be directly used for image anomaly detection in the future, thereby improving the accuracy and efficiency of data detection.
[0229] Further, please refer to Figure 12, which is a schematic diagram of another data detection device provided in an embodiment of the present application. The data detection device can be a computer program (including program code, etc.) running in a computer device. For example, the data detection device can be an application software; the device can be used to execute the corresponding steps in the method provided in an embodiment of the present application. As shown in Figure 12, the data detection device 1200 can be used for the computer device in the embodiment corresponding to Figure 10. Specifically, the device may include: a feature acquisition module 21, a category prediction module 22 and an image detection module 23.
[0230] A feature acquisition module 21 is used to acquire the image features to be parsed of the image to be parsed;
[0231] The category prediction module 22 is used to predict the image feature category corresponding to the image feature to be analyzed through the trained feature classification model; the trained feature classification model is obtained by dividing the first sample feature into (N+1) sample feature categories and training the first sample feature; N is a positive integer, and the (N+1) sample feature categories are obtained by dividing the multiple first sample features based on the first feature distances corresponding to the multiple first sample features; the multiple first sample features are extracted from the image sample; the target first sample feature refers to the first sample feature with the largest first feature distance among the multiple first sample features, and the first feature distance is the minimum value of the feature distances between the first sample feature and other first sample features among the multiple first sample features except the first sample feature; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature categories are used to indicate that the detected data is subjected to secondary detection;
[0232] The image detection module 23 is configured to perform image anomaly detection on the image to be analyzed based on the image feature categories corresponding to the features of the image to be analyzed.
[0233] The image features to be analyzed include block features of multiple image blocks constituting the image to be analyzed, and the image feature categories include subcategories corresponding to the block features of the multiple image blocks. The image detection module 23 can be used to:
[0234] If the subcategories corresponding to the block features of the plurality of image blocks all belong to the N first feature categories, then it is determined that the image to be parsed is normal data;
[0235] If there is a block feature whose subcategory is the second feature category among the block features of multiple image blocks, the second feature distance between the image feature to be analyzed and the target first sample feature is obtained, and image anomaly detection is performed on the image to be analyzed based on the second feature distance between the image feature to be analyzed and the target first sample feature.
[0236] The image features to be analyzed include block features of a plurality of image blocks constituting the image to be analyzed, and the image feature categories include subcategories corresponding to the block features of the plurality of image blocks;
[0237] If a block feature of the second feature category exists among the block features of the plurality of image blocks, a second feature distance between the feature of the image to be analyzed and the target first sample feature is obtained. When performing image anomaly detection on the image to be analyzed based on the second feature distance between the feature of the image to be analyzed and the target first sample feature, the image detection module 23 may be used to:
[0238] If there is a block feature of the second feature category among the block features of the multiple image blocks, obtaining the block feature to be detected whose subcategory is the second feature category, and obtaining the second feature distance between the block feature to be detected and the target first sample feature;
[0239] If the second characteristic distance is less than or equal to the normal distance threshold, the image to be analyzed is determined to be normal data;
[0240] If the second characteristic distance is greater than the normal distance threshold, the second characteristic distance is converted into the abnormality degree of the image to be analyzed.
[0241] The embodiment of the present application provides a data detection device, which can obtain an image sample and extract the first sample feature corresponding to the image sample; determine the target first sample feature with the largest first feature distance from the first sample feature; the first sample feature includes the target first sample feature; based on the first feature distance between the first sample feature and the target first sample feature, determine the (N+1) sample feature categories corresponding to the first sample feature, and train the initial feature classification model based on the (N+1) sample feature categories and the first sample feature to obtain a trained feature classification model; N is a positive integer, and the target first sample feature and the trained feature classification model are used to perform image anomaly detection on the image to be analyzed. In the above process, only normal samples (i.e., image samples) are used, that is, defective samples do not need to be used, and only normal samples are used to complete the modeling, so that samples used for model training are easier to obtain, which can improve the efficiency of data detection. Moreover, since a sufficient amount of normal samples can be obtained to train a model with better robustness, the accuracy of data detection is improved. At the same time, during the training process, the first sample features will be subjected to feature reduction processing to obtain more compact and fine-grained sample features (i.e., the target first sample features), so that semantic segmentation of feature distance can be performed based on the sample features before feature reduction and the sample features after feature reduction, so as to train a post-trained feature classification model for image anomaly detection of the image to be analyzed, so that the post-trained feature classification model can be directly used for image anomaly detection in the future, thereby improving the accuracy and efficiency of data detection.
[0242] Referring to Figure 13, Figure 13 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. As shown in Figure 13, the computer device in an embodiment of the present application may include: one or more processors 1301, a memory 1302, and an input / output interface 1303. The processor 1301, the memory 1302, and the input / output interface 1303 are connected via a bus 1304. The memory 1302 is used to store a computer program, which includes program instructions. The input / output interface 1303 is used to receive and output data, such as for data exchange between a business device and a computer device; the processor 1301 is used to execute the program instructions stored in the memory 1302.
[0243] The processor 1301 may perform the following operations when used for model training:
[0244] Acquire an image sample, and extract a plurality of first sample features from the image sample;
[0245] Determine a target first sample feature having the largest first feature distance from the plurality of first sample features, where the first feature distance is the minimum value of feature distances between the first sample feature and other first sample features other than the first sample feature in the plurality of first sample features;
[0246] Based on the first feature distance, the (N+1) sample feature categories corresponding to the multiple first sample features are determined, and based on the (N+1) sample feature categories and the multiple first sample features, the initial feature classification model is trained to obtain a trained feature classification model; N is a positive integer, and the target first sample features and the trained feature classification model are jointly used to perform image anomaly detection on the image to be analyzed; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature categories are used to indicate that a secondary detection is performed on the detected data.
[0247] The processor 1301 may perform the following operations when performing model prediction:
[0248] Obtain the image features to be analyzed of the image to be analyzed, and predict the image feature categories corresponding to the image features to be analyzed by using a trained feature classification model; the trained feature classification model is obtained by dividing multiple first sample features into (N+1) sample feature categories and training multiple first sample features; N is a positive integer, and the (N+1) sample feature categories are obtained by dividing multiple first sample features based on the first feature distances corresponding to the multiple first sample features; the multiple first sample features are features extracted from image samples; the target first sample feature refers to the first sample feature with the largest corresponding first feature distance among the multiple first sample features, and the first feature distance is the minimum value of the feature distances between the first sample feature and other first sample features among the multiple first sample features except the first sample feature; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature categories are used to indicate that the detected data is subjected to secondary detection;
[0249] Based on the image feature categories corresponding to the features of the image to be analyzed, image anomaly detection is performed on the image to be analyzed.
[0250] In some feasible implementations, the processor 1301 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc.
[0251] The memory 1302 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1301 and the input / output interface 1303. A portion of the memory 1302 may also include a non-volatile random access memory. For example, the memory 1302 may also store device type information.
[0252] In a specific implementation, the computer device can execute the implementation methods provided by the various steps in Figure 3 through its built-in functional modules. For details, please refer to the implementation methods provided by the various steps in Figure 3, which will not be repeated here.
[0253] The embodiment of the present application provides a computer device, including: a processor, an input and output interface, and a memory. The processor obtains a computer program in the memory, executes the various steps of the method shown in Figure 3, and performs a data detection operation. The embodiment of the present application realizes obtaining an image sample, extracting a first sample feature corresponding to the image sample; performing feature reduction processing on the first sample feature to obtain a target first sample feature; the first sample feature includes the target first sample feature; based on the first feature distance between the first sample feature and the target first sample feature, determining the (N+1) sample feature categories corresponding to the first sample feature, and training the initial feature classification model based on the (N+1) sample feature categories and the first sample feature to obtain a trained feature classification model; N is a positive integer, and the target first sample feature and the trained feature classification model are used to perform image anomaly detection on the image to be analyzed. In the above process, only normal samples (i.e., image samples) are used, that is, defective samples do not need to be used, and only normal samples are used to complete the modeling, making it easier to obtain samples for model training, which can improve the efficiency of data detection. Moreover, since a sufficient amount of normal samples can be obtained to train a model with good robustness, the accuracy of data detection is improved. At the same time, during the training process, the first sample features will be subjected to feature reduction processing to obtain more compact and fine-grained sample features (i.e., the target first sample features), so that semantic segmentation of feature distance can be performed based on the sample features before feature reduction and the sample features after feature reduction, so as to train a post-trained feature classification model for image anomaly detection of the image to be analyzed, so that the post-trained feature classification model can be directly used for image anomaly detection in the future, thereby improving the accuracy and efficiency of data detection.
[0254] The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and the computer program is suitable for being loaded by the processor and executing the data detection method provided by each step in Figure 3. For details, please refer to the implementation method provided by each step in Figure 3, which will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, the computer program can be deployed to execute on a computer device, or on multiple computer devices located in one place, or on multiple computer devices distributed in multiple places and interconnected by a communication network.
[0255] The computer-readable storage medium can be the data detection device provided in any of the aforementioned embodiments or the internal storage unit of the computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. equipped on the computer device. Further, the computer-readable storage medium can also include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or is to be output.
[0256] The embodiment of the present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the method provided in the various optional methods in Figure 3, so that only normal samples (i.e., image samples) are used, that is, no defective samples are needed, and only normal samples are used to complete the modeling, so that samples used for model training are easier to obtain, which can improve the efficiency of data detection. Moreover, since a sufficient amount of normal samples can be obtained for training a model with good robustness, the accuracy of data detection is improved. At the same time, during the training process, the first sample feature will be subjected to feature reduction processing to obtain a more compact and fine-grained sample feature (i.e., the target first sample feature), so that the semantic segmentation of feature distance can be performed based on the sample features before feature reduction and the sample features after feature reduction, so as to train a trained feature classification model for image anomaly detection of the image to be analyzed, so that the trained feature classification model can be directly used for image anomaly detection in the future, thereby improving the accuracy and efficiency of data detection.
[0257] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.
[0258] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in this description according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0259] The method that the embodiment of the present application provides and related device are described with reference to the method flow chart and / or structural diagram that the embodiment of the present application provides, specifically can be realized by computer program instruction each flow process and / or square frame and the flow process and / or square frame in method flow chart and / or structural diagram.These computer program instructions can be provided to the processor of general-purpose computer, special-purpose computer, embedded processing machine or other programmable data detection equipment to produce a machine, make the instruction executed by the processor of computer or other programmable data detection equipment produce the device for realizing the function specified in flow chart one flow process or multiple flow processes and / or structural diagram one square frame or multiple square frames.These computer program instructions also can be stored in the computer-readable memory that can guide computer or other programmable data detection equipment to work in an ad hoc manner, make the instruction stored in this computer-readable memory produce the manufacture comprising instruction device, and this instruction device realizes the function specified in flow chart one flow process or multiple flow processes and / or structural diagram one square frame or multiple square frames. These computer program instructions can also be loaded onto a computer or other programmable data detection device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the structure diagram.
[0260] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.
[0261] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.
[0262] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data detection method, characterized in that: The method comprises: Acquire an image sample, and extract a plurality of first sample features from the image sample; Determine a target first sample feature having a maximum first feature distance from the multiple first sample features, where the first feature distance is the minimum value of feature distances between the first sample feature and other first sample features among the multiple first sample features except the first sample feature; Based on the first feature distance, (N+1) sample feature categories corresponding to the multiple first sample features are determined, and based on the (N+1) sample feature categories and the multiple first sample features, an initial feature classification model is trained to obtain a trained feature classification model; N is a positive integer, and the target first sample features and the trained feature classification model are used together to perform image anomaly detection on the image to be analyzed; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature category is used to indicate that a secondary detection is performed on the detected data.
2. The method according to claim 1, characterized in that The obtaining of image samples comprises: For the object to be detected, an image of the object to be detected is collected to obtain a template image corresponding to the object to be detected; the template image refers to a standard image generated when the object to be detected is designed; The template image is used to perform image registration on the image of the object to be detected to obtain a registered image; the image registration refers to the process of matching and superimposing two or more images acquired at different times, by different sensors or under different conditions; The region corresponding to the object to be detected is intercepted from the registered image, and the region corresponding to the object to be detected is determined as an image sample.
3. The method according to any one of claims 1 to 2, characterized in that: The step of using the template image to perform image registration on the image of the object to be detected to obtain a registered image includes: Detecting a first object contour of the object to be detected in the image of the object to be detected, and detecting a second object contour of the object to be detected in the template image; Acquire contour offset information of the first object contour relative to the second object contour, and perform image rotation and offset processing on the image of the object to be detected based on the contour offset information to obtain a registered image; The step of intercepting the region corresponding to the object to be detected from the registered image comprises: The area corresponding to the first object contour in the registered image is determined as the area corresponding to the object to be detected in the registered image, and the area corresponding to the object to be detected is intercepted.
4. The method according to any one of claims 1 to 3, characterized in that: The step of using the template image to perform image registration on the image of the object to be detected to obtain a registered image includes: Using a Gaussian kernel to perform convolution processing on the image of the object to be detected, so as to obtain a feature matrix of pixel points included in the image of the object to be detected; Obtaining matrix parameter weights for the feature matrix, and performing weighted processing on the feature matrix using the matrix parameter weights to obtain pixel feature values of pixel points included in the image of the object to be detected; Using the pixel feature values of the pixel points included in the image of the object to be detected, the image of the object to be detected is subjected to non-maximum suppression processing to obtain initial feature points of the image of the object to be detected; the non-maximum suppression processing refers to the processing of suppressing non-maximum elements for performing local maximum search; Perform extreme value detection on the initial feature point to obtain a first feature point of the image of the object to be detected, detect the wavelet feature of the first feature point, and determine the direction of the wavelet feature with the largest modulus value among the wavelet features of the first feature point as the feature main direction of the first feature point Towards; Constructing a first feature vector of the first feature point according to the feature main direction of the first feature point; Detecting a second feature point in the template image, and constructing a second feature vector of the second feature point; Performing image registration on the image of the object to be detected and the template image according to the similarity between the first feature vector and the second feature vector to obtain a registered image; The step of intercepting the region corresponding to the object to be detected from the registered image comprises: Based on the object template corresponding to the template image, a region corresponding to the object to be detected is intercepted from the registered image; the object template is used to represent the position information corresponding to the object to be detected in the template image.
5. The method according to any one of claims 1 to 4, characterized in that: The extracting a plurality of first sample features from the image sample comprises: extracting initial image features from the image samples; Performing convolution processing on the initial image features to obtain residual features of the image samples, and performing feature enhancement processing on the residual features using the initial image features to obtain initial sample features of the image samples; the initial sample features include sample block features corresponding to M sample image blocks constituting the image samples, respectively; M is a positive integer; The sample block feature corresponding to the k-th sample image block is feature fused with the sample block features of the adjacent sample image blocks of the k-th sample image block to obtain the first sample feature of the sample image block, until the first sample features corresponding to the M sample image blocks are respectively obtained; k is a positive integer less than or equal to M.
6. The method according to any one of claims 1 to 5, characterized in that: The performing convolution processing on the initial image features to obtain residual features of the image samples, and performing feature enhancement processing on the residual features using the initial image features to obtain initial sample features of the image samples, comprises: In the i-th network unit, channel downsampling processing is performed on the i-1th enhanced sample feature to obtain the i-th downsampling feature; when i is a first initial value, the i-1th enhanced sample feature is the initial image feature; when i is not the first initial value, the i-1th enhanced sample feature is the output feature of the i-1th network unit; Performing convolution processing on the i-th down-sampled feature to obtain the i-th convolution feature of the image sample; Perform channel upsampling processing on the i-th convolution feature to obtain the i-th residual feature of the image sample; Using the i-1th enhanced sample feature to perform feature enhancement processing on the i-th residual feature to obtain the i-th enhanced sample feature of the image sample; If the i-th network unit is the last network unit, the i-th enhanced sample feature is determined as the initial sample feature of the image sample.
7. The method according to any one of claims 1 to 6, characterized in that: The step of fusing the sample block feature corresponding to the k-th sample image block with the sample block features of the adjacent sample image blocks of the k-th sample image block to obtain the first sample feature of the sample image block, until the first sample features respectively corresponding to the M sample image blocks are obtained, comprises: Acquire sample block features of adjacent sample image blocks of the k-th sample image block, perform pooling processing on the sample block features of the adjacent sample image blocks, and obtain adjacency enhancement features of the k-th sample image block; Performing feature fusion on the adjacent enhanced feature of the k-th sample image block and the sample block feature corresponding to the k-th sample image block to obtain a first sample feature of the k-th sample image block; When k is M, the first sample features respectively corresponding to the M sample image blocks are obtained.
8. The method according to any one of claims 1 to 7, characterized in that: The first sample feature refers to the first sample features respectively corresponding to the M sample image blocks constituting the image sample; The determining a target first sample feature from the plurality of first sample features comprises: Constructing an initial reference feature set, and adding a first sample feature corresponding to any sample image block to the initial reference feature set; In the s-th set construction stage, first feature distances between M first sample features and first sample features in the reference feature set of the (s-1)-th set construction stage are obtained, and the first sample feature corresponding to the largest first feature distance obtained in the s-th set construction stage is added to the reference feature set of the (s-1)-th set construction stage to obtain the reference feature set of the s-th set construction stage; s is a positive integer; when s is the second initial value, the reference feature set of the (s-1)-th set construction stage is the initial reference feature set; If the reference feature set in the s-th set construction stage meets the set convergence condition, the reference feature set in the s-th set construction stage is determined as the target reference feature set corresponding to the image sample, and the first sample feature included in the target reference feature set is determined as the target first sample feature.
9. The method according to any one of claims 1 to 8, characterized in that: The number of the first sample features is M; M is a positive integer; The method of determining (N+1) sample feature categories corresponding to the first sample feature based on the first feature distance, and training an initial feature classification model based on the (N+1) sample feature categories and the plurality of first sample features to obtain a trained feature classification model includes: In the tth iteration, based on the first feature distance between the first sample feature included in the feature set to be detected in the (t-1)th iteration and the first target sample feature included in the auxiliary feature set in the (t-1)th iteration, p is determined. t-1 The associated sample features f corresponding to the first sample features of the target t ; t is a positive integer; when t is the third initial value, the feature set to be detected in the (t-1)th iteration includes M first sample features, p t-1 is a positive integer, p t-1 refers to the number of target first sample features included in the auxiliary feature set in the (t-1)th iteration; Based on the p t-1 The associated sample features f corresponding to the first sample features of the target t , determine the p t-1 The statistical frequency information corresponding to the first sample features of the target is respectively taken as the first sample feature of the target with the largest statistical frequency information. t The corresponding associated sample feature f t , corresponding to the tth sample feature category; Using the t-th sample feature category and the feature set to be detected in the (t-1)-th iteration, the updated feature classification model in the (t-1)-th iteration is trained to obtain the updated feature classification model in the t-th iteration; when t is the third initial value, the updated feature classification model in the (t-1)-th iteration is the initial feature classification model; If the p t-1 If the statistical frequency information corresponding to the first sample features of the target does not meet the statistical convergence condition, then the feature set to be detected in the (t-1)th iteration is removed except for the first sample feature q t The corresponding associated sample feature f t The first sample features other than the first sample features constitute a feature set to be detected in the t-th iteration, and the auxiliary feature set in the t-th iteration is obtained from the feature set to be detected in the t-th iteration; If the p t-1 If the statistical frequency information corresponding to the first sample features of the targets respectively meets the statistical convergence condition, the updated feature classification model in the t-th iteration is determined as the trained feature classification model.
10. A data detection method, characterized in that: The method comprises: Obtain an image feature to be analyzed of an image to be analyzed, and predict an image feature category corresponding to the image feature to be analyzed by using a trained feature classification model; the trained feature classification model is obtained by dividing a plurality of first sample features into (N+1) sample feature categories and training the plurality of first sample features; N is a positive integer, and the (N+1) sample feature categories are obtained by dividing the plurality of first sample features based on first feature distances respectively corresponding to the plurality of first sample features; the plurality of first sample features are obtained from image samples. The extracted features; the target first sample feature refers to the first sample feature with the largest corresponding first feature distance among the multiple first sample features, and the first feature distance corresponding to any first sample feature is the minimum value of the feature distances between the first sample feature and other first sample features among the multiple first sample features except the first sample feature; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature category is used to indicate that a secondary detection is performed on the detected data; Based on the image feature category corresponding to the image feature to be analyzed, image anomaly detection is performed on the image to be analyzed.
11. The method according to claim 10, characterized in that The image features to be analyzed include block features of a plurality of image blocks constituting the image to be analyzed, and the image feature categories include subcategories corresponding to the block features of the plurality of image blocks respectively; The performing image anomaly detection on the image to be analyzed based on the image feature category corresponding to the image feature to be analyzed includes: If the subcategories corresponding to the block features of the plurality of image blocks all belong to the N first feature categories, determining that the image to be analyzed is normal data; If there is a block feature whose subcategory is the second feature category among the block features of the multiple image blocks, the second feature distance between the image feature to be analyzed and the target first sample feature is obtained, and image anomaly detection is performed on the image to be analyzed based on the second feature distance between the image feature to be analyzed and the target first sample feature.
12. The method according to any one of claims 10-11, characterized in that: If there is a block feature whose subcategory is the second feature category among the block features of the multiple image blocks, obtaining a second feature distance between the image feature to be analyzed and the target first sample feature, and performing image anomaly detection on the image to be analyzed based on the second feature distance between the image feature to be analyzed and the target first sample feature, including: If there is a block feature whose subcategory is the second feature category among the block features of the multiple image blocks, obtaining the block feature to be detected whose subcategory is the second feature category, and obtaining a second feature distance between the block feature to be detected and the target first sample feature; If the second characteristic distance is less than or equal to the normal distance threshold, determining that the image to be analyzed is normal data; If the second characteristic distance is greater than the normal distance threshold, the second characteristic distance is converted into the abnormality degree of the image to be analyzed.
13. A data detection device, characterized in that: The device comprises: A sample acquisition module, used for acquiring image samples; A feature extraction module, used for extracting a plurality of first sample features from the image sample; A feature reduction module, configured to determine a target first sample feature from the plurality of first sample features, wherein the target first sample feature refers to a first sample feature having the largest corresponding first feature distance among the plurality of first sample features, and the first feature distance corresponding to any first sample feature is the minimum value of feature distances between the first sample feature and other first sample features among the plurality of first sample features except the first sample feature; A model training module is used to determine the (N+1) sample feature categories corresponding to the first sample feature based on the first feature distance, and to train the initial feature classification model based on the (N+1) sample feature categories and the multiple first sample features to obtain a trained feature classification model; N is a positive integer, and the target first sample feature and the trained feature classification model are used together to perform image anomaly detection on the image to be analyzed; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature category is used to indicate that a secondary detection is performed on the detected data.
14. A data detection device, characterized in that: The device comprises: A feature acquisition module, used for acquiring the image features to be analyzed of the image to be analyzed; a category prediction module, used for predicting the image feature category corresponding to the image feature to be analyzed by a trained feature classification model; the trained feature classification model is obtained by dividing a plurality of first sample features into (N+1) sample feature categories and training the plurality of first sample features; N is a positive integer, the (N+1) sample feature categories are obtained by dividing the plurality of first sample features based on the first feature distances respectively corresponding to the plurality of first sample features; the plurality of first sample features are features extracted from image samples; the target first sample feature refers to the first sample feature with the largest first feature distance corresponding to the plurality of first sample features, and the first feature distance corresponding to any one of the first sample features is the minimum value of the feature distances between the first sample feature and the other first sample features in the plurality of first sample features except the first sample feature; the (N+1) sample feature categories include N first feature categories and second feature categories; the N first feature categories are used to indicate that the detected data is normal data, and the second feature category is used to indicate that a secondary detection is performed on the detected data; The image detection module is used to perform image anomaly detection on the image to be analyzed based on the image feature category corresponding to the image feature to be analyzed.
15. A computer device, characterized in that: Includes processor, memory, input and output interfaces; The processor is connected to the memory and the input / output interface respectively, wherein the input / output interface is used to receive data and output data, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method described in any one of claims 1 to 9, or executes the method described in any one of claims 10 to 12.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 9, or executes the method according to any one of claims 10 to 12.
17. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 9 is implemented, or the method according to any one of claims 10 to 12 is executed.
Citation Information
Patent Citations
Stomach early cancer model training method and device, computer equipment and storage medium
CN113593707A
Image recognition model training method and device, equipment and storage medium
CN114330522A
Processing method and device and electronic equipment
CN116071558A
Data detection method and device, computer, storage medium and program product
CN116977719A
Object detection optimization
US20210027106A1