Defect detection of target objects, model training methods, devices, equipment and media
By performing image processing on target objects in an industrial production environment, extracting and classifying feature data of defect sub-images, and combining semantic segmentation and classification technology, the problem of low defect detection accuracy and efficiency in the existing technology is solved, achieving a more efficient , accurate defect detection.
Patent Information
- Application Number
- CN202210395791.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-04-15
AI Technical Summary
In the existing technology, in complex and diverse industrial production environments, the accuracy of defect detection methods is low, the detection efficiency is not high, and it is difficult to adapt to the detection needs of various defect forms.
By acquiring the image of the target object, detecting the area of interest, cropping the defect sub-image, extracting image feature data, performing semantic segmentation and classification processing, determining the contour and category information of the defect, detecting based on morphological parameters, and updating using the trained model parameters to improve detection accuracy and efficiency.
It improves the accuracy and efficiency of defect detection, can locate and identify defects in target objects more efficiently and accurately, and enhances the robustness of detection results.
Smart Images

Figure CN115131283B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, equipment and medium for defect detection and model training of a target object. Background Art
[0002] In recent years, with the rapid development of artificial intelligence technology, various types of machine learning models have achieved relatively good application results in the fields of image classification, face recognition, and autonomous driving. Among them, in the field of industrial production, there are applications that use computer vision technology to detect defects in target objects (generally industrial products).
[0003] In the related technologies, due to the complexity of the production environment, the non-uniformity of process standards and other factors, the defects on the products may take various forms. The current defect detection methods are often only applicable to the type of single defect detection. When faced with complex and diverse detection requirements, the accuracy of the detection results is low and the detection efficiency is not high. Summary of the invention
[0004] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
[0005] The embodiments of the present application provide a target defect detection, model training method, device, electronic device and medium, which can improve the accuracy and detection efficiency of target defect detection.
[0006] On the one hand, an embodiment of the present application provides a defect detection method for a target object, comprising:
[0007] Acquire a first image of a target object;
[0008] Detecting an area of interest in the first image, and cropping the area of interest to obtain a defect sub-image of the target object;
[0009] Extracting image feature data of the defect sub-image;
[0010] Performing semantic segmentation processing on the defect sub-image according to the image feature data to obtain a defect outline of the defect sub-image; performing defect classification processing on the defect sub-image according to the image feature data to obtain category information of defects in the defect sub-image;
[0011] Determining the morphological parameters of the defect in the defect sub-image according to the defect contour;
[0012] The defect detection result of the target object is determined according to the category information and the morphological parameters of the defects in each of the defect sub-images.
[0013] On the other hand, the embodiment of the present application also provides a method for training a target object defect detection model, including:
[0014] Acquire multiple sample sub-images; the sample sub-images carry defect labels; the defect labels are used to characterize defect contours of the sample sub-images and category information of defects in the sample sub-images;
[0015] Extracting image feature data of each of the sample sub-images through a target object defect detection model;
[0016] Performing semantic segmentation processing on the sample sub-image according to the image feature data to obtain a defect contour prediction result of the sample sub-image;
[0017] Perform defect classification processing on the sample sub-image according to the image feature data to obtain a prediction result of category information of the defects in the sample sub-image;
[0018] Determining a first loss value according to the defect contour prediction result and the defect label;
[0019] Determining a second loss value according to the category information prediction result and the defect label;
[0020] According to the first loss value and the second loss value, the parameters of the target defect detection model are updated to obtain a trained target defect detection model.
[0021] On the other hand, an embodiment of the present application further provides a target object defect detection device, comprising:
[0022] An acquisition module, used for acquiring a first image of a target object;
[0023] A cropping module, used for detecting an area of interest in the first image, and cropping the area of interest to obtain a defect sub-image of the target object;
[0024] A first processing module, used for extracting image feature data of the defect sub-image;
[0025] A second processing module is used to perform semantic segmentation processing on the defect sub-image according to the image feature data to obtain a defect contour of the defect sub-image;
[0026] A third processing module is used to perform defect classification processing on the defect sub-image according to the image feature data to obtain category information of the defects in the defect sub-image;
[0027] An identification module, used to determine the morphological parameters of the defect in the defect sub-image according to the defect contour;
[0028] A detection module is used to determine the defect detection result of the target object according to the category information and the morphological parameters of the defects in each of the defect sub-images.
[0029] Furthermore, the above-mentioned cutting module is specifically used for:
[0030] determining a pixel mean of the first image;
[0031] Determine a plurality of first target pixel points from the first image according to the pixel mean; wherein a difference between the pixel value of the first target pixel point and the pixel mean is greater than a first preset threshold or less than a second preset threshold, the first preset threshold is a positive number, and the second preset threshold is a negative number;
[0032] In the first image, determining a connected area formed by a plurality of the first target pixels;
[0033] Each of the connected regions is cropped from the first image to obtain a defect sub-image of the target object.
[0034] Furthermore, the above-mentioned cutting module is specifically used for:
[0035] Determine a second target pixel from the first image according to the pixel values of each pixel of the first image; wherein the pixel value of the second target pixel is greater than a third preset threshold and less than a fourth preset threshold, and the third preset threshold is less than the fourth preset threshold;
[0036] The average value of the pixel values of each of the second target pixel points is calculated to obtain the pixel mean value of the first image.
[0037] Furthermore, the target object defect detection device further comprises:
[0038] The normalization processing module is used to perform image scale normalization processing on the defect sub-image to obtain a new defect sub-image.
[0039] Furthermore, the above identification module is specifically used for:
[0040] According to the defect contour, based on the size of the defect sub-image before image scale normalization processing, the size of the defect contour is restored to obtain the original contour of the defect in the defect sub-image;
[0041] According to the original contour, morphological parameters of the defects in the defect sub-image are determined.
[0042] Furthermore, the second processing module is specifically used for:
[0043] Extracting image feature data of the defect sub-image at different image scales;
[0044] Performing feature fusion processing on the image feature data of the different layers of image scales to obtain first target feature data;
[0045] The first target feature data is semantically segmented by a decoder to obtain a defect outline of the defect sub-image.
[0046] Furthermore, the third processing module is specifically used for:
[0047] Determine the image feature data at the smallest layer of the image scale as the second target feature data;
[0048] The second target feature data is subjected to defect classification processing by a classifier to obtain category information of the defects in the defect sub-image.
[0049] Furthermore, the target object defect detection device further comprises:
[0050] A filtering module, used for filtering the defects of the target object according to the morphological parameters corresponding to each defect in the target object, to obtain the target defects of the target object;
[0051] An accumulation module, used to determine the accumulated number of target defects corresponding to each defect category in the target object;
[0052] A defect processing module is used to determine a defect processing mode of the target object according to the defect category and the accumulated number, wherein the defect processing mode includes at least one of alarm processing, shutdown processing or labeling processing.
[0053] Furthermore, the filtering module is specifically used for:
[0054] Obtaining preset morphological parameter categories and preset morphological parameter thresholds corresponding to each defect category;
[0055] Under each of the preset morphological parameter categories, comparing the morphological parameter corresponding to the defect with the preset morphological parameter threshold;
[0056] When all the morphological parameters corresponding to the defect are less than or equal to the preset morphological parameter threshold, the defect is eliminated; or, when any morphological parameter corresponding to the defect is greater than the preset morphological parameter threshold, the defect is determined as a target defect.
[0057] On the other hand, the embodiment of the present application also provides a training device for a target object defect detection model, including:
[0058] A second acquisition module is used to acquire a plurality of sample sub-images; the sample sub-images carry defect labels; the defect labels are used to characterize the defect contours of the sample sub-images and the category information of the defects in the sample sub-images;
[0059] An extraction module, used for extracting image feature data of each of the sample sub-images through a target object defect detection model;
[0060] A fourth processing module, configured to perform semantic segmentation processing on the sample sub-image according to the image feature data to obtain a defect contour prediction result of the sample sub-image;
[0061] A fifth processing module, configured to perform defect classification processing on the sample sub-image according to the image feature data, and obtain a prediction result of category information of the defects in the sample sub-image;
[0062] A first loss value determination module, used to determine a first loss value according to the defect contour prediction result and the defect label;
[0063] A second loss value determination module, used to determine a second loss value according to the category information prediction result and the defect label;
[0064] A training module is used to update the parameters of the target defect detection model according to the first loss value and the second loss value to obtain a trained target defect detection model.
[0065] Furthermore, the second acquisition module is specifically used for:
[0066] acquiring a second image of the sample object;
[0067] An area of interest in the second image is detected and the area of interest is cropped, wherein the sample sub-image is annotated with a corresponding defect label.
[0068] Furthermore, the training device of the target object defect detection model further includes:
[0069] A coincidence detection module, used for detecting the coincidence of defect contours of each defect in the sample sub-image when it is determined that the number of defects in the sample sub-image is multiple;
[0070] An overlap comparison module, used for determining that there is a defective overlap area in the sample sub-image when the overlap is greater than a preset overlap threshold;
[0071] The marking module is used to determine the defect label corresponding to the defect with the highest defect priority in the defect overlap area as the defect label corresponding to the defect overlap area according to preset defect priority sorting information.
[0072] Furthermore, the training device of the target object defect detection model further includes:
[0073] The re-cropping module is used to re-crop the sample sub-image when the overlap degree is less than or equal to the preset overlap threshold value to obtain a plurality of new sample sub-images.
[0074] On the other hand, an embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the above-mentioned target object defect detection method or target object defect detection model training method.
[0075] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, which stores a program, and the program is executed by a processor to implement the above-mentioned target object defect detection method or target object defect detection model training method.
[0076] On the other hand, the embodiment of the present application further provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned target object defect detection method or the target object defect detection model training method.
[0077] The embodiments of the present application include at least the following beneficial effects: the embodiments of the present application detect and crop the region of interest of the first image of the target object to obtain a defect sub-image, which can quickly locate the position of the defect to be detected in the target object, and detect the defect sub-image, which is beneficial to reduce the overall data processing amount and improve the data processing efficiency; in the defect detection process, after extracting the image feature data, the image feature data is semantically segmented to determine the contour information of the defect, and then the morphological parameters of the defect are determined, and the image feature data is defectively classified to determine the category of the defect, wherein the defect sub-image is semantically segmented and the defect category is classified, respectively, and the classification accuracy is higher than that of directly performing multi-classification semantic segmentation; compared with a simple classification network, the semantic segmentation process is combined to extract the defect contour, which is convenient for determining the morphological parameters of the defect, thereby improving the accuracy of defect detection as a whole. Therefore, the embodiments of the present application perform defect detection by combining semantic segmentation with target object classification, which can obtain the target defect detection result more efficiently and accurately, and is beneficial to improving the robustness of defect location and recognition.
[0078] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0080] Figure 1 A schematic diagram of an implementation environment provided for an embodiment of the present application;
[0081] Figure 2 A schematic diagram of another implementation environment provided for an embodiment of the present application;
[0082] Figure 3 A schematic diagram of a process for detecting defects in a target object provided in an embodiment of the present application;
[0083] Figure 4 A defect outline schematic diagram of a defect sub-image provided in an embodiment of the present application;
[0084] Figure 5 A schematic diagram of displaying a defect detection result provided in an embodiment of the present application;
[0085] Figure 6 A schematic diagram of another display of defect detection results provided in an embodiment of the present application;
[0086] Figure 7 A schematic diagram of a cropped defect sub-image provided in an embodiment of the present application;
[0087] Figure 8 A schematic diagram of performing image scale normalization processing on a defect sub-image provided in an embodiment of the present application;
[0088] Fig. 9 A schematic diagram of a lithium battery coating defect category provided in an embodiment of the present application;
[0089] Fig.10 A schematic diagram of a task flow for lithium battery coating defects provided in an embodiment of the present application;
[0090] Fig.11 A schematic diagram of a coating image of a lithium battery pole piece provided in an embodiment of the present application;
[0091] Fig.12 A schematic diagram of cropping a region of interest of a coating image provided in an embodiment of the present application;
[0092] Fig.13 A schematic diagram of a partial structure of a neural network provided in an embodiment of the present application;
[0093] Fig.14A schematic diagram of an operation interface for performing rule post-processing based on defect detection results provided in an embodiment of the present application;
[0094] Fig.15 A flowchart of a method for training a target object defect detection model provided in an embodiment of the present application;
[0095] Fig.16 A schematic diagram of marking defect labels of a sample sub-image provided in an embodiment of the present application;
[0096] Fig.17 A structural block diagram of a target object defect detection device provided in an embodiment of the present application;
[0097] Fig.18 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0098] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and are not to be construed as limitations on the present application. For the step numbers in the following embodiments, they are only provided for the convenience of explanation, and the order between the steps is not limited in any way, and the execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.
[0099] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0100] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0101] Region of interest: ROI (region of interest), in machine vision and image processing, the area to be processed is outlined in the image in the form of a box, circle, ellipse, irregular polygon, etc., which is called the region of interest. In machine vision software such as Halcon, OpenCV, Matlab, etc., various operators and functions are often used to obtain the region of interest and perform the next step of image processing.
[0102] The defect detection method and model training method of the target object provided in the embodiments of the present application mainly involve artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. Among them, basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc.; artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, machine learning / deep learning, autonomous driving, and smart transportation.
[0103] The defect detection method and model training method for the target object provided in the embodiments of the present application specifically relate to computer vision technology and machine learning / deep learning in the field of artificial intelligence.
[0104] Among them, Computer Vision (CV) is a science that studies how to make machines "see". To be more specific, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further perform graphic processing to make computer processing into images that are more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0105] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning (deep learning) usually includes artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.
[0106] Specifically, the method provided in the embodiments of the present application can use computer vision technology to perform defect detection on the image of the target object, so as to perform detailed contour positioning and type identification of the defects of the target object; in the process of defect detection on the image of the target object, the model obtained through machine learning / deep learning training can be used to perform image feature data extraction, classification tasks of the type of defects in the image, etc., and a training method for the model that can detect and process defects of the target object is also provided.
[0107] The method provided in the embodiments of the present application can be executed in various application scenarios in the field of artificial intelligence: for example, in the application scenario of industrial manufacturing, there is a need to perform quality inspection on products. Among them, defect detection on the appearance of a product is one of the items of quality inspection. In this scenario, the method provided in the embodiments of the present application can be used to perform defect detection on the product, thereby obtaining defect detection results, which can be used to analyze the quality of the product. Of course, it should be noted that the above application scenarios only serve as an example and do not mean to limit the actual application of the methods in the embodiments of the present application. Those skilled in the art can understand that in different application scenarios, artificial intelligence systems can use the methods provided in the embodiments of the present application to perform specified tasks.
[0108] In recent years, with the rapid development of artificial intelligence technology, various types of machine learning models have achieved relatively good application results in the fields of image classification, face recognition, and autonomous driving. Among them, in the field of industrial production, there are applications that use computer vision technology to detect defects in target objects (generally industrial products).
[0109] In the related technologies, due to the complexity of the production environment, the non-uniformity of process standards and other factors, the defects on the products may take various forms. The current defect detection methods are often only applicable to the type of single defect detection. For example, in some applications, the presence or absence of defects is judged only by detecting the difference in the grayscale value of the image of the target object. The application scenarios of this method are very limited. When faced with complex and diverse detection requirements, the accuracy of the detection results is low and the detection efficiency is not high.
[0110] Based on this, the embodiment of the present application provides a target object defect detection method, a target object defect detection model training method, a device, an electronic device and a storage medium, wherein the detection method detects and crops the region of interest of the first image of the target object to obtain a defect sub-image, which can quickly locate the position of the defect to be detected in the target object, and detects the defect sub-image, which is conducive to reducing the overall data processing amount and improving data processing efficiency; in the defect detection process, after extracting the image feature data, the image feature data is semantically segmented to determine the contour information of the defect, and then the morphological parameters of the defect are determined, and the image feature data is defectively classified to determine the category of the defect, wherein the defect sub-image is semantically segmented and the defect category is classified, respectively, and the classification accuracy is higher than that of directly performing multi-classification semantic segmentation; compared with a simple classification network, the semantic segmentation processing is combined to extract the defect contour, which is convenient for determining the morphological parameters of the defect, thereby improving the accuracy of defect detection as a whole. Therefore, the embodiment of the present application performs defect detection by combining semantic segmentation with target object classification, which can obtain the target defect detection result more efficiently and accurately, which is conducive to improving the robustness of defect location and recognition.
[0111] The specific implementation of the embodiment of the present application is described in detail below in conjunction with the accompanying drawings.
[0112] Reference Figure 1 , Figure 1 A schematic diagram of an implementation environment of the target object defect detection method provided in the embodiment of the present application is shown. In the implementation environment, the main software and hardware entities involved include a first terminal 110.
[0113] Specifically, a related defect detection application may be installed in the first terminal 110, and the defect detection application may execute the defect detection method provided in the embodiment of the present application based on the image of the target object acquired by the first terminal 110, thereby obtaining the corresponding defect detection result, and displaying it on the application interface for the user to browse. It should be noted that, here, the first terminal 110 acquires the image of the target object, which may be acquired by other image acquisition devices and then transmitted to the first terminal 110, or acquired by the first terminal 110 based on its own camera application.
[0114] In addition, refer to Figure 2 , Figure 2 A schematic diagram of another implementation environment of the target object defect detection method provided in an embodiment of the present application, wherein the software and hardware entities mainly involved in the implementation environment include a second terminal 210 and a server 220, wherein the second terminal 210 and the server 220 are communicatively connected.
[0115] Specifically, the server 220 may be installed with a relevant defect detection application, which may execute the defect detection method provided in the embodiment of the present application based on the image of the target object, thereby obtaining the corresponding defect detection result, and may send the defect detection result to the local second terminal 210 for display and browsing by the user. It should be noted that, here, the image of the target object may be acquired by other image acquisition devices and then transmitted to the server 220, or may be acquired by the second terminal 210 based on its own camera application and then transmitted to the server 220.
[0116] Among them, the first terminal 110 and the second terminal 210 of the above embodiments may include a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, but are not limited thereto.
[0117] Server 220 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides 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, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0118] In addition, the server 220 may also be a node server in the blockchain network.
[0119] The second terminal 210 and the server 220 may establish a communication connection via a wireless network or a wired network. The wireless network or wired network uses standard communication technology and / or protocols, and the network may be set to the Internet or any other network, such as but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or any combination of a virtual private network.
[0120] Of course, it is understandable that Figure 1 and Figure 2 The implementation environment in the embodiment of the present application is only some optional application scenarios of the target object defect detection method provided in the embodiment of the present application, and the actual application is not fixed. Figure 1 and Figure 2 The method provided in the embodiment of the present application can be applied to various technical fields, including but not limited to multimedia, image processing, cloud computing and other technical fields.
[0121] Reference Figure 3 , Figure 3 A flow chart of a target object defect detection method provided in an embodiment of the present application is provided. The target object defect detection method can be executed by a terminal alone or by a terminal and a server in cooperation. The target object defect detection method includes but is not limited to the following steps 301 to 306.
[0122] Step 301: Acquire a first image of a target object.
[0123] In this step, the target object may include any industrial product and its components that need to be inspected for defects, but is not limited to this. Here, the image of the target object obtained is recorded as the first image, and the first image may include the image content of the entire or partial area of the target object. In some cases, the overall function or characteristics of the target object are not significantly different. For example, if the target object is a glass product, the place where defects are prone to occur is not fixed. At this time, the overall image of the target object can be obtained as the first image; in other cases, a partial area of the target object belongs to the area where defect detection is required, for example, if it is desired to detect scratches on the body of a car, then the image of the specified area of the target object can be obtained as the first image. It should be noted that in this step, the first image can be obtained locally or from the cloud, and the embodiments of the present application do not limit this.
[0124] Step 302: Detect an area of interest in the first image, and crop the area of interest to obtain a defect sub-image of the target object.
[0125] In this step, before the defects in the target object are carefully classified and their positions are identified, the first image may be pre-processed for defect detection. Here, the purpose of the pre-processing for defect detection is to determine whether there are defects in the first image. Specifically, a detection method based on the pixel mean may generally be used to determine whether there are pixels in the first image that have a large deviation from the pixel mean, thereby determining whether there are defects in the first image. When it is detected that there are pixels in the first image that have a large deviation from the pixel mean, it can be determined that there are defects in the first image. At this time, the region of interest in the first image may be detected and cropped to obtain a small image containing defects, which is recorded as a defect sub-image. The region of interest here may be determined based on the position of the detected pixel that has a large deviation from the pixel mean.
[0126] It is understandable that in this step, the number of defect sub-images obtained by detecting and cropping the first image in the region of interest can be one or more, and this application does not impose any limitation on this. For the convenience of description, the following embodiments are introduced and explained by taking cropping to obtain multiple defect sub-images as an example.
[0127] It should be noted that in this step, the size of the region of interest is not necessarily equal to the size of the defect. The region of interest is a preliminary determination of the defect location, and the specific defect contour still needs further accurate identification.
[0128] Step 303: extracting image feature data of the defect sub-image.
[0129] In this step, after obtaining each defect sub-image, the image feature data of these defect sub-images can be extracted. Here, the feature refers to the (essential) characteristics or properties that distinguish a certain type of object from other types of objects, and the feature data is the data that can characterize the above-mentioned characteristics or properties extracted by measurement or processing. For image-type data, its features may include natural features of the image, such as brightness, edges, texture, and color; it may also include digital features of the image, such as moments, histograms, and principal components, but is not limited to this. In this step, when extracting the image feature data of the defect sub-image, any one or more image processing algorithms such as statistical algorithms, machine learning model processing, or signal processing can be used to extract it; and the image feature data obtained, its data format may include at least one of numbers, vectors, matrices, or tensors, and this application does not limit this. Taking machine learning model processing as an example, the implementation method of extracting image feature data of defect sub-images in this step is exemplified.
[0130] In one possible implementation, a convolutional neural network can be used to extract image feature data of a defect sub-image. It is understandable that in a defect sub-image, each pixel has a corresponding pixel value. By extracting features from a defect sub-image through a convolutional neural network, the convolutional layer in the convolutional neural network can be used to slide on the defect sub-image, multiply the pixel value of each pixel on the defect sub-image with the convolution coefficient on the corresponding convolutional layer, and then add all the multiplied values as the image feature data of a partial area on the defect sub-image extracted by the convolutional neural network, and then slide the entire defect sub-image to obtain the image feature data of the defect sub-image.
[0131] Step 304: semantically segment the defect sub-image according to the image feature data to obtain the defect outline of the defect sub-image; and classify the defect sub-image according to the image feature data to obtain category information of the defects in the defect sub-image.
[0132] In this step, semantic segmentation is performed on the defect sub-image based on the extracted image feature data. Semantic segmentation is to classify each pixel in the image and determine the category to which each pixel belongs, so as to facilitate accurate contour segmentation of the content belonging to different categories in the entire image. In this step, semantic segmentation is performed on the defect sub-image with the aim of determining the contour of the defect in the defect sub-image and obtaining the defect contour in the defect sub-image. It is understandable that in order to determine the contour of the defect in the defect sub-image, when semantic segmentation is performed on the defect sub-image, the category corresponding to each pixel can be set as belonging to a defect or not. In this way, according to the range of all pixel points that are determined to belong to the defect category during the semantic segmentation process, the defect contour in the defect sub-image can be determined. Specifically, please refer to Figure 4 , Figure 4 A schematic diagram of defect contours obtained by semantic segmentation of defect sub-graphs is shown. Figure 4 In the figure, image 410 is a defect sub-image at the pixel scale. After semantic segmentation processing is performed on image 410, the pixels therein are respectively determined to be pixels belonging to defects and pixels not belonging to defects. Extracting all the pixels determined to be defects can form a connected area, and the contour 411 of the connected area is the defect contour in image 410. Of course, it should be noted that contour 411 is only used to introduce and illustrate the range of the defect contour obtained by semantic segmentation processing in this application, and this application does not limit its specific shape.
[0133] It should be noted that in this step, the specific method for semantic segmentation can be flexibly selected as needed. In one possible implementation, a segmentation pipeline based on CRF (conditional random field) can be used to perform semantic segmentation on the defect subgraph; in another possible implementation, a deep learning model based on an encoder-decoder structure can be used to perform semantic segmentation on the defect subgraph, such as a traditional U-Net model.
[0134] In this step, defect classification processing is also performed on the defect sub-image based on the extracted image feature data. Defect classification processing is to classify the defects contained in the defect sub-image based on the defect category, and the defect category here can be flexibly set according to the specific application scenario and needs. For example, in some embodiments, the target object may be a glass product, and the corresponding defect category may include holes, cracks, scratches, dirt, etc.; in some embodiments, the target object may be a metal product, and the corresponding defect category may include spots, scratches, bumps, impurities, bubbles, wrinkles, etc. It can be understood that in the field of machine learning, classification task is one of the basic tasks, and there are many types of models and algorithms that can be selected. Therefore, in this application, the classification model selected for defect classification processing is not limited.
[0135] It should be noted that in this step, when performing contour and category detection on the defects of the defect sub-image, semantic segmentation processing and defect classification processing are respectively used; wherein, semantic segmentation processing is a classification processing performed at the pixel point scale, which can more accurately determine the contour edge of the defect and improve the accuracy of defect location information recognition in defect detection, while defect classification processing is judged on the dimension of the entire defect sub-image, which can largely take into account the overall characteristics of the defect, thereby improving the accuracy of defect category detection. In addition, it should be noted that in this step, when performing two steps of processing, both are performed according to the image feature data of the defect sub-image extracted in step 303. Compared with performing semantic segmentation processing and defect classification processing tasks independently from extracting image feature data on the defect sub-image, on the one hand, it can improve the utilization rate of image feature data, reduce the consumption of computing resources for extracting image feature data, and help improve the efficiency of defect detection; on the other hand, using the image feature data extracted in the same processing process to perform semantic segmentation processing and defect classification processing can make the input data of semantic segmentation processing and defect classification processing have a strong correlation, and can achieve synchronous processing, thereby helping to improve the accuracy of defect detection.
[0136] Step 305: Determine the morphological parameters of the defect in the defect sub-image according to the defect contour.
[0137] In this step, after obtaining the defect contour of the defect sub-image through semantic segmentation processing, the morphological parameters of the defect in the defect sub-image can be determined based on the defect contour. Here, the morphological parameters may include parameters such as the size, area, volume, and angle of the defect in a predetermined reference system. By determining the morphological parameters of the defect in the defect sub-image, it is easier to output accurate and intuitive defect detection results, thereby improving the utilization value of the defect detection results.
[0138] Specifically, when determining the morphological parameters based on the defect contour, the morphological parameters can be determined based on the coordinates, number or positional relationship between multiple pixels in the defect contour. For example, when it is necessary to determine the length of the defect, the horizontal coordinate difference of the pixels at both ends of the defect contour can be taken to calculate it; when it is necessary to determine the area of the defect, the number of pixels covered in the defect contour can be calculated, and then based on experience or statistical data, the area of the defect can be determined by the number of pixels; when it is necessary to determine the volume of the defect, it can be determined in combination with the above-mentioned determined area data and parameters such as the thickness of the target object. It should be noted that the above-mentioned morphological parameter types are only used to illustrate the implementation of this application, and are not limited to this.
[0139] Step 306: Determine the defect detection result of the target object according to the category information and morphological parameters of the defects in each defect sub-image.
[0140] In this step, after the defect category information and morphological parameters of each defect sub-image are detected, the defect detection result of the target object can be determined. Here, the specific output form of the defect detection result can be flexibly set according to user needs. For example, in a possible implementation, refer to Figure 5 , the defect detection results can list and display the category information and morphological parameters of the defects detected in each defect sub-graph. Figure 5 In the example, for the product with product number "150726", four defects are detected by executing the defect detection method provided in the embodiment of the present application, wherein the category information corresponding to the four defects is hole, crack, crack and spot, respectively, and the morphological parameters corresponding to each defect are different. At this time, the defect detection result can list the category information and morphological parameters corresponding to each defect in turn. For example, for the defect ranked first, its category information "hole" and the corresponding morphological parameter "0.86cm 2 ", indicating that in the product numbered "150726", a particle with a size of 0.86cm 2 For defects in other positions, they can be displayed in the above manner, which will not be described in detail here. It is understandable that the morphological parameters of defects also have different categories, such as length, width, area, etc. Therefore, in order to facilitate users to quickly confirm the physical meaning represented by the displayed morphological parameters, the category information corresponding to the morphological parameters can also be displayed: For example, for the defect ranked first, when displaying its corresponding morphological parameter "0.86cm 2 ", the category information "area" corresponding to the morphological parameter can be displayed.
[0141] Furthermore, it should be noted that Figure 5 In the embodiment shown in the figure, when displaying the morphological parameters corresponding to the defects, one category of morphological parameters is displayed for each defect. In other embodiments, for some defects, when displaying their morphological parameters, multiple categories of morphological parameters can be displayed: for example, multiple data of the length, width or area of some defects can be displayed at the same time. The present application does not impose any restrictions on this.
[0142] In a possible implementation, when determining the defect detection result of the target object, data post-processing can be performed based on the defect category information and morphological parameters. For example, the number of defects of each category in the target object can be counted based on the defect category information; the severity of each defect can be determined based on the defect morphological parameters. Figure 6, the number of defects in the target object under each defect category and the morphological parameters of the most serious defect can be counted. Here, the severity of the defect can be determined based on the size of the defect's morphological parameters. For example, when the morphological parameter is length or width, the larger the value, the larger the size of the defect, reflecting that the defect coverage in the target object is larger. Therefore, the defect is relatively more serious at this time. Figure 6 In the embodiment shown, for the product with product number "150743", three defects are detected by executing the defect detection method provided in the embodiment of the present application, among which, the number of defects with corresponding category information of "scratches" is 2; the number of defects with corresponding category information of "spots" is 1, and the number of defects with corresponding category information of "holes" or "cracks" is 0. At this time, for the two defects with category information of "scratches", the defect detection results can be compared with the post-processing process to display the morphological parameters of the more serious defect, such as Figure 6 It is shown that there are two scratch defects in the product with product number "150743", of which the longest is 2.1 cm. For defects in other positions in the ranking, they can be displayed accordingly in the above manner, which will not be repeated here. It can be understood that in the embodiment of the present application, by adaptively processing and displaying the defect detection results, it is convenient for users to quickly or the overall defect situation and severity of the product, so that users can have a clear and clear understanding of the defect data of the target object in a timely manner.
[0143] Of course, it should be noted that Figure 5 and Figure 6 In the illustrated embodiments, the output form of the defect detection results of the target object is displayed in a displayed manner. It can be understood that in the present application, the actual output form of the defect detection results can be flexibly set and adjusted according to specific needs. For example, in some cases, relevant chart data can be made and stored in real time; in other cases, the defect detection results can also be used as intermediate data of local applications or other applications, so as to facilitate the automatic execution of corresponding post-processing processes according to the defect detection results.
[0144] Specifically, in a possible implementation, when executing a corresponding post-processing process according to the defect detection result, it may include:
[0145] According to the morphological parameters corresponding to each defect in the target object, the defects of the target object are filtered to obtain the target defects of the target object;
[0146] Determine the cumulative number of target defects corresponding to each defect category in the target object;
[0147] According to the defect category and the accumulated number, a defect handling mode of the target object is determined, wherein the defect handling mode includes at least one of alarm handling, shutdown handling or labeling handling.
[0148] In the embodiment of the present application, after the defect detection result of the target object is obtained, the defects of the target object can be filtered according to the morphological parameters of each defect detected in the target object to obtain the target defects of the target object. Then, the cumulative number of target defects corresponding to each defect category in the target object can be counted, and the overall defect severity of the target object can be determined according to the defect category and the cumulative number, so as to facilitate the determination of the defect processing mode for it.
[0149] Here, the defect handling mode is generally aimed at the products on the production line, and may include at least one of alarm processing, shutdown processing or labeling processing, for example. Among them, the alarm processing includes notifying the staff through the relevant alarm equipment that the product has defects and requires timely processing by the staff; the shutdown processing mainly refers to triggering the power supply equipment or switching devices of the production line, so that the production line is suspended and waits for the staff to check and deal with it; the labeling processing mainly involves affixing relevant labels to the defective products to facilitate identification by the staff. Of course, the defect handling mode here can be flexibly set according to the quality control requirements and operation processes of different products, and this application does not limit this.
[0150] It should be noted that the defect handling mode is determined based on the defect category and the cumulative number. In some embodiments, all target defects may be comprehensively considered. For example, a defect score may be preset for each defect category, and the corresponding defect handling mode is determined by totaling the total defect score of the target object. In some embodiments, each defect category may have an independent judgment logic. For example, a number threshold may be preset for each defect category. When the cumulative number detected reaches the corresponding number threshold, the corresponding post-processing procedure is executed based on the defect handling mode that matches the number threshold.
[0151] It should be noted that, in the embodiments of the present application, the defect filtering of the target object can be performed according to specific needs. For example, it can be understood that the morphological parameters can reflect the size and severity of the defects to a certain extent. Therefore, in some embodiments, the defects with smaller corresponding morphological parameters can be filtered out to reduce the pressure of subsequent data processing. Of course, since the severity of the defects corresponding to different defect categories is also different, different morphological parameter thresholds can be used to filter defects for different defect categories. When the morphological parameters of the corresponding defects are less than the morphological parameter threshold, the defects can be filtered out. For example, for the two types of defects "scratches" and "cracks", it is generally believed that the severity of the defects in the "crack" category is higher than that of the defects in the "scratches" category. Therefore, when filtering the two types of defects, a larger morphological parameter threshold can be set for the defects in the "scratches" category, and a smaller morphological parameter threshold can be set for the defects in the "cracks" category, so that the defects in the "scratches" category with the same length and area are easier to be filtered out than the defects in the "cracks" category.
[0152] Furthermore, it should be noted that, as mentioned above, the morphological parameters themselves also have categories. Therefore, in the embodiments of the present application, different morphological parameter thresholds can be set according to different defect categories and morphological parameter categories. Then when filtering defects, the morphological parameters corresponding to the defects in each preset morphological parameter category and the preset morphological parameter thresholds can be compared according to the category to which the defects belong. For example, for defects in the "crack" category, there may be two types of morphological parameters, length and area. Each type of morphological parameter can correspond to a preset morphological parameter threshold. For example, the preset morphological parameter threshold corresponding to the length can be 1.5 cm, and the preset morphological parameter threshold corresponding to the area can be 2 cm 2 . In this way, when all the morphological parameters corresponding to a defect are less than or equal to the preset morphological parameter threshold, it means that the defect is small and less serious, and the defect can be eliminated at this time; conversely, when any morphological parameter corresponding to a defect is greater than the preset morphological parameter threshold, it means that the defect is more serious under a certain morphological parameter category, and the defect can be determined as a target defect. For example, taking the preset morphological parameter threshold of the defect of the "crack" category set above as an example, assuming that the length of a detected "crack" category defect is 1.2cm and the area is 0.8cm 2 , then all its morphological parameters are less than or equal to the preset morphological parameter threshold, which meets the elimination conditions and can be filtered out. Assume that the length of a "crack" defect detected is 2.4cm and the area is 1.8cm 2 , then the morphological parameter of its length category is greater than the preset morphological parameter threshold, which meets the conditions for being determined as a target defect, so it can be determined as a target defect.
[0153] In a possible implementation, detecting a region of interest in the first image and cropping the region of interest to obtain a defect sub-image of the target object includes:
[0154] determining a pixel mean of the first image;
[0155] Determine a plurality of first target pixel points from the first image according to the pixel mean; wherein a difference between a pixel value of the first target pixel point and the pixel mean is greater than a first preset threshold or less than a second preset threshold;
[0156] In the first image, determining a plurality of connected regions formed by a plurality of first target pixel points;
[0157] Each connected region is cropped from the first image to obtain a defect sub-image of the target object.
[0158] In the embodiment of the present application, when cropping the region of interest from the first image, the pixel mean of the first image may be determined first. In some embodiments, the pixel values of each pixel in the first image may be directly obtained, and then the average value may be calculated to obtain the pixel mean; then, multiple first target pixel points may be determined from the first image based on the pixel mean. Specifically, refer to Figure 7 , Figure 7 The image 710 in the figure is the first image of the target object. In the image 710, there are two defects, namely the first defect 711 and the second defect 712. Generally speaking, when there is a defect on the target object, the pixel values of the pixels in the area where the defect is located in the first image collected will be different from the pixel values of the pixels in other normal parts. Therefore, the area where the defect is located can be determined based on the pixels in the first image that have a large deviation from the pixel mean.
[0159] Specifically, in an embodiment of the present application, a comparison threshold of the deviation can be pre-set, the difference between the pixel value and the pixel mean of each pixel point in the first image is calculated, and the difference is compared with the comparison threshold to determine the deviation between the pixel and the pixel mean of each pixel point. Here, the difference between the pixel value and the pixel mean of each pixel point exists in two cases: positive and negative. Therefore, two comparison thresholds can be set accordingly, respectively recorded as the first preset threshold and the second preset threshold. Among them, the first preset threshold is a positive number, and the second preset threshold is a negative number. When the difference between the pixel value of a pixel point and the pixel mean is greater than the first preset threshold, it means that the pixel value deviation of the pixel point is large, and it can be determined that the pixel point has a high probability of being in the defect area; similarly, when the difference between the pixel value of a pixel point and the pixel mean is less than the second preset threshold, it means that the pixel value deviation of the pixel point is large, and it can also be determined that the pixel point has a high probability of being in the defect area. In this way, multiple first target pixel points can be determined from the first image, and the location of the first target pixel point is likely to be the location of the defect in the target object. As Figure 7 By comparing the difference between the pixel value of each pixel and the pixel mean, a plurality of first target pixel points 721 are determined, and these first target pixel points 721 as a whole substantially completely cover the first defect 711 and the second defect 712 in the image 710. Next, based on the determined first target pixel points 721, the connected area formed by these pixel points can be determined, such as Figure 7 It can be determined that the first target pixel 721 as a whole constitutes two connected regions, namely the first connected region 731 and the second connected region 732, wherein the first connected region 731 corresponds to the position of the first defect 711 in the image 710, and the second connected region 732 corresponds to the position of the second defect 712 in the image 710. Then, according to the positions of the determined connected regions, each connected region can be cropped from the first image to obtain a defect sub-image of the target object.
[0160] Specifically, when cutting out each connected region from the first image, in some embodiments, the minimum bounding rectangle of each connected region in the first image can be directly cut out to obtain the corresponding defect sub-image. Figure 7 In the example, the minimum bounding rectangle of the first connected region 731 is cut out from the first image to obtain the corresponding first defect sub-image 741, and the minimum bounding rectangle of the second connected region 732 is cut out from the first image to obtain the corresponding second defect sub-image 742. In this way, the defect sub-image including the first defect 711 and the second defect 712 can be cut out from the first image, so as to facilitate the processing of the subsequent steps.
[0161] It should be noted that the overall accuracy of cropping the region of interest in the first image by the above-mentioned pixel difference method is relatively low. In order to reduce the erroneous cropping of pixels belonging to the defective area, in some embodiments, after determining the connected area formed by the first target pixel point, appropriate loose processing can be performed during cropping. For example, the minimum circumscribed rectangle of the connected area can be determined first, and then the length and width of the minimum circumscribed rectangle can be appropriately expanded to obtain the target rectangular area, and the target rectangular area can be cropped out to obtain the defective sub-image of the target object. Here, the specific expanded cropping scale can be flexibly set as needed. And it can be understood that the cropping operation of each connected area should be performed on the premise of not interfering with the cropping of other connected areas.
[0162] In a possible implementation manner, determining a pixel mean of the first image includes:
[0163] Determine a second target pixel from the first image according to the pixel values of each pixel of the first image; the pixel value of the second target pixel is greater than a third preset threshold and less than a fourth preset threshold, wherein the first preset threshold is greater than the third preset threshold, and the second preset threshold is less than the fourth preset threshold;
[0164] The average value of the pixel values of each second target pixel point is calculated to obtain the pixel mean value of the first image.
[0165] In the aforementioned embodiment, when determining the pixel mean of the first image, the pixel value of each pixel point in the first image is directly obtained, and then the average value is calculated to obtain the pixel mean. This method is simple and fast as a whole, and can improve the processing efficiency of defect detection. However, in some cases, such as when the target object contains too many defects or the characteristics of the defects are close to the characteristics of the image background, the defects or background in the first image may have a greater interference effect on the pixel mean, resulting in a low accuracy of the cropped area of interest. Therefore, in the embodiment of the present application, when determining the pixel mean of the first image, first consider removing the influence of the defects and background pixels, that is, set a pixel interval, filter out the pixels in the first image that do not belong to the pixel interval, and then calculate the pixel mean of the first image.
[0166] It is understandable that in the embodiment of the present application, the set pixel interval should be as close as possible to the pixel value represented by the image of the product itself. Here, the pixel interval includes two numerical limits of pixel values, which are respectively recorded as the third preset threshold and the fourth preset threshold, wherein the third preset threshold is less than the fourth preset threshold. When the pixel value of a certain pixel point in the first image is not within the set pixel interval, it can be eliminated, thereby reducing the impact of defects and background pixels.
[0167] Specifically, in the embodiment of the present application, when calculating the pixel mean, the pixel value of each pixel point can be compared with the set third preset threshold and fourth preset threshold. When the pixel value of the pixel point is greater than the third preset threshold and less than the fourth preset threshold, the pixel point is determined as the second target pixel point. Then, based on the average value of the pixel values of each second target pixel point, a more reliable pixel mean of the first image can be obtained.
[0168] In a possible implementation, after obtaining the defect subgraph of the target object, the following steps are further included:
[0169] The defect sub-image is normalized to obtain a new defect sub-image.
[0170] It is understandable that in the target object, due to the differences in defect types, generation factors, etc., it is very likely that the sizes of various defects are not uniform, and the scales of the various defect sub-graphs obtained thereby will also vary greatly, which may easily cause more troubles for subsequent data processing. Therefore, in the embodiment of the present application, after cropping the region of interest of the first image to obtain the defect sub-graph, the image scale normalization processing can be performed on each defect sub-graph to obtain multiple new defect sub-graphs. For example, referring to Figure 7 and Figure 8 , Figure 7 The first defect sub-image 741 and the second defect sub-image 742 obtained by cropping are different in size. The first defect sub-image 741 is subjected to image scale normalization processing to obtain a new third defect sub-image 751, and the second defect sub-image 742 is subjected to image scale normalization processing to obtain a new fourth defect sub-image 752. It can be seen that the new third defect sub-image 751 and the fourth defect sub-image 752 are consistent in image scale, which can greatly reduce the complexity of subsequent image processing and improve the efficiency of defect detection.
[0171] It should be noted that in the embodiments of the present application, when normalizing the image scale of each defect sub-image, the normalized image scale can be flexibly set as needed. For example, in some embodiments, some defect sub-images with larger image scales can be reduced, while some defect sub-images with smaller image scales can be enlarged, so that the image scales of each defect sub-image are unified; in other embodiments, all defect sub-images can be enlarged, wherein the magnification factor used when enlarging some defect sub-images with larger image scales is smaller, and the magnification factor used when enlarging some defect sub-images with smaller image scales is larger, so that the image scales of each defect sub-image are unified.
[0172] In a possible implementation, determining the morphological parameters of the defect in the defect sub-image according to the defect contour includes:
[0173] According to the defect contour, based on the size of the defect sub-image before the image scale normalization processing, the size of the defect contour is restored to obtain the original contour of the defect in the defect sub-image;
[0174] According to the original contour, the morphological parameters of the defect in the defect sub-image are determined.
[0175] It should be noted that if the defect sub-image is obtained after cropping the area of interest and the defect sub-image is scale normalized, then correspondingly, when the morphological parameters of the defect in the defect sub-image are subsequently determined based on the detected defect contour, the image size change caused by the image scale normalization needs to be restored in order to determine the accurate morphological parameters.
[0176] Specifically, after the defect contour in the defect sub-image is detected, the defect contour can be restored to its original size according to the size of the defect sub-image before the image scale normalization process to obtain the original contour of the defect in the defect sub-image. For example, for a defect sub-image, when the image scale normalization process is performed, its width is halved and its length is halved; then, the defect contour detected in the defect sub-image needs to be enlarged by double the width and double the length to obtain the original contour of the defect of the target object, and then, according to the morphology of the original contour, the accurate morphological parameters can be determined. The specific morphological parameter calculation method has been introduced in detail in the aforementioned step 304 and will not be repeated here.
[0177] The target object defect detection method provided in the present application is described in detail below in conjunction with some more specific embodiments.
[0178] Lithium battery is a widely used power component. In the production process of lithium batteries, slurry coating is the next step after the preparation of slurry. The main purpose of this step is to evenly coat the slurry with good stability, good viscosity and good fluidity on the positive and negative current collectors (pole pieces) of lithium batteries. This process can also be called pole piece coating. Pole piece coating is of great significance to lithium batteries. When the slurry is good enough, the density of the active material on the pole piece is basically consistent, and no impurities need to be mixed in the coating process. If the pole piece has severe powder loss, is not resistant to bending, or has white bubbles, it will have a greater impact on the coating effect, which will lead to quality defects in the produced lithium battery products. Therefore, in this scenario, there is a need to detect defects in the coating process to determine whether there are serious quality risks in the lithium battery.
[0179] Reference Fig. 9 , Fig. 9Several typical defect categories that are easily generated during the lithium battery coating operation are shown. Among them, the first coating image 910 is a normal defect-free lithium battery coating image. The second coating image 920 is a lithium battery coating image with a "concave and convex point" defect. The concave and convex points appear in the coating image, which is generally caused by the presence of particles on the coated plate. These particles cause the surface to bulge or dent after coating, resulting in concave and convex points. The third coating image 930 is a lithium battery coating image with a "bubble" defect. The image of the bubble defect is generally black in the middle and has a white circle pattern on the edge. The fourth coating image 940 is a lithium battery coating image with a "bright spot" defect. The image of the bright spot defect is generally a white dot-shaped object. The reason for the bright spot in the coating image is mostly dust falling into the plate or coating. The fifth coating image 950 is a lithium battery coating image with a "black spot" defect. The black spots appear in the coating image, which is generally caused by uneven coating of the coating. The image of the black spot defect is generally relatively blurred at the edge. The sixth coating image 960 is a coating image of a lithium battery with a "metal leakage" defect. The metal leakage defect is caused by the damage of the coating, which exposes the metal material underneath. It is a relatively serious defect category. The seventh coating image 970 is a coating image of a lithium battery with a "decarbonization" defect. Decarbonization is the process of carbon powder shedding during the coating production process, which causes the coating to become dark black. The image of the decarbonization defect generally has clear and sharp edges. The eighth coating image 980 is a coating image of a lithium battery with a "streak" defect. Streaks are usually caused by scratches during the coating production process, also known as scratches. The ninth coating image 990 is a coating image of a lithium battery with a "blurred" defect. Under this defect category, there are partially blurred white areas or blurred black areas in the coating image, and the degree of the defect is relatively small.
[0180] Of course, it should be noted that the above Fig. 9 The examples are only used to illustrate several typical cases of defects in lithium battery coating, and do not represent the situation in the actual production process. Based on the understanding of the technical solution of this application, people in this field can adjust and replace the defect categories according to actual needs, and this application does not limit this.
[0181] Reference Fig.10 , Fig.10 This is an overall flow chart of the target object defect detection method provided in the embodiment of the present application applied in the lithium battery coating defect detection application. In this application, it mainly includes three links. The first link is sample-level prediction, that is, first obtaining the original image of the lithium battery coating, and then detecting and identifying the area of interest in the image after reading the image through relevant image processing software. Fig.11 , Fig.111 shows a coating image of a lithium battery pole piece taken by a line scan camera. It is understandable that, in general, in industrial production, the coating operation of lithium battery pole pieces is carried out continuously. Therefore, a coating image may contain one or more lithium battery pole pieces 1110, which is related to the setting position of the camera, and this application does not limit this. Fig.11 It can be seen that the image size of the coating image directly collected is generally large, and it may be difficult to directly put it into the defect detection model. In addition, the number of defects that may exist on the coating is small, and directly performing defect detection on the entire original coating image may result in low processing efficiency. Therefore, in the embodiment of the present application, the area of interest of the coating image can be detected and cropped first to obtain a defect sub-image containing coating defects. Please refer to Fig.12 , assuming that there is a defect 1211 on a certain pole piece 1210, through the defect detection method in the embodiment of the present application, the defect sub-image 1220 can be obtained by detecting and cropping the region of interest of the coating image. Subsequently, by performing more accurate defect detection on the defect sub-image 1220, accurate defect detection results can be obtained, and the computing resources consumed by the defect detection process can be reduced, thereby improving the efficiency of defect detection.
[0182] Specifically, in the process of cropping the region of interest, a maximum threshold and a minimum threshold can be set for the pixel values of the pixels in the image, for example, the maximum threshold (i.e., the aforementioned fourth preset threshold) can be 100, and the minimum threshold (i.e., the aforementioned third preset threshold) can be 60, and then the pixel values within the threshold are averaged as the overall pixel mean A. Next, pixels with pixel values greater than A+25 and pixel values less than A-30 are selected to form multiple connected regions, which are recorded as ROI 1, ROI 2, ROI 3...ROI N (N is a positive integer).
[0183] The second step is image-level prediction. After detecting multiple connected areas, the image can be cropped by expanding the area around the connected area by 200 pixels to obtain a defect sub-image containing coating defects. The size of each defect sub-image is normalized and processed into images of the same size, which are input into the built neural network. Specifically, the pixel value of the image is used as input to predict the defect outline of the defect sub-image and the category information of the defect in the defect sub-image.
[0184] Reference Fig.13 , Fig.13 This is a schematic diagram of a portion of the structure of the neural network used in the embodiment of the present application, which is mainly used to extract and fuse image features. Specifically, the neural network can extract image feature data of defect sub-images at different image scales, and can perform multiple feature fusion processing on these image feature data at different image scales. Fig.13In the neural network shown, the model may include functional modules for performing convolution, strided convolution, upsampling and other processing. For the input defect sub-image, the image feature data of the defect sub-image can be extracted through convolution processing (image feature data is generally also called feature map), and the image feature data initially extracted can be further subjected to multiple strided convolution processing to continue feature extraction at a smaller image scale, thereby obtaining image feature data of multiple different scales. Fig.13 For the image input into the neural network, first, the image feature data 1310 at the first image scale can be extracted through convolution processing. Then, after performing multiple convolution processing on the image feature data 1310 at the first image scale, a strided convolution can be performed to obtain image feature data 1320 at the second image scale. Similarly, image feature data 1330 at the third image scale and image feature data 1340 at the fourth image scale can be further obtained. For the obtained image feature data at different image scales, multiple feature fusion processing can be performed. For example, in some embodiments, the image feature data at a larger image scale or multiple layers can be fused to the image feature data at a smaller image scale after the strided convolution processing. For example, the image feature data 1310 at the first image scale or the image feature data 1320 at the second image scale can be fused to the image feature data 1330 at the third image scale after the strided convolution processing. In other embodiments, the image feature data at a smaller layer or layers of the image scale may be fused to the image feature data at a larger layer of the image scale after upsampling. For example, the image feature data 1340 at the fourth image scale or the image feature data 1330 at the third image scale may be fused to the image feature data 1320 at the second image scale after strided convolution processing. Of course, the above fusion processing method is only for illustration. Fig.13 In the neural network shown, multiple feature fusion processes are performed on the image feature data of multiple image scales, so that there is a lot of information exchange and fusion between the image feature data of each image scale, thereby improving the expression accuracy of the image feature data at each image scale.
[0185] In the embodiments of the present application, when using these image feature data, refer to Fig.13, the image feature data of 4 layers of different image scales obtained after fusion in a certain stage can be extracted, and then the 4 layers of image feature data of different image scales are fused and spliced to obtain the first target feature data 1350, and then the first target feature data 1350 is input into a simple decoder to output the binary semantic segmentation result, and the defect outline of the defect sub-image can be obtained. Similarly, when performing defect classification processing, the image feature data with the smallest image scale (that is, the image feature data at the fourth image scale) can be selected from the 4 layers of image feature data of different image scales as the second target feature data 1360, and then the second target feature data 1360 is input into the convolutional neural network and the full connector, and the classification result is output to obtain the category information of the defect in the defect sub-image. Here, the decoder, the convolutional neural network and the full connector can be directly connected to the setting in Fig.13 The structure of the neural network shown in the figure constitutes a complete defect detection model as a whole.
[0186] It should be noted that in the embodiment of the present application, the image feature data of multiple image scales of the defect sub-image are extracted and fused for semantic segmentation processing and defect classification processing, which can more fully mine and utilize the image information of the defect sub-image, which is conducive to improving the accuracy of defect detection. In addition, when performing semantic segmentation processing and defect classification processing, the embodiment of the present application uses image feature data in a targeted manner according to specific task requirements. For example, semantic segmentation processing can be performed based on image feature data after fusion of multiple image scales, which can greatly improve the accuracy of semantic segmentation; using image feature data at the smallest image scale for defect classification processing can better take into account the overall characteristics of the image, thereby making the detection results of defect categories more reliable.
[0187] The third step is rule post-processing. Fig.14 , Fig.14 A specific implementation method of performing rule post-processing based on defect detection results provided in an embodiment of the present application is shown in FIG. Fig.14 In the , the staff can pre-set the trigger conditions for executing the corresponding defect handling mode for each defect type. For example, for defects of the "metal leakage" category, the area parameter and the number parameter can be entered. When a metal leakage defect is detected during the coating of a lithium battery, and the number of defects with an area greater than the preset area parameter exceeds the number parameter, the corresponding defect handling mode can be executed. Here, the defect handling mode includes at least one of alarm processing, shutdown processing or labeling processing. It should be noted that Fig.14For the two defects of "tape splicing" and "glue sticking", generally, the product is spliced and glued before starting up, and then it is determined whether the set defect processing mode is executed to detect whether the defect detection program is running normally. In the actual operation process, there is no need to set the specific parameters of these two defects.
[0188] It should be noted that the number of combinations of the above area parameters and number parameters can be flexibly set according to specific needs, and this application does not impose any restrictions on this.
[0189] It can be understood that the above-mentioned post-processing rules can greatly reduce the operational complexity of lithium battery coating defect detection, which is beneficial to improving the production quality and efficiency of lithium batteries.
[0190] Reference Fig.15 , Fig.15 A flowchart of a method for training a target object defect detection model provided in an embodiment of the present application. Similar to the aforementioned method for training a target object defect detection model, the method for training a target object defect detection model can be executed by a terminal alone or by a terminal and a server in cooperation, and the method for training a target object defect detection model includes but is not limited to the following steps 1501 to 1507.
[0191] Step 1501: Acquire multiple sample sub-images; the sample sub-images carry defect labels; the defect labels are used to characterize the defect contours of the sample sub-images and the category information of the defects in the sample sub-images;
[0192] Step 1502: extracting image feature data of each sample sub-image through the target object defect detection model;
[0193] Step 1503: performing semantic segmentation processing on the sample sub-image according to the image feature data to obtain a defect contour prediction result of the sample sub-image;
[0194] Step 1504: performing defect classification processing on the sample sub-image according to the image feature data to obtain a prediction result of defect category information in the sample sub-image;
[0195] Step 1505: determining a first loss value according to the defect contour prediction result and the defect label;
[0196] Step 1506: Determine a second loss value according to the category information prediction result and the defect label;
[0197] Step 1507: Update the parameters of the target defect detection model according to the first loss value and the second loss value to obtain a trained target defect detection model.
[0198] The above-mentioned embodiment introduces that in the defect detection method provided in the embodiment of the present application, the semantic segmentation processing and defect classification processing of the defect sub-graph can be implemented based on a single model. In the field of machine learning, the model generally needs to be trained and adjusted before it is put into use. Therefore, in the embodiment of the present application, a training method for a target object defect detection model is provided. Specifically, here, it can be trained by a labeled training data set. The training data in the training data set can be pictures with defects, which are recorded as sample sub-graphs in this application. The sample sub-graph carries a defect label, which is used to characterize the defect contour of the sample sub-graph and the category information of the defect in the sample sub-graph.
[0199] For each sample sub-image, it can be input into the target object defect detection model to extract its image feature data, and perform semantic segmentation processing based on the image feature data to obtain the defect contour prediction result of the sample sub-image output by the target object defect detection model. Defect classification processing is performed based on the image feature data to obtain the category information prediction result of the defect in the sample sub-image output by the target object defect detection model. After obtaining the defect contour prediction result and the category information prediction result, the accuracy of the machine learning model prediction can be evaluated based on the prediction result and the aforementioned defect label, so as to perform back-propagation training on the model and update its internal relevant parameters.
[0200] Specifically, for a machine learning model, the accuracy of its prediction can be measured by a loss function (LossFunction), which is defined on a single training data and is used to measure the prediction error of a training data. Specifically, the loss value of the training data is determined by the label of a single training data and the prediction result of the model for the training data. In actual training, a training data set has a lot of training data, so a cost function (CostFunction) is generally used to measure the overall error of the training data set. The cost function is defined on the entire training data set and is used to calculate the average value of the prediction error of all training data, which can better measure the prediction effect of the model. For a general machine learning model, based on the aforementioned cost function, plus a regularization term that measures the complexity of the model, it can be used as the objective function of the training, and the loss value of the entire training data set can be calculated based on the objective function. There are many types of commonly used loss functions, such as 0-1 loss function, square loss function, absolute loss function, logarithmic loss function, cross entropy loss function, etc., which can all be used as loss functions of machine learning models, which will not be described one by one here. In the embodiment of the present application, one loss function can be selected to determine the loss value of the training, that is, the loss value between the prediction result and the defect label. Based on the training loss value, the back propagation algorithm is used to update the parameters of the model, and the trained target object defect detection model can be obtained by iterating the preset rounds.
[0201] Specifically, in the embodiment of the present application, when determining the loss value based on the prediction results and defect labels, it includes two parts, wherein the first part is the loss value in the semantic segmentation process, recorded as the first loss value, and the first loss value can be calculated by the defect contour prediction result and the defect label; the second part is the loss value in the defect classification process, recorded as the second loss value, and the second loss value can be calculated by the category information prediction result and the defect label. After obtaining the first loss value and the second loss value, the two can be summed or weighted based on a predetermined weight parameter to obtain the overall loss value, and then the parameters of the model can be updated based on the overall loss value.
[0202] It should be noted that the above training process is only used to exemplify an optional training implementation scheme for the target object defect detection model, and does not mean to limit its specific training method.
[0203] In a possible implementation, multiple sample subgraphs are obtained, including:
[0204] acquiring a second image of the sample object;
[0205] An area of interest in the second image is detected, and the area of interest is cropped to obtain a plurality of sample sub-images of the sample, wherein the sample sub-images are annotated with corresponding defect labels.
[0206] In the embodiment of the present application, the process of obtaining the sample sub-image can be similar to the aforementioned defect sub-image, and multiple sample sub-images of the sample can be obtained by detecting and cropping the region of interest of the second image of the original sample containing defects. The specific implementation method can refer to the introduction and description of the aforementioned embodiment, which will not be repeated here.
[0207] In a possible implementation, the training method of the target defect detection model provided in the embodiment of the present application further includes the step of marking the defect label corresponding to each sample sub-graph, and the steps include:
[0208] When it is determined that there are multiple defects in the sample sub-image, the overlap of defect contours of each defect in the sample sub-image is detected;
[0209] When the overlap degree is greater than a preset overlap threshold, it is determined that there is a defect overlap area in the sample sub-image;
[0210] According to the preset defect priority sorting information, the defect label corresponding to the defect with the highest defect priority sorting in the defect overlap area is determined as the defect label corresponding to the defect overlap area.
[0211] It should be noted that in the process of generating defects, there may be a situation where one defect causes another defect, thereby causing multiple defects to overlap. For example, for glass products, when a hole defect is generated by external impact, a crack defect will generally occur along with the hole defect. In the embodiment of the present application, when training the model, for defects of overlapping types, the model can give a prediction result with the highest defect priority ranking in the overlapping area, so as to facilitate the prediction output of more serious defect categories, which improves the accuracy of defect detection on the one hand, and reduces the data processing amount of the model on the other hand, thereby improving the efficiency of defect detection and the utilization rate of hardware equipment.
[0212] Specifically, the above-mentioned effect of making the model give the prediction result with the highest defect priority in the overlapping area can be achieved by processing the defect labels in the training process. In the embodiment of the present application, first, when the number of defects in the sample sub-image is multiple, the overlap of the defect contours of each defect in the sample sub-image can be detected. Here, the overlap can be measured by the numerical value of the intersection and union ratio of the defect contours, and the overlap threshold can be set specifically. When the overlap between multiple defects is greater than the preset overlap threshold, they can be considered to overlap, that is, it can be determined that there is a defect overlap area in the sample sub-image. For the defect overlap area, the defect label corresponding to the defect with the highest defect priority in the defect overlap area can be determined as the defect label corresponding to the defect overlap area according to the preset defect priority information. In this way, during the prediction process, the model will tend to output the defect contour and defect category of the defect with the highest defect priority in the defect overlap area, thereby achieving the technical effect of improving the accuracy of defect detection and reducing the data processing amount of the model. Reference Fig.16 Taking the defect categories of the aforementioned lithium battery coating as an example, assuming that there are defects of the "metal leakage" and "bubble" categories in a coating image, and the areas where the two defects are located basically overlap, then in the training method provided in the embodiment of the present application, when the coating image is used as a sample sub-image, when labeling the "metal leakage" and "bubble" defects therein, the defect priorities of the two types of defects, "metal leakage" and "bubble", will be considered. For example, when the defect priority of the "metal leakage" category is higher than the defect priority of the "bubble" category, the defects in the overlapping area of the sample sub-image are labeled as the "metal leakage" category, and the defect label corresponding to the defect contour is determined based on the metal leakage area.
[0213] It should be noted that in the embodiments of the present application, the defect priority sorting information can be flexibly set according to specific needs, and the present application does not impose any restrictions on this.
[0214] In a possible implementation, the training method of the target defect detection model further includes:
[0215] When the overlap degree is less than or equal to a preset overlap threshold, the sample sub-image is cropped again to obtain a plurality of new sample sub-images.
[0216] In an embodiment of the present application, when the overlap of multiple defects is less than or equal to a preset overlap threshold, it indicates that the correlation of these defects may be low. In order to increase the amount of training data, these sample sub-images can be cropped again to obtain multiple new sample sub-images. Moreover, re-cropping these sample sub-images with a certain overlap can reduce interference with model training, improve the prediction accuracy of the trained model, and thus help improve the accuracy of defect detection using the model. Specifically, when re-cropping, it can be cropped according to the contour edges of some of the defects, so as to crop the overlapping defect areas and obtain multiple sample sub-images.
[0217] Reference Fig.17 , Fig.17 A schematic diagram of the structure of a target object defect detection device provided in an embodiment of the present application, the target object defect detection device comprises:
[0218] An acquisition module 1710 is used to acquire a first image of a target object;
[0219] A cropping module 1720 is used to detect an area of interest in the first image, and crop the area of interest to obtain a defect sub-image of the target object;
[0220] The first processing module 1730 is used to extract image feature data of the defect sub-image;
[0221] The second processing module 1740 is used to perform semantic segmentation processing on the defect sub-image according to the image feature data to obtain the defect contour of the defect sub-image;
[0222] The third processing module 1750 is used to perform defect classification processing on the defect sub-image according to the image feature data to obtain category information of the defects in the defect sub-image;
[0223] An identification module 1760 is used to determine the morphological parameters of the defect in the defect sub-image according to the defect contour;
[0224] The detection module 1770 is used to determine the defect detection result of the target object according to the category information and morphological parameters of the defects in each defect sub-image.
[0225] Furthermore, the above-mentioned cutting module is specifically used for:
[0226] determining a pixel mean of the first image;
[0227] Determine a plurality of first target pixel points from the first image according to the pixel mean; wherein the difference between the pixel value of the first target pixel point and the pixel mean is greater than a first preset threshold or less than a second preset threshold, the first preset threshold is a positive number, and the second preset threshold is a negative number;
[0228] In the first image, determining a plurality of connected regions formed by a plurality of first target pixel points;
[0229] Each connected region is cropped from the first image to obtain a defect sub-image of the target object.
[0230] Furthermore, the above-mentioned cutting module is specifically used for:
[0231] Determine a second target pixel from the first image according to the pixel values of each pixel of the first image; wherein the pixel value of the second target pixel is greater than a third preset threshold and less than a fourth preset threshold, and the third preset threshold is less than the fourth preset threshold;
[0232] The average value of the pixel values of each second target pixel point is calculated to obtain the pixel mean value of the first image.
[0233] Furthermore, the target object defect detection device further comprises:
[0234] The normalization processing module is used to perform image scale normalization processing on the defect sub-image to obtain a new defect sub-image.
[0235] Furthermore, the above identification module is specifically used for:
[0236] According to the defect contour, based on the size of the defect sub-image before the image scale normalization processing, the size of the defect contour is restored to obtain the original contour of the defect in the defect sub-image;
[0237] According to the original contour, the morphological parameters of the defect in the defect sub-image are determined.
[0238] Furthermore, the second processing module is specifically used for:
[0239] Extract image feature data of defect sub-images at different image scales;
[0240] Performing feature fusion processing on image feature data of different layers of image scales to obtain first target feature data;
[0241] The first target feature data is semantically segmented by the decoder to obtain a defect outline of the defect sub-image.
[0242] Furthermore, the third processing module is specifically used for:
[0243] Determine the image feature data at the smallest layer of the image scale as the second target feature data;
[0244] The second target feature data is subjected to defect classification processing by a classifier to obtain category information of defects in the defect sub-graph.
[0245] Furthermore, the target object defect detection device further comprises:
[0246] A filtering module is used to filter the defects of the target object according to the morphological parameters corresponding to each defect in the target object to obtain the target defects of the target object;
[0247] A cumulative module, used to determine the cumulative number of target defects corresponding to each defect category in the target object;
[0248] The defect handling module is used to determine the defect handling mode of the target object according to the defect category and the cumulative number, wherein the defect handling mode includes at least one of alarm processing, shutdown processing or labeling processing.
[0249] Furthermore, the filtering module is specifically used for:
[0250] Obtaining preset morphological parameter categories and preset morphological parameter thresholds corresponding to each defect category;
[0251] Under each preset morphological parameter category, compare the morphological parameter corresponding to the defect with the preset morphological parameter threshold;
[0252] When all morphological parameters corresponding to the defect are less than or equal to the preset morphological parameter threshold, the defect is eliminated; or, when any morphological parameter corresponding to the defect is greater than the preset morphological parameter threshold, the defect is determined as a target defect.
[0253] It is understandable that if Figure 3 The contents of the target object defect detection method embodiment shown in the figure are applicable to the target object defect detection device embodiment. The functions specifically implemented by the target object defect detection device embodiment are similar to those of the target object defect detection method embodiment shown in the figure. Figure 3 The target object defect detection embodiment shown is the same as that shown in FIG. Figure 3 The beneficial effects achieved by the target object defect detection embodiment shown are also the same.
[0254] On the other hand, the embodiment of the present application also provides a training device for a target object defect detection model, including:
[0255] The second acquisition module is used to acquire multiple sample sub-images; the sample sub-images carry defect labels; the defect labels are used to characterize the defect contours of the sample sub-images and the category information of the defects in the sample sub-images;
[0256] An extraction module, used for extracting image feature data of each sample sub-image through a target object defect detection model;
[0257] The fourth processing module is used to perform semantic segmentation processing on the sample sub-image according to the image feature data to obtain a defect contour prediction result of the sample sub-image;
[0258] A fifth processing module is used to perform defect classification processing on the sample sub-image according to the image feature data to obtain a prediction result of the category information of the defects in the sample sub-image;
[0259] A first loss value determination module, used to determine a first loss value according to a defect contour prediction result and a defect label;
[0260] A second loss value determination module, used to determine a second loss value according to the category information prediction result and the defect label;
[0261] The training module is used to update the parameters of the target defect detection model according to the first loss value and the second loss value to obtain a trained target defect detection model.
[0262] Furthermore, the second acquisition module is specifically used for:
[0263] acquiring a second image of the sample object;
[0264] An area of interest in the second image is detected and cropped, wherein the sample sub-image is annotated with a corresponding defect label.
[0265] Furthermore, the training device of the target object defect detection model further includes:
[0266] A coincidence detection module, used for detecting the coincidence of defect contours of each defect in the sample sub-image when it is determined that the number of defects in the sample sub-image is multiple;
[0267] An overlap comparison module is used to determine whether there is a defective overlap area in the sample sub-image when the overlap is greater than a preset overlap threshold;
[0268] The marking module is used to determine the defect label corresponding to the defect with the highest defect priority in the defect overlap area as the defect label corresponding to the defect overlap area according to the preset defect priority sorting information.
[0269] Furthermore, the training device of the target object defect detection model further includes:
[0270] The re-cropping module is used to re-crop the sample sub-images to obtain multiple new sample sub-images when the overlap degree is less than or equal to a preset overlap threshold.
[0271] It is understandable that if Fig.15The contents of the target object defect detection model training method embodiment shown in the figure are applicable to the target object defect detection model training device embodiment. The functions specifically implemented by the target object defect detection model training device embodiment are similar to those in the example shown in the figure. Fig.15 The training method embodiment of the target object defect detection model shown in FIG. 1 is the same as that of the embodiment of the target object defect detection model shown in FIG. 1 , and the beneficial effects achieved are the same as those of the embodiment of the target object defect detection model shown in FIG. Fig.15 The beneficial effects achieved by the target object defect detection model training method embodiment shown are also the same.
[0272] Reference Fig.18 , the embodiment of the present application further discloses an electronic device, including:
[0273] at least one processor 1810;
[0274] At least one memory 1820, used to store at least one program;
[0275] When at least one program is executed by at least one processor 1810, at least one processor 1810 implements the following Figure 3 The defect detection method embodiment of the target object shown or Fig.15 An embodiment of a method for training a target object defect detection model is shown.
[0276] It is understandable that if Figure 3 The defect detection method embodiment of the target object shown, Fig.15 The contents of the training method embodiment of the target object defect detection model shown in the figure are all applicable to the computer device embodiment, and the functions specifically implemented by the computer device embodiment are similar to those in the example shown in the figure. Figure 3 The defect detection method embodiment of the target object shown, Fig.15 The training method embodiment of the target object defect detection model shown in FIG. 1 is the same as that of the embodiment of the target object defect detection model shown in FIG. 1 , and the beneficial effects achieved are the same as those of the embodiment of the target object defect detection model shown in FIG. Figure 3 The defect detection method embodiment of the target object shown, Fig.15 The beneficial effects achieved by the target object defect detection model training method embodiment shown are also the same.
[0277] The present application also discloses a computer-readable storage medium in which a program executable by a processor is stored. When the program executable by the processor is executed by the processor, it is used to implement the following Figure 3 The defect detection method embodiment of the target object shown or Fig.15 An embodiment of a method for training a target object defect detection model is shown.
[0278] Understandably, Figure 3 The defect detection method embodiment of the target object shown, Fig.15The contents of the training method embodiment of the target object defect detection model shown in the figure are all applicable to the embodiment of the computer-readable storage medium. The functions specifically implemented by the embodiment of the computer-readable storage medium are similar to those of the embodiment of the computer-readable storage medium. Figure 3 The defect detection method embodiment of the target object shown, Fig.15 The training method embodiment of the target object defect detection model shown in FIG. 1 is the same as that of FIG. 1 , and the beneficial effects achieved are the same as those of FIG. 1 . Figure 3 The defect detection method embodiment of the target object shown, Fig.15 The beneficial effects achieved by the target object defect detection model training method embodiment shown are also the same.
[0279] The embodiment of the present application further discloses a computer program product or a computer program, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in the above-mentioned computer-readable storage medium; Fig.18 The processor of the electronic device shown can read the computer instruction from the above-mentioned computer readable storage medium, and the processor executes the computer instruction so that the computer device executes Figure 3 The defect detection method embodiment of the target object shown, Fig.15 An embodiment of a method for training a target object defect detection model is shown.
[0280] Understandably, Figure 3 The defect detection method embodiment of the target object shown, Fig.15 The contents of the training method embodiment of the target object defect detection model shown in the figure are all applicable to the present computer program product or computer program embodiment, and the functions specifically implemented by the present computer program product or computer program embodiment are the same as those of the present computer program product or computer program embodiment. Figure 3 The defect detection method embodiment of the target object shown, Fig.15 The training method embodiment of the target object defect detection model shown in FIG. 1 is the same as that of FIG. 1 , and the beneficial effects achieved are the same as those of FIG. 1 . Figure 3 The defect detection method embodiment of the target object shown, Fig.15 The beneficial effects achieved by the target object defect detection model training method embodiment shown are also the same.
[0281] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the application is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part described as a larger operation is performed independently.
[0282] In addition, although the present application is described in the context of functional modules, it should be understood that, unless otherwise specified, one or more of the functions and / or features can be integrated into a single physical device and / or software module, or one or more functions and / or features can be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present application. More specifically, in view of the properties, functions, and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional techniques of the engineer. Therefore, those skilled in the art can implement the present application set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present application, which is determined by the full scope of the attached claims and their equivalents.
[0283] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.
[0284] The logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer-readable storage medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, apparatus, or device and execute instructions), or in conjunction with such instruction execution system, apparatus, or device. For purposes of this specification, a "computer-readable storage medium" may be any device that can contain, store, communicate, propagate, or transmit a program for use by an instruction execution system, apparatus, or device, or in conjunction with such instruction execution system, apparatus, or device.
[0285] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0286] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0287] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.
[0288] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the embodiments. Technical personnel familiar with the field can make various equivalent modifications or substitutions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A method for detecting defects of a target object, characterized in that: include: Acquire a first image of a target object; Determine a second target pixel from the first image according to the pixel values of each pixel of the first image; wherein the pixel value of the second target pixel is greater than a third preset threshold and less than a fourth preset threshold, and the third preset threshold is less than the fourth preset threshold; Calculating an average value of pixel values of each of the second target pixel points to obtain a pixel mean value of the first image; Determine a plurality of first target pixel points from the first image according to the pixel mean; wherein a difference between the pixel value of the first target pixel point and the pixel mean is greater than a first preset threshold or less than a second preset threshold, the first preset threshold is a positive number, and the second preset threshold is a negative number; In the first image, determining a connected area formed by a plurality of the first target pixels; Cutting out each of the connected regions from the first image to obtain a defect sub-graph of the target object; Extracting image feature data of the defect sub-image at different image scales; The defect sub-image is semantically segmented according to the image feature data to obtain the defect contour of the defect sub-image; the image feature data at the smallest layer of the image scale is determined as the second target feature data; the second target feature data is defectively classified by a classifier to obtain category information of the defects in the defect sub-image; wherein the semantic segmentation is used to determine the pixel points of the defect sub-image as pixel points belonging to defects or pixel points not belonging to defects, and the defect classification is used to classify the defects contained in the defect sub-image in terms of defect categories; Determining the morphological parameters of the defect in the defect sub-image according to the defect contour; The defect detection result of the target object is determined according to the category information and the morphological parameters of the defects in each of the defect sub-images.
2. The defect detection method of the target object according to claim 1, characterized in that: After obtaining the defect subgraph of the target object, the method further includes: The defect sub-image is subjected to image scale normalization processing to obtain a new defect sub-image.
3. The defect detection method of the target object according to claim 2, characterized in that: Determining the morphological parameters of the defect in the defect sub-image according to the defect contour includes: According to the defect contour, based on the size of the defect sub-image before image scale normalization processing, the size of the defect contour is restored to obtain the original contour of the defect in the defect sub-image; According to the original contour, morphological parameters of the defects in the defect sub-image are determined.
4. The defect detection method of the target object according to claim 3, characterized in that: The performing semantic segmentation processing on the defect sub-image according to the image feature data to obtain the defect contour of the defect sub-image includes: Performing feature fusion processing on the image feature data of the different layers of image scales to obtain first target feature data; The first target feature data is semantically segmented by a decoder to obtain a defect outline of the defect sub-image.
5. The defect detection method of the target object according to claim 1, characterized in that: The method further comprises: Filtering the defects of the target object according to the morphological parameters corresponding to each defect in the target object to obtain the target defects of the target object; Determining the cumulative number of target defects corresponding to each defect category in the target object; A defect handling mode of the target object is determined according to the defect category and the accumulated number, wherein the defect handling mode includes at least one of an alarm process, a shutdown process or a labeling process.
6. The defect detection method of the target object according to claim 5, characterized in that: The filtering process is performed on the defects of the target object according to the morphological parameters corresponding to each defect in the target object to obtain the target defects of the target object, including: Obtaining preset morphological parameter categories and preset morphological parameter thresholds corresponding to each defect category; Under each of the preset morphological parameter categories, comparing the morphological parameter corresponding to the defect with the preset morphological parameter threshold; When all the morphological parameters corresponding to the defect are less than or equal to the preset morphological parameter threshold, the defect is eliminated; or, when any morphological parameter corresponding to the defect is greater than the preset morphological parameter threshold, the defect is determined as a target defect.
7. The defect detection method of the target object according to claim 1, characterized in that: The semantic segmentation processing of the defect sub-image according to the image feature data and the defect classification processing of the second target feature data by a classifier are implemented based on a target defect detection model, and the target defect detection model is trained in the following manner: Acquire multiple sample sub-images; the sample sub-images carry defect labels; the defect labels are used to characterize defect contours of the sample sub-images and category information of defects in the sample sub-images; Extracting image feature data of each of the sample sub-images through a target object defect detection model; Performing semantic segmentation processing on the sample sub-image according to the image feature data to obtain a defect contour prediction result of the sample sub-image; Perform defect classification processing on the sample sub-image according to the image feature data to obtain a prediction result of category information of the defects in the sample sub-image; Determining a first loss value according to the defect contour prediction result and the defect label; Determining a second loss value according to the category information prediction result and the defect label; According to the first loss value and the second loss value, the parameters of the target defect detection model are updated to obtain a trained target defect detection model.
8. The defect detection method of the target object according to claim 7, characterized in that: The obtaining of multiple sample subgraphs comprises: acquiring a second image of the sample object; An area of interest in the second image is detected, and the area of interest is cropped to obtain a plurality of sample sub-images of the sample object, wherein the sample sub-images are annotated with corresponding defect labels.
9. The defect detection method of the target object according to claim 8, characterized in that: The method further includes the step of marking defect labels corresponding to each of the sample sub-graphs, the step comprising: When it is determined that there are multiple defects in the sample sub-image, detecting the overlap of defect contours of each defect in the sample sub-image; When the overlap degree is greater than a preset overlap threshold, it is determined that there is a defect overlap area in the sample sub-image; According to preset defect priority sorting information, the defect label corresponding to the defect with the highest defect priority sorting in the defect overlap area is determined as the defect label corresponding to the defect overlap area.
10. The method for detecting defects of a target object according to claim 9, characterized in that: The method further comprises: When the overlap degree is less than or equal to the preset overlap threshold, the sample sub-image is cropped again to obtain a plurality of new sample sub-images.
11. A target object defect detection device, characterized in that: include: An acquisition module, used for acquiring a first image of a target object; The cropping module is specifically used for: Determine a second target pixel from the first image according to the pixel values of each pixel of the first image; wherein the pixel value of the second target pixel is greater than a third preset threshold and less than a fourth preset threshold, and the third preset threshold is less than the fourth preset threshold; Calculating an average value of pixel values of each of the second target pixel points to obtain a pixel mean value of the first image; Determine a plurality of first target pixel points from the first image according to the pixel mean; wherein a difference between the pixel value of the first target pixel point and the pixel mean is greater than a first preset threshold or less than a second preset threshold, the first preset threshold is a positive number, and the second preset threshold is a negative number; In the first image, determining a connected area formed by a plurality of the first target pixels; Cutting out each of the connected regions from the first image to obtain a defect sub-graph of the target object; A first processing module is used to extract image feature data of the defect sub-image at different image scales; A second processing module is used to perform semantic segmentation processing on the defect sub-image according to the image feature data to obtain a defect contour of the defect sub-image; A third processing module is used to determine the image feature data at the smallest layer of the image scale as the second target feature data; perform defect classification processing on the second target feature data through a classifier to obtain category information of the defects in the defect sub-image; wherein the semantic segmentation processing is used to determine the pixel points of the defect sub-image as pixel points belonging to defects or pixel points not belonging to defects, and the defect classification processing is used to classify the defects contained in the defect sub-image in terms of defect categories; An identification module, used to determine the morphological parameters of the defect in the defect sub-image according to the defect contour; A detection module is used to determine the defect detection result of the target object according to the category information and the morphological parameters of the defects in each of the defect sub-images.
12. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the target object defect detection method according to any one of claims 1 to 10 is implemented.
13. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the target object defect detection method according to any one of claims 1 to 10 is implemented.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the target object defect detection method according to any one of claims 1 to 10 is implemented.
