A bottle cap detection method, device, equipment and medium

By constructing the ST-YOLO detection model, integrating global and local features and performing bidirectional feature fusion, the problem of balancing accuracy and real-time performance in bottle cap detection under complex scenarios is solved, achieving efficient and high-precision bottle cap detection.

CN118429710BActive Publication Date: 2025-11-11BEIJING ONE CODE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410553465.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-07
Publication Date
2025-11-11
Estimated Expiration
2044-05-07

AI Technical Summary

Technical Problem

Existing technologies fail to balance detection accuracy and real-time performance in complex scenarios, under varying lighting conditions and viewing angles.

Method used

An ST-YOLO detection model is constructed, which uses the CST module to fuse global and local features, uses the BiFPN network for bidirectional feature fusion, optimizes the model through the MPDIoU loss function, and combines the SwinBottleneck module and the Transformer Block module to improve feature extraction capability.

Benefits of technology

It achieves high-precision bottle cap detection in complex scenarios while maintaining high detection efficiency, meeting the requirements of modern production testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118429710B_ABST
    Figure CN118429710B_ABST
Patent Text Reader

Abstract

This invention provides a bottle cap detection method, apparatus, device, and medium. The method includes: acquiring bottle cap defect images, constructing an image set, and annotating the image set; constructing an ST-YOLO detection model, training the ST-YOLO detection model using the image set until convergence, and obtaining a trained ST-YOLO detection model; wherein the ST-YOLO detection model includes a convolutional layer for feature extraction, a CST module for fusing global and local features to generate multi-scale feature maps, a BiFPN network for multi-layer feature fusion, and a classification layer for classifying and regressing the features output by the BiFPN network; and using the trained ST-YOLO detection model to detect the bottle cap images to be detected to obtain detection results, thereby solving the problem that the bottle cap detection effect fails to balance detection accuracy and real-time performance when facing complex scenes, changes in lighting, and changes in viewing angle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of production testing technology, and in particular to a method, apparatus, equipment and medium for testing bottle caps. Background Technology

[0002] The design of existing bottle cap detectors should meet the following two conditions: First, they need to detect various types of bottle caps and support rings with high precision; second, the speed of the detection algorithm must meet the requirements of efficient production line operation, i.e., real-time and low latency. Traditional detection methods may perform poorly in complex scenes, under varying lighting conditions, and with changing viewing angles. Deep learning-based object detection methods, however, can better address these problems and possess stronger generalization ability and stability.

[0003] Common deep learning-based bottle cap detection algorithms mainly fall into two categories:

[0004] The first category is two-stage methods based on region proposal generation, such as Faster R-CNN. These methods generate regions of interest in the first stage and perform classification and regression in the second stage, but they lose the spatial information of local targets in the whole image, and the detection speed is difficult to achieve real-time.

[0005] The second type is single-stage detectors, such as YOLO, RetinaNet, and SSD. These algorithms directly perform regression prediction on the entire image instead of generating regions of interest, so the detection speed can generally meet real-time requirements. However, these methods have problems with accuracy and recall in locating fine bottle caps.

[0006] In existing technologies, YOLOv8 employs a design that predicts multiple targets at once, resulting in extremely fast detection speeds. It also improves upon the detection accuracy issues of YOLOv5 and YOLOv7 through anchor-free mapping and network structure optimization. However, due to its overly simple network model, its detection accuracy does not meet the standards for industrial applications.

[0007] Therefore, there is an urgent need to propose a bottle cap detection method to solve the problem that the bottle cap detection effect fails to balance detection accuracy and real-time performance when faced with complex scenes, changes in lighting and viewing angles. Summary of the Invention

[0008] To overcome the problems existing in related technologies, this disclosure provides a bottle cap detection method, apparatus, equipment and medium to solve the technical problem that the bottle cap detection effect fails to balance detection accuracy and real-time performance when facing complex scenes, changes in lighting and viewing angles.

[0009] This specification provides one or more embodiments of a bottle cap detection method, including the following steps:

[0010] Collect images of bottle cap defects, construct an image set, and annotate the image set;

[0011] Construct an ST-YOLO detection model, and train the ST-YOLO detection model using the image set until it converges to obtain a trained ST-YOLO detection model;

[0012] The ST-YOLO detection model includes a convolutional layer for extracting features, a CST module for fusing global and local features to generate multi-scale feature maps, a BiFPN network for fusing multi-layer features, and a classification layer for classifying and regressing the features output by the BiFPN network.

[0013] The bottle cap image to be detected is used to obtain the detection result by using a trained ST-YOLO detection model.

[0014] Preferably, the method further includes the step of:

[0015] The loss function of the ST-YOLO detection model is the MPDIoU function.

[0016] Preferably, the CST module includes N SwinBottleneck modules and a residual connection layer, and the output of each SwinBottleneck module serves as the input of the next SwinBottleneck module and the input of the residual connection layer.

[0017] The SwinBottleneck module divides the input feature map into two paths. One path directly passes the features downwards, while the other path is input to the first CBS module and the first Transformer Block module respectively. The outputs of the first CBS module and the first Transformer Block module are fused together and used as the input to the second CBS module. The output of the first Transformer Block module is used as the input to the second Transformer Block module. The outputs of the second CBS module and the second Transformer Block module are fused with the input features and then output.

[0018] The first Transformer Block module adopts a window-based multi-head self-attention module, and the second Transformer Block module adopts a moving window-based multi-head self-attention module.

[0019] Preferably, the BiFPN network performs bidirectional feature fusion through a top-down path and a bottom-up path, and sets up horizontal cross-layer connections of the same scale between the original input and output nodes of the features.

[0020] The top-down path refers to the process of upsampling and feature extraction by the CST module.

[0021] The bottom-up path refers to the process of downsampling and feature extraction by the CST module.

[0022] This specification provides one or more embodiments of a bottle cap detection device, comprising:

[0023] The dataset creation module is used to collect images of bottle cap defects, construct an image set, and annotate the image set;

[0024] The model building module is used to build an ST-YOLO detection model. The ST-YOLO detection model is trained using the image set until it converges, resulting in a trained ST-YOLO detection model.

[0025] The ST-YOLO detection model includes a convolutional layer for extracting features, a CST module for fusing global and local features to generate multi-scale feature maps, a BiFPN network for fusing multi-layer features, and a classification layer for classifying and regressing the features output by the BiFPN network.

[0026] The detection module is used to perform detection on the test set using a trained ST-YOLO detection model.

[0027] Preferably, it further includes:

[0028] The loss function of the ST-YOLO detection model is the MPDIoU function.

[0029] Preferably, the CST module includes N SwinBottleneck modules and a residual connection layer, and the output of each SwinBottleneck module serves as the input of the next SwinBottleneck module and the input of the residual connection layer.

[0030] The SwinBottleneck module divides the input feature map into two paths. One path directly passes the features downwards, while the other path is input to the first CBS module and the first Transformer Block module respectively. The outputs of the first CBS module and the first Transformer Block module are fused together and used as the input to the second CBS module. The output of the first Transformer Block module is used as the input to the second Transformer Block module. The outputs of the second CBS module and the second Transformer Block module are fused with the input features and then output.

[0031] The first Transformer Block module adopts a window-based multi-head self-attention module, and the second Transformer Block module adopts a moving window-based multi-head self-attention module.

[0032] Preferably, the BiFPN network performs bidirectional feature fusion through a top-down path and a bottom-up path, and sets up horizontal cross-layer connections of the same scale between the original input and output nodes of the features.

[0033] The top-down path refers to the process of upsampling and feature extraction by the CST module.

[0034] The bottom-up path refers to the process of downsampling and feature extraction by the CST module.

[0035] This specification provides one or more embodiments of a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a bottle cap detection method as described above.

[0036] This specification provides one or more embodiments of a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the bottle cap detection method described above.

[0037] The bottle cap detection method, apparatus, device, and medium disclosed herein have the advantage of using an ST-YOLO detection model. This model includes a CST module for extracting and fusing global and local features to better capture the correlation between features and improve the ability to model global features, as well as a BiFPN network for fusing at different scales and mitigating the problem of feature information loss due to excessive network layers, thereby enhancing the model's feature extraction capabilities. The method in this embodiment effectively fuses global and local features and uses the trained ST-YOLO detection model to detect the bottle cap image to obtain the detection result. This achieves both high detection accuracy and high detection efficiency in bottle cap detection, meeting the requirements of modern production testing. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in one or more embodiments of this specification or in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1 A schematic flowchart illustrating a bottle cap detection method provided in one or more embodiments of this specification;

[0040] Figure 2 An overall structural diagram of the ST-YOLO for a bottle cap detection method provided in one or more embodiments of this specification;

[0041] Figure 3 A structural diagram of the SwinBottleneck module for a bottle cap detection method provided in one or more embodiments of this specification;

[0042] Figure 4 The diagram shows the structure of the weighted bidirectional feature pyramid network BiFPN provided in one or more embodiments of this specification. (a) is a PAN network structure diagram, and (b) is a BiFPN feature fusion network structure diagram.

[0043] Figure 5 A structural diagram of a bottle cap detection device provided in one or more embodiments of this specification;

[0044] Figure 6 This is a schematic diagram of the structure of a computer device provided for one or more embodiments of this specification. Detailed Implementation

[0045] To enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this invention.

[0046] The present invention will now be described in detail with reference to specific embodiments and accompanying drawings.

[0047] Method Implementation Examples

[0048] According to embodiments of the present invention, a bottle cap detection method is provided, such as... Figure 1 The diagram shown is a flowchart of a bottle cap detection method provided in this embodiment. According to an embodiment of the present invention, a bottle cap detection method includes the following steps:

[0049] Step S110: Collect images of bottle cap defects, construct an image set, and annotate the image set.

[0050] Step S120: Construct the ST-YOLO detection model. Train the ST-YOLO detection model using the image set until convergence, and obtain the trained ST-YOLO detection model. The ST-YOLO detection model includes a convolutional layer for feature extraction, a CST module for extracting global and local features of the image and fusing the global and local features to generate a multi-scale feature map, a weighted bidirectional feature pyramid network (BiFPN) for fusing multi-layer features, and a classification layer for classifying and regressing the features output by the BiFPN network.

[0051] like Figure 2 The diagram shown illustrates the overall ST-YOLO architecture of a bottle cap detection method provided in this embodiment. The image is input into a feature extraction network consisting of ordinary convolutional layers, a CST module, and a Spatial Pyramid Pooling-Fast (SPPF) module. The ordinary convolutional layers compress the image resolution through downsampling. The CST module inputs feature maps into branches composed of convolutional layers and Transformer Blocks, while another branch is passed directly as a bypass. The feature maps obtained from the two branches are fused, and the fused result is output to the next module. Typically, multiple CST modules are stacked after the downsampling convolutional layers, and after multiple downsampling operations, a preliminary backbone network is formed. The feature fusion network receives multi-scale feature maps from the preceding networks and performs feature fusion through a BiFPN network.

[0052] Step S130: Use the trained ST-YOLO detection model to detect the bottle cap image to be detected and obtain the detection result.

[0053] The method provided in this embodiment acquires images of bottle cap defects, constructs an image set, and annotates the image set to obtain data for training the model. The constructed ST-YOLO detection model includes a CST module for extracting and fusing global and local features to better capture the correlation between features and improve the ability to model global features, and a BiFPN network for fusing at different scales and mitigating feature information loss due to excessive network layers, thus enhancing the model's feature extraction capabilities. This method effectively fuses global and local features, and uses the trained ST-YOLO detection model to detect the bottle cap images to obtain detection results. This achieves both high detection accuracy and high detection efficiency in bottle cap detection, meeting the requirements of modern production testing.

[0054] In one embodiment, the step further includes:

[0055] S150. In the bottle cap detection task, the loss function of the ST-YOLO detection model is the MPDIoU function. The ST-YOLO detection model is optimized by the MPDIoU loss function, and the bounding box regression loss is calculated. By minimizing the distance between the top left corner and the bottom right corner between the predicted bounding box and the true bounding box, the similarity comparison between the two bounding boxes is simplified.

[0056] The MPDIoU loss function is calculated as follows:

[0057]

[0058]

[0059] L MPDIoU =1-MPDIoU;

[0060] Among them, B gt B represents the true bounding box. prd The image represents the predicted bounding box, d1 represents the Euclidean distance between the top-left point of the ground truth bounding box and the predicted bounding box, d2 represents the Euclidean distance between the bottom-right point of the ground truth bounding box and the predicted bounding box, h represents the height of the image, w represents the width of the image, and L represents the height of the image. MPDIoU This represents the MPDIoU loss function.

[0061] In one embodiment, the CST module in step S120 uses a multi-head self-attention mechanism and a convolutional fusion module to extract features, including N SwinBottleneck modules and residual connection layers. The output of each SwinBottleneck module is used as the input of the next SwinBottleneck module and the input of the residual connection layer.

[0062] like Figure 3 The diagram shows the SwinBottleneck module structure of a bottle cap detection method provided in this embodiment. The SwinBottleneck module divides the input feature map into two paths: one path directly passes the features downwards, and the other path is input to the first CBS module and the first Transformer Block module respectively. The outputs of the first CBS module and the first Transformer Block module are fused together and used as the input to the second CBS module. The output of the first Transformer Block module is used as the input to the second Transformer Block module. The outputs of the second CBS module, the second Transformer Block module, and the input features are fused together and then output.

[0063] In one specific embodiment, by introducing an overlapping window and translation strategy, global attention interaction is achieved while maintaining low computational complexity. If the window size of a feature map is S×S, then in the next layer, the entire pane is moved by (S / 2, S / 2). Through the interaction between windows, the model can better capture the correlations between features, improving the ability to model global features. Using the moving window method, the calculation formula for a continuous Transformer block is:

[0064]

[0065]

[0066]

[0067]

[0068] in, Z represents the output characteristics of the l-th layer W-MSA module. l denoted by , W-MSA and SW-MSA represent the output features of the l-th layer MLP module, respectively, and represent the multi-head self-attention mechanism using a fixed window and a sliding window.

[0069] In this embodiment, the CBS module consists of convolution, batch normalization (BN), and the SiLU activation function. Both Transformer Blocks include a multi-head self-attention mechanism and a feedforward neural network for global feature modeling of the input features. To enable interaction between windows, the first Transformer Block uses a window-based multi-head self-attention module (W-MSA), and the second Transformer Block uses a moving window-based multi-head self-attention module (SW-MSA).

[0070] The calculation process of the SwinBottleneck module is as follows:

[0071] X l =CBS(X) l-1 )+W-MSA(X l-1 );

[0072] X l+1 =CBS(X) l )+SW-MSA(W-MSA(X l-1 ))+X l-1 ;

[0073] Where: X lThe numbers represent the number of layers in the feature map. CBS represents a convolutional module, W-MSA represents a window-based self-attention module, and SW-MSA represents a sliding window-based self-attention module.

[0074] The method provided in this embodiment utilizes a CNN-Transformer CST module comprising N SwingBottleneck modules and residual connection layers. The output of each SwingBottleneck module serves as the input to the next SwingBottleneck module and the input to the residual connection layer. The SwingBottleneck module divides the input feature map into two paths: one path directly passes the features downwards, and the other path is input to the first CBS module and the first Transformer Block module, respectively. The outputs of the first CBS module and the first Transformer Block module are fused and used as the input to the second CBS module. The output of the first Transformer Block module is used as the input to the second Transformer Block module. The outputs of the second CBS module and the second Transformer Block module are fused with the input features and then output. The first Transformer Block module employs a window-based multi-head self-attention module, and the second Transformer Block module employs a moving window-based multi-head self-attention module. This overcomes the feature locality problem in CNNs, helps the model better capture the correlation between features, and improves the ability to model global features.

[0075] In one embodiment, the feature fusion network in the YOLOv8 model is a path aggregation network (PANet), which performs simple bidirectional fusion in the feature pyramid through direct summation, without considering weighted correlation design. Since different features have different resolutions and contribute differently to the final output features, direct summation may not effectively fuse these features. This embodiment employs a BiFPN feature fusion network, such as... Figure 4 The diagram shows the structure of the weighted bidirectional feature pyramid network BiFPN provided in this embodiment. (a) is the structure diagram of the PAN network, and (b) is the structure diagram of the BiFPN feature fusion network.

[0076] BiFPN adds a learnable weight to each feature, gradually learning the importance of each feature and the relationships between different features during network training. The weighted BiFPN network performs bidirectional feature fusion through a top-down path and a bottom-up path. The top-down path is the process of upsampling operation and CST module feature extraction, while the bottom-up path is the process of downsampling operation and CST module feature extraction. A horizontal same-scale cross-layer connection is set between the original input and output nodes of the feature.

[0077] The BiFPN network used employs a fast normalization fusion method for weighted fusion, and the calculation process is as follows:

[0078]

[0079] Among them: I i O represents the input feature, and O represents the output feature. i and w j ε represents the learnable weights, and it is a very small number to ensure that the denominator is not zero.

[0080] The method provided in this embodiment performs bidirectional feature fusion using both top-down and bottom-up approaches. Upsampling and downsampling are used to unify the feature resolution scale for fusion across different scales. Simultaneously, lateral connections are added between the original input and output nodes of the features to mitigate feature information loss caused by excessive network layers. The top-down path mainly involves upsampling operations and feature extraction by the CST module, while the bottom-up path mainly involves downsampling operations and feature extraction by the CST module. Furthermore, lateral connections at the same scale across layers are established to retain more deep and shallow semantic information.

[0081] Device Examples

[0082] According to embodiments of the present invention, a bottle cap detection device is provided, such as... Figure 5 The diagram shown is a structural diagram of a bottle cap detection device provided in this embodiment. According to an embodiment of the present invention, a bottle cap detection device includes:

[0083] The dataset creation module 510 is used to collect images of bottle cap defects, construct an image set, and annotate the image set.

[0084] The model building module 520 is used to build an ST-YOLO detection model. The ST-YOLO detection model is trained using the image set until it converges, thus obtaining a trained ST-YOLO detection model.

[0085] The ST-YOLO detection model includes convolutional layers for feature extraction, a CST module for fusing global and local features to generate multi-scale feature maps, a BiFPN network for fusing multi-layer features, and a classification layer for classifying and regressing the features output by the BiFPN network.

[0086] The detection module 530 is used to detect the bottle cap image to be detected using a trained ST-YOLO detection model to obtain the detection result.

[0087] The apparatus provided in this embodiment includes a dataset creation module 510 that collects images of bottle cap defects, constructs an image set, and annotates the image set to obtain data for training the model. A model construction module 520 constructs an ST-YOLO detection model. The constructed ST-YOLO detection model includes a CST module for extracting and fusing global and local features to better capture the correlation between features and improve the ability to model global features, and a BiFPN network for fusing at different scales and mitigating the problem of feature information loss due to excessive network layers, thereby enhancing the model's feature extraction capability. This embodiment effectively fuses global and local features. The detection module 530 uses the trained ST-YOLO detection model to detect the bottle cap images to be detected, obtaining detection results. This achieves both high detection accuracy and high detection efficiency in bottle cap detection, meeting the requirements of modern production testing.

[0088] In one embodiment, it also includes:

[0089] In the bottle cap detection task, the loss function of the ST-YOLO detection model is the MPDIoU function. The ST-YOLO detection model is optimized by using the MPDIoU loss function, and the bounding box regression loss is calculated. By minimizing the distance between the top left corner and the bottom right corner between the predicted bounding box and the true bounding box, the similarity comparison between the two bounding boxes is simplified.

[0090] In one embodiment, the CST module includes N SwingBottleneck modules and a residual connection layer, with the output of each SwingBottleneck module serving as the input of the next SwingBottleneck module and the input of the residual connection layer.

[0091] The SwinBottleneck module splits the input feature map into two paths. One path directly passes the features down, while the other path is input into the first CBS module and the first Transformer Block module respectively. The outputs of the first CBS module and the first Transformer Block module are fused together and used as the input to the second CBS module. The output of the first Transformer Block module is used as the input to the second Transformer Block module. The outputs of the second CBS module and the second Transformer Block module are fused with the input features and then output.

[0092] The first Transformer Block module adopts a window-based multi-head self-attention module, while the second Transformer Block module adopts a moving window-based multi-head self-attention module.

[0093] The apparatus provided in this embodiment includes a CST module comprising N SwingBottleneck modules and a residual connection layer. The output of each SwingBottleneck module serves as the input to the next SwingBottleneck module and the input to the residual connection layer. The SwingBottleneck module divides the input feature map into two paths: one path directly passes the features downwards, and the other path is input to the first CBS module and the first Transformer Block module, respectively. The outputs of the first CBS module and the first Transformer Block module are fused and used as the input to the second CBS module. The output of the first Transformer Block module is used as the input to the second Transformer Block module. The outputs of the second CBS module and the second Transformer Block module are fused with the input features and then output. The first Transformer Block module adopts a window-based multi-head self-attention module, and the second Transformer Block module adopts a moving window-based multi-head self-attention module. This can overcome the feature locality problem of CNNs, help the model better capture the correlation between features, and improve the ability to model global features.

[0094] In one embodiment, the BiFPN network performs bidirectional feature fusion through top-down and bottom-up paths, setting up horizontal same-scale cross-layer connections between the original input and output nodes of the features.

[0095] The top-down path involves the upsampling operation and the feature extraction process by the CST module.

[0096] The bottom-up path involves the downsampling operation and the feature extraction process by the CST module.

[0097] The apparatus provided in this embodiment performs bidirectional feature fusion using both top-down and bottom-up approaches. Upsampling and downsampling are used to unify the feature resolution scale for fusion across different scales. Simultaneously, lateral connections are added between the original input and output nodes of the features to mitigate feature information loss caused by excessive network layers. The top-down path primarily involves upsampling operations and feature extraction by the CST module, while the bottom-up path also primarily involves upsampling operations and feature extraction by the CST module, with lateral connections across layers at the same scale to retain more deep and shallow semantic information.

[0098] The embodiments of the present invention are device embodiments corresponding to the above method embodiments. The specific operations of each module processing step can be understood with reference to the description of the method embodiments, and will not be repeated here.

[0099] like Figure 6 As shown, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a bottle cap detection method in the above embodiments, or the computer program, when executed by a processor, implements a bottle cap detection method in the above embodiments.

[0100] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0101] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for apparatus or system embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. The apparatus and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and the contents not described in detail in the specification of the present invention are well known to those skilled in the art.

Claims

1. A method for detecting bottle caps, characterized in that, Includes the following steps: Collect images of bottle cap defects, construct an image set, and annotate the image set; Construct an ST-YOLO detection model, and train the ST-YOLO detection model using the image set until it converges to obtain a trained ST-YOLO detection model; The ST-YOLO detection model includes convolutional layers for feature extraction, a CST module for fusing global and local features to generate multi-scale feature maps, a BiFPN network for multi-layer feature fusion, and a classification layer for classifying and regressing the features output by the BiFPN network. The CST module inputs feature maps into branches composed of convolutional layers and Transformer Blocks, while another path is passed directly as a bypass. The feature maps obtained from the two branches are fused, and the fusion result is output to the next module. Multiple CST modules are stacked after the downsampling convolutional layers. After multiple downsampling operations, a preliminary backbone network is formed. The feature fusion network receives multi-scale feature maps from the previous network and achieves feature fusion through the BiFPN network. The bottle cap image to be detected is detected using a trained ST-YOLO detection model to obtain the detection results; The CST module includes multiple SwingBottleneck modules and a residual connection layer. The output of each SwingBottleneck module serves as the input of the next SwingBottleneck module and the input of the residual connection layer. The SwinBottleneck module divides the input feature map into two paths. One path directly passes the features downwards, while the other path is input to the first CBS module and the first Transformer Block module respectively. The outputs of the first CBS module and the first Transformer Block module are fused together and used as the input to the second CBS module. The output of the first Transformer Block module is used as the input to the second Transformer Block module. The outputs of the second CBS module and the second Transformer Block module are fused with the input features and then output. The first Transformer Block module adopts a window-based multi-head self-attention module, and the second Transformer Block module adopts a moving window-based multi-head self-attention module.

2. The bottle cap detection method as described in claim 1, characterized in that, The loss function of the ST-YOLO detection model is the MPDIoU function.

3. The bottle cap detection method as described in claim 1, characterized in that, The BiFPN network performs bidirectional feature fusion through top-down and bottom-up paths, and sets up horizontal cross-layer connections of the same scale between the original input and output nodes of the features. The top-down path refers to the process of upsampling and feature extraction by the CST module. The bottom-up path refers to the process of downsampling and feature extraction by the CST module.

4. A bottle cap detection device, characterized in that, include: The dataset creation module is used to collect images of bottle cap defects, construct an image set, and annotate the image set; The model building module is used to build an ST-YOLO detection model. The ST-YOLO detection model is trained using the image set until it converges, resulting in a trained ST-YOLO detection model. The ST-YOLO detection model includes convolutional layers for feature extraction, a CST module for fusing global and local features to generate multi-scale feature maps, a BiFPN network for multi-layer feature fusion, and a classification layer for classifying and regressing the features output by the BiFPN network. The CST module inputs feature maps into branches composed of convolutional layers and Transformer Blocks, while another path is passed directly as a bypass. The feature maps obtained from the two branches are fused, and the fusion result is output to the next module. Multiple CST modules are stacked after the downsampling convolutional layers. After multiple downsampling operations, a preliminary backbone network is formed. The feature fusion network receives multi-scale feature maps from the previous network and achieves feature fusion through the BiFPN network. The detection module is used to detect the bottle cap image to be detected using a trained ST-YOLO detection model to obtain the detection result; The CST module includes N SwingBottleneck modules and a residual connection layer. The output of each SwingBottleneck module serves as the input of the next SwingBottleneck module and the input of the residual connection layer. The SwinBottleneck module divides the input feature map into two paths. One path directly passes the features downwards, while the other path is input to the first CBS module and the first Transformer Block module respectively. The outputs of the first CBS module and the first Transformer Block module are fused together and used as the input to the second CBS module. The output of the first Transformer Block module is used as the input to the second Transformer Block module. The outputs of the second CBS module and the second Transformer Block module are fused with the input features and then output. The first Transformer Block module adopts a window-based multi-head self-attention module, and the second Transformer Block module adopts a moving window-based multi-head self-attention module.

5. The bottle cap detection device as described in claim 4, characterized in that, Also includes: The loss function of the ST-YOLO detection model is the MPDIoU function.

6. The bottle cap detection device as described in claim 4, characterized in that, The BiFPN network performs bidirectional feature fusion through top-down and bottom-up paths, and sets up horizontal cross-layer connections of the same scale between the original input and output nodes of the features. The top-down path refers to the process of upsampling and feature extraction by the CST module. The bottom-up path refers to the process of downsampling and feature extraction by the CST module.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements a bottle cap detection method as described in any one of claims 1 to 3.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of a bottle cap detection method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Lightweight flame detection method fused with BiFPN

    CN117409358A