Marine T profile welding surface defect detecting and marking method based on machine vision
By improving the backbone network of the YOLOv8 model, introducing some convolution and attention modules, and combining data augmentation and loss function optimization, automated defect detection and marking of the welded surface of marine T-sections was achieved. This solved the problems of low efficiency and insufficient automatic marking in traditional detection methods, and improved detection accuracy and production efficiency.
Patent Information
- Application Number
- CN202511034166.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-25
- Publication Date
- 2025-11-11
AI Technical Summary
Traditional manual inspection of the welding quality of marine T-sections is inefficient and inaccurate, and the completion rate of automatic defect marking is low. Existing machine vision inspection methods have failed to effectively utilize defect detection information to guide the marking task.
An improved YOLOv8 model is adopted, replacing the traditional backbone network with Fasternet, introducing partial convolution and large separable kernel attention modules, improving the loss function to MPDIoU, and performing data augmentation and model training in actual production. Defect detection and labeling are achieved by combining image acquisition equipment.
It improves the accuracy and efficiency of surface defect detection for T-profile welding, realizes automated defect marking, reduces labor costs, and improves the practicality of production.
Smart Images

Figure CN120931584A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision inspection technology, specifically to a method for detecting and marking surface defects in marine T-shaped profile welds based on machine vision. Background Technology
[0002] Marine T-sections are widely used in ship hull structures, offering advantages such as light weight and high strength. During shipbuilding, the welding quality of T-sections directly affects the structural strength and service life of the vessel. However, traditional welding quality inspection relies on manual inspection, which is inefficient, inaccurate, and easily affected by subjective factors. With the rapid development of the shipbuilding industry, the demand for automated and intelligent welding quality inspection is increasing daily.
[0003] Compared with traditional inspection methods, machine vision technology has advantages such as non-contact operation, high speed, and high precision, which can significantly improve the inspection efficiency and accuracy of welded surface quality of marine T-sections, thereby ensuring the reliability and safety of the hull structure. This technological background provides strong support for intelligent shipbuilding. Currently, most machine vision-based welded surface defect detection methods only focus on the defect detection stage, lacking research on using inspection information to guide defect marking.
[0004] The detection methods disclosed in Chinese patent applications No. 202311235655.2, entitled "A Weld Defect Detection Method and Welding System Based on an Improved YOLO Algorithm," and No. 202411002290.3, entitled "A Method for Detecting Rail Surface Defects in Complex Backgrounds Based on an Improved YOLO Model," only utilize the improved algorithm to complete the defect detection stage. In the welding and manufacturing process of T-sections, in addition to detecting defects, timely and automatic marking of defects to reduce labor costs is also crucial. However, the aforementioned literature does not fully utilize defect detection information to guide the marking task in actual production. Therefore, researching and developing a machine vision-based method for detecting and marking surface defects in marine T-section welds has significant theoretical importance and broad application value. Summary of the Invention
[0005] The purpose of this invention is to address the problems of high reliance on subjective inspection, low efficiency, and insufficient accuracy in the current welding process of marine T-sections, as well as the low completion rate of automatic defect marking tasks in actual production. This invention proposes a machine vision-based method for detecting and marking surface defects in marine T-section welding. The method identifies the types of welding defects in marine T-sections, realizes the identification of welding defects and the calculation of marking parameters during the welding process, makes full use of defect detection information, and improves the practicality of the method.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] The present invention provides a machine vision-based method for detecting and marking surface defects in marine T-shaped profile welds, comprising the following steps:
[0008] Step 1: Acquire images of surface defects in the welding of T-profiles and create a dataset;
[0009] Step 2: Improve the YOLOv8 model to obtain an improved algorithm model;
[0010] Step 3: Train the improved algorithm model to obtain the trained algorithm model;
[0011] Step 4: Use the trained algorithm model to detect defects and use the detection information to obtain labeling information.
[0012] As a further preferred option, step one includes the following process:
[0013] 1.1 In the actual welding workshop, use cameras or image acquisition equipment to collect image data of welding surface defects, and eliminate image distortion and blurry images caused by human operation;
[0014] 1.2. Use Python to perform data augmentation on image data, including spatial domain data augmentation methods and frequency domain data augmentation methods, which will be used randomly.
[0015] Spatial domain data augmentation methods include random horizontal flipping, random vertical flipping, random rotation, and random cropping;
[0016] Frequency domain data enhancement methods include image smoothing and image sharpening;
[0017] 1.3. Import the processed data into the Labelimg software, label the defect location and defect category of each image, obtain the labeled txt file, and package the image dataset and txt file into a complete dataset. Randomly divide it into training set, validation set and test set in a 7:1:2 ratio. The validation set and test set will be used later. The validation set is used to evaluate the model performance during the training process, and the test set is used to evaluate the generalization performance of the model at the end.
[0018] As a further preferred option, step two involves improvements to the YOLOv8 model in the following three aspects:
[0019] 2.1 Replace the traditional YOLOv8 backbone network with a new backbone network, Fasternet. Fasternet introduces a partial convolution (PConv) to reduce redundant computation and memory access. PConv only applies regular Convolution to a portion of the input channels for spatial feature extraction, and its computational cost is only h*w*k. 2 *cp 2 Where h represents the height of the input image or feature map, w represents the width of the input image or feature map, k represents the size of a single convolution sum, and c p The number of channels representing the partial convolution operation;
[0020] 2.2. The Large Separable Kernel Attention Module (LSKA) is applied to the traditional SPPF module in YOLOv8; LSKA first uses horizontal and vertical convolutions F... h =Conv h (I), F v =Conv v (I) Extract horizontal and vertical features from the feature map to generate a preliminary attention map A. initial =σ(F h )+σ(F v The first step is to focus the model's attention on important parts of the image. Then, LSKA uses spatially dilated convolutions with different dilation rates to further extract features, covering a larger receptive field and capturing broader contextual information. Finally, LSKA obtains the final attention map through the last convolution and performs element-wise multiplication with the original input feature map, thus applying the attention mechanism F' = A. initial ⊙F, highlighting important features and suppressing unimportant features, outputs the final feature map Y = Conv(F'); where I is the input feature map, Conv represents the convolution operation, and A initial σ is the attention map, σ is the activation function, F' is the weighted feature map, ⊙ is element-wise multiplication, and Y is the final feature map.
[0021] 2.3 Modify the original CIoU loss function in YOLOv8, replacing CIoU with MPDIoU; MPDIoU is based on the principle of minimum point distance, minimizing the distance between the top left and bottom right corners of the predicted bounding box and the actual labeled bounding box; MPDIoU comprehensively considers all relevant factors in the existing loss function, including overlapping or non-overlapping regions, center point distance, and width and height deviation, while simplifying the calculation process;
[0022] The calculation process for MPDIoU is as follows:
[0023] d1=(x1 prd -x1 gt ) 2 +(y1 prd -y1 gt ) 2
[0024] d2=(x2 prd -x2 gt ) 2 +(y2prd -y2 gt ) 2
[0025]
[0026] Where d1 and d2 are the distances between the two corner points of the predicted bounding box and the ground truth bounding box, and x1 prd x2 prd y1 prd y2 prd x1 represents the x and y coordinates of the two corner points of the prediction box. gt x2 gt y1 gt y2 gt The x and y coordinates are the two corner points of the true bounding box.
[0027] As a further preferred option, in step three, training is performed on the Ubuntu 22.4 operating system platform, with PyCharm as the development environment, PyTorch version 2.3.0 as the framework, SGD as the optimizer, 300 training iterations, a batch size of 16, and mosaic data augmentation enabled; the complete dataset is then imported into the model for training to obtain the trained algorithm model.
[0028] The specific configuration parameters of the PyTorch framework include: CUDA version 12.1, cuDNN version 12.1.105, and the optimizer is SGD with an initial learning rate of 0.001.
[0029] In step three, during model training, if the validation loss stops decreasing or decreases by less than 0.05% for 50 consecutive epochs, an early stopping mechanism is automatically triggered to halt model training and prevent overfitting.
[0030] As a further preferred option, step four includes the following process;
[0031] 4.1 Using Python software, import the trained algorithm model and fix the camera or image acquisition device; use the camera or image acquisition device to acquire defect images during the welding process of T-profiles, perform defect detection on the acquired T-profile welding defect images, and obtain defect detection information on the welding surface.
[0032] 4.2. Use Python software to set the width and height (x in pixels) of the screen used to display the detection results. p y p Determine the vertical distance h between the camera or image acquisition device and the weld surface of the T-section using measuring tools; this is the actual working distance of the camera or image acquisition device. Based on the actual working distance, determine the field of view x of the camera or image acquisition device. w yw The unit is mm;
[0033] 4.3. Assuming the welding direction of the T-profile is along the x-axis, determine the ratio n between the camera's field of view and the displayed image, and using the center of the displayed image as the origin of the coordinate system, complete the matching between the displayed image and the field of view of the camera or image acquisition device.
[0034] 4.4 Using Python, when the predicted bounding box outlines the defect information in the acquired image, calculate the pixel length L1 of the right boundary of the detection box from the origin of the coordinate system. Then, the distance between the defect and the camera or image acquisition device in the x-axis direction is L1', where L1' = n*L1.
[0035] 4.5. Using measuring tools, determine the actual distance L2 between the marking device and the fixed camera or image acquisition device. Then, the distance from the detected defect to the marking device is L1' + L2. Assuming the welding process is a uniform motion process with a speed of v in mm / s, then the opening time of the marking device is... When a defect is detected on the weld surface, the aforementioned time t is used as a delay time to control the activation of the marking device, thereby marking the defect on the weld surface.
[0036] The beneficial effects of this invention are:
[0037] 1. The improved YOLOv8 model obtained in this application is able to identify defects in unknown T-profile welding defect image data.
[0038] 2. This application proposes a method for detecting and marking defects on the welded surface of T-profiles based on machine vision. It makes full use of the detection information. Compared with simply using the YOLOv8 improved model, it uses the detection information to obtain practical parameters that can be used to guide defect marking. Attached Figure Description
[0039] Figure 1 A flowchart illustrating the implementation of a machine vision-based method for detecting and marking surface defects in marine T-shaped profile welds.
[0040] Figure 2 Schematic diagram for the implementation of the introduced partial convolution (PConv);
[0041] Figure 3 Add a strategy graph to the LSKA attention module;
[0042] Figure 4 This is a schematic diagram illustrating the calculation principle of MPDIoU;
[0043] Figure 5 A schematic diagram showing the specific types of defects on the welded surface;
[0044] Figure 6 Images showing actual defects during the welding process of T-profiles;
[0045] Figure 7 A schematic diagram illustrating the matching of geometric parameters of the display area set in Python software;
[0046] Figure 8 This is a schematic diagram showing the actual location of the defect frame on the weld surface.
[0047] Figure 9 This is a schematic diagram showing the distance between the defect box and the camera on the defined X-axis.
[0048] Figure 10 This is a schematic diagram illustrating a method for calculating the distance from a defect to a certain marking device. Detailed Implementation
[0049] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0050] This invention relates to a machine vision-based method for detecting and marking surface defects in marine T-shaped profile welds, implemented using the following technical solution, comprising the following steps:
[0051] Step 1: Collect images of surface defects in the welding of T-profiles and create a dataset;
[0052] Dataset creation involves using industrial cameras or image acquisition equipment to photograph defects on the welded surface of T-profiles, ensuring a fixed shooting angle and distance, and acquiring clear images under stable lighting conditions to form the original dataset. To guarantee effective algorithm training and recognition performance, the original dataset needs to be screened, removing images distorted or blurred due to human manipulation. Furthermore, to improve model training efficiency, all images are uniformly adjusted to the same resolution.
[0053] The data creation process also included expanding the existing dataset using data augmentation techniques. In addition to classic spatial domain data augmentation methods such as horizontal and vertical flipping and random translation, frequency domain data augmentation methods were employed, including contrast enhancement, image quality compression, and noise simulation. By setting different probabilities, various data augmentation methods were randomly selected for expansion to improve the diversity of the dataset and the robustness of the algorithm model.
[0054] The dataset creation process also includes: importing the processed data into Labelimg software, labeling the defect locations and categories of each image, and obtaining labeled txt files. The image dataset and the corresponding txt files are then packaged into a complete dataset. The complete dataset is then randomly divided into training, validation, and test sets in a 7:1:2 ratio. The training and validation sets are used for training the algorithm model and evaluating its performance, while the test set is used to test the final performance of the algorithm model.
[0055] Step 2: Improve the YOLOv8 model to obtain an improved algorithm model;
[0056] Improved algorithm models obtained by modifying the YOLOv8 model include replacing the traditional YOLOv8 backbone network with a new backbone network, Fasternet.
[0057] Because T-profile welding is a continuous process, the number of defects increases as welding progresses. Traditional backbone networks struggle to meet the inspection needs of real-world production. Therefore, to improve computational speed without sacrificing detection accuracy, FasterNet introduces a partial convolution (PConv) technique, unlike traditional feature extraction backbone networks, to reduce redundant computation and memory access. PConv abandons the comprehensive application of traditional convolution, opting instead to perform convolution operations on a portion of the input feature map.
[0058] For traditional convolution, the input I∈R c*h*w Apply c filters w∈R k*k The output O∈R is obtained. c*h*w Then the traditional Conv has h*w*k 2 *c 2 The computational cost of PConv is h*w*k. PConv, on the other hand, only applies regular Conv for spatial feature extraction on a portion of the input channels, keeping the remaining channels unchanged. Therefore, the computational cost of PConv is h*w*k. 2 *c p 2 .
[0059] I represents the input image or feature map, c represents the number of channels in I, h represents the height of I, w represents the width of I, and k represents the size of a single convolution sum. p The number of channels representing the partial convolution effect.
[0060] The improved YOLOv8 model also includes the application of the Large Separable Kernel Attention (LSKA) module to the traditional SPPF module in YOLOv8 to enhance multi-scale feature extraction capabilities. SPPF, as a spatial pyramid pooling layer in YOLOv8, aggregates features at multiple scales. By pooling at different scales, it effectively captures multi-scale information, thereby improving the model's detection performance for targets of different sizes. The LSKA attention mechanism utilizes large, separable convolutional kernels and spatially dilated convolutions to capture extensive contextual information from the image, generating an attention map. This map is then used to weight the original features, enhancing the network's focus on important features and improving model performance.
[0061] In the SPPF structure of this invention, the LSKA attention mechanism is added after all max pooling layer (MaxPool2d) operations are completed and before the second convolutional layer (Conv).
[0062] The improved algorithm model obtained by modifying the YOLOv8 model also includes: modifying the original CIoU loss function in YOLOv8 and replacing CIoU with MPDIoU.
[0063] MPDIU is a novel bounding box similarity comparison metric that, based on the principle of minimum point distance, directly minimizes the distance between the top-left and bottom-right corners of the predicted bounding box and the actual labeled bounding box. MPDIoU comprehensively considers all relevant factors in existing loss functions, including overlapping or non-overlapping regions, center point distance, and width and height deviation, while simplifying the calculation process.
[0064] The calculation method for MPDIoU is as follows:
[0065] d1=(x1 prd -x1 gt ) 2 +(y1 prd -y1 gt ) 2
[0066] d2=(x2 prd -x2 gt ) 2 +(y2 prd -y2 gt ) 2
[0067]
[0068] d1 and d2 are the distances between the two corner points of the predicted bounding box and the ground truth bounding box, and x1 is the distance between the two corner points of the predicted bounding box and the ground truth bounding box. prd x2 prd y1 prd y2 prdx1 represents the x and y coordinates of the two corner points of the prediction box. gt x2 gt y1 gt y2 gt The x and y coordinates are the two corner points of the true bounding box.
[0069] Step 3: Train the improved algorithm model to obtain the trained algorithm model;
[0070] Training the improved algorithm model involves: training on an Ubuntu 22.4 platform using an RTX 2080Ti GPU with CUDA version 12.1, developing in PyCharm using PyTorch version 2.3.0, selecting SGD as the optimizer, conducting 300 training iterations, setting the batch size to 16, and enabling mosaic data augmentation. The complete dataset is then imported into the model for training, resulting in the trained algorithm model.
[0071] Step 4: Use the trained algorithm model to detect defects and use the detection information to obtain labeling information.
[0072] Using a trained algorithm model for defect detection and using the detection information to obtain labeling information means: importing the trained algorithm model, using a camera or image acquisition device to detect the welding process of T-profiles, and obtaining detection information of defects on the welding surface. The defect detection information refers to the prediction box.
[0073] Defect detection using the trained algorithm model and the acquisition of marking information from the detection information also include: matching the display screen with the field of view of the camera or image acquisition device, and defining the X-axis and origin of the detection screen. When a predicted bounding box appears, the pixel distance from the right boundary of the predicted bounding box to the origin is calculated and converted into the actual distance L1'. A marking device is installed at a fixed distance L2 from the camera. Assuming the T-profile welding process is a uniform process with a speed of v, the activation time of the marking device is determined using the above methods.
[0074] The technical solution of the present invention will be analyzed and described below with reference to the accompanying drawings.
[0075] Figure 1 The method for detecting and marking surface defects in marine T-shaped profile welds based on machine vision, as provided in this embodiment of the invention, specifically includes the following steps:
[0076] Step (1): Collect image data of surface defects in the welding of marine T-sections and create a dataset.
[0077] First, in an actual welding workshop, images of welding surface defects are collected using cameras or image acquisition equipment, eliminating images distorted or blurry due to human error. Furthermore, to improve model training efficiency, Python is used to uniformly adjust all images to a 640*640 resolution. For example... Figure 5 As shown, weld surface defects are specifically classified into four categories: weld beads ( Figure 5 (a)), weld break ( Figure 5 (b)), pores ( Figure 5 (c) and bite edge ( Figure 5 (d)).
[0078] Furthermore, we continue to use Python to augment the image data. In addition to classic spatial domain data augmentation methods, such as horizontal and vertical flipping and random translation, we combine them with frequency domain data augmentation techniques, such as contrast enhancement, image quality compression, and noise simulation. Multiple methods are randomly selected with varying probabilities for augmentation.
[0079] Finally, the processed data was imported into the Labelimg software for defect location and category labeling, generating a txt file. The image dataset and the txt file were then packaged into a complete dataset, which was then randomly divided into training, validation, and test sets in a 7:1:2 ratio.
[0080] Step (2): Improve the YOLOv8 model to obtain the improved YOLOv8 model.
[0081] First, the traditional YOLOv8 backbone network was replaced with a new backbone network, Fasternet.
[0082] FasterNet introduces a partial convolution (PConv) to reduce redundant computation and memory access. PConv abandons the full application of traditional convolution, choosing instead to perform convolution operations on a portion of the input feature map.
[0083] like Figure 2 As shown, Figure 2 (a) is a conceptual diagram of Conv. Figure 2 (b) is a conceptual diagram of PConv. PConv applies conventional Conv to extract spatial features only on a portion of the input channels, while keeping the remaining channels unchanged. Traditional Conv has h*w*k... 2 *c 2 The computational cost of PConv is much higher than that of PConv, while the computational cost of PConv is only h*w*k. 2 *c p 2 By utilizing PConv, the computational load of the model was reduced, while the computation speed was improved.
[0084] Furthermore, the Large Separable Core Attention Module (LSKA) is applied to the traditional SPPF module of YOLOv8.
[0085] LSKA first uses convolutions F in the horizontal and vertical directions h =Conv h (I), F v =Conv v (I) Extract horizontal and vertical features from the feature map to generate a preliminary attention map A. initial =σ(F h )+σ(F v This allows the model to focus its attention on important parts of the image. LSKA then uses spatially dilated convolutions with different dilation rates to further extract features, covering a larger receptive field and capturing broader contextual information. Finally, LSKA obtains the final attention map through the last convolution and performs element-wise multiplication with the original input feature map, thus applying the attention mechanism F' = A. initial ⊙F, highlighting important features and suppressing unimportant features, outputs the final feature map Y = Conv(F').
[0086] I is the input feature map, Conv represents the convolution operation, and A... initial σ is the attention map, σ is the activation function, F' is the weighted feature map, ⊙ is element-wise multiplication, and Y is the final feature map.
[0087] like Figure 3 As shown, the LSKA attention module is added after all the max pooling (MaxPool2d) operations in the SPPF structure and before the second convolutional layer (Conv).
[0088] Finally, the original CIoU loss function in YOLOv8 was modified, replacing CIoU with MPDIoU.
[0089] MPDIU is a novel bounding box similarity comparison metric that, based on the principle of minimum point distance, directly minimizes the distance between the top-left and bottom-right corners of the predicted bounding box and the actual labeled bounding box. MPDIoU comprehensively considers all relevant factors in existing loss functions, including overlapping or non-overlapping regions, center point distance, and width and height deviation, while simplifying the calculation process.
[0090] like Figure 4 As shown, the MPDIoU calculation process is as follows:
[0091] d1=(x1 prd -x1 gt ) 2 +(y1 prd -y1 gt ) 2
[0092] d2=(x2 prd -x2 gt ) 2 +(y2 prd -y2 gt ) 2
[0093]
[0094] Where d1 and d2 are the distances between the two corner points of the predicted bounding box and the ground truth bounding box, and x1 prd x2 prd y1 prd y2 prd x1 represents the x and y coordinates of the two corner points of the prediction box. gt x2 gt y1 gt y2 gt The x and y coordinates are the two corner points of the true bounding box.
[0095] Step (3): Train the improved algorithm model.
[0096] First, training was performed on an Ubuntu 22.4 platform using an RTX 2080Ti graphics card with CUDA version 12.1, PyCharm as the development environment, PyTorch version 2.3.0 as the framework, SGD as the optimizer, 300 training iterations, a batch size of 16, and mosaic data augmentation enabled. The complete dataset was imported into the model for training. The improved algorithm model was trained using the training and validation sets, and finally, the performance of the trained algorithm model was tested using the test set.
[0097] Step (4): Use the trained algorithm model to detect defects and use the detection information to obtain labeling information.
[0098] First, using Python software, the trained algorithm model is imported and the camera or image acquisition device is fixed. Defect images of the T-profile welding process are then acquired using the camera or image acquisition device. Defect detection is performed on the acquired T-profile welding defect images to obtain weld surface defect detection information. Specifically, the detection information refers to the detection results displayed in the Python software interface, which include predicted bounding boxes.
[0099] Furthermore, such as Figure 6 and Figure 7 As shown, Python software is used to set the width and height (x in pixels) of the screen used to display the detection results. p y pThe vertical distance *h* between the camera or image acquisition device and the weld surface of the T-section is determined using measuring tools; this is the actual working distance of the camera or image acquisition device. Based on the actual working distance, the field of view *x* of the camera or image acquisition device is determined. w y w The unit is mm.
[0100] Furthermore, assuming the welding direction of the T-profile is along the x-axis, the ratio n between the camera's field of view and the displayed image is determined, and the center of the displayed image is taken as the origin of the coordinate system to complete the matching between the displayed image and the field of view of the camera or image acquisition device.
[0101] Furthermore, using Python, such as Figure 8 and Figure 9 As shown, when the prediction box outlines the defect information in the acquired image, the pixel length L1 of the right boundary of the detection box from the origin is calculated. Then, the distance between the defect and the camera or image acquisition device in the x-axis direction is L1', where L1' = n*L1.
[0102] Furthermore, such as Figure 10 As shown, the actual distance L2 between a certain marking device and the fixed camera or image acquisition device is determined using a measuring tool. Then, the distance from the detected defect to the marking device is L1' + L2. Assuming the welding process is a uniform motion process with a speed of v (in mm / s), then the activation time of the marking device is... When a defect is detected on the weld surface, the aforementioned time t is used as a delay time to control the activation of a marking device, thereby marking the defect on the weld surface.
[0103] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for detecting and marking surface defects in marine T-shaped profile welds based on machine vision, characterized in that, Includes the following steps: Step 1: Acquire images of surface defects in the welding of T-profiles and create a dataset; Step 2: Improve the YOLOv8 model to obtain an improved algorithm model; Step 3: Train the improved algorithm model to obtain the trained algorithm model; Step 4: Use the trained algorithm model to detect defects and use the detection information to obtain labeling information.
2. The method for detecting and marking surface defects in marine T-shaped profiles based on machine vision according to claim 1, characterized in that: Step one includes the following process: 1.1 In the actual welding workshop, use cameras or image acquisition equipment to collect image data of welding surface defects, and eliminate image distortion and blurry images caused by human operation; 1.
2. Use Python to perform data augmentation on image data, including spatial domain data augmentation methods and frequency domain data augmentation methods, which will be used randomly. 1.
3. Import the processed data into the Labelimg software, mark the defect location and defect category of each image, obtain the marked txt file, and package the image dataset and txt file into a complete dataset.
3. The method for detecting and marking surface defects in marine T-shaped profiles based on machine vision according to claim 2, characterized in that: The complete dataset is divided into training, validation, and test sets in a 7:1:2 ratio.
4. The method for detecting and marking surface defects in marine T-shaped profiles based on machine vision according to claim 2, characterized in that: Spatial domain data augmentation methods include random horizontal flipping, random vertical flipping, random rotation, and random cropping.
5. The method for detecting and marking surface defects in marine T-shaped profiles based on machine vision according to claim 2, characterized in that: Frequency domain data enhancement methods include image smoothing and image sharpening.
6. The method for detecting and marking surface defects in marine T-section welding based on machine vision according to claim 1, characterized in that: Step two involves improvements to the YOLOv8 model in the following three aspects: 2.1 Replace the traditional YOLOv8 backbone network with a new backbone network, Fasternet. Fasternet introduces a partial convolution (PConv) to reduce redundant computation and memory access. PConv only applies regular Convolution to a portion of the input channels for spatial feature extraction, and its computational cost is only h*w*k. 2 *c p 2 Where h represents the height of the input image or feature map, w represents the width of the input image or feature map, k represents the size of a single convolution sum, and c p The number of channels representing the partial convolution operation; 2.
2. The Large Separable Kernel Attention Module (LSKA) is applied to the traditional SPPF module in YOLOv8; LSKA first uses horizontal and vertical convolutions F... h =Conv h (I), F v =Conv v (I) Extract horizontal and vertical features from the feature map to generate a preliminary attention map A. initial =σ(F h )+σ(F v The first step is to focus the model's attention on important parts of the image. Then, LSKA uses spatially dilated convolutions with different dilation rates to further extract features, covering a larger receptive field and capturing broader contextual information. Finally, LSKA obtains the final attention map through the last convolution and performs element-wise multiplication with the original input feature map, thus applying the attention mechanism F' = A. initial ⊙F, highlighting important features and suppressing unimportant features, outputs the final feature map Y = Conv(F'); where I is the input feature map, Conv represents the convolution operation, and A initial σ is the attention map, σ is the activation function, F' is the weighted feature map, ⊙ is element-wise multiplication, and Y is the final feature map. 2.3 Modify the original CIoU loss function in YOLOv8, replacing CIoU with MPDIoU; MPDIoU is based on the principle of minimum point distance, minimizing the distance between the top left and bottom right corners of the predicted bounding box and the actual labeled bounding box; MPDIoU comprehensively considers all relevant factors in the existing loss function, including overlapping or non-overlapping regions, center point distance, and width and height deviation, while simplifying the calculation process; The calculation process for MPDIoU is as follows: d1=(x1 prd -x1 gt ) 2 +(y1 prd -y1 gt ) 2 d2=(x2 prd -x2 gt ) 2 +(y2 prd -y2 gt ) 2 Where d1 and d2 are the distances between the two corner points of the predicted bounding box and the ground truth bounding box, and x1 prd x2 prd y1 prd y2 prd x1 represents the x and y coordinates of the two corner points of the prediction box. gt x2 gt y1 gt y2 gt The x and y coordinates are the two corner points of the true bounding box.
7. The method for detecting and marking surface defects in marine T-section welding based on machine vision according to claim 1, characterized in that: In step three, training is performed on the Ubuntu 22.4 operating system platform, with PyCharm as the development environment, PyTorch version 2.3.0 as the framework, SGD as the optimizer, 300 training iterations, a batch size of 16, and mosaic data augmentation enabled. The complete dataset is then imported into the model for training to obtain the trained algorithm model.
8. The method for detecting and marking surface defects in marine T-section welding based on machine vision according to claim 7, characterized in that: The specific configuration parameters of the PyTorch framework include: CUDA version 12.1, cuDNN version 12.1.105, and the optimizer is SGD with an initial learning rate of 0.
001.
9. A method for detecting and marking surface defects in marine T-section welding based on machine vision, as described in claim 7, characterized in that: In step three, during model training, when the validation loss stops decreasing or decreases by less than 0.05% for 50 consecutive rounds, an early stopping mechanism is automatically triggered to stop model training in order to avoid overfitting.
10. A method for detecting and marking surface defects in marine T-shaped profiles based on machine vision, as described in claim 1, characterized in that: Step four includes the following process; 4.1 Using Python software, import the trained algorithm model and fix the camera or image acquisition device; use the camera or image acquisition device to acquire defect images during the welding process of T-profiles, perform defect detection on the acquired T-profile welding defect images, and obtain defect detection information on the welding surface. 4.
2. Use Python software to set the width and height (x in pixels) of the screen used to display the detection results. p y p Determine the vertical distance h between the camera or image acquisition device and the weld surface of the T-section using measuring tools; this is the actual working distance of the camera or image acquisition device. Based on the actual working distance, determine the field of view x of the camera or image acquisition device. w y w The unit is mm; 4.
3. Assuming the welding direction of the T-profile is along the x-axis, determine the ratio n between the camera's field of view and the displayed image, and using the center of the displayed image as the origin of the coordinate system, complete the matching between the displayed image and the field of view of the camera or image acquisition device. 4.4 Using Python, when the predicted bounding box outlines the defect information in the acquired image, calculate the pixel length L1 of the right boundary of the detection box from the origin of the coordinate system. Then, the distance between the defect and the camera or image acquisition device in the x-axis direction is L1', where L1' = n*L1. 4.
5. Using measuring tools, determine the actual distance L2 between the marking device and the fixed camera or image acquisition device. Then, the distance from the detected defect to the marking device is L1' + L2. Assuming the welding process is a uniform motion process with a speed of v in mm / s, then the opening time of the marking device is... When a defect is detected on the weld surface, the aforementioned time t is used as a delay time to control the activation of the marking device, thereby marking the defect on the weld surface.
Citation Information
Patent Citations
Weld defect detection method based on improved YOLO algorithm and welding system
CN117470849A
Rail surface defect detection method under complex background based on improved YOLO model
CN118840357A