A defect detection method, computing device and storage medium
By converting the annular workpiece image into a rectangle and combining the defect determination model with the defect-free template, the problems of low efficiency and poor robustness in nuclear fuel rod groove defect detection are solved, achieving efficient and accurate defect detection and reducing data set costs.
Patent Information
- Application Number
- CN202311203492.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-18
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2043-09-18
AI Technical Summary
Existing technology is difficult to efficiently and accurately detect defects in nuclear fuel rod grooves, especially when the diameter is small and a comprehensive inspection is required. Manual inspection is inefficient and lacks standardization. Machine vision-based methods are time-consuming and costly in labeling. Self-templating methods are inefficient and have poor robustness.
By converting the annular workpiece image into a rectangle, a sample image is generated and input into the defect determination model. The defect area is determined using self-reference template matching. The defect determination model is combined with the defect-free template to improve detection efficiency and accuracy and reduce the cost of data set construction.
It achieves more efficient and accurate defect detection, avoids interference from adjacent defect areas, improves the robustness of the self-reference template, and reduces the cost of constructing a groove defect data set.
Smart Images

Figure CN117197101B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a defect detection method, a computing device and a storage medium. Background Art
[0002] Due to the continuous development of science and technology, energy demand is increasing, traditional non-renewable energy is constantly depleting and causing serious pollution. Therefore, nuclear energy, as a clean energy, has gradually attracted more attention. However, nuclear power plants may have leakage accidents, causing huge losses, so it is crucial to accurately control the safety of the nuclear reaction process.
[0003] The nuclear fuel-filled zirconium tube is one of the main components of the heavy water reactor nuclear fuel element. The two ends of the zirconium tube are welded to the end covers to seal the nuclear fuel in the tube. Therefore, grooves are set on the inner and outer walls of both ends to ensure the reliability and stability of the welding process. However, the grooves are easily damaged and inevitably contaminated during the disassembly process, which may lead to unstable or failed welding, seriously affecting the safety of the nuclear reaction.
[0004] As the nuclear energy industry continues to expand, the demand for zirconium tubes has increased significantly. However, these zirconium tubes have a challenging feature - their small diameter makes it very difficult to identify defects with the naked eye. Currently, technicians usually use magnifying glasses and light sources to spot check the grooves. However, this manual inspection method is inefficient and lacks a standardized defect assessment process, resulting in many unqualified parts being overlooked. In addition, ensuring nuclear safety requires a comprehensive inspection of all nuclear fuel rod grooves. Therefore, relying solely on manual visual inspection is no longer sufficient to meet this stringent requirement.
[0005] In recent years, machine vision-based methods have been widely used in defect detection due to their fast detection speed, high accuracy, and ability to establish unified standards. However, all training images need to be given specific labels, especially semantic segmentation, which is time-consuming and costly. Self-template-based methods provide a viable alternative by achieving high accuracy without relying on a large amount of labeled data. These methods generate specific templates for each sample, significantly improving the generalization ability of the detection algorithm, but the method often indiscriminately establishes templates for non-defective areas, resulting in low efficiency. In addition, when there are clustered defects in the groove, the robustness of the algorithm is challenged.
[0006] Therefore, there is an urgent need to develop a simple, efficient and accurate method for detecting nuclear fuel rod groove defects. Summary of the invention
[0007] In view of the above problems, the present invention is proposed to provide a defect detection method, a computing device and a storage medium that overcome the above problems or at least partially solve the above problems.
[0008] According to one aspect of the present invention, there is provided a defect detection method, which is executed in a computing device and is suitable for detecting annular workpieces. The method comprises: converting an annular area in an annular workpiece image into a rectangle to obtain a rectangular image; generating at least one sample image based on the rectangular image; inputting each sample image into a defect determination model for processing to output a corresponding detection result and generate a corresponding class activation heat map group, wherein the detection result includes whether each sample image contains a defect; for each class of activation heat map group, determining an initial target area containing defects and generating a self-reference template, wherein the self-reference template indicates an area in the sample image that does not contain defects; matching each initial target area with the corresponding self-reference template to determine the pixel position of the defect area.
[0009] Optionally, in the defect detection method according to the present invention, generating a self-reference template includes: determining at least one image column containing defects as a defect column according to image columns in the rectangular image corresponding to columns in the initial target area; for each defect column, selecting a set of candidate image columns from the rectangular image; and generating corresponding reference templates based on each candidate image column set.
[0010] Optionally, in the defect detection method according to the present invention, the columns in the initial target area correspond to the image columns in the rectangular image, which are determined by:
[0011]
[0012] Wherein, L is the pixel column index of the rectangular image, p is the sorting index of the sample image, q is the sub-image index contained in the sample image, W is the width value of the rectangle, α is the scaling factor of the sample image to which the initial target area belongs, and l is the pixel column index of the initial target area in the sample area.
[0013] Optionally, in the defect detection method according to the present invention, the candidate image column set is obtained in the following manner:
[0014]
[0015] Where D is the pixel column set of the initial target area in the rectangular image, D = {[R L1 ,R L2 ]∪[R L3 ,R L4 ]∪…}, R L is the target defect column, and t is the number of preset columns on both sides of the target defect column.
[0016] Optionally, in the defect detection method according to the present invention, the self-reference template is generated by the following method:
[0017]
[0018] Where N is the number of column vectors in M.
[0019] Optionally, in the defect detection method according to the present invention, each initial target area is matched with a corresponding self-reference template to determine the pixel position of the defect area, including: for each defect column, calculating the pixel difference between the defect column and the corresponding pixel point in the corresponding self-reference template; if the absolute value of the pixel difference is greater than a threshold, then the pixel point corresponding to the defect column is determined as a defective pixel point; and counting the positions of all defective pixels to determine the pixel position of the defect area.
[0020] Optionally, in the defect detection method according to the present invention, the annular area in the annular workpiece image is converted into a rectangle to obtain a rectangular image, including: binarizing the annular workpiece image to obtain a binary image; obtaining graphic parameters of the annular area in the binary image based on Hough circle detection, the graphic parameters at least including the circumference of the outer circle, the circumference of the inner circle, the grayscale value of each pixel point in the annular area, and the horizontal coordinate and vertical coordinate of the center of the annular area in the pixel coordinate system; and obtaining the rectangular image using the graphic parameters.
[0021] Optionally, in the defect detection method according to the present invention, a rectangular image is obtained by using graphic parameters, including: constructing an initial rectangle with the circumference of the outer circle in the annular area as the width of the rectangular image and the difference between the outer circle radius and the inner circle radius as the height of the rectangle; and filling the grayscale value of each pixel point in the annular area into the initial rectangle to obtain a rectangular image.
[0022] Optionally, in the defect detection method according to the present invention, the grayscale value of each pixel point in the annular area is correspondingly filled into the initial rectangle to obtain a rectangular image, including: obtaining the corresponding relationship between each pixel point in the annular area and the pixel point in the initial rectangle based on the following relationship:
[0023] R i.j =O m,n , i=1,2,…H, j=1,2,…,W,
[0024]
[0025]
[0026] Among them, O m,n is the gray value of the pixel in the ring, R i.jis the grayscale value of the pixel in the rectangle, i and j are the height and width indexes of the rectangular pixel respectively, W is the width value of the rectangular image, W is equal to the circumference of the outer circle of the ring, H is the height value of the rectangular image, H is equal to the radius difference between the inner and outer circles of the ring, r is the average radius of the inner and outer circles of the ring, c x , c y are the horizontal and vertical coordinates of the center of the circle in the pixel coordinate system, respectively.
[0027] Optionally, in the defect detection method according to the present invention, it further includes: if it is detected that there are pixels with unfilled grayscale values in the rectangular image, using a bilinear interpolation method to obtain the grayscale value of each blank pixel.
[0028] Optionally, in the defect detection method according to the present invention, at least one sample image is generated based on a rectangular image, including: dividing the rectangular image into at least one group of sub-images along the width direction of the rectangle; for each group of sub-images, sequentially splicing the sub-images contained therein in the height direction of the rectangle to obtain a sample image.
[0029] Optionally, in the defect detection method according to the present invention, the rectangular image is divided into at least one group of sub-images along the width direction of the rectangle, including: equally dividing the rectangular image in the width direction of the rectangle to obtain multiple sub-images; and selecting three adjacent sub-images as a group of sub-images.
[0030] Optionally, in the defect detection method according to the present invention, the defect determination model includes at least multiple feature extraction layers and classification layers; and generating a corresponding class activation heat map group, including: for each sample image containing defects, obtaining the feature map outputted at each feature extraction layer and the prediction probability outputted at the classification layer corresponding to the sample image; based on each feature map and the prediction probability, generating a class activation heat map corresponding to each feature map as a class activation heat map group.
[0031] Optionally, in the defect detection method according to the present invention, determining the initial target area containing defects includes: marking the area where the thermal value of each type of activation heat map in the class activation heat map group is greater than the thermal threshold as a sub-target area; merging all sub-target areas to generate a target area.
[0032] Optionally, in the defect detection method according to the present invention, each sample image is input into the defect determination model for processing, including:
[0033] Each sample image is processed to obtain sample images of the same size; each sample image of the same size is input into a defect determination model to determine whether each sample image contains defects. The defect determination model includes multiple feature extraction layers, an attention layer, a global average pooling layer, and a classification layer.
[0034] According to another aspect of the present invention, there is provided a computing device, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be suitable for being executed by the at least one processor, and the program instructions include instructions for executing the above method.
[0035] According to another aspect of the present invention, a readable storage medium storing program instructions is provided. When the program instructions are read and executed by a computing device, the computing device executes the above method.
[0036] According to the solution of the present invention, by combining the defect determination model with the defect-free template, defects can be detected more efficiently and accurately, and it is also helpful to reduce the cost of constructing a groove defect data set.
[0037] The solution of the present invention, for an input image containing defects, designs a defect-free template which largely avoids interference from adjacent defective areas, thereby improving the robustness of the self-reference template.
[0038] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0040] Figure 1 A schematic diagram showing a groove structure on the end face of a zirconium tube is shown;
[0041] Figure 2 A schematic diagram of a computing device 200 according to an embodiment of the present invention is shown;
[0042] Figure 3 A flow chart of a defect detection method 300 according to an embodiment of the present invention is shown;
[0043] Figure 4 A schematic diagram of a rectangular image according to an embodiment of the present invention is shown;
[0044] Figure 5 A schematic diagram showing defect determination model results according to an embodiment of the present invention is shown;
[0045] Figure 6A physical representation diagram showing a class activation heat map according to an embodiment of the present invention;
[0046] Figure 7 A schematic diagram of a process for detecting groove defects of a nuclear fuel rod according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0047] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0048] Nuclear fuel rods are hollow zirconium tubes with a groove on each end face made by turning. Industrial cameras are used to capture images of the groove surface for defect detection. Figure 1 As shown, Figure 1 A schematic diagram of a groove structure of a zirconium tube end face is shown. When there are defects in the groove of the zirconium tube end face, it will lead to instability or failure of welding, seriously affecting the safety of nuclear reaction.
[0049] Due to the small diameter of zirconium tubes, it becomes very difficult to identify defects with the naked eye. Currently, technicians usually use magnifying glasses and light sources to spot check the grooves. However, this manual inspection method is inefficient and lacks a standardized defect evaluation process, resulting in many unqualified parts being overlooked.
[0050] Therefore, in order to solve the problems existing in the above-mentioned prior art, an embodiment of the present invention provides a defect detection method, which uses a defect determination model combined with a defect-free template to detect defects more efficiently and accurately, and is also conducive to reducing the cost of building a groove defect data set. For an input image containing defects, the designed defect-free template largely avoids interference from adjacent defective areas, thereby improving the robustness of the self-reference template. The method can be executed in a computing device. Figure 1 FIG. 2 shows a structural diagram of a computing device 200 according to an embodiment of the present invention. It should be noted that: Figure 2 The computing device 200 shown is only an example. In practice, the computing device used to implement the defect detection method of the present invention can be any type of device, and its hardware configuration can be different from the above. Figure 2 The computing device 200 shown is the same as Figure 2 The computing device 200 shown in the figure is different. In practice, the computing device used to implement the groove defect detection method of the present invention can be Figure 2 The hardware components of the computing device 200 shown are increased or deleted, and the present invention does not limit the specific hardware configuration of the computing device.
[0051] like Figure 2 As shown, in a basic configuration 202, computing device 200 typically includes a system memory 206 and one or more processors 204. A memory bus 208 may be used for communication between processor 204 and system memory 206.
[0052] Depending on the desired configuration, the processor 204 can be any type of processor, including but not limited to: a microprocessor (μP), a microcontroller (μC), a digital information processor (DSP), or any combination thereof. The processor 204 can include one or more levels of cache such as a primary cache 210 and a secondary cache 212, a processor core 214, and registers 216. An example processor core 214 can include an arithmetic logic unit (ALU), a floating point unit (FPU), a digital signal processing core (DSP core), or any combination thereof. An example memory controller 218 can be used with the processor 204, or in some implementations, the memory controller 218 can be an internal part of the processor 204.
[0053] Depending on the desired configuration, the system memory 206 can be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.) or any combination thereof. The physical memory in the computing device generally refers to the volatile memory RAM, and the data in the disk needs to be loaded into the physical memory before it can be read by the processor 204. The system memory 206 may include an operating system 220, one or more applications 222, and program data 224. In some embodiments, the application 222 may be arranged to execute instructions on the operating system by one or more processors 204 using program data 224. The operating system 220 may be, for example, Linux, Windows, etc., which includes program instructions for processing basic system services and performing tasks that depend on hardware. The application 222 includes program instructions for implementing various user-desired functions, and the application 222 may be, for example, a browser, instant messaging software, a software development tool (such as an integrated development environment IDE, a compiler, etc.), etc., but is not limited thereto. When the application 222 is installed in the computing device 200, a driver module may be added to the operating system 220.
[0054] When the computing device 200 starts running, the processor 204 reads and executes the program instructions of the operating system 220 from the memory 206. The application 222 runs on the operating system 220 and uses the interfaces provided by the operating system 220 and the underlying hardware to implement various functions desired by the user. When the user starts the application 222, the application 222 is loaded into the memory 206, and the processor 204 reads and executes the program instructions of the application 222 from the memory 206.
[0055] The computing device 200 also includes a storage device 232 including a removable storage 236 and a non-removable storage 238 , both of which are connected to the storage interface bus 234 .
[0056] The computing device 200 may also include an interface bus 240 that facilitates communication from various interface devices (e.g., output devices 242, peripheral interfaces 244, and communication devices 246) to the basic configuration 202 via the bus / interface controller 230. Example output devices 242 include a graphics processing unit 248 and an audio processing unit 250. They can be configured to facilitate communication with various external devices such as a display or speakers via one or more A / V ports 252. Example peripheral interfaces 244 may include a serial interface controller 254 and a parallel interface controller 256, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboards, mice, pens, voice input devices, touch input devices) or other peripherals (e.g., printers, scanners, etc.) via one or more I / O ports 258. Example communication devices 246 may include a network controller 260, which may be arranged to facilitate communication with one or more other computing devices 262 via a network communication link via one or more communication ports 264.
[0057] A network communication link can be an example of a communication medium. Communication media can generally be embodied as computer-readable instructions, data structures, program modules in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium. A "modulated data signal" can be a signal in which one or more of its data sets or its changes can be carried out in a manner that encodes information in the signal. As non-limiting examples, communication media can include wired media such as a wired network or a dedicated line network, and various wireless media such as sound, radio frequency (RF), microwave, infrared (IR) or other wireless media. The term computer-readable medium used herein can include both storage media and communication media.
[0058] In the computing device 200 according to the present invention, the application 222 includes instructions for executing the groove defect detection method 300 of the present invention, and the instructions can instruct the processor 204 to execute the groove defect detection method of the present invention. Those skilled in the art can understand that, in addition to the instructions for executing the defect detection method 300, the application 222 can also include other applications 226 for implementing other functions.
[0059] Figure 3 A flow chart of a defect detection method 300 according to an embodiment of the present invention is shown. The method 300 is suitable for being executed in a computing device (such as the aforementioned computing device 300).
[0060] like Figure 3 As shown, the purpose of method 300 is to implement a method for defect detection on annular workpieces (for example, the end bevel of a nuclear fuel-filled zirconium tube). This method utilizes a defect determination model combined with a defect-free template to detect defects more efficiently and accurately, which helps to reduce the cost of constructing a bevel defect data set.
[0061] The method 300 begins at step 302 , where an annular region in an annular workpiece image is converted into a rectangle to obtain a rectangular image.
[0062] In this embodiment, the annular workpiece image can be understood as the image of the end face groove of the zirconium tube. When the image of the end face groove of the zirconium tube is collected, a ring light source adapted to the end face groove of the zirconium tube can be used. In this way, the groove area in the collected end image will be clearer, thereby ensuring the accuracy of groove defect detection. Of course, images can also be collected based on other light sources, and the present invention does not make specific restrictions on this.
[0063] refer to Figure 1 The groove area to be detected is a circular ring (ring area), and its area accounts for less than 10% of the collected image. In order to eliminate the interference of non-interest areas and improve the detection accuracy, it is necessary to expand the ring into a rectangle.
[0064] Specifically, first, the annular workpiece image is binarized to obtain a binarized image. The end image can be binarized using an adaptive binarization method. However, it should be noted that the present invention does not limit the specific algorithm used to binarize the end image, and any known or future known image binarization method is within the protection scope of the present invention.
[0065] In some embodiments, holes and edge burrs in the binary image can be removed (i.e., the binary image is subjected to noise reduction processing), and only the annular region is retained. Preferably, a morphological processing method can be used to remove holes and edge burrs in the end binary image. Of course, other methods can also be used to remove holes and edge burrs in the end binary image, and the present invention does not make specific restrictions on this.
[0066] Then, the graphic parameters of the annular area in the binary image are obtained based on the Hough circle detection, and the graphic parameters at least include the outer circle circumference 2πR 外 、Inner circumference 2πR 内 , the gray value of each pixel in the annular area is O m,n , the horizontal coordinate c of the center of the ring in the pixel coordinate system x and the vertical coordinate c y .
[0067] Among them, the outer radius R 外 We can first determine the circumscribed square of the outer circle of the annular area, and then use half of the side length of the circumscribed square as the radius of the outer circle. 内 It is half the length of the side of the circumscribed square of the circle in the annular region.
[0068] Finally, the rectangular image is obtained using the graphic parameters. Specifically, the initial rectangle is constructed with the outer circle circumference in the annular region as the width of the rectangular image and the difference between the outer circle radius and the inner circle radius as the height of the rectangular image. The grayscale values of each pixel in the annular region are filled into the initial rectangle to obtain a rectangular image.
[0069] Among them, the corresponding relationship between each pixel point in the circular area and the pixel points in the initial rectangle can be obtained based on the following relationship:
[0070] R i.j =O m,n , i=1,2,…H, j=1,2,…,W
[0071]
[0072]
[0073] Among them, O m,n is the gray value of the pixel in the ring, R i.j is the grayscale value of the pixel in the rectangle, i and j are the height and width indexes of the rectangular pixel respectively, W is the width value of the rectangular image, W is equal to the circumference of the outer circle of the ring, H is the height value of the rectangular image, H is equal to the radius difference between the inner and outer circles of the ring, r is the average radius of the inner and outer circles of the ring, c x , c y are the horizontal and vertical coordinates of the center of the circle in the pixel coordinate system, respectively.
[0074] After determining the correspondence between each pixel point in the circular area and the pixel points in the initial rectangle, each pixel in the circular area is converted into a rectangular image.
[0075] In a specific example, according to the coordinates of any point A in the rectangular image, the coordinates of the point A' in the annular image corresponding to point A are calculated using the above correspondence relationship, and then the pixel value of point A' in the annular groove image is assigned to point A in the rectangular image. In this way, the pixel value of point A in the rectangular image is equal to the pixel value of point A' in the corresponding annular image, thereby obtaining the rectangular image (such as Figure 4 shown).
[0076] It should be noted that in many cases, the coordinates of the calculated point A' are not an integer. In other words, the calculated point A' is not a pixel point in the annular groove image, but a point between pixels. Obviously, in this case, the pixel value of point A in the rectangular image cannot be determined. Therefore, according to one embodiment, a bilinear interpolation method can be used to determine the pixel value of point A in the rectangular image based on the pixel values of pixels near point A'. That is, if it is detected that there are pixels with unfilled gray values in the rectangular image, the gray values of each blank pixel are obtained using a bilinear interpolation method.
[0077] Of course, interpolation methods such as nearest neighbor interpolation and bicubic interpolation of a 4x4 pixel neighborhood may also be used to determine the pixel value of each point in the rectangular image, and the present invention does not impose any limitation on this.
[0078] After the rectangular image is obtained, the process proceeds to step 304 to generate at least one sample image based on the rectangular image.
[0079] Specifically, first, the rectangular image is divided into at least one group of sub-images along the width direction of the rectangle. In some embodiments, the rectangular image can be equally divided along the width direction of the rectangle to obtain multiple sub-images. Three adjacent sub-images are taken as a group of sub-images. For example, the rectangular image is divided along the width direction ( Figure 4 The image is divided into 9 sub-images in the W direction and marked as 1, 2, ..., 9 in sequence. Sub-images 1, 2, and 3 are taken as a group of sub-images, sub-images 4, 5, and 6 are taken as a group of sub-images, and sub-images 7, 8, and 9 are taken as a group of sub-images.
[0080] Then, for each group of sub-images, the sub-images contained therein are sequentially spliced in the height direction of the rectangle to obtain a sample image. Continuing with the above example, for sub-image groups 1, 2, and 3, sub-image 2 is translated to below sub-image 1 ( Figure 4The 3rd sub-image is then translated to the bottom of the 2nd sub-image after the movement to obtain a sample image. Similarly, the sample images of the 4th, 5th and 6th sub-image groups and the sample images of the 7th, 8th and 9th sub-image groups are obtained respectively. Dividing the rectangular image into multiple sample images can effectively improve the computational efficiency.
[0081] After obtaining each sample image, proceed to step 306, where each sample image is input into the defect determination model for processing to output a corresponding detection result and generate a corresponding class activation heat map group, wherein the detection result includes whether each sample image contains a defect.
[0082] Specifically, each sample image is first processed (cropped, scaled) to obtain each sample image with the same size. Preferably, the size of each sample image can be modified to 224*224.
[0083] Then, each sample image with the same size is input into the defect determination model to determine whether each sample image contains a defective part.
[0084] like Figure 5 As shown, the defect determination model of this embodiment consists of three parts: feature extraction layer, attention layer, global average pooling layer and classification layer.
[0085] The sample image is first input into the feature extraction layer for feature extraction to obtain the feature map of the sample image.
[0086] The feature extraction layer is connected to the attention layer, and the feature map is used as the input of the attention layer. This process does not change the size of the feature map. The attention layer makes the network pay more attention to the defect area, thereby enhancing the feature extraction capability. Preferably, in order to improve the applicability of the classification model, this embodiment adopts a pyramid squeeze attention module as the attention layer. The module uses convolution kernels of different sizes and grouped convolutions to obtain multi-scale feature maps on the channel.
[0087] In this embodiment, in order to reduce the number of parameters, the feature map is not flattened directly, but global average pooling is used, and the output result is finally obtained through full connection. In order to improve the classification accuracy and accelerate the convergence speed, the backbone network with pre-trained weights is selected as the feature extraction layer, and transfer learning is used.
[0088] In some embodiments, during network training, the optimizer uses stochastic gradient descent SGD, and the loss function uses cross entropy loss.
[0089] If defects are found in the sample data through the defect determination model, the corresponding class activation heat map group is generated using each sample image containing the defects.
[0090] Specifically, for each sample image containing defects, first, the feature map output by each feature extraction layer corresponding to the sample image (that is, the feature map output by each feature extraction layer in the above defect determination model) and the predicted probability output by the classification layer are obtained.
[0091] Then, based on each feature map and the predicted probability, a class activation heat map corresponding to each feature map is generated as the class activation heat map group, such as Figure 6 As shown, Figure 6 1 shows a physical display diagram of a class activation heat map according to an embodiment of the present invention. It should be noted that in order to better illustrate the different heat values between the pixels in the class activation heat map of this embodiment, Figure 6 and Figure 7 Color images are selected for display.
[0092] Preferably, a LayerCAM method may be used to construct activation heat maps of each initial class.
[0093] After obtaining the class activation heat map group, step 308 is entered to determine the initial target area containing defects for each activation heat map group and generate a self-reference template, wherein the self-reference template indicates the area in the sample image that does not contain defects. Specifically, the area in the class activation heat map group where the thermal value of each activation heat map is greater than the thermal threshold is marked as a sub-target area. All sub-target areas are merged to generate the initial target area ( Figure 6 In other words, to ensure that defects are not missed, the union area of the class activation heat maps of feature maps with different network depths is selected as the final initial target area.
[0094] In some embodiments, in order to make the extracted target area fit the actual defect location as closely as possible, when constructing the class activation heat map of each feature map, different thresholds are set for feature maps of different depths, and the deeper the network, the larger the threshold.
[0095] It is worth noting that the initial target area of the present embodiment is a rough area containing defects, and the initial target area includes all defective areas, and also includes non-defective areas. In order to obtain a more accurate defective area, in step 310, each initial target area is matched with the corresponding self-reference template to determine the pixel position of the defective area.
[0096] The steps of constructing a defect-free template include:
[0097] First, according to the correspondence between each column (l) in the initial target area and each image column (L) in the rectangular image, at least one image column containing defects is determined as a defect column (R L ).
[0098] The mapping relationship between each column (l) in the initial target area and each image column (L) in the rectangular image is:
[0099]
[0100] Wherein, L is the pixel column index of the rectangular image, p is the sorting index of the sample image, q is the sub-image index contained in the sample image, W is the width value of the rectangle, α is the scaling factor of the sample image to which the initial target area belongs (i.e., the scaling factor when the sample image size is modified to 224*224 as mentioned above), and l is the pixel column index of the initial target area in the sample area.
[0101] Then, for each defect column (R L ), select a candidate image column set (M) from the rectangular image respectively.
[0102] Assume R j is a pixel column vector with dimension H×1 in the original rectangular image. Then the set of pixel columns in the rectangular image where the initial target area is located is D={[R L1 ,R L2 ]∪[R L3 ,R L4 ]∪…}.
[0103] Let the target defect column be R L , a template is made by using an image column matrix (i.e., a candidate image column set) consisting of t columns on the left and t columns on the right. The image column matrix is shown as:
[0104]
[0105] Finally, based on each of the candidate image column sets, the corresponding self-reference templates are generated.
[0106] The target defect is listed as R L The defect-free template can be expressed as:
[0107]
[0108] Where N is the number of column vectors in M.
[0109] It is worth noting that since the rectangle is formed by expanding the ring, when R L When the number of columns on the left is less than t, it should be added from the end of the rectangle. Similarly, when R L When the number of columns on the right is less than t, they should be added from the beginning of the rectangle.
[0110] After obtaining the defect-free template of each target area, for each defect column, the pixel difference between the defect column and the corresponding pixel in the corresponding self-reference template is calculated. If the absolute value of the pixel difference is greater than the threshold, the pixel corresponding to the defect column is determined as a defective pixel.
[0111] Specifically, for each R L , and calculate its difference with the defect-free template according to the following formula:
[0112] Δ L =|R L -T L |=[Δ 0,L , Δ 1,L …Δ H,L ] T
[0113] If the absolute value of the difference is greater than the threshold K, the position is considered to be a defect. In addition, due to the noise interference of a single pixel, the difference may be greater than the threshold, so the pixel-level defect area is obtained by removing the abnormal points through corrosion and expansion operations.
[0114] In a specific example, combining Figure 7 , Figure 7 A schematic diagram of a process for detecting groove defects of a nuclear fuel rod according to an embodiment of the present invention is shown.
[0115] Figure 7 In the method 300 , stage 1 corresponds to steps 302 to 304 , stage 2 corresponds to step 306 , stages 3 and 4 correspond to step 308 , and stage 5 corresponds to step 310 .
[0116] For the specific process of nuclear fuel rod groove defect detection, please refer to the description of the above method 300, which will not be described in detail in this application.
[0117] The method provided by the present invention utilizes a defect determination model combined with a defect-free template, which can detect defects more efficiently and accurately, and is also helpful in reducing the cost of constructing a groove defect data set.
[0118] The method of the present invention, for an input image containing defects, designs a defect-free template which largely avoids interference from adjacent defective areas, thereby improving the robustness of the self-reference template.
[0119] A9. The method as described in A8, wherein the grayscale value of each pixel point in the circular area is filled into the initial rectangle to obtain the rectangular image, comprising:
[0120] Based on the following relationship, the corresponding relationship between each pixel point in the circular area and the pixel points in the initial rectangle is obtained:
[0121] Ri.j =O m,n , i=1,2,…H, j=1,2,…,W,
[0122]
[0123]
[0124] Among them, O m,n is the gray value of the pixel in the ring, R i.j is the grayscale value of the pixel in the rectangle, i and j are the height and width indexes of the rectangular pixel respectively, W is the width value of the rectangular image, W is equal to the circumference of the outer circle of the ring, H is the height value of the rectangular image, H is equal to the radius difference between the inner and outer circles of the ring, r is the average radius of the inner and outer circles of the ring, c x , c y are the horizontal and vertical coordinates of the center of the circle in the pixel coordinate system, respectively.
[0125] A10. The method as described in A9, further comprising:
[0126] If it is detected that there are pixels with unfilled grayscale values in the rectangular image, the grayscale value of each blank pixel is obtained by using a bilinear interpolation method.
[0127] A11. The method as described in A1, wherein generating at least one sample image based on the rectangular image comprises:
[0128] Dividing the rectangular image into at least one group of sub-images along the width direction of the rectangle;
[0129] For each group of sub-images, the sub-images contained therein are sequentially spliced in the height direction of the rectangle to obtain a sample image.
[0130] A12. The method as described in A11, wherein the rectangular image is divided into at least one group of sub-images along the width direction of the rectangle, comprising:
[0131] Dividing the rectangular image equally in the direction of the rectangular width to obtain a plurality of sub-images;
[0132] Select three adjacent sub-images as a group of sub-images.
[0133] A13. The method as described in A1, wherein the defect determination model comprises at least a plurality of feature extraction layers and classification layers;
[0134] as well as
[0135] Generate the corresponding class activation heat map group, including:
[0136] For each sample image containing defects,
[0137] Obtain the feature graphs outputted by each feature extraction layer and the predicted probability outputted by the classification layer corresponding to the sample image;
[0138] Based on each feature map and the predicted probability, a class activation heat map corresponding to each feature map is generated as the class activation heat map group.
[0139] A14. The method as described in A13, wherein determining the initial target area containing defects comprises:
[0140] Mark the area where the heat value of each type of activation heat map in the class activation heat map group is greater than the heat threshold as a sub-target area;
[0141] All sub-target regions are merged to generate the target region.
[0142] A15. The method as described in A1, wherein each sample image is input into the defect determination model for processing, including:
[0143] Processing each sample image to obtain each sample image with the same size;
[0144] Each sample image with the same size is input into the defect determination model to determine whether each sample image contains defects. The defect determination model includes multiple feature extraction layers, attention layers, global average pooling layers and classification layers.
[0145] The various techniques described herein may be implemented in combination with hardware or software, or a combination thereof. Thus, the method and apparatus of the present invention, or some aspects or parts of the method and apparatus of the present invention may be in the form of program codes (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, a USB flash drive, a floppy disk, a CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for practicing the present invention.
[0146] In the case where the program code is executed on a programmable computer, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store the program code; the processor is configured to execute the method of the present invention according to the instructions in the program code stored in the memory.
[0147] By way of example and not limitation, readable media include readable storage media and communication media. Readable storage media stores information such as computer readable instructions, data structures, program modules or other data. Communication media generally embody computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and include any information transfer medium. Any combination of the above is also included within the scope of readable media.
[0148] In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the examples of the present invention. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to implement the content of the present invention described herein, and the above description of specific languages is for the purpose of disclosing the preferred embodiment of the present invention.
[0149] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0150] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0151] Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in the devices described in the embodiment, or alternatively may be located in one or more devices different from the devices in the examples. The modules in the foregoing examples may be combined into one module or may be divided into multiple submodules.
[0152] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0153] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0154] In addition, some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the functions. Therefore, a processor with necessary instructions for implementing the method or method elements forms a device for implementing the method or method elements. In addition, the elements described herein of the device embodiments are examples of devices for implementing the functions performed by the elements for the purpose of implementing the invention.
[0155] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved, and is not intended to imply that the objects so described must have a given order in time, space, order, or in any other manner.
[0156] Although the present invention has been described according to a limited number of embodiments, it will be apparent to those skilled in the art, with the benefit of the above description, that other embodiments may be envisioned within the scope of the invention thus described. In addition, it should be noted that the language used in this specification is selected primarily for readability and teaching purposes, rather than for explaining or defining the subject matter of the present invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is illustrative and not restrictive with respect to the scope of the present invention, and the scope of the present invention is defined by the appended claims.
Claims
1. A defect detection method, executed in a computing device, suitable for detecting an annular workpiece, the method comprising: Convert the annular region in the annular workpiece image into a rectangle to obtain a rectangular image; Based on the rectangular image, generating at least one sample image; Input each sample image into the defect determination model for processing to output a corresponding detection result and generate a corresponding class activation heat map group, wherein the detection result includes whether each sample image contains a defect; For each type of activated heat map group, determining an initial target area containing defects and generating a self-reference template, including: determining at least one image column containing defects as a defect column according to the image columns in the rectangular image corresponding to each column in the initial target area, and selecting a candidate image column set from the rectangular image for each defect column, and generating corresponding self-reference templates based on each candidate image column set, wherein the self-reference template indicates an area in the sample image that does not contain defects; Matching each initial target area with the corresponding self-reference template to determine the pixel position of the defect area; Wherein, each column in the initial target area corresponds to each image column in the rectangular image, which is determined by: Wherein, L is the pixel column index of the rectangular image, p is the sorting index of the sample image, q is the sub-image index contained in the sample image, W is the width of the rectangle, α is the scaling factor of the sample image to which the initial target area belongs, and l is the pixel column index of the initial target area in the sample area; The candidate image column set is obtained as follows: M=[R L-t R L-t+1 …R i …R L+t ], Where D is the pixel column set of the initial target area in the rectangular image, D = {[R L1 ,R L2 ]∪[R L3 ,R L4 ]∪…}, R L is the target defect column, and t is the number of preset columns on both sides of the target defect column; The self-referencing template is generated as follows: Where N is the number of column vectors in M.
2. The method of claim 1, wherein: Match each initial target area with the corresponding self-reference template to determine the pixel position of the defect area, including: For each defect column, calculating the pixel difference between the defect column and the corresponding pixel point in the corresponding self-reference template; If the absolute value of the pixel difference is greater than the threshold, the pixel point corresponding to the defective column is determined as a defective pixel point; The positions of all defective pixels are counted to determine the pixel positions of the defective area.
3. The method of claim 1, wherein: Convert the annular area in the annular workpiece image into a rectangle to obtain a rectangular image, including: Binarizing the annular workpiece image to obtain a binary image; Obtaining graphic parameters of the annular area in the binary image based on Hough circle detection, wherein the graphic parameters at least include the circumference of the outer circle, the circumference of the inner circle, the grayscale value of each pixel point in the annular area, and the horizontal coordinate and vertical coordinate of the center of the annular area in the pixel coordinate system; The rectangular image is obtained by using the graphic parameters.
4. The method of claim 3, wherein: Using the graphic parameters, obtaining the rectangular image includes: An initial rectangle is constructed by taking the outer circle circumference in the annular region as the width of the rectangular image and the difference between the outer circle radius and the inner circle radius as the height of the rectangle; The grayscale value of each pixel point in the circular area is correspondingly filled into the initial rectangle to obtain the rectangular image.
5. The method of claim 4, wherein: Filling the grayscale value of each pixel point in the circular area into the initial rectangle to obtain the rectangular image, including: Based on the following relationship, the correspondence between each pixel point in the annular area and the pixel points in the initial rectangle is obtained: R i.j =O m,n ,i=1,2,……H,j=1,2,……,W, Among them, O m,n is the gray value of the pixel in the ring, R i.j is the grayscale value of the pixel in the rectangle, i and j are the height and width indexes of the rectangular pixel respectively, W is the width value of the rectangular image, W is equal to the circumference of the outer circle of the ring, H is the height value of the rectangular image, H is equal to the radius difference between the inner and outer circles of the ring, r is the average radius of the inner and outer circles of the ring, c x , c y are the horizontal and vertical coordinates of the center of the circle in the pixel coordinate system, respectively.
6. The method of claim 5, wherein: Also includes: If it is detected that there are pixels with unfilled grayscale values in the rectangular image, the grayscale value of each blank pixel is obtained by using a bilinear interpolation method.
7. The method of claim 1, wherein: Based on the rectangular image, generating at least one sample image includes: Dividing the rectangular image into at least one group of sub-images along the width direction of the rectangle; For each group of sub-images, the sub-images contained therein are sequentially spliced in the height direction of the rectangle to obtain a sample image.
8. The method of claim 7, wherein: The rectangular image is divided into at least one group of sub-images along the width direction of the rectangle, comprising: Dividing the rectangular image equally in the direction of the rectangular width to obtain a plurality of sub-images; Select three adjacent sub-images as a group of sub-images.
9. The method of claim 1, wherein: The defect determination model at least comprises a plurality of feature extraction layers and classification layers; as well as Generate the corresponding class activation heat map group, including: For each sample image containing defects, Obtain the feature graphs outputted by each feature extraction layer and the predicted probability outputted by the classification layer corresponding to the sample image; Based on each feature map and the predicted probability, a class activation heat map corresponding to each feature map is generated as the class activation heat map group.
10. The method of claim 9, wherein: Identify initial target areas containing defects, including: Mark the area where the heat value of each type of activation heat map in the class activation heat map group is greater than the heat threshold as a sub-target area; All sub-target regions are merged to generate the target region.
11. The method of claim 1, wherein: Each sample image is input into the defect determination model for processing, including: Processing each sample image to obtain each sample image with the same size; Each sample image with the same size is input into the defect determination model to determine whether each sample image contains defects. The defect determination model includes multiple feature extraction layers, attention layers, global average pooling layers and classification layers.
12. A computing device comprising: at least one processor; and A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the method according to any one of claims 1 to 11.
13. A readable storage medium storing program instructions, when the program instructions are read and executed by a computing device, the computing device executes the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Driving risk monitoring method based on attention mechanism
CN113780385A
