Glass defect detection method and device, computer equipment and storage medium
By using the multi-head slice self-attention mechanism, channel self-attention mechanism and defect prediction mechanism models in glass defect detection, the accuracy problem of glass defect detection in multi-light source imaging scenarios is solved, and a more efficient defect detection effect is achieved.
Patent Information
- Application Number
- CN202411427761.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-02-07
AI Technical Summary
The existing glass defect detection methods lack universality in multi-light source imaging scenarios and cannot accurately detect complementary morphological defects in glass.
The glass defect detection model adopts the multi-head slice self-attention mechanism, channel self-attention mechanism and defect prediction mechanism. By acquiring multi-channel stitching images, the channel image features are extracted, the channel weight is determined, and the image fusion is performed to improve the accuracy of defect detection. sex.
The accuracy of glass defect detection is improved, not only considering the image characteristics of all channels, but also measuring its importance to defect detection by the weights of different channels. Compared with single-channel feature inference, the accuracy of detection results is significantly improved.
Smart Images

Figure CN119399129A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of industrial defect detection, and in particular to a glass defect detection method, device, computer equipment and storage medium. Background Art
[0002] As a common inorganic non-metallic material, glass is widely used in the fields of construction, automobile, aerospace, etc. due to its transparency, heat insulation, corrosion resistance and other characteristics. However, various defects and hidden dangers may appear in glass products during production and use, such as cracks, bubbles, inclusions, etc. These defects not only affect the aesthetics of glass products, but also may reduce their strength and weather resistance, and even threaten the safety of users. Therefore, it is particularly important to detect defects in glass.
[0003] At present, when performing glass defect detection, the features of one channel of the multi-channel glass image are identified and then mapped to other features, that is, only one feature layer is inferred to obtain the defect detection result. This method has certain shortcomings: it is not universal, especially in the scenario of multi-light source imaging, many defects are complementary, and it is impossible to accurately detect the defects in the glass based on only one channel data. Therefore, how to accurately detect the defects in the glass has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] Based on this, it is necessary to provide a glass defect detection method, device, computer equipment, computer readable storage medium and computer program product to address the above technical problems, which can improve the accuracy of glass defect detection.
[0005] In a first aspect, the present application provides a glass defect detection method, which is applied to a computer device deployed with a pre-trained glass defect detection model, wherein the glass defect detection model includes at least a multi-head slice self-attention mechanism, a channel self-attention mechanism, and a defect prediction mechanism, and the method includes:
[0006] Obtain a multi-channel stitching image corresponding to the glass to be inspected;
[0007] Through the multi-head slicing self-attention mechanism, the channel image features of each channel are extracted from the multi-channel spliced image;
[0008] Determine the channel weight of each channel in the multi-channel stitched image through the channel self-attention mechanism;
[0009] Determine the image fusion feature according to the channel weight and channel image feature of each channel in the multi-channel stitched image;
[0010] Through the defect prediction mechanism and combined with the image fusion features, the defect mask corresponding to the glass to be inspected is determined.
[0011] In a second aspect, the present application provides a glass defect detection device, which is configured on a computer device deployed with a pre-trained glass defect detection model, the glass defect detection model at least includes a multi-head slice self-attention mechanism, a channel self-attention mechanism and a defect prediction mechanism, and the device includes:
[0012] An acquisition module, used for acquiring a multi-channel stitching image corresponding to the glass to be inspected;
[0013] The extraction module is used to extract the channel image features of each channel from the multi-channel spliced image through the multi-head slicing self-attention mechanism;
[0014] The weighting module is used to determine the channel weight of each channel in the multi-channel stitched image through the channel self-attention mechanism;
[0015] A fusion module, used for determining image fusion features according to the channel weight and channel image features of each channel in the multi-channel stitched image;
[0016] The detection module is used to determine the defect mask corresponding to the glass to be detected through the defect prediction mechanism combined with the image fusion features.
[0017] In a third aspect, the present application provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.
[0018] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above method when executed by a processor.
[0019] In a fifth aspect, the present application provides a computer program product, which includes a computer program, and the computer program implements the steps in the above method when executed by a processor.
[0020] The above-mentioned glass defect detection method, device, computer equipment, computer-readable storage medium and computer program product extract the image features of each channel from the multi-channel stitched image through the multi-head slicing self-attention mechanism, determine the channel weight of each channel through the channel self-attention mechanism, and then fuse the channel weights and image features of each channel to detect defects in the glass based on the fused features. It can be seen that when detecting glass defects, the present application not only considers the image features of all channels, but also measures the importance of the features of different channels to defect detection through the weights of different channels. Compared with reasoning based on the features of one channel to obtain defect detection results, the accuracy of glass defect detection can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 An application environment diagram of a glass defect detection method provided in an embodiment of the present application;
[0022] Figure 2 A schematic diagram of a process for glass defect detection provided in an embodiment of the present application;
[0023] Figure 3 A logical schematic diagram of a glass defect detection method provided in an embodiment of the present application;
[0024] Figure 4 A structural block diagram of a glass defect detection device provided in an embodiment of the present application;
[0025] Figure 5 An internal structure diagram of a computer device provided in an embodiment of the present application;
[0026] Figure 6 An internal structure diagram of another computer device provided in an embodiment of the present application;
[0027] Figure 7 An internal structure diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0029] The glass defect detection method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through a communication network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, image acquisition devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0030] like Figure 2 As shown, the embodiment of the present application provides a glass defect detection method, which is applied to Figure 1The server 104 in the example is used as an example to illustrate that a trained glass defect detection model is pre-deployed in the server 104, and the glass defect detection model at least includes a multi-head slice self-attention mechanism, a channel self-attention mechanism and a defect prediction mechanism. The method includes the following steps:
[0031] S201, obtaining a multi-channel stitching image corresponding to the glass to be inspected.
[0032] In the present application, the glass to be inspected can be mobile phone glass (such as screen glass or back cover glass), car glass, or other glass, which is not specifically limited here. When performing glass defect detection, due to the strong light transmittance and reflective properties of the glass surface, defects are often difficult to be fully and clearly imaged using a single lighting method, and often require at least two, and up to a dozen lighting methods to present; wherein, lighting refers to illuminating the glass to be inspected by artificially controlling the light source; in this way, images of the glass to be inspected can be collected under different lighting methods, so that defect detection can be performed based on the images collected under different lighting. It can be understood that in photography, lighting can not only enhance the brightness and clarity of the photo, but also show a deeper sense of hierarchy and rich details. Therefore, defect detection using images of the glass to be inspected collected under different lighting conditions can accurately detect possible defects in the glass.
[0033] In the present application, after obtaining multiple images of the glass to be inspected under different lighting conditions, the multiple images can be fused, and the fusion method can be a method of splicing the multiple images, for example, splicing according to the channel direction (i.e., the direction perpendicular to the plane), so as to obtain a multi-channel stitched image corresponding to the glass to be inspected.
[0034] It is understandable that the generation of the multi-channel stitched image can be achieved on the server 104 side or on the image acquisition side (eg, the terminal 102), which is not specifically limited here.
[0035] In the present application, after obtaining the multi-channel stitched image corresponding to the glass to be detected, the multi-channel stitched image can be input into the glass defect detection model, and then the multi-slice self-attention mechanism, channel self-attention mechanism and defect prediction mechanism included in the glass defect detection model are used to complete the defect detection. The specific process can be seen in steps S202-S205.
[0036] It should be noted that the multi-slice self-attention mechanism and channel self-attention mechanism in the glass defect detection model are two concurrently executed mechanisms, so steps S202 and S203 can be performed concurrently based on the multi-channel stitched image.
[0037] S202. Through the multi-head slicing self-attention mechanism, the channel image features of each channel are extracted from the multi-channel stitched image.
[0038] In the present application, the multi-head slicing self-attention mechanism is an attention mechanism that specifically processes image data, and each "head" usually processes different parts of the input data. In the present application, after the multi-channel spliced image is input into the glass defect detection model, in order to use the multi-head slicing self-attention mechanism to extract the image features of different channels, the multi-channel spliced image can be first separated and extracted by channel features to obtain the initial image features of each channel, wherein the initial image data is data that can be directly processed by the multi-head slicing self-attention mechanism. Each "head" of the multi-head slicing self-attention mechanism processes the initial image features of a channel to obtain the channel image features corresponding to each channel. The specific process can be as follows: the initial image features are converted into three vectors: query vector (Query, Q), key vector (Key, K) and value vector (Value, V). For each head, the corresponding Q, K, and V vectors are calculated respectively, and the self-attention mechanism is applied to calculate the attention score. Specifically, each query vector is dot-producted with all key vectors to obtain the compatibility score (Compatibility Scores), and then normalized by the softmax function to obtain the attention weights (Attention Weights). Finally, these attention weights are used to perform a weighted summation of the value vectors to obtain the output of each head, i.e., the channel image features of each channel.
[0039] S203. Determine the channel weight of each channel in the multi-channel stitched image through a channel self-attention mechanism.
[0040] In the present application, when the attention mechanism is used to determine the weight of each channel in a multi-channel image, this attention mechanism is usually called a channel self-attention mechanism. The core idea of the channel self-attention mechanism is to dynamically adjust the importance of different channels by learning the weight of each channel. These weights reflect the contribution of each channel to glass defect detection.
[0041] Specifically, the channel weight of each channel in the multi-channel stitched image is determined through the channel self-attention mechanism. First, the multi-channel stitched image is feature extracted using a model such as a convolutional neural network (CNN) to obtain feature maps of multiple channels; then, the feature maps of each channel are globally aggregated. Commonly used methods include global average pooling and global maximum pooling. These operations can compress the spatial information of each channel into a single value, thereby obtaining a global representation of each channel. Finally, the weight of each channel is calculated using the aggregated global information. This is usually achieved through a series of fully connected layers (or convolutional layers), activation functions (such as ReLU, Sigmoid, etc.) and normalization operations. The size of the weight reflects the importance of the channel for glass defect detection.
[0042] S204: Determine image fusion features according to the channel weight and channel image features of each channel in the multi-channel stitched image.
[0043] In an embodiment of the present application, a weighted fusion method can be used to obtain image fusion features. For example, for any channel, the channel weight and the channel image feature of the channel are multiplied; the multiplication results corresponding to each channel are spliced to obtain the image fusion feature.
[0044] S205. Determine the defect mask corresponding to the glass to be inspected by using the defect prediction mechanism and combining the image fusion features.
[0045] In an embodiment of the present application, the glass defect detection model includes a defect prediction mechanism. After obtaining the image fusion feature, the image fusion feature can be used as the input of the defect prediction mechanism, and the defect prediction mechanism outputs a defect mask corresponding to the glass to be detected based on the image fusion feature. Among them, the defect mask refers to a processed image or data representation, which identifies the location of the detected defect. Specifically, the defect mask is usually a binary image of the same size as each image that constitutes the multi-channel stitched image, in which the value of each pixel indicates whether there is a defect at the corresponding position. It can be understood that as long as the defect mask is obtained, the location of the defect in the glass to be detected can be known, that is, the detection of glass defects is completed.
[0046] In the present application, the image features of each channel are extracted from the multi-channel stitched image through the multi-head slicing self-attention mechanism, the channel weight of each channel is determined through the channel self-attention mechanism, and then the channel weights and image features of each channel are fused, so as to detect defects in the glass based on the fused features. It can be seen that when detecting glass defects, the present application not only considers the image features of all channels, but also measures the importance of the features of different channels to defect detection through the weights of different channels. Compared with reasoning based on the features of one channel to obtain defect detection results, the accuracy of glass defect detection can be improved.
[0047] In some embodiments, the channel image features of each channel are extracted from the multi-channel stitched image through a multi-head slice self-attention mechanism, including:
[0048] Separate and extract channel features of multi-channel stitched images to obtain initial image features of each channel;
[0049] Through the multi-head slicing self-attention mechanism, the channel image features of each channel are extracted from the initial image features of each channel.
[0050] It is understandable that when performing channel feature separation and extraction, channel separation can be performed based on the channel separation function first; and then the separated channels can be preliminarily extracted. By performing channel feature separation and extraction on the multi-channel spliced image, the initial image features of each channel are obtained, and the purpose is to extract data that can be used by the multi-head slicing self-attention mechanism from the multi-channel spliced image. On this basis, each head of the multi-head slicing self-attention mechanism processes the initial image data of a channel, and the output of each head is the channel image feature corresponding to each channel.
[0051] The channel image features of each channel are extracted in order to subsequently perform glass defect detection based on the channel image features of all channels. Compared with reasoning based on the features of only one channel to obtain defect detection results, comprehensively considering the image features of all channels can improve the accuracy of glass defect detection.
[0052] In some embodiments, before determining the channel weight of each channel in the multi-channel stitched image through the channel self-attention mechanism, the method further includes:
[0053] Perform feature compression processing on the multi-channel stitching image to obtain a feature compressed image.
[0054] Correspondingly, the channel weight of each channel in the multi-channel stitched image is determined through the channel self-attention mechanism, including:
[0055] Through the channel self-attention mechanism, the channel weight of each channel in the feature compressed image is determined.
[0056] In the present application, feature compression processing is performed on the multi-channel stitched image, which actually reduces the feature dimension of the multi-channel stitched image to a preset feature dimension. Specifically, a lossless compression algorithm or a lossy compression algorithm can be used for feature compression, and the feature compression strategy can be to compress each channel separately. After obtaining the feature compressed image, the channel weight of each channel is determined based on the feature compressed image. The specific process is similar to the above-mentioned process of directly determining the channel weight based on the multi-channel stitched image, and will not be repeated here.
[0057] It can be understood that the feature compression processing of the multi-channel stitched image reduces the image size, and based on the feature compressed image, the channel weight of each channel is determined through the channel attention mechanism, which can reduce the amount of calculation and improve the efficiency of determining the channel weight.
[0058] In some embodiments, obtaining a multi-channel stitched image corresponding to the glass to be inspected includes:
[0059] Acquire images of the glass to be inspected under different lighting conditions;
[0060] The multiple acquired images are stitched together in the channel direction to obtain a multi-channel stitched image.
[0061] In the present application, the captured images of the glass to be inspected under different lighting conditions can be captured by an image capture device, and the image capture device can be the terminal 102. The image capture device can capture the images of the glass to be inspected under different lighting conditions to obtain multiple captured images; illustratively, n captured images with dimensions of H x W can be obtained, where H is the image height and W is the image width. It should be noted that the captured image can be a color image or a grayscale image, which is not specifically limited here. After obtaining the captured images of the glass to be inspected under different lighting conditions, each captured image can also be saved for subsequent post-processing based on the saved captured images.
[0062] Taking the n acquired images as grayscale images as an example, since the grayscale image has only one grayscale channel, the n grayscale images can be spliced in the channel direction, and the dimension of the obtained multi-channel spliced image is: nx H x W; that is, the multi-channel spliced image includes n channels, and each channel is a H x W grayscale image.
[0063] The present application scheme stitches the collected images under different lighting conditions, and subsequently glass defect detection can be performed based on the stitched images, thereby ensuring the accuracy of the detection results.
[0064] In some embodiments, after determining the defect mask corresponding to the glass to be inspected by combining the defect prediction mechanism with the image fusion feature, the method further includes:
[0065] Based on the defect mask, post-processing suppression is performed on the acquired image to determine whether to filter the defects in the acquired image.
[0066] In the present application, the defect mask is usually a binary image of the same size as each captured image, which identifies the detected defect location. In this way, when the captured image is post-processed and suppressed based on the defect mask, for any captured image A, the defect location in the captured image A can be determined according to the defect location in the defect mask; the difference between the grayscale value at the defect location in the captured image A and the grayscale value around the defect location (that is, the adjacent area of the defect location) is compared. If the difference is less than the preset grayscale threshold, it is considered that the defect in the captured image A is not obvious, and it can be filtered to continue to judge the next captured image. By performing similar processing on each captured image, if the difference between the grayscale value at the defect location and the grayscale value around the defect location in each captured image is less than the preset grayscale threshold, it is considered that the glass to be detected does not have defects; if the difference between the grayscale value at the defect location and the grayscale value around the defect location in at least one captured image is greater than the preset grayscale threshold, it is considered that the defect is more obvious in some captured images, and at this time, it is considered that the glass to be detected has defects. It is understandable that some defects with little impact can be filtered out through post-processing suppression, avoiding the situation where a large amount of glass is required to be reworked and repaired due to some acceptable defects, and more effectively detecting defects that really have a serious impact on the quality of the glass.
[0067] In order to better understand the present application scheme, this application provides a glass defect detection logic flow. The specific logic flow chart can be found in Figure 3 . In the present application scheme, a multi-channel stitched image is first obtained, and the multi-channel stitched image is input into a pre-trained glass defect detection model. The process of the glass defect detection model processing the multi-channel stitched image is as follows: first, the multi-channel stitched image is channel separated to obtain the initial image features of each channel; each head of the multi-head slicing self-attention mechanism is used to process the initial image features of a channel respectively to obtain the channel image features of each channel; while extracting the channel features, another branch of the glass defect detection model will perform channel weighting. Specifically, the multi-channel stitched image is compressed, and then the weight of each channel is determined through the channel self-attention mechanism. The specific process can be found in the above description. Furthermore, according to the channel weight and channel image features of each channel, feature fusion is performed to obtain image fusion features; then based on the defect prediction mechanism of the glass defect detection model, a defect mask is generated according to the image fusion features, and then each collected image constituting the multi-channel stitched image is post-processed and suppressed according to the defect mask. The specific process can be found in the above embodiment description. In this way, the whole process of glass defect detection is completed.
[0068] It should be understood that, although the steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0069] Based on the same inventive concept, the embodiment of the present application also provides a glass defect detection device. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more embodiments of the glass defect detection device provided below can refer to the limitations of the glass defect detection method above, and will not be repeated here.
[0070] like Figure 4 As shown, an embodiment of the present application provides a glass defect detection device 400, which is configured on a computer device deployed with a pre-trained glass defect detection model, the glass defect detection model at least includes a multi-head slice self-attention mechanism, a channel self-attention mechanism and a defect prediction mechanism, and the device includes:
[0071] An acquisition module 401 is used to acquire a multi-channel stitched image corresponding to the glass to be inspected;
[0072] An extraction module 402 is used to extract channel image features of each channel from the multi-channel stitched image through a multi-head slicing self-attention mechanism;
[0073] A weighting module 403 is used to determine the channel weight of each channel in the multi-channel stitched image through a channel self-attention mechanism;
[0074] A fusion module 404 is used to determine an image fusion feature according to a channel weight and a channel image feature of each channel in the multi-channel stitched image;
[0075] The detection module 405 is used to determine the defect mask corresponding to the glass to be detected by combining the defect prediction mechanism with the image fusion feature.
[0076] In some embodiments, in extracting the channel image features of each channel from the multi-channel stitched image through the multi-head slicing self-attention mechanism, the extraction module 402 is specifically used to:
[0077] Separate and extract channel features of multi-channel stitched images to obtain initial image features of each channel;
[0078] Through the multi-head slicing self-attention mechanism, the channel image features of each channel are extracted from the initial image features of each channel.
[0079] In some embodiments, the apparatus further comprises:
[0080] A compression module is used to perform feature compression processing on the multi-channel stitched image to obtain a feature compressed image;
[0081] Accordingly, in determining the channel weight of each channel in the multi-channel stitched image through the channel self-attention mechanism, the weighting module 403 is specifically used for:
[0082] Through the channel self-attention mechanism, the channel weight of each channel in the feature compressed image is determined.
[0083] In some embodiments, in terms of acquiring a multi-channel stitched image corresponding to the glass to be inspected, the acquisition module 401 is specifically used to:
[0084] Acquire images of the glass to be inspected under different lighting conditions;
[0085] The multiple acquired images are stitched together in the channel direction to obtain a multi-channel stitched image.
[0086] In some embodiments, the apparatus further comprises:
[0087] The post-processing module is used to perform post-processing suppression on the collected image based on the defect mask to determine whether to filter the defects in the collected image.
[0088] In some embodiments, in performing post-processing suppression on a captured image based on a defect mask to determine whether to filter defects in the captured image, the post-processing module is specifically configured to:
[0089] Determine the defect position in the captured image according to the defect position in the defect mask;
[0090] Compare the grayscale value at the defect position in the acquired image with the grayscale value of the area adjacent to the defect position. If the difference is less than the preset grayscale threshold, the defects in the acquired image are filtered.
[0091] Each module in the above-mentioned glass defect detection device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0092] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data related to the implementation of the glass defect detection method. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in the above-mentioned glass defect detection method are implemented.
[0093] In some embodiments, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, the steps in the above-mentioned glass defect detection method are implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen; the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0094] Those skilled in the art will understand that Figure 5 or Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0095] In some embodiments, a computer device is provided. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps in the above method embodiments are implemented.
[0096] In some embodiments, Figure 7 The figure shows an internal structure diagram of a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0097] In some embodiments, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0098] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0099] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0100] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0101] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A glass defect detection method, characterized in that: Applied to a computer device deployed with a pre-trained glass defect detection model, the glass defect detection model at least includes a multi-head slice self-attention mechanism, a channel self-attention mechanism and a defect prediction mechanism, the method includes: Obtain a multi-channel stitching image corresponding to the glass to be inspected; Extracting channel image features of each channel from the multi-channel stitched image through the multi-head slice self-attention mechanism; Determining the channel weight of each channel in the multi-channel stitched image through the channel self-attention mechanism; Determining an image fusion feature according to the channel weight of each channel in the multi-channel stitched image and the channel image feature; The defect mask corresponding to the glass to be inspected is determined by combining the defect prediction mechanism with the image fusion feature.
2. The method according to claim 1, characterized in that The extracting the channel image features of each channel from the multi-channel stitched image through the multi-head slicing self-attention mechanism includes: Separating and extracting channel features of the multi-channel stitched image to obtain initial image features of each channel; Through the multi-head slicing self-attention mechanism, the channel image features of each channel are extracted from the initial image features of each channel.
3. The method according to claim 1, characterized in that Before determining the channel weight of each channel in the multi-channel stitched image through the channel self-attention mechanism, the method further includes: Performing feature compression processing on the multi-channel stitched image to obtain a feature compressed image; Accordingly, determining the channel weight of each channel in the multi-channel stitched image through the channel self-attention mechanism includes: The channel weight of each channel in the feature compressed image is determined through the channel self-attention mechanism.
4. The method according to claim 1, characterized in that: The step of obtaining a multi-channel stitched image corresponding to the glass to be inspected includes: Acquire images of the glass to be inspected under different lighting conditions; The multiple acquired images are stitched together in the channel direction to obtain a multi-channel stitched image.
5. The method according to claim 4, characterized in that After determining the defect mask corresponding to the glass to be inspected by combining the defect prediction mechanism with the image fusion feature, the method further includes: Based on the defect mask, post-processing suppression is performed on the acquired image to determine whether to filter defects in the acquired image.
6. The method according to claim 5, characterized in that The post-processing suppression of the acquired image based on the defect mask to determine whether to filter the defects in the acquired image includes: Determining the defect position in the acquired image according to the defect position in the defect mask; The grayscale value at the defect position in the acquired image is compared with the grayscale value of the area adjacent to the defect position. If the difference is less than a preset grayscale threshold, the defects in the acquired image are filtered.
7. A glass defect detection device, characterized in that: A computer device configured to deploy a pre-trained glass defect detection model, wherein the glass defect detection model includes at least a multi-slice self-attention mechanism, a channel self-attention mechanism, and a defect prediction mechanism, wherein the device includes: An acquisition module, used for acquiring a multi-channel stitching image corresponding to the glass to be inspected; An extraction module, used for extracting channel image features of each channel from the multi-channel stitched image through the multi-head slicing self-attention mechanism; A weighting module, used for determining a channel weight of each channel in the multi-channel stitched image through the channel self-attention mechanism; A fusion module, used for determining an image fusion feature according to the channel weight of each channel in the multi-channel stitched image and the channel image feature; The detection module is used to determine the defect mask corresponding to the glass to be detected by combining the defect prediction mechanism with the image fusion feature.
8. The device according to claim 7, characterized in that In the aspect of extracting the channel image features of each channel from the multi-channel stitched image through the multi-head slicing self-attention mechanism, the extraction module is specifically used for: Separating and extracting channel features of the multi-channel stitched image to obtain initial image features of each channel; Through the multi-head slicing self-attention mechanism, the channel image features of each channel are extracted from the initial image features of each channel.
9. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Glass detection processing method and device and terminal equipment
CN120525809A
Universal semiconductor defect detection method and system
CN121074035A
A general semiconductor defect detection method and system
CN121074035B
Optical glass AOI detection method based on deep learning
CN121147230A