A defect segmentation and positioning method and system based on casting X-ray images

By embedding the attention module and transfer learning in the Unet model, combined with the image augmentation strategy, the problem of low accuracy and efficiency of multi-scale defect positioning in casting X-ray images is solved, and efficient and high-precision defect detection is achieved.

CN114972269BActive Publication Date: 2024-09-06HUAZHONG UNIV OF SCI & TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210610819.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-31
Publication Date
2024-09-06
Estimated Expiration
2042-05-31

AI Technical Summary

Technical Problem

Existing defect segmentation and positioning methods in casting X-ray images have low accuracy and low efficiency. It is difficult to accurately locate multi-scale defects in high-resolution images, and it is difficult for traditional methods to find unified hyperparameters suitable for different images.

Method used

The defect segmentation and localization method based on the Unet model is used, and the feature extraction network and enhanced feature extraction network are combined with the attention module to construct a transfer learning defect segmentation model. ImageNet, Pascal VOC and casting X-ray image data sets are used for training to achieve image Multi-scale feature pyramid fusion and weight allocation, combined with image augmentation strategy to improve model generalization ability.

Benefits of technology

It achieves efficient and high-precision positioning of multi-scale defects in X-ray images of castings, improves detection efficiency and accuracy, and avoids the problem of missed defects caused by image scaling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114972269B
    Figure CN114972269B
Patent Text Reader

Abstract

The present invention provides a defect segmentation and positioning method and system based on X-ray images of castings, including: determining an X-ray image of a casting; having multiple defects on the casting; inputting the X-ray image of the casting into a pre-trained defect segmentation and positioning model to segment and locate the defect image of the casting in the X-ray image; the defect segmentation and positioning model is obtained by embedding an attention module at the connection jump of each level of characteristics of the Unet model and at the fusion of each adjacent two-level feature. The present invention uses a data augmentation strategy to solve the problem of limited number of X-ray images of casting defects and time-consuming labeling, uses a data-driven deep learning model to segment defects in high-resolution X-ray images of castings, and constructs a defect segmentation and positioning model including a lightweight attention module, which realizes efficient and high-precision positioning of multi-scale defects in X-ray images of castings.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image recognition, and more specifically, relates to a defect segmentation and positioning method and system based on casting X-ray images. Background Art

[0002] The metal industry is one of the important basic industries of the manufacturing industry and an important support for achieving a strong manufacturing country. With the continuous increase of my country's industrial strength, the quality requirements for industrial materials are getting higher and higher, especially for castings, which are extremely important in various fields. The production process of castings is affected by many factors, such as pouring temperature, pouring pressure, annealing temperature, annealing time, etc., and any disturbance of any factor will cause various defects in the castings, affecting the performance of the castings. Therefore, it is of great significance to discover defects and analyze and solve them.

[0003] In casting production practice, casting quality inspection is mostly done by professionally trained and experienced inspectors who visually inspect casting X-ray images and manually record defect information (location, type) in X-ray images in paper logs. However, visual quality inspection is easily affected by the subjective consciousness and physical and mental state of inspectors, resulting in the inability to guarantee inspection accuracy, efficiency, stability and reliability, which seriously hinders the development trend of full process automation of metal component production.

[0004] With the rapid development of technologies such as digital image processing, machine learning, and deep learning, as well as the continuous improvement of hardware performance such as digital image acquisition equipment and graphics processors, computer vision has made intelligent detection and identification of metal component defects based on digital images possible.

[0005] The location of defects in casting X-ray images is the basis for defect classification and identification. In the defect location task, how to locate and detect defects in high-resolution casting X-ray images with a low missed detection rate is the core issue. Image scaling will cause small defects to disappear, resulting in missed defects; it is difficult to find unified hyperparameters suitable for different images in traditional methods, and it is also difficult to complete the defect location task quickly. Therefore, according to development needs, it is of great significance to combine computer technology to achieve efficient and high-precision positioning of multi-scale defects in casting X-ray images. Summary of the invention

[0006] In view of the defects of the prior art, the purpose of the present invention is to provide a defect segmentation and positioning method and system based on casting X-ray images, aiming to solve the problems of low accuracy and low efficiency of the existing defect segmentation and positioning methods of casting X-ray images.

[0007] To achieve the above object, in a first aspect, the present invention provides a defect segmentation and positioning method based on a casting X-ray image, comprising the following steps:

[0008] Determine an X-ray image of a casting; the casting has multiple defects;

[0009] The X-ray image of the casting is input into a pre-trained defect segmentation and positioning model to segment and locate the defect image of the casting in the X-ray image; the defect segmentation and positioning model is obtained by embedding an attention module at the connection jump of each level of characteristics of the Unet model and at the fusion of each adjacent two-level feature; the Unet model performs n convolution operations on the received X-ray image through a feature extraction network to obtain a feature pyramid of the X-ray image; the feature pyramid includes n levels of features; each level of features is input into a corresponding attention module to assign weights to the features at each level; then the nth level features are upsampled level by level, first the nth level features are compared with the nth-level features, and then the nth-level features are upsampled. The first-level features are fused according to the corresponding weights to obtain the n-1th-level fused features, and the n-1th-level fused features are convoluted and activated to obtain new n-1th-level features, which are input into the corresponding attention module. The first n-2-level features and the corresponding weights of the feature pyramid are combined to re-assign weights to the first n-2-level features and the new n-1th-level features. Subsequently, the new n-1th-level features are upsampled and the aforementioned steps are repeated until the first-level fused features are obtained after the new second-level features and the first-level features are fused according to the weights. The first-level fused features are predicted and processed by the activation function to obtain the defect image after segmentation and positioning. n is a positive integer.

[0010] In an optional example, the Unet model includes: a backbone feature extraction network, an enhanced feature extraction network, and a prediction network;

[0011] The backbone feature extraction network is used to extract multi-level features of the image; the enhanced feature extraction network is used to fuse the multi-level features to obtain fused features; the prediction network is used to perform prediction processing on the fused features using an activation function;

[0012] The defect segmentation and positioning model is obtained through transfer training, and the process of the transfer training is as follows:

[0013] Determine the datasets required for migration training: ImageNet image dataset, Pascal VOC image semantic segmentation dataset, and casting X-ray image dataset;

[0014] A convolutional neural network VGG16 is trained on the ImageNet image dataset; the VGG16 includes: a feature extraction network and a classification network;

[0015] The parameters of the convolutional layer in the trained VGG16 feature extraction network are transferred to the backbone feature extraction network of the Unet model as the initial values ​​of the corresponding layers of the backbone feature extraction network of the Unet model to obtain a new Unet model. The new Unet model is trained on the PascalVOC image semantic segmentation dataset to obtain a trained new Unet model.

[0016] A plurality of attention modules are added to the enhanced feature extraction network of the trained new Unet model to obtain a defect segmentation and positioning model, so that the attention modules are embedded at the connection jumps of each level of features extracted by the backbone feature extraction network of the new Unet model and at the fusion points of each two adjacent levels of features. The defect segmentation and positioning model is trained on the casting X-ray image dataset to obtain a trained defect segmentation and positioning model.

[0017] Specifically, the parameters of the convolution layer include: convolution kernel size, convolution kernel step size, convolution kernel depth and convolution layer weight;

[0018] In an optional example, the casting X-ray image dataset is obtained by the following steps:

[0019] Determining a plurality of X-ray images; each X-ray image is obtained by X-raying different castings or different regions of the same casting, the casting having a plurality of defects;

[0020] Cutting and annotating defect images of castings in multiple X-ray images to obtain X-ray images of multi-scale defects; the cutting is: distinguishing defects from non-defect backgrounds, and annotating as a set of pixel point positions recording defect areas;

[0021] The X-ray image of the multi-scale defect is subjected to image augmentation processing to obtain an enlarged casting X-ray image data set; the process of the image augmentation processing is: spatial position transformation, grayscale transformation, image distortion, and random cropping and scaling are performed on the X-ray image in sequence.

[0022] In an optional example, the process of image augmentation processing is specifically as follows:

[0023] Transform the spatial position of the image by flipping or rotating it to prevent the defect segmentation and positioning model from overfitting the position of the defect in the image;

[0024] The image after spatial position transformation is subjected to grayscale transformation through contrast transformation or brightness transformation to prevent the defect segmentation and positioning model from overfitting the grayscale of the image;

[0025] Distort the grayscale transformed image by grid distortion or affine transformation to prevent the defect segmentation and location model from overfitting the shape, texture and scale of the defects in the image;

[0026] The distorted images are cropped and scaled to obtain a casting X-ray image dataset to increase the diversity of the images to a greater extent.

[0027] In a second aspect, the present invention provides a defect segmentation and positioning system based on casting X-ray images, comprising:

[0028] An X-ray image determination unit, used for determining an X-ray image of a casting; the casting has a plurality of defects;

[0029] The defect segmentation and positioning unit is used to input the X-ray image of the casting into a pre-trained defect segmentation and positioning model to segment and locate the defect image of the casting in the X-ray image; the defect segmentation and positioning model is obtained by embedding an attention module at the connection jump of each level of characteristics of the Unet model and at the fusion of each adjacent two levels of features; the Unet model performs n convolution operations on the received X-ray image through a feature extraction network to obtain a feature pyramid of the X-ray image; the feature pyramid includes n levels of features; each level of features is input into a corresponding attention module to assign weights to the features at each level; then the nth level features are upsampled level by level, first the nth level features are upsampled, and then the nth level features are upsampled. The first level feature is fused with the n-1th level feature according to the corresponding weight to obtain the n-1th level fused feature, and the n-1th level fused feature is convoluted and activated to obtain a new n-1th level feature, which is input into the corresponding attention module, and the first n-2 level features and the corresponding weights of the feature pyramid are combined to re-assign weights to the first n-2 level features and the new n-1th level features, and then the new n-1th level features are upsampled, and the above steps are repeated until the first level fused feature after the new second level feature and the first level feature are fused according to the weight is obtained; the first level fused feature is predicted and processed by the activation function to obtain the defect image after segmentation and positioning; n is a positive integer.

[0030] In an optional example, the Unet model used by the defect segmentation and positioning unit includes: a backbone feature extraction network, an enhanced feature extraction network and a prediction network; the backbone feature extraction network is used to extract multi-level features of the image; the enhanced feature extraction network is used to fuse the multi-level features to obtain fused features; the prediction network is used to perform prediction processing on the fused features using an activation function;

[0031] The system also includes: a segmentation and positioning model training unit;

[0032] The segmentation and positioning model is used to obtain a defect segmentation and positioning model through transfer training. The process of the transfer training is as follows: determining the data sets required for the transfer training: ImageNet image data set, Pascal VOC image semantic segmentation data set and casting X-ray image data set; training the convolutional neural network VGG16 on the ImageNet image data set; the VGG16 includes: a feature extraction network and a classification network; migrating the parameters of the convolution layer in the trained VGG16 feature extraction network to the backbone feature extraction network of the Unet model as the initial values ​​of the corresponding layers of the backbone feature extraction network of the Unet model to obtain a new Unet model, training the new Unet model on the Pascal VOC image semantic segmentation data set to obtain a trained new Unet model; and adding multiple attention modules to the enhanced feature extraction network of the trained new Unet model to obtain a defect segmentation and positioning model, so that the attention modules are embedded in the connection jumps of the various levels of features extracted by the backbone feature extraction network of the new Unet model and the fusion of the two adjacent levels of features, and the defect segmentation and positioning model is trained on the casting X-ray image data set to obtain a trained defect segmentation and positioning model.

[0033] In an optional example, the casting X-ray image dataset used by the segmentation and positioning model training unit is obtained by the following steps: determining multiple X-ray images; each X-ray image is obtained by taking X-ray photos of different castings or different areas of the same casting, and the casting has multiple defects; cutting and annotating the defective image of the casting in the multiple X-ray images to obtain multi-scale defective X-ray images; the cutting is: distinguishing defects from non-defective backgrounds, and annotating them as a set of pixel point positions recording the defective area; and performing image augmentation processing on the multi-scale defective X-ray images to obtain an expanded casting X-ray image dataset; the image augmentation processing process is: performing spatial position transformation, grayscale transformation, image distortion, and random cropping and scaling on the X-ray images in sequence.

[0034] In an optional example, the process of image augmentation processing performed by the segmentation and positioning model training unit is specifically as follows: spatially transforming the image by flipping or rotating to prevent the defect segmentation and positioning model from overfitting the position of defects in the image; performing grayscale transformation on the image after spatial position transformation by contrast transformation or brightness transformation to prevent the defect segmentation and positioning model from overfitting the grayscale of the image; distorting the image after grayscale transformation by grid distortion or affine transformation to prevent the defect segmentation and positioning model from overfitting the shape, texture and scale of defects in the image; and cropping and scaling the image after the distortion operation to obtain a casting X-ray image data set to increase the diversity of the image to a greater extent.

[0035] In a third aspect, the present invention provides a defect segmentation and positioning system based on X-ray images of castings, comprising: a memory and a processor; the memory is used to store a computer program; the processor is used to implement the defect segmentation and positioning method provided in the first aspect when executing the computer program.

[0036] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the defect segmentation and positioning method provided in the first aspect is implemented.

[0037] In general, the above technical solution conceived by the present invention has the following beneficial effects compared with the prior art:

[0038] The present invention provides a defect segmentation and positioning method and system based on casting X-ray images, which improves the existing casting X-ray image segmentation technology. The image scaling will make small defects disappear, resulting in defect leakage; it is difficult to find a unified hyperparameter suitable for different images in the traditional method, and it is also difficult to quickly complete the defect positioning task. The present invention converts the problem of multi-scale defect detection and positioning of high-resolution images into a sub-image segmentation problem; the method of segmenting defects in high-resolution X-ray images of castings using a data-driven deep learning model solves the problem that traditional image segmentation methods are difficult to effectively detect defects in X-ray images; in view of the limited number of X-ray images of casting defects and the time-consuming labeling, a data augmentation strategy suitable for casting X-ray images is proposed; finally, in view of the problem of difficulty in segmenting multi-scale defects in casting X-ray images, a defect segmentation model including a lightweight attention module is constructed, which realizes efficient and high-precision positioning of multi-scale defects in casting X-ray images. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 is a flow chart of a defect segmentation and positioning method based on casting X-ray images provided by an embodiment of the present invention;

[0040] Figure 2 This is a flow chart of another method for multi-scale defect segmentation and positioning of casting X-ray images based on deep learning provided by an embodiment of the present invention.

[0041] Figure 3 It is a flow chart of a random image augmentation strategy provided by an embodiment of the present invention.

[0042] Figure 4 It is a flow chart of the transfer learning strategy provided by an embodiment of the present invention.

[0043] Figure 5 It is a schematic diagram of an ECA module provided by an embodiment of the present invention.

[0044] Figure 6It is a schematic diagram of a feature pyramid (PFN) embedded with an ECA module provided in an embodiment of the present invention.

[0045] Figure 7 It is an architecture diagram of a defect segmentation and positioning system based on casting X-ray images provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention 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 invention and are not used to limit the present invention.

[0047] The purpose of the present invention is to provide a method for multi-scale defect segmentation and positioning of casting X-ray images based on deep learning, aiming at the defect positioning problem in high-resolution X-ray images of castings. The method uses a data augmentation strategy to solve the problem of limited number of X-ray images of casting defects and time-consuming annotation. It uses a data-driven deep learning model to segment defects in high-resolution X-ray images of castings, constructs a defect segmentation model including a lightweight attention module, and realizes efficient and high-precision positioning of multi-scale defects in casting X-ray images.

[0048] Figure 1 is a flow chart of a defect segmentation and positioning method based on casting X-ray images provided by an embodiment of the present invention; Figure 1 As shown, the following steps are included:

[0049] S101, determining an X-ray image of a casting; the casting has a plurality of defects;

[0050] S102, inputting the X-ray image of the casting into a pre-trained defect segmentation and positioning model to segment and locate the defect image of the casting in the X-ray image; the defect segmentation and positioning model is obtained by embedding an attention module at the connection jump of each level of features of the Unet model and at the fusion of each two adjacent levels of features; the Unet model performs n convolution operations on the received X-ray image through a feature extraction network to obtain a feature pyramid of the X-ray image; the feature pyramid includes n levels of features; each level of features is input into a corresponding attention module to assign weights to the features at each level; then the nth level features are upsampled level by level, first the nth level features are compared with the first level features, and then the nth level features are upsampled. The n-1 level features are fused according to the corresponding weights to obtain the n-1 level fused features, and the n-1 level fused features are convoluted and activated to obtain new n-1 level features, which are input into the corresponding attention module. The first n-2 level features and corresponding weights of the feature pyramid are combined to re-assign weights to the first n-2 level features and the new n-1 level features, and then the new n-1 level features are upsampled. The above steps are repeated until the first level fused features after the new second level features and the first level features are fused according to the weights are obtained; the first level fused features are predicted and processed by the activation function to obtain the defect image after segmentation and positioning; n is a positive integer.

[0051] In an optional example, the Unet model includes: a backbone feature extraction network, an enhanced feature extraction network, and a prediction network;

[0052] The backbone feature extraction network is used to extract multi-level features of the image; the enhanced feature extraction network is used to fuse the multi-level features to obtain fused features; the prediction network is used to perform prediction processing on the fused features using an activation function;

[0053] The defect segmentation and positioning model is obtained through transfer training, and the process of the transfer training is as follows:

[0054] Determine the datasets required for migration training: ImageNet image dataset, Pascal VOC image semantic segmentation dataset, and casting X-ray image dataset;

[0055] A convolutional neural network VGG16 is trained on the ImageNet image dataset; the VGG16 includes: a feature extraction network and a classification network;

[0056] Migrating the parameters of the convolutional layer in the trained VGG16 feature extraction network to the backbone feature extraction network of the Unet model as the initial values ​​of the corresponding layers of the backbone feature extraction network of the Unet model to obtain a new Unet model, and training the new Unet model on the PascalVOC image semantic segmentation dataset to obtain a trained new Unet model; the parameters of the convolutional layer include: convolution kernel size, convolution kernel step size, convolution kernel depth, and convolution layer weight;

[0057] A plurality of attention modules are added to the enhanced feature extraction network of the trained new Unet model to obtain a defect segmentation and positioning model, so that the attention modules are embedded at the connection jumps of each level of features extracted by the backbone feature extraction network of the new Unet model and at the fusion points of each two adjacent levels of features. The defect segmentation and positioning model is trained on the casting X-ray image dataset to obtain a trained defect segmentation and positioning model.

[0058] In an optional example, the casting X-ray image dataset is obtained by the following steps:

[0059] Determining a plurality of X-ray images; each X-ray image is obtained by X-raying different castings or different regions of the same casting, the casting having a plurality of defects;

[0060] Cutting and marking defect images of castings in multiple X-ray images to obtain X-ray images of multi-scale defects; the cutting is: distinguishing defects from non-defect backgrounds, and marking to record pixel point positions of defect areas;

[0061] The X-ray image of the multi-scale defect is subjected to image augmentation processing to obtain an enlarged casting X-ray image data set; the process of the image augmentation processing is: spatial position transformation, grayscale transformation, image distortion, and random cropping and scaling are performed on the X-ray image in sequence.

[0062] In an optional example, the process of image augmentation processing is specifically as follows:

[0063] Transform the spatial position of the image by flipping or rotating it to prevent the defect segmentation and positioning model from overfitting the position of the defect in the image;

[0064] The image after spatial position transformation is subjected to grayscale transformation through contrast transformation or brightness transformation to prevent the defect segmentation and positioning model from overfitting the grayscale of the image;

[0065] Distort the grayscale transformed image by grid distortion or affine transformation to prevent the defect segmentation and location model from overfitting the shape, texture and scale of the defects in the image;

[0066] The distorted images are cropped and scaled to obtain a casting X-ray image dataset to increase the diversity of the images to a greater extent.

[0067] The present invention provides a method for segmenting and locating multi-scale defects in casting X-ray images based on deep learning, which can achieve efficient and high-precision positioning of multi-scale defects in casting X-ray images.

[0068] Figure 2 This is a flow chart of the multi-scale defect segmentation and positioning method of casting X-ray images based on deep learning according to the present invention. The steps mainly include:

[0069] S1: Obtain casting X-ray image data, randomly select part of the image data, cut and annotate multi-scale defects to obtain the initial data set;

[0070] S2: Expand the initial dataset data through image augmentation strategy;

[0071] S3: Based on the transfer learning strategy and the augmented dataset, the ASCUnet model is trained with an efficient and lightweight attention module (ECA) embedded at each level of the Unet model’s connection jumps and at each adjacent level feature fusion point;

[0072] It should be noted that, for the sake of simplicity, the present invention refers to the defect segmentation and positioning model as the ASCUnet model, which will not be specifically described in the following embodiments of the present invention.

[0073] S4: Segment and locate the X-ray image using the trained ASCUnet model.

[0074] Furthermore, the migration training described in S3 includes three datasets: ImageNet image semantic segmentation dataset, Pascal VOC image semantic segmentation dataset and augmented X-ray image dataset. The steps of the migration training are as follows:

[0075] S31. Train the backbone network model of the semantic segmentation network on ImageNet. The backbone network selected is VGG16.

[0076] S32. Use the parameters of some layers of the backbone network model trained in S41 as initial values, train the "target semantic segmentation network model II" through the PascalVOC semantic segmentation dataset, and obtain the Unet network model with VGG16 as the backbone network.

[0077] S33. Using the weights of the corresponding layers of the “target semantic segmentation network model II” as the initial weights of the corresponding layers of the “target semantic segmentation network model”; training the “target semantic segmentation network model” on the initial data set to obtain the ASCUnet network model embedded with the attention concentration module.

[0078] Furthermore, the ASCUnet model constructed in S3 is a Unet-like model with a pyramid structure that integrates the features of each level of the backbone network. A lightweight attention mechanism module ECA is embedded in the model, specifically:

[0079] The image is activated by multiple convolutions in the feature extraction network to form a feature pyramid; each level of features will be passed as input to the respective connected ECA modules, and the ECA module will assign weights to the channels of each level of features; after the ECA module is processed, it will start from the deepest layer and perform upsampling fusion step by step, fusing two items into adjacent level features; after the two items are fused and activated by convolution, they are input into the ECA module to assign corresponding weights to each channel again until the fusion is complete. The introduction of the ECA module can highlight effective features, suppress invalid features, and improve segmentation performance.

[0080] Figure 3 It is a flow chart of the random image augmentation strategy in the multi-scale defect segmentation and positioning method of casting X-ray images based on deep learning according to the present invention.

[0081] Image augmentation strategies include four processing methods: spatial position transformation, grayscale transformation, image distortion, and random cropping and scaling. The settings of hyperparameters vary depending on the processing method. The processing steps are as follows:

[0082] S21. Transform the spatial position of the image by flipping or rotating (including horizontal flipping, random 90° rotation, transposition, vertical flipping, etc., randomly selecting one) to prevent the deep learning model from overfitting the position of defects in the image.

[0083] S22. Transform the grayscale of the image by contrast transformation or brightness transformation (including optical darkening, random contrast transformation, random gamma transformation, random brightness transformation, etc., randomly select one) (the label image does not need to be processed during this transformation process) to prevent the deep learning model from overfitting the grayscale of the sub-image.

[0084] S23. Distort the image by means of grid distortion or affine transformation (including IAA segmented radial transformation, scale transformation and rotation, elastic deformation and grid distortion, etc., one of which is randomly selected) to prevent the deep learning model from overfitting the shape, texture and scale of defects in the sub-image.

[0085] S24. Crop and scale the image to increase the diversity of the image to a greater extent.

[0086] Figure 4 It is a flow chart of the transfer learning strategy in the multi-scale defect segmentation and positioning method of casting X-ray images based on deep learning according to the present invention.

[0087] First, train the backbone network model of the semantic segmentation network on ImageNet, and the selected backbone network is VGG16;

[0088] Secondly, the parameters of some layers of the trained backbone network model are used as initial values, and the "Unet model" is trained using the Pascal VOC semantic segmentation dataset to obtain the Unet network model with VGG16 as the backbone network.

[0089] Finally, the weights of the corresponding layers of the "Unet model" are used as the initial weights of the corresponding layers of the "ASCUnet model"; the "target semantic segmentation network model" is trained on the initial data set to obtain the ASCUnet network model embedded with the attention concentration module.

[0090] It should be noted that VGG16 consists of two parts: feature extraction network and classification output part. Unet model consists of three parts: feature extraction network, enhanced feature network and prediction network. The feature extraction network of VGG16 and Unet model is used to extract the features of the image and input it into the next network for related processing. The present invention first migrates the relevant parameters of some layers in the trained VGG16 feature extraction network to the Unet model to form a complete Unet network model.

[0091] Specifically, the present invention uses the feature extraction network parameters of VGG16 as the initial values ​​of the Unet model, where the parameters include the parameters of the convolution layer, such as the size, step size, depth of the convolution kernel, and the weights of each convolution layer in the feature extraction network.

[0092] After completing the migration of the feature extraction network parameters of VGG16, the parameters of all layers of the Unet network, including the parameters of the feature extraction network determined previously, may also change during the training of the Unet model.

[0093] After the Unet model is trained, the ECA module is introduced into the Unet model. At this time, the U-shaped outer contour of the Unet model will not change, but the ECA module is embedded in the skip connection and the upsampling convolution fusion. Then, all the convolution layers and pooling layer parameters in the outer contour are migrated from the parameters of the trained Unet model, and the training is continued as the initial value, and finally the trained ASCUnet network model is obtained.

[0094] Figure 5 It is a schematic diagram of the ECA module in the multi-scale defect segmentation and positioning method of casting X-ray images based on deep learning according to the present invention.

[0095] The ECA module is a lightweight and effective attention mechanism module that replaces the fully connected operation with 1D convolution, significantly improving the model performance without introducing too many parameters. The convolution kernel size k of the 1D convolution operation in the ECA module is determined by the following formula based on the features it processes:

[0096]

[0097] Among them, C in is the number of channels of the features processed by this module; γ is 2, b is 1; odd means rounding up to an odd number.

[0098] Figure 6 It is a schematic diagram of a feature pyramid (PFN) module embedded with an ECA module in the multi-scale defect segmentation and positioning method of casting X-ray images based on deep learning according to the present invention.

[0099] The four PFN modules introduced with the ECA module are located in the decoding part, which can assign corresponding weights to each channel while realizing feature fusion at all levels to improve the segmentation performance.

[0100] Table 1 shows the comparison results between ASCUnet and other semantic segmentation models. To verify the performance of ASCUnet, four other semantic segmentation models were trained: MobileV2PSPNet, Res50PSPNet, Res50DeepLabV3+, and Res101DeepLabV3+. These four models were compared with the Unet-like model containing the ECA module constructed in this embodiment, and Mean Intersection over Union (MIoU), Pixel Accuracy (PA), and Mean Pixel Accuracy (MPA) were used as evaluation criteria.

[0101] Table 1

[0102]

[0103] From Table 1, we can see that the segmentation performance of PSPNet with MobileV2 as the backbone network is the worst, with MIoU of only 55.3% and MPA of only 56.2%; while the MIoU of PSPNet with ResNet50 as the backbone network is 81.9%, indicating that the features extracted by the backbone network have a greater impact on the segmentation performance; the MIoU of DeepLabV3+ with ResNet50 as the backbone network is lower than that of Res50PSPNet, indicating that only fusing the intermediate-level resolution features of the backbone network under the same backbone network fails to improve the segmentation performance; DeepLabV3+ with ResNet101 as the backbone network has higher performance than the above three models, which again shows that the backbone network has a greater impact on the segmentation performance. However, the performance of Res101DeepLabV3+ is not as good as the Unet-like model with only VGG16 as the backbone and embedded with the ECA module, indicating that the fusion of high-resolution features has a greater impact than the backbone network in this task.

[0104] In summary, the multi-scale defect segmentation and positioning method of casting X-ray images based on deep learning can ensure the efficient and high-precision positioning of multi-scale defects in casting X-ray images, which is of great significance to the authenticity and security of product data in the casting process.

[0105] Figure 7 is a diagram of the defect segmentation and positioning system based on casting X-ray images provided by an embodiment of the present invention, such as Figure 7 As shown, including:

[0106] An X-ray image determination unit 710 is used to determine an X-ray image of a casting having a plurality of defects;

[0107] The defect segmentation and positioning unit 720 is used to input the X-ray image of the casting into a pre-trained defect segmentation and positioning model to segment and locate the defect image of the casting in the X-ray image; the defect segmentation and positioning model is obtained by embedding an attention module at the connection jump of each level of the Unet model and at the fusion of each adjacent two-level feature; the Unet model performs n convolution operations on the received X-ray image through a feature extraction network to obtain a feature pyramid of the X-ray image; the feature pyramid includes n levels of features; each level of features is input into the corresponding attention module to assign weights to the features at each level; then the nth level features are upsampled level by level, first the nth level The features are fused with the n-1th level features according to the corresponding weights to obtain the n-1th level fused features, and the n-1th level fused features are convoluted and activated to obtain new n-1th level features, which are input into the corresponding attention module. The first n-2 level features and the corresponding weights of the feature pyramid are combined to re-assign weights to the first n-2 level features and the new n-1th level features, and then the new n-1th level features are upsampled, and the above steps are repeated until the new second-level features and the first-level features are fused according to the weights to obtain the first-level fused features; the first-level fused features are predicted and processed by the activation function to obtain the defect image after segmentation and positioning; n is a positive integer.

[0108] The Unet model used in the defect segmentation and positioning unit includes: a backbone feature extraction network, an enhanced feature extraction network and a prediction network; the backbone feature extraction network is used to extract multi-level features of the image; the enhanced feature extraction network is used to fuse the multi-level features to obtain the fused features; the prediction network is used to predict the fused features using an activation function;

[0109] The segmentation and positioning model training unit 730 is used to obtain a defect segmentation and positioning model through migration training. The process of the migration training is as follows: determining the data sets required for the migration training: ImageNet image data set, Pascal VOC image semantic segmentation data set and casting X-ray image data set; training the convolutional neural network VGG16 on the ImageNet image data set; the VGG16 includes: a feature extraction network and a classification network; migrating the parameters of the convolution layer in the trained VGG16 feature extraction network to the backbone feature extraction network of the Unet model as the initial values ​​of the corresponding layers of the backbone feature extraction network of the Unet model to obtain a new Unet model, training the new Unet model on the Pascal VOC image semantic segmentation data set to obtain a trained new Unet model; and adding multiple attention modules to the enhanced feature extraction network of the trained new Unet model to obtain a defect segmentation and positioning model, so that the attention modules are embedded in the connection jumps of the features of each level extracted by the backbone feature extraction network of the new Unet model and the fusion of each adjacent two levels of features, and the defect segmentation and positioning model is trained on the casting X-ray image data set to obtain a trained defect segmentation and positioning model.

[0110] It should be noted that Figure 7 The detailed functional implementation of each unit in the method can be found in the introduction of the aforementioned method embodiment, which will not be repeated here.

[0111] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A defect segmentation and positioning method based on casting X-ray images, It is characterized in that The steps include: Determine an X-ray image of a casting; the casting has multiple defects; Inputting an X-ray image of a casting into a pre-trained defect segmentation and positioning model to segment and locate the defect image of the casting in the X-ray image; the defect segmentation and positioning model is obtained by embedding an attention module at a connection jump of each level of features of a Unet model and at a fusion point of each two adjacent levels of features; the Unet model performs n convolution operations on the received X-ray image through a feature extraction network to obtain a feature pyramid of the X-ray image; the feature pyramid includes n levels of features; Each level of features is input into the corresponding attention module to assign weights to each level of features; Then, the n-th level features are upsampled step by step. The n-th level features are first fused with the n-1-th level features according to the corresponding weights to obtain the n-1-th level fused features. The n-1-th level fused features are convolutionally activated to obtain new n-1-th level features, which are input into the corresponding attention module. The weights are reassigned to the first n-2 level features and the new n-1-th level features in combination with the first n-2 level features and the corresponding weights of the feature pyramid. The new n-1-th level features are then upsampled and the above steps are repeated until the first-level fused features are obtained after the new second-level features and the first-level features are fused according to the weights. The first-level fused features are predicted by the activation function to obtain the defect image after segmentation and positioning. n is a positive integer.

2. The method according to claim 1, It is characterized in that The Unet model includes: a backbone feature extraction network, an enhanced feature extraction network and a prediction network; The backbone feature extraction network is used to extract multi-level features of the image; the enhanced feature extraction network is used to fuse the multi-level features to obtain fused features; the prediction network is used to perform prediction processing on the fused features using an activation function; The defect segmentation and positioning model is obtained through transfer training, and the process of the transfer training is as follows: Determine the datasets required for migration training: ImageNet image dataset, Pascal VOC image semantic segmentation dataset, and casting X-ray image dataset; A convolutional neural network VGG16 is trained on the ImageNet image dataset; the VGG16 includes: a feature extraction network and a classification network; The parameters of the convolutional layer in the trained VGG16 feature extraction network are transferred to the backbone feature extraction network of the Unet model as the initial values ​​of the corresponding layers of the backbone feature extraction network of the Unet model to obtain a new Unet model. The new Unet model is trained on the Pascal VOC image semantic segmentation dataset to obtain a trained new Unet model. A plurality of attention modules are introduced into the enhanced feature extraction network of the trained new Unet model to obtain a defect segmentation and positioning model, so that the attention modules are embedded at the connection jumps of each level of features extracted by the backbone feature extraction network of the new Unet model and at the fusion points of each two adjacent levels of features. The defect segmentation and positioning model is trained on the casting X-ray image dataset to obtain a trained defect segmentation and positioning model.

3. The method according to claim 2, It is characterized in that The casting X-ray image data set is obtained by the following steps: Determining a plurality of X-ray images; each X-ray image is obtained by X-raying different castings or different regions of the same casting, the casting having a plurality of defects; Cutting and annotating defect images of castings in multiple X-ray images to obtain X-ray images of multi-scale defects; the cutting is: distinguishing defects from non-defect backgrounds, and annotating as a set of pixel point positions recording defect areas; The X-ray image of the multi-scale defect is subjected to image augmentation processing to obtain an enlarged casting X-ray image data set; the process of the image augmentation processing is: spatial position transformation, grayscale transformation, image distortion, and random cropping and scaling are performed on the X-ray image in sequence.

4. The method according to claim 3, It is characterized in that The process of image augmentation processing is specifically as follows: Transform the spatial position of the image by flipping or rotating it to prevent the defect segmentation and positioning model from overfitting the position of the defect in the image; The image after spatial position transformation is subjected to grayscale transformation through contrast transformation or brightness transformation to prevent the defect segmentation and positioning model from overfitting the grayscale of the image; Distort the grayscale transformed image by grid distortion or affine transformation to prevent the defect segmentation and location model from overfitting the shape, texture and scale of the defects in the image; The distorted images are cropped and scaled to obtain a casting X-ray image dataset to increase the diversity of the images to a greater extent.

5. A defect segmentation and positioning system based on casting X-ray images, It is characterized in that include: An X-ray image determination unit, used for determining an X-ray image of a casting; the casting has a plurality of defects; A defect segmentation and positioning unit is used to input the X-ray image of the casting into a pre-trained defect segmentation and positioning model to segment and locate the defect image of the casting in the X-ray image; the defect segmentation and positioning model is obtained by embedding an attention module at the connection jump of each level of characteristics of the Unet model and at the fusion of each two adjacent levels of features; the Unet model performs n convolution operations on the received X-ray image through a feature extraction network to obtain a feature pyramid of the X-ray image; the feature pyramid includes n levels of features; Each level of features is input into the corresponding attention module to assign weights to each level of features; Then, the n-th level features are upsampled step by step. The n-th level features are first fused with the n-1-th level features according to the corresponding weights to obtain the n-1-th level fused features. The n-1-th level fused features are convolutionally activated to obtain new n-1-th level features, which are input into the corresponding attention module. The weights are reassigned to the first n-2 level features and the new n-1-th level features in combination with the first n-2 level features and the corresponding weights of the feature pyramid. The new n-1-th level features are then upsampled and the above steps are repeated until the first-level fused features are obtained after the new second-level features and the first-level features are fused according to the weights. The first-level fused features are predicted by the activation function to obtain the defect image after segmentation and positioning. n is a positive integer.

6. The system according to claim 5, It is characterized in that The Unet model used in the defect segmentation and positioning unit includes: a backbone feature extraction network, an enhanced feature extraction network and a prediction network; the backbone feature extraction network is used to extract multi-level features of the image; the enhanced feature extraction network is used to fuse the multi-level features to obtain the fused features; the prediction network is used to predict the fused features using an activation function; The system also includes: a segmentation and positioning model training unit; The segmentation and positioning model is used to obtain a defect segmentation and positioning model through transfer training. The process of the transfer training is as follows: determining the data sets required for the transfer training: ImageNet image data set, Pascal VOC image semantic segmentation data set and casting X-ray image data set; training the convolutional neural network VGG16 on the ImageNet image data set; the VGG16 includes: a feature extraction network and a classification network; migrating the parameters of the convolution layer in the trained VGG16 feature extraction network to the backbone feature extraction network of the Unet model as the initial values ​​of the corresponding layers of the backbone feature extraction network of the Unet model to obtain a new Unet model, training the new Unet model on the Pascal VOC image semantic segmentation data set to obtain a trained new Unet model; and adding multiple attention modules to the enhanced feature extraction network of the trained new Unet model to obtain a defect segmentation and positioning model, so that the attention modules are embedded in the connection jumps of the various levels of features extracted by the backbone feature extraction network of the new Unet model and the fusion of the two adjacent levels of features, and the defect segmentation and positioning model is trained on the casting X-ray image data set to obtain a trained defect segmentation and positioning model.

7. The system according to claim 6, It is characterized in that The casting X-ray image data set used by the segmentation and positioning model training unit is obtained by the following steps: determining multiple X-ray images; each X-ray image is obtained by taking X-ray photos of different castings or different areas of the same casting, and the casting has multiple defects; cutting and marking the defective images of the castings in the multiple X-ray images to obtain multi-scale defective X-ray images; the cutting is: distinguishing defects from non-defective backgrounds, and marking as a set of pixel point positions recording defective areas; and performing image augmentation processing on the multi-scale defective X-ray images to obtain an enlarged casting X-ray image data set; the process of the image augmentation processing is: performing spatial position transformation, grayscale transformation, image distortion, and random cropping and scaling on the X-ray images in sequence.

8. The system according to claim 7, It is characterized in that The process of image augmentation processing performed by the segmentation and positioning model training unit is specifically as follows: spatial position transformation of the image is performed by flipping or rotating to prevent the defect segmentation and positioning model from overfitting the position of the defect in the image; grayscale transformation of the image after spatial position transformation is performed by contrast transformation or brightness transformation to prevent the defect segmentation and positioning model from overfitting the grayscale of the image; distortion operation is performed on the image after grayscale transformation by grid distortion or affine transformation to prevent the defect segmentation and positioning model from overfitting the shape, texture and scale of the defect in the image; and the image after distortion operation is cropped and scaled to obtain a casting X-ray image data set to increase the diversity of the image to a greater extent.

9. A defect segmentation and positioning system based on casting X-ray images, It is characterized in that include: Memory and processor; The memory is used to store a computer program; the processor is used to implement the defect segmentation and positioning method according to any one of claims 1 to 4 when executing the computer program.

10. A computer-readable storage medium, It is characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the defect segmentation and positioning method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Spatial positioning method for defects in lap joint welding piece

    CN109991248A

  • Ultrasonic breast tumor automatic segmentation method based on attention-enhanced U-shaped network

    CN112348794A

  • Workpiece defect detection method and device fusing multi-attention mechanism

    CN113822885A

  • Product defect detection method, device and system

    US20210374940A1