Oiling machine hose production quality detection method based on target detection
Through the improved YOLOv10 model and target detection method, the problems of low efficiency and insufficient accuracy in the production quality inspection of the tanker hose are solved, and efficient and accurate detection of a variety of hose types and shapes are achieved, improving the overall efficiency and inspection accuracy of the production line.
Patent Information
- Application Number
- CN202411408383.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-02-25
AI Technical Summary
The existing fueling hose production quality inspection methods are inefficient, insufficient accuracy, and lack versatility, making it difficult to adapt to a variety of hose types and shapes.
Using a target detection method, images are collected through the camera and pre-processed, and the improved YOLOv10 model is used for detection. The model enhances the detection capability of small targets by introducing the fourth detection scale X4, redesigning the AnchorBox and introducing the Focal Loss loss function.
It improves the accuracy and efficiency of detection, significantly reduces false detection and missed detection, enhances the universality and adaptability of the system, and reduces maintenance and operation costs.
Smart Images

Figure CN119515775A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of quality inspection, and in particular to a method for inspecting the production quality of a fuel dispenser hose based on target detection. Background Art
[0002] At present, the production quality inspection of fuel dispenser hoses mainly relies on manual inspection or rule-based sensor inspection systems. Manual inspection has the disadvantages of strong subjectivity and low efficiency, and is prone to missed detection or false detection when dealing with large-scale production. Although the rule-based inspection system can partially automate the inspection process, it can usually only detect specific hose types or defects, lacking versatility and flexibility. In addition, when dealing with complex hose shapes and multiple surface defects, the existing sensor system is often unable to accurately detect all defects, which can easily lead to product quality problems. Therefore, there is an urgent need for an efficient and accurate quality inspection method and system that can adapt to a variety of hose types and shapes to improve the inspection efficiency and accuracy of the production line. Summary of the invention
[0003] The purpose of the invention is to provide a fuel dispenser hose production quality detection method based on target detection to solve the problems of low detection efficiency, insufficient accuracy, poor versatility, etc. existing in the prior art.
[0004] In order to solve the above technical problems, the present invention creates a technical solution: a method for detecting the production quality of a fuel dispenser hose based on target detection, the steps are:
[0005] 1) Collect images through the camera installed on the production line and transmit the collected images to the computer.
[0006] 2) Preprocess the data, including denoising, grayscale adjustment, contrast enhancement, etc.
[0007] 3) Train and update the YOLOv10 model, redesign the AnchorBox and four-scale detection network, and introduce Focal Loss to adjust the loss function to obtain a new YOLOv10 model; then substitute the preprocessed data into the updated YOLOv10 model for detection.
[0008] The method of redesigning the four-scale detection network is as follows:
[0009] a1) Improvement of the backbone network: Based on the YOLOv10 backbone network, the fourth detection scale X4 is introduced. The X4 feature map is generated by 1 / 4 downsampling. By adding a new convolution operation in the shallow part of the backbone network, that is, close to the input layer, it is possible to generate a high-resolution feature map suitable for detecting small targets;
[0010] a11) Introducing X4 in the backbone network: Introduce a convolutional layer near the input layer, and generate a new feature map X4 through 1 / 4 downsampling. This new feature map X4 is the same as the existing P3, P4 and P5, and is used to detect small targets through subsequent detection heads;
[0011] a12) Adjust the convolution kernel size and number of channels: Adjust the size of the feature map of X4 and the number of channels of the feature map accordingly. The number of channels of the feature map of X4 is set to 128, and the size of the feature map of X4 is 160*128.
[0012] a2) Improvement of detection head: In the detection head, a new detection branch is added for the X4 feature map. The new branch is responsible for detecting small targets based on the high-resolution feature map. By redesigning the AnchorBox, the network can match and regress the bounding box of small targets. The size and proportion of the AnchorBox are optimized according to the characteristics of the small target to capture the position and shape of the small target.
[0013] a21) Add a detection head branch for X4: In the detection head part, add a new branch to process the output of X4. This branch is responsible for object classification and bounding box regression based on the features of X4.
[0014] a21) Adjust the design of Anchor Box: In view of the high resolution and small target characteristics of the X4 feature map, the Anchor Box is redesigned. The new Anchor Box is smaller in size and the aspect ratio is also adjusted according to the characteristics of the small target.
[0015] a3) Multi-scale fusion: Based on the existing three-scale fusion, feature fusion of X4 is added. Through upsampling and feature concatenation operations with P3, P4 and P5, the model can combine shallow and deep features to fully cover detection of large, medium and small targets;
[0016] a31) Upsampling and feature concatenation: Fuse the X4 feature map with P3, P4, and P5, and use the `Upsample` and `Concat` operations to enable the shallow small target features to be passed to the deep detection head.
[0017] a32) Feature level enhancement: The deep and shallow features are fused through the PANet feature fusion method.
[0018] The method of redesigning AnchorBox is as follows:
[0019] b1) Dataset analysis: Statistics are collected on the bounding box sizes and aspect ratios of all objects in the training dataset, with attention paid to the distribution of small objects. The distribution range of small objects is obtained by analyzing the average size and aspect ratio of the objects. The width of the small objects is between 5 and 20 pixels, and the aspect ratio is between 1:1 and 1:3.
[0020] b2) AnchorBox size determination: The size of the newly designed AnchorBox is as follows:
[0021] {(8,12),(10,14),(12,16),(14,18),(16,20)}
[0022] b3) Multi-scale design of AnchorBox: Different AnchorBoxes are set for feature maps at different downsampling levels, so that the model can take into account the detection of objects of different sizes;
[0023] Specifically, in small target detection, i.e., in shallow feature maps, the feature map size is 160*120, and smaller AnchorBoxes (8,12) and (10,14) are introduced to capture the details of small targets; in medium target detection, i.e., in medium-layer feature maps, the feature map sizes are 80*60 and 40*30, and medium-sized AnchorBoxes (12,16) and (14,18) are used to capture medium targets; in large target detection, i.e., in deeper feature maps, the feature map size is 20*15, and a larger AnchorBox (16,20) is used to capture the boundaries and features of large targets;
[0024] b4) AnchorBox aspect ratio optimization:
[0025] Design AnchorBoxes with different aspect ratios, such as 1:1, 2:1, and 1:2, to match small objects of different shapes;
[0026] b5) Mapping of AnchorBox and feature map: By generating multiple AnchorBoxes for each pixel on the feature map, each pixel corresponds to an AnchorBox of different size and proportion.
[0027] The specific method to adjust the loss function is:
[0028] Focal Loss adds an adjustment factor based on the cross entropy loss to dynamically adjust the contribution of samples to the total loss, so that the model pays more attention to small targets that are difficult to classify. The formula is:
[0029] FL(p t )=-α t (1-p t )γ log p t
[0030] Among them, p t Represents the model's predicted probability of the target category; α t is the balance factor of positive and negative samples; γ is the hyperparameter of the adjustment factor; (1-p t ) γ is the adjustment factor, when p t When it is close to 1, the adjustment factor value tends to 0, reducing the loss contribution of easy-to-classify samples. t When it is close to 0, the adjustment factor is close to 1, increasing the weight of difficult-to-classify samples.
[0031] 4) Output the test results. When a new type of hose or a new type of defect is detected on the production line, the system retrains and updates the model in 3) by collecting new sample data.
[0032] The beneficial effects of the present invention are:
[0033] 1. Improved detection accuracy: By adopting a deep learning target detection algorithm, the present invention can accurately identify and detect various types of hose defects, significantly reduce the occurrence of false detections and missed detections, and ensure product quality.
[0034] 2. Improved detection efficiency: The present invention realizes the automation of the detection process and can process the hose products on the production line in real time, which greatly shortens the detection time, improves the overall efficiency of the production line, and reduces the reliance on manual detection.
[0035] 3. Enhanced system versatility: The detection system of the present invention has good adaptability and can handle various types and specifications of fuel dispenser hoses. There is no need to frequently replace equipment or reset parameters. It has strong adaptability and high versatility.
[0036] 4. Reduced maintenance and operating costs: Since the system relies on the update and optimization of software algorithms, it reduces hardware loss and equipment maintenance costs. At the same time, accurate and efficient detection capabilities reduce rework and the generation of unqualified products, saving production costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 Flow chart of the method of the present invention;
[0038] Figure 2 This is the existing YOLOv10 network structure diagram;
[0039] Figure 3 This is the YOLOv10 network structure diagram of the present invention;
[0040] Figure 4 To improve the training effect diagram before;
[0041] Figure 5 This is a training effect diagram of the method of the present invention;
[0042] Figure 6 This is the PR curve before improvement;
[0043] Figure 7 It is the PR curve diagram of the method of the present invention;
[0044] Figure 8a This is the hole detection result diagram of the original YOLOv10 algorithm;
[0045] Figure 8b This is the hole detection result diagram of the YOLOv10 optimization algorithm;
[0046] Figure 9a This is the damage detection result diagram of the original YOLOv10 algorithm;
[0047] Figure 9b This is the damage detection result diagram of the YOLOv10 optimization algorithm;
[0048] Fig.10a This is the convex detection result diagram of the original YOLOv10 algorithm;
[0049] Fig.10b This is the bump detection result diagram of the YOLOv10 optimized algorithm. DETAILED DESCRIPTION
[0050] The production quality inspection method of the fuel dispenser hose based on target detection includes the following steps:
[0051] 1) Collect images through the camera installed on the production line and transmit the collected images to the computer.
[0052] 2) Preprocess the data, including denoising, grayscale adjustment, contrast enhancement, etc.
[0053] 3) Train and update the YOLOv10 model, redesign the AnchorBox and four-scale detection network, and introduce Focal Loss to adjust the loss function to obtain a new YOLOv10 model; then substitute the preprocessed data into the updated YOLOv10 model for detection.
[0054] The method of redesigning the four-scale detection network is as follows:
[0055] a1) Improvement of the backbone network: Based on the YOLOv10 backbone network, the fourth detection scale X4 is introduced. The X4 feature map is generated by 1 / 4 downsampling. By adding a new convolution operation in the shallow part of the backbone network, that is, close to the input layer, it is possible to generate a high-resolution feature map suitable for detecting small targets;
[0056] a11) Introducing X4 in the backbone network: Introduce a convolutional layer near the input layer, and generate a new feature map X4 through 1 / 4 downsampling. This new feature map X4 is the same as the existing P3, P4 and P5, and is used to detect small targets through subsequent detection heads;
[0057] a12) Adjust the convolution kernel size and number of channels: Adjust the size of the feature map of X4 and the number of channels of the feature map accordingly. The number of channels of the feature map of X4 is set to 128, and the size of the feature map of X4 is 160*128.
[0058] a2) Improvement of detection head: In the detection head, a new detection branch is added for the X4 feature map. The new branch is responsible for detecting small targets based on the high-resolution feature map. By redesigning the AnchorBox, the network can match and regress the bounding box of small targets. The size and proportion of the AnchorBox are optimized according to the characteristics of the small target to capture the position and shape of the small target.
[0059] a21) Add a detection head branch for X4: In the detection head part, add a new branch to process the output of X4. This branch is responsible for object classification and bounding box regression based on the features of X4.
[0060] a21) Adjust the design of Anchor Box: In view of the high resolution and small target characteristics of the X4 feature map, the Anchor Box is redesigned. The new Anchor Box is smaller in size and the aspect ratio is also adjusted according to the characteristics of the small target.
[0061] a3) Multi-scale fusion: Based on the existing three-scale fusion, feature fusion of X4 is added. Through upsampling and feature concatenation operations with P3, P4 and P5, the model can combine shallow and deep features to fully cover detection of large, medium and small targets;
[0062] a31) Upsampling and feature concatenation: Fuse the X4 feature map with P3, P4, and P5, and use the `Upsample` and `Concat` operations to enable the shallow small target features to be passed to the deep detection head.
[0063] a32) Feature level enhancement: The PANet feature fusion method is used to fuse deep and shallow features; in YOLOv10, PANet further enhances the feature fusion capability. In addition to high-to-low feature fusion, PANet also introduces a bottom-up path to aggregate low-level feature information upward, thereby increasing the utilization of shallow features. This two-way fusion strategy enables the network to detect small targets more effectively while maintaining good detection performance for large targets.
[0064] The method of redesigning AnchorBox is as follows:
[0065] b1) Dataset analysis: Statistics are collected on the bounding box sizes and aspect ratios of all objects in the training dataset, with attention paid to the distribution of small objects. The distribution range of small objects is obtained by analyzing the average size and aspect ratio of the objects. The width of the small objects is between 5 and 20 pixels, and the aspect ratio is between 1:1 and 1:3.
[0066] b2) AnchorBox size determination: The size of the newly designed AnchorBox is as follows:
[0067] {(8,12),(10,14),(12,16),(14,18),(16,20)};
[0068] b3) Multi-scale design of AnchorBox: Different AnchorBoxes are set for feature maps at different downsampling levels, so that the model can take into account the detection of objects of different sizes;
[0069] Specifically, in small target detection, i.e., in shallow feature maps, the feature map size is 160*120, and smaller AnchorBoxes (8,12) and (10,14) are introduced to capture the details of small targets; in medium target detection, i.e., in medium-layer feature maps, the feature map sizes are 80*60 and 40*30, and medium-sized AnchorBoxes (12,16) and (14,18) are used to capture medium targets; in large target detection, i.e., in deeper feature maps, the feature map size is 20*15, and a larger AnchorBox (16,20) is used to capture the boundaries and features of large targets;
[0070] b4) AnchorBox aspect ratio optimization:
[0071] Design AnchorBoxes with different aspect ratios, such as 1:1, 2:1, and 1:2, to match small objects of different shapes;
[0072] b5) Mapping of AnchorBox and feature map: By generating multiple AnchorBoxes for each pixel on the feature map, each pixel corresponds to an AnchorBox of different size and proportion.
[0073] The specific method to adjust the loss function is:
[0074] Focal Loss adds an adjustment factor based on the cross entropy loss to dynamically adjust the contribution of samples to the total loss, so that the model pays more attention to small targets that are difficult to classify. The formula is:
[0075] FL(p t )=-α t (1-p t ) γ log p t
[0076] Among them, p t Represents the model's predicted probability of the target category; α t is the balance factor of positive and negative samples; γ is the hyperparameter of the adjustment factor; (1-P t ) γ is the adjustment factor, when p t When it is close to 1, the adjustment factor value tends to 0, reducing the loss contribution of easy-to-classify samples. t When it is close to 0, the adjustment factor is close to 1, increasing the weight of difficult-to-classify samples.
[0077] 4) Output the test results. When a new type of hose or a new type of defect is detected on the production line, the system retrains and updates the model in 3) by collecting new sample data.
[0078] Embodiment 1:
[0079] In the quality inspection of rubber hoses, defects mainly include breakage, holes, bulges, etc., and these defect detections all belong to small target detection. Although YOLOv10 performs well in target detection, it is insufficient in its detection capability for small targets, especially small targets are easily missed due to feature fuzziness, low resolution, and mismatched Anchor Boxes. In order to solve these problems, the present invention proposes a series of improvements for small target detection based on YOLOv10, including the introduction of four-scale detection, the redesign of AnchorBox, and the introduction of Focal Loss function.
[0080] 1. Introducing four-scale detection: In order to enhance YOLOv10's ability to detect small targets, this paper introduces a fourth detection scale X4 based on the YOLOv10 backbone network. The X4 feature map is generated by 1 / 4 downsampling, and the larger resolution ensures that the network can extract more spatial details when processing small targets. By adding new convolution operations in the shallow part of the backbone network (close to the input layer), we can generate high-resolution feature maps suitable for detecting small targets. It includes the following aspects:
[0081] Improvement of the backbone network: In order to enhance the detection capability of YOLOv10 for small objects, this paper introduces a fourth detection scale X4 based on the YOLOv10 backbone network. The X4 feature map is generated by 1 / 4 downsampling, and the larger resolution ensures that the network can extract more spatial details when processing small objects. By adding new convolution operations in the shallow part of the backbone network (close to the input layer), we can generate high-resolution feature maps suitable for detecting small objects.
[0082] Improvements in detection head: In the detection head, we added a new detection branch for the X4 feature map. The new branch is responsible for detecting small objects based on the high-resolution feature map. By redesigning the anchor box suitable for small objects, the network is able to better match and regress the bounding box of small objects. The size and scale of the anchor box are optimized according to the characteristics of small objects, so that it can capture the position and shape of small objects more accurately.
[0083] Multi-scale fusion: We added feature fusion of X4 on the basis of the existing three-scale fusion. Through upsampling and feature concatenation operations with P3, P4 and P5, the model can better combine shallow and deep features to achieve full coverage detection of large, medium and small objects.
[0084] Specific:
[0085] The existing YOLOv10 network is as follows Figure 2 As shown, it mainly consists of the following parts:
[0086] Backbone network: used to extract the basic features of the input image and generate feature maps of different resolutions through multi-layer convolution operations and downsampling.
[0087] Feature Pyramid (FPN): Multi-scale detection is performed by fusing features from shallow to deep layers. It includes P3 (1 / 8 downsampling), P4 (1 / 16 downsampling), and P5 (1 / 32 downsampling).
[0088] Detection head: Uses feature maps obtained from different layers to perform target classification and regression (locate bounding boxes).
[0089] Four-scale detection network of the present invention: In order to enhance the detection capability of YOLOv10 for small targets, a four-scale detection scheme is proposed, that is, on the basis of the existing three-scale, a shallower feature map (1 / 4 downsampling) is added, and the network structure is modified accordingly to support the detection of this new scale. The network structure is as follows Figure 3 As shown, the improvement steps are:
[0090] a. Introducing a new feature map X4 in Backbone: The feature maps generated by the current YOLOv10 backbone network are: P3: 1 / 8 downsampling; P4: 1 / 16 downsampling; P5: 1 / 32 downsampling. In order to better detect small targets, we introduced a new feature map X4 in the shallow part of the backbone network. This feature map is 1 / 4 downsampled, retaining more spatial information, and is very suitable for small target detection.
[0091] Improvement steps:
[0092] 1. Introduce X4 in the backbone network: Introduce a convolutional layer near the input layer (such as the Conv2 layer or the SCDown layer) and generate a new feature map X4 by downsampling by 1 / 4. This new feature map X4 will be used to detect small objects through subsequent detection heads, just like the existing P3, P4, and P5.
[0093] 2. Adjust the convolution kernel size and number of channels: Since X4 is a shallow feature map with a high feature resolution, we need to adjust the size of the convolution kernel and the number of channels of the feature map accordingly to ensure the computational efficiency and feature extraction effect of the network. The number of channels of the feature map of X4 can be set to a smaller value of 128 to ensure that it does not increase the computational overhead too much.
[0094] b. Support four-scale features in the detection head: The existing detection head processes feature maps of three scales, P3, P4, and P5. In order to introduce four-scale detection, the detection head needs to additionally process a new feature map X4.
[0095] Improvement steps:
[0096] 1. Add a detection head branch for X4: In the detection head part, add a new branch to process the output of X4. This branch is responsible for object classification and bounding box regression based on the features of X4.
[0097] 2. Adjust the design of Anchor Box: In view of the high resolution and small target characteristics of X4 feature map, we redesigned the Anchor Box to make it more suitable for small targets. The new Anchor Box is smaller in size and the aspect ratio is also adjusted according to the characteristics of small targets.
[0098] c. Multi-scale feature fusion: YOLOv10 performs multi-scale feature fusion through feature pyramid network. In order to ensure the effective use of X4 feature map, we need to fuse X4 with other feature maps. The fusion can be done through upsampling and feature concatenation.
[0099] Improvement steps:
[0100] 1. Upsampling and feature concatenation: Fuse the X4 feature map with P3, P4, and P5 to ensure that the shallow small target features can be passed to the deep detection head. The specific operation can be done using the `Upsample` and `Concat` operations.
[0101] 2. Feature level improvement: In order to avoid information loss, we will enhance the model’s perception of objects of different scales by fusing deep and shallow features.
[0102] 2. AnchorBox redesign:
[0103] In the object detection task, AnchorBox is a basic tool used to help the model predict the bounding box of the object on the feature map. The design of AnchorBox plays a vital role in the detection performance, especially in the multi-scale object detection task, a reasonable AnchorBox design can significantly improve the detection accuracy. Especially for small targets, the traditional AnchorBox often leads to reduced detection accuracy or missed detection due to its large size or mismatched shape. Therefore, we redesigned the AnchorBox to improve the detection accuracy and recall rate based on the characteristics of small targets.
[0104] The design of AnchorBox directly affects the model's ability to match targets. Object detection models such as YOLO predefine a set of AnchorBoxes whose sizes and shapes cover the different scales and aspect ratios that targets may appear. The overlap between each AnchorBox and the true target bounding box is used to guide the model's bounding box regression.
[0105] However, for small objects, traditional AnchorBox faces the following challenges:
[0106] Insufficient coverage: The default AnchorBox is often designed based on the distribution of large objects in the training set, and it is difficult to cover the actual size of small objects.
[0107] Mismatch: When the real bounding box of a small target differs too much from the AnchorBox, the regression error is too large, resulting in a decrease in detection performance or even missed detection.
[0108] To solve these problems, we redesigned the AnchorBox based on the characteristics of small objects so that it can better adapt to the detection task of small objects.
[0109] 1. When redesigning AnchorBox, we followed the following principles:
[0110] (1) Multi-scale coverage: By introducing a variety of AnchorBoxes of different sizes, we ensure that we can effectively cover objects from small to large. Especially for small objects, we add more small-sized AnchorBoxes to ensure that they can better match small objects.
[0111] (2) Ratio optimization: By analyzing the aspect ratio of the objects in the dataset, we adjust the aspect ratio of the AnchorBox to better match the aspect ratio of the small object, reduce the error between the AnchorBox and the real bounding box of the small object, and improve the prediction accuracy.
[0112] (3) Dense Anchor Distribution: By increasing the number of AnchorBoxes, we ensure that there are enough AnchorBoxes around each pixel to match, thereby increasing the confidence and accuracy of detection. This design is particularly suitable for detailed detection of small targets when the feature map resolution is high.
[0113] 2. Specific steps
[0114] (1) Dataset analysis:
[0115] First, we counted the bounding box size and aspect ratio of all objects in the training dataset, paying special attention to the distribution of small objects. By analyzing the average size and aspect ratio of the objects, we obtained the distribution range of small objects. For example, the width of small objects is mostly between 5-20 pixels, and the aspect ratio is mostly between 1:1 and 1:3.
[0116] (2) AnchorBox size determination:
[0117] Based on the above analysis results, we designed a set of new AnchorBoxes to ensure that these AnchorBoxes can effectively cover the size of small objects. Specifically, we set a more compact AnchorBox for small objects to ensure more accurate matching of the bounding box. The sizes of the newly designed AnchorBoxes are as follows:
[0118] {(8, 12), (10, 14), (12, 16), (14, 18), (16, 20)}
[0119] The width and height of these AnchorBoxes are smaller than those of traditional AnchorBoxes, and they are densely distributed in areas where small objects may appear.
[0120] (3) Multi-scale design of AnchorBox:
[0121] To ensure that the model can take into account large, medium and small objects, we set different AnchorBoxes for feature maps at different downsampling levels. In small object detection (such as feature map P2, 1 / 4 downsampling), we introduced a smaller AnchorBox, while in deeper layers (such as P5, 1 / 32 downsampling), we used a larger AnchorBox to capture large objects. Through this multi-scale design, the model can handle objects of multiple different sizes at the same time.
[0122] (4) AnchorBox aspect ratio optimization:
[0123] We noticed that small objects often have specific aspect ratios, such as elongated scratches or round defects. Therefore, we designed AnchorBox with different aspect ratios to ensure better matching of small objects of different shapes. The newly designed AnchorBox includes multiple aspect ratios, such as 1:1, 2:1, and 1:2, to ensure good matching for objects of different shapes.
[0124] (5) Mapping between AnchorBox and feature map:
[0125] When generating AnchorBox, we ensure that these AnchorBox can be effectively mapped to each pixel in the feature map. Through this mapping, each pixel can have multiple AnchorBoxes corresponding to it, which improves the coverage density of AnchorBox on the target.
[0126] 3. Advantages and performance improvements
[0127] Through the above redesign, the improved AnchorBox significantly improves the detection capability of small objects in the following aspects:
[0128] Improved matching accuracy: The redesign for small targets makes the AnchorBox more closely fit the real small target bounding box, reduces matching errors, and improves the accuracy of bounding box regression.
[0129] Reduced missed detection rate: Due to the dense anchor distribution and reasonable multi-scale design, the improved model has a significantly reduced missed detection rate in small target detection.
[0130] Improved recall rate: The newly designed AnchorBox can better capture small objects and ensure a high recall rate for detection. In experiments, compared with the traditional AnchorBox, the redesigned AnchorBox increased the recall rate of small objects by about 20%.
[0131] Through the redesign of the AnchorBox mentioned above, we have effectively solved the matching problem in small target detection, ensuring that the model can take into account the detection tasks of large, medium and small targets, and improving the overall detection accuracy and recall rate of the model.
[0132] 3. Introducing Focal Loss:
[0133] In the target detection task, class imbalance is a common challenge, especially in the small target detection scenario, the background area (negative samples) usually occupies the vast majority, while the real target (positive sample), especially the proportion of small targets is often very small. In the case of such class imbalance, the traditional cross entropy loss function easily causes the model to over-focus on the background that is easy to classify and ignore the small targets that are difficult to detect. In order to effectively solve this problem, the present invention introduces Focal LOSS in the training process.
[0134] In conventional target detection tasks, cross-entropy loss is the most commonly used loss function, which is used to measure the difference between the model prediction value and the true label. The formula of cross-entropy loss is as follows:
[0135] CE(pt)=-log(p t )
[0136] Among them, p t Represents the model's predicted probability of the target category. If the sample is easy to classify (i.e., pt is close to 1), the value of this formula will be small; if the sample is difficult to classify (i.e., p t closer to 0), the value of this formula will be larger.
[0137] However, cross entropy loss has the following drawbacks:
[0138] Category imbalance problem: In target detection scenarios, especially small target detection, negative samples (background areas) account for the majority, making the model more sensitive to the loss of negative samples during training and ignoring the loss contribution of positive samples. This causes the model to tend to prioritize learning the background that is easy to classify, while having difficulty focusing on small targets.
[0139] Difficult sample neglect problem: Cross entropy cannot distinguish between easy-to-classify samples and difficult-to-classify samples, and all samples contribute equally to the loss, resulting in poor learning effect of the model for small targets.
[0140] 2. The core idea of Focal Loss
[0141] In order to solve the above problems, Focal Loss adds an adjustment factor based on the cross entropy loss to dynamically adjust the contribution of samples to the total loss, so that the model pays more attention to small targets that are difficult to classify. The formula is:
[0142] FL(p t )=-α t (1-p t ) γ log p t
[0143] Where: α t It is the balance factor of positive and negative samples, which is used to adjust the ratio of positive and negative samples. It is usually set to 0.25 or other empirical values to reduce the impact of negative samples.
[0144] (1-p t ) γ is a regulating factor used to reduce the impact of easy-to-classify samples on the total loss. t When it is close to 1, the factor value tends to 0, thereby reducing the loss contribution of easy-to-classify samples; when p t When it is close to 0, the factor is close to 1, increasing the weight of difficult-to-classify samples.
[0145] γ is a hyperparameter of the adjustment factor, which is usually set to 2. This means that when the sample is easy to classify, the loss will be significantly reduced; when the sample is difficult to classify, the weight of the loss will increase, and the model will pay more attention to these difficult-to-classify samples.
[0146] 3. Advantages and effects
[0147] Compared with the traditional cross entropy loss, the introduction of Focal Loss brings the following significant advantages:
[0148] Solve the problem of class imbalance: By introducing an adjustment factor, Focal Loss reduces the loss contribution of most easily classified negative samples, making the model pay more attention to a small number of positive samples (such as small objects), thereby effectively alleviating the problem of class imbalance.
[0149] Improve small target detection ability: Small targets are usually difficult to classify because their features on the feature map are fuzzy. Focal Loss can enhance the model's learning ability for these difficult-to-classify targets and improve the recall rate of small targets.
[0150] Dynamically adjust the loss: Focal Loss dynamically adjusts the loss through γ, so that the model can gradually focus on those difficult-to-detect targets during the training process. Through this dynamic adjustment, the model can learn the details of small targets more effectively.
[0151] The effects of the present invention are described in detail below through experimental data and comparison:
[0152] First, the relevant terms are explained as follows:
[0153] mAP (Average Precision): It is an important indicator to measure model performance in target detection tasks.
[0154] Precision: Indicates how many of the targets predicted by the model are correct. The higher the precision, the fewer false positives the model has.
[0155] Calculation formula: Precision = True Positives / (True Positives + False Positives).
[0156] Recall: Indicates how many of the actual objects are correctly detected by the model. The higher the recall, the fewer objects the model misses.
[0157] Calculation formula: Recall = true positive examples / (true positive examples + false negative examples).
[0158] AP (Average Precision): The comprehensive performance of the model's precision and recall under all possible detection thresholds (i.e., different confidence levels) for a certain category of targets. AP is calculated by plotting the Precision-Recall curve and then taking the area under the curve.
[0159] Calculation method: For each category of targets, calculate multiple precision and recall values at different detection thresholds. Draw the precision-recall curve (i.e. Figure 6 , Figure 7 ) and calculate the area under the curve, which is the AP value of this category.
[0160] mAP (meanAverage Precision): Average the AP values of all categories to get the overall performance of the entire model.
[0161] Calculation formula: mAP = sum of AP values of all categories / total number of categories.
[0162] In object detection, mAP reflects the average performance of the model across all categories and is a common standard for measuring the overall performance of the object detection model.
[0163] The difference between mAP@0.5 and mAP@0.5:0.95:
[0164] mAP@0.5: This refers to the mAP when the IoU (Intersection over Union) is 0.5. IoU is an indicator to evaluate the overlap between the predicted box and the true box. 0.5 means that the overlap ratio between the predicted box and the true target box must reach at least 50% for the prediction to be correct.
[0165] mAP@0.5:0.95: This is a more stringent evaluation standard, which means taking the average of the AP corresponding to each IoU threshold under multiple thresholds between 0.5 and 0.95. This indicator can more comprehensively measure the performance of the model under different IoU standards, so mAP@0.5:0.95 is usually lower than mAP@0.5, but reflects the overall performance of the model under different conditions.
[0166] example:
[0167] If a target detection model detects objects of different categories: the AP for class A is 0.90; the AP for class B is 0.80; the AP for class C is 0.70; then the mAP is (0.90+0.80+0.70) / 3=0.80.
[0168] mAP is the average value of the detection accuracy of the model on multiple categories. It combines the precision and recall of the model and is a comprehensive indicator for evaluating target detection performance.
[0169] mAP@0.5 is a looser standard suitable for general situations, while mAP@0.5:0.95 is a stricter standard that requires a higher overlap rate. The higher the mAP value, the more accurate the model is in locating and classifying objects, and the better the performance.
[0170] like Figure 4 As shown, this is the training curve before improvement:
[0171] in:
[0172] train / box_om, train / cls_om, and train / dfl_om represent different types of errors that the model made during training. As the number of training rounds increases, these error values decrease, indicating that the model is learning and becoming more accurate. Specifically, train / box_om represents the difference between the model's predicted target location and its actual location, which is the bounding box regression error. train / cls_om represents the model's error in classifying targets, that is, whether it correctly determined the category of the object. train / dfl_om represents the error in fine-tuning the bounding box, which is used to improve the accuracy of the target box. A decrease in the loss value indicates that the model's errors are decreasing and the predictions are getting closer to the real situation.
[0173] metrics / recall(B), metrics / mAP50(B), metrics / mAP50-95(B), and metrics / precision(B) indicate the performance of the model on different evaluation indicators. Recall: The proportion of objects that the model correctly detects to be actually present. The higher the curve, the fewer objects the model misses. mAP50 (average precision): A common indicator for measuring model accuracy, indicating the average accuracy of the model at different prediction thresholds. The number 50 means that the prediction is considered correct when there is 50% overlap between the predicted box and the actual box. The higher the value, the more accurate the model. mAP50-95: A stricter accuracy indicator that measures performance at different overlap thresholds. It combines stricter detection criteria, so this value is more difficult to achieve than mAP50, but it better reflects the overall performance of the model. Precision: Indicates the correct proportion of objects predicted by the model as targets. The higher the value, the fewer false positives the model has.
[0174] like Figure 5 As shown, this is the improved training curve:
[0175] train / box_oo, train / cls_oo, train / dfl_oo: These graphs are similar to the above, showing the error of the improved model during training. It can be seen that the error value of the improved model decreases faster and the decline curve is smoother, indicating that the improved model has improved learning speed and the training process is more stable.
[0176] metrics / recall(B), metrics / mAP50(B), metrics / mAP50-95(B), metrics / precision(B): These graphs show the performance of the improved model in terms of evaluation indicators. As can be seen from the graph, the recall and precision of the improved model are higher, especially the rising curves of mAP50 and mAP50-95 are more obvious, indicating that the improved model has significantly improved the detection accuracy.
[0177] By comparison Figure 4 and Figure 5 It can be seen that the improved model learns faster, makes fewer errors, and makes more accurate predictions. The loss value (the model's error) decreases more smoothly, while evaluation metrics such as recall and precision have improved significantly, especially when detecting small objects. This shows that the overall performance of the model has improved, not only can it better detect objects, but it can also more accurately locate objects.
[0178] Figure 6The precision-recall curves of the pre-improvement model for different defect types are shown, including the detection performance of the pre-improvement model for three different defect types:
[0179] damage: The curve shows that the model performs best in detecting damage, and the upper part of the curve is relatively flat, indicating that the model has high precision and recall in detecting damage, and the overall performance is strong, with an mAP (average accuracy) of 0.931. bump: The model also performs relatively well in detecting bumps, with an mAP of 0.903, but the performance is slightly lower than that of damage. hole: The model performs relatively poorly in detecting holes, with an mAP of 0.809. The curve of holes drops early, indicating that the model is prone to false positives or missed detections in hole detection. all classes: Combining the detection performance of all defect categories, the overall mAP of the model is 0.881. This represents the detection accuracy of the model in all categories.
[0180] The meaning of the curves in the figure:
[0181] Precision: Indicates how many of the targets predicted by the model are correct. The higher the precision, the fewer false positives the model has. Recall: Indicates how many of the actual targets are detected by the model. The higher the recall, the fewer missed detections the model has. The closer the curve is to the upper right corner, the better the model performs.
[0182] Figure 7 The improved precision-recall curve is shown:
[0183] The improved model has significant improvements on the same three defect types:
[0184] damage: The curve is closer to the upper right corner, indicating that the model has greatly improved the precision and recall of damage detection, with a mAP of 0.981. bump: The improved model also significantly improved the detection performance of bumps, with a mAP of 0.974. hole: The detection performance of holes has been greatly improved, with a mAP of 0.936, which is a significant improvement compared to before the improvement, indicating that the model has enhanced its ability to detect small objects (such as holes). all classes: Combining all categories, the overall mAP of the model has increased to 0.963, indicating that the improved model has significantly improved the detection accuracy and performance of all defect types.
[0185] By comparison Figure 6 and Figure 7 It can be seen that:
[0186] Before the improvement, the model performed poorly on hole detection, but performed relatively well on breakage and agglomeration detection. After the improvement, the model's detection performance for all defect types has been significantly improved, especially in hole detection, where both precision and recall have been significantly improved. Overall, the improved model can better achieve higher detection performance on different defect types, with fewer false positives and missed detections. Through this improvement, the accuracy and reliability of the model in practical applications have been greatly improved.
[0187] like Figure 8a-8b As shown in the figure, compared with the hole detection result graph of the original YOLOv10 algorithm, the hole detection result graph of the YOLOv10 optimized algorithm is more accurate and comprehensive. Figure 8a ) only detected larger holes, while smaller holes were not effectively captured. In the YOLOv10 optimization algorithm ( Figure 8b ), not only the larger holes are accurately detected, but also multiple smaller holes are identified, indicating that the optimized algorithm has significantly improved its ability to detect small objects. In addition, the confidence scores predicted by the optimized model are higher overall, further demonstrating the improvement in detection accuracy.
[0188] like Figure 9a-9b As shown in the figure, compared with the damage detection result of the original YOLOv10 algorithm, the damage detection result of the YOLOv10 optimized algorithm is more accurate and has a higher confidence. Figure 9a In (original algorithm), the confidence of the detected damaged area is 0.91 and 0.88, while in Figure 9b In the optimized algorithm, the confidence levels are increased to 0.97 and 0.93 respectively. This indicates that the optimized YOLOv10 algorithm is more accurate in locating the damaged area and more confident in identifying the target. In addition, the damaged bounding box fits the actual damaged area more closely, further demonstrating the improvement in detection accuracy and performance of the optimized algorithm.
[0189] like Figure 10a-10b As shown in the figure, compared with the convex detection result graph of the original YOLOv10 algorithm, the convex detection result graph of the YOLOv10 optimized algorithm is more accurate and has a higher confidence. Fig.10a In (original algorithm), the confidence of the detected convex area ranges from 0.85 to 0.91. Fig.10b In the optimized algorithm, the confidence level is increased to 0.94 to 0.95, indicating that the optimized algorithm is more accurate in identifying convex areas. At the same time, the optimized algorithm can detect more convex targets and identify more small convexities, indicating that the optimized YOLOv10 algorithm has significantly improved the performance of small target detection.
Claims
1. A method for detecting the production quality of a fuel dispenser hose based on target detection, characterized in that: The steps are: 1) Collect images through the camera set on the production line and transmit the collected images to the computer; 2) Preprocess the data; 3) Train and update the YOLOv10 model, redesign the AnchorBox and four-scale detection network, and introduce Focal Loss to adjust the loss function to obtain a new YOLOv10 model; then substitute the preprocessed data into the updated YOLOv10 model for detection; 4) Output the test results. When a new type of hose or a new type of defect is detected on the production line, the system retrains and updates the model in 3) by collecting new sample data.
2. The method for detecting the production quality of a fuel dispenser hose based on target detection according to claim 1 is characterized in that: In the above 3), the method of redesigning the four-scale detection network is as follows: a1) Improvement of backbone network: The fourth detection scale X4 is introduced based on the YOLOv10 backbone network. The X4 feature map is generated by 1 / 4 downsampling. By adding a new convolution operation in the shallow part of the backbone network, that is, close to the input layer, it can generate a high-resolution feature map suitable for detecting small targets. a2) Improvement of detection head: In the detection head, a new detection branch is added to the X4 feature map. The new branch is responsible for detecting small targets based on the high-resolution feature map. By redesigning the AnchorBox, the network can match and regress the bounding box of small targets. The size and proportion of the AnchorBox are optimized according to the characteristics of the small target to capture the position and shape of the small target. a3) Multi-scale fusion: On the basis of the existing three-scale fusion, the feature fusion of X4 is added. Through upsampling and feature splicing operations with P3, P4 and P5, the model can combine shallow and deep features to fully cover the detection of large, medium and small targets.
3. The method for detecting the production quality of a fuel dispenser hose based on target detection according to claim 2 is characterized in that: In the above a1), the specific method is: a11) Introducing X4 in the backbone network: Introduce a convolutional layer near the input layer, and generate a new feature map X4 through 1 / 4 downsampling. This new feature map X4 is the same as the existing P3, P4 and P5, and is used to detect small targets through subsequent detection heads; a12) Adjust the convolution kernel size and number of channels: Adjust the size of the feature map of X4 and the number of channels of the feature map accordingly. The number of channels of the feature map of X4 is set to 128, and the size of the feature map of X4 is 160*128.
4. The method for detecting the production quality of a fuel dispenser hose based on target detection according to claim 2 is characterized in that: In the above a2), the specific method is: a21) Add a detection head branch for X4: In the detection head part, add a new branch to process the output of X4. This branch is responsible for object classification and bounding box regression based on the features of X4. a21) Adjust the design of Anchor Box: In view of the high resolution and small target characteristics of the X4 feature map, the Anchor Box is redesigned. The new Anchor Box is smaller in size and the aspect ratio is also adjusted according to the characteristics of the small target.
5. The method for detecting the production quality of a fuel dispenser hose based on target detection according to claim 2 is characterized in that: In the above a3), the specific method is: a31) Upsampling and feature concatenation: Fuse the X4 feature map with P3, P4, and P5, and use the `Upsample` and `Concat` operations to enable the shallow small target features to be passed to the deep detection head. a32) Feature level enhancement: The deep and shallow features are fused through the PANet feature fusion method.
6. The method for detecting the production quality of a fuel dispenser hose based on target detection according to claim 2 is characterized in that: The method of redesigning AnchorBox is as follows: b1) Dataset Analysis: The bounding box size and aspect ratio of all objects in the training data set are counted, and the distribution of small objects is paid attention to. By analyzing the average size and aspect ratio of the objects, the distribution range of small objects is obtained. The width of the small objects is between 5-20 pixels, and the aspect ratio is between 1:1 and 1:3; b2) AnchorBox size determination: The dimensions of the newly designed AnchorBox are as follows: {(8,12),(10,14),(12,16),(14,18),(16,20)} b3) Multi-scale design of AnchorBox: Different AnchorBoxes are set for feature maps at different downsampling levels, so that the model can detect objects of different sizes. b4) AnchorBox aspect ratio optimization: Design AnchorBoxes with different aspect ratios, such as 1:1, 2:1, and 1:2, to match small objects of different shapes; b5) Mapping of AnchorBox and feature map: By generating multiple AnchorBoxes for each pixel on the feature map, each pixel corresponds to an AnchorBox of different size and proportion.
7. The method for detecting the production quality of a fuel dispenser hose based on target detection according to claim 6 is characterized in that: In the above b3, the specific method is: In small target detection, i.e. in shallow feature maps, the feature map size is 160*120, and smaller AnchorBoxes (8,12) and (10,14) are introduced to capture the details of small targets. In medium target detection, i.e. in mid-layer feature maps, the feature map sizes are 80*60 and 40*30, and medium-sized AnchorBoxes (12,16) and (14,18) are used to capture medium targets. In large target detection, i.e. in deeper feature maps, the feature map size is 20*15, and larger AnchorBoxes (16,20) are used to capture the boundaries and features of large targets.
8. The method for detecting the production quality of a fuel dispenser hose based on target detection according to claim 1 is characterized in that: The specific method of adjusting the loss function is: Focal Loss adds an adjustment factor based on the cross entropy loss to dynamically adjust the contribution of samples to the total loss, so that the model pays more attention to small targets that are difficult to classify. The formula is: FL(p t )=-α t (1-p t ) γ logp t Among them, p t Represents the model's predicted probability of the target category; α t is the balance factor of positive and negative samples; γ is the hyperparameter of the adjustment factor; (1-p t ) γ is the adjustment factor, when p t When it is close to 1, the adjustment factor value tends to 0, reducing the loss contribution of easy-to-classify samples. t When it is close to 0, the adjustment factor is close to 1, increasing the weight of difficult-to-classify samples.
Citation Information
Cited By
Real-time monitoring system for ultrahigh pressure hose joint assembly
CN121686346A