Wine bottle defect detection method and device based on improved YOLO
By improving the YOLO network model, combining multi-head attention mechanism and CARAFE upsampling, the identification problem in low efficiency and complex environments in bottle defect detection is solved, efficient and accurate defect detection is achieved, labor costs are reduced and automation is improved degree.
Patent Information
- Application Number
- CN202411359067.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-01-14
AI Technical Summary
The existing technology has problems such as low efficiency, easy fatigue and strong subjectivity in the detection of bottle defects. Traditional image processing technology is difficult to cope with complex and changeable production environments, uneven light, and glass material reflection, resulting in missed inspection and Misconduct.
Using the bottle defect detection method based on improved YOLO, by building a machine vision detection platform, collecting bottle sample information from multiple angles, performing preprocessing and data enhancement, building an improved YOLO network model, using the multi-head attention mechanism and CARAFE upsampling method, Optimize the backbone and neck networks, combine the dynamic non-monotonic focus mechanism for training, and generate an efficient defect detection model.
It realizes efficient detection of bottle defects, improves the degree of automation of the production line, reduces labor costs, enhances the ability to identify subtle defects, and reduces missed and missed inspections.
Smart Images

Figure CN119313626A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of wine bottle defect detection, and in particular to a wine bottle defect detection method and device based on improved YOLO. Background Art
[0002] Brown wine bottles are widely used in the industry because they have good light-proof properties and can effectively protect the liquid in the bottle from ultraviolet rays and maintain the quality of the drink. However, during the production process, due to the characteristics of glass materials and the complexity of the production process, wine bottles often have various defects such as suspended matter, bubbles, dirt, spots, mold, foreign matter, cracks, oil stains, etc. These defects not only affect the appearance quality of the wine bottles, but may also cause product safety issues, thereby increasing the production costs and market risks of enterprises. Therefore, accurately and quickly detecting these defects is of great significance to improving product quality and reducing losses.
[0003] At present, wine bottle defect detection mainly relies on manual inspection and traditional image processing technology. Although manual inspection is highly flexible, it has problems such as low efficiency, easy fatigue and strong subjectivity; while traditional image processing technology relies on preset rules and feature extraction methods. Although it can achieve certain results under specific circumstances, it is difficult to cope with complex and changing production environments, and its ability to identify subtle defects on the bottle is limited. In addition, traditional methods often show shortcomings when dealing with uneven lighting, reflective glass materials and background interference, resulting in missed detections and false detections.
[0004] In order to overcome the above problems, the industry has gradually introduced deep learning-based defect detection algorithms, which can automatically learn and extract features from images and have stronger robustness and adaptability. However, existing deep learning methods still face some challenges when processing brown glass bottle images. For example, due to the darker color of brown glass bottles, subtle defects have low contrast in the image and are difficult to be accurately identified by traditional convolutional neural networks (CNNs). At the same time, due to the reflectivity and light transmittance of the glass surface, the detection process is easily affected by lighting conditions, which increases the difficulty of detection. Summary of the invention
[0005] In view of the defects in the prior art, the purpose of the present invention is to provide a wine bottle defect detection method and device based on improved YOLO, which can efficiently detect wine bottle defects.
[0006] To solve the above problems, the technical solution of the present invention is:
[0007] A wine bottle defect detection method based on improved YOLO includes the following steps:
[0008] Build a machine vision inspection platform to collect wine bottle sample information from multiple angles;
[0009] Preprocess the collected wine bottle image sample data to obtain a wine bottle defect image sample data set;
[0010] Perform data augmentation on the wine bottle defect image sample dataset;
[0011] Build and improve the YOLO network model;
[0012] The improved YOLO network model is trained using the wine bottle defect image sample dataset to obtain a wine bottle defect detection model;
[0013] The wine bottle defect detection model is used to perform defect detection on the image of the wine bottle to be inspected, and the wine bottle defect detection result is obtained.
[0014] Preferably, in the step of building a machine vision inspection platform and collecting wine bottle sample information at multiple angles, the vision inspection platform includes a suspended clamping and conveying mechanism, a multi-view imaging system and a signal processing unit. The suspended clamping and conveying mechanism is used to stably fix the wine bottle on the conveyor belt and ensure that the wine bottle can rotate 360 degrees during the conveying process, so that the wine bottle can be photographed by cameras at multiple angles during the movement; the multi-view imaging system cooperates with the suspended clamping and conveying mechanism, and when the wine bottle passes through the conveyor belt, multiple cameras photograph the wine bottle to capture images of the wine bottle at various angles; the signal processing unit receives and processes the image data from the multi-view imaging system.
[0015] Preferably, the step of preprocessing the collected wine bottle image sample data to obtain a wine bottle defect image sample data set specifically includes:
[0016] Performing data cleaning on the collected wine bottle image sample data, removing the wine bottle image sample data without defects, and retaining the image sample data with defects;
[0017] Automatically annotate the collected image data using the Segment Anything Model and Label Studio software to generate preliminary annotation results;
[0018] The automatic annotation results are manually corrected to ensure the accuracy and completeness of the annotations, and finally a high-quality annotation dataset is generated for training.
[0019] Preferably, the step of constructing an improved YOLO network model specifically includes:
[0020] Constructing a traditional YOLO network model, wherein the traditional YOLO network model includes a backbone network Backbone, a neck network Neck and a detection head Head, wherein the backbone network Backbone and the neck network Neck both include multiple C2f modules and multiple convolution modules Conv;
[0021] The backbone network of the traditional YOLO network is optimized, and the C2f_NDCN module replaces the C2f module in the original backbone network;
[0022] Add the multi-head attention mechanism to the backbone network of the YOLO network;
[0023] The neck network of the traditional YOLO network is optimized and sampled using the CARAFE upsampling method;
[0024] The optimized backbone network Backbone, neck network Neck and detection head Head are combined to obtain the improved YOLO network model.
[0025] Preferably, in the step of optimizing the backbone network of the traditional YOLO network and replacing the C2f module in the original backbone network with the C2f_NDCN module, the C2f_NDCN module is constructed by replacing the original Bottleneck module with two sequentially connected deformable convolutional layers. Compared with the traditional convolutional layer, the deformable convolutional layer can adaptively adjust the shape and size of the receptive field according to different input features.
[0026] Preferably, in the step of adding the multi-head attention mechanism to the backbone network of the YOLO network, the multi-head attention mechanism is added to the backbone network of the YOLO network to calculate multiple self-attention heads in parallel so as to extract contextual information from the input features and enhance the capability of feature representation.
[0027] Preferably, the step of optimizing the neck network of the traditional YOLO network and using the CARAFE upsampling method for sampling specifically includes: using the CARAFE upsampling method in the neck network for upsampling, and dynamically adjusting the upsampling position to better retain the detail information of the image, especially at the edges and subtle defect areas, thereby improving the detection accuracy of wine bottle defects.
[0028] Preferably, in the step of training the improved YOLO network model using the wine bottle defect image sample dataset to obtain the wine bottle defect detection model, a loss function is used to obtain the error between the predicted box and the true value to evaluate the performance of the target detection model. The loss function Loss consists of three parts, including a boundary loss function loss box , confidence loss function lossobj And classification loss function loss cls ; The overall loss function is as follows:
[0029] Loss = λ box loss box +λ obj loss obj +λ cls loss cls
[0030] In the formula, λ box , obj and λ cls They represent the positioning loss weight, confidence loss weight, and classification loss weight respectively.
[0031] Preferably, the boundary loss function uses Wise-IoU based on a dynamic non-monotonic focusing mechanism as a bounding box regression loss function to weaken the influence of geometric factors on anchor box regression and accelerate network training and reasoning speed. The calculation method of the WIoU loss function is:
[0032] L WIoUv1 =R WIoU L IoU
[0033]
[0034] L WIoU =kL WIoUv1
[0035] Among them, L IoU The number loU, R, representing the bounding box loss WIoU represents the distance attention, x and y are the horizontal and vertical coordinates of the center point of the prediction box, respectively. gt ,y gt are the horizontal and vertical coordinates of the center point of the real frame, W g , H g are the width and height of the minimum bounding rectangle of the predicted box and the true box, respectively. * indicates a separation operation, which helps to eliminate factors that hinder convergence and thus improve the convergence speed. k is the non-monotonic focusing coefficient.
[0036] Furthermore, the present invention also provides a wine bottle defect detection device based on improved YOLO, comprising a processor and a memory for storing executable instructions of the processor, wherein the processor is configured to execute the wine bottle defect detection method based on improved YOLO as described above by executing the executable instructions.
[0037] Compared with the prior art, the present invention develops a wine bottle defect detection method and device based on an improved YOLO network, which can not only efficiently detect wine bottle defects, but also improve the automation level of the production line and reduce labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0039] Figure 1 This is a flowchart of the wine bottle defect detection method based on improved YOLO of the present invention;
[0040] Figure 2 This is an example diagram of defects of various categories in the wine bottle defect detection image of the present invention;
[0041] Figure 3 This is a flow chart based on the improved YOLO algorithm of the present invention;
[0042] Figure 4 This is a deformable convolution module diagram of an embodiment provided by the present invention;
[0043] Figure 5 This is a C2f-NDCN flow chart of an embodiment provided by the present invention;
[0044] Figure 6 D_Bottleneck flow chart of the embodiment provided by the present invention;
[0045] Figure 7 This is a structural diagram of the MHSA of an embodiment provided by the present invention;
[0046] Figure 8 This is a diagram of the overall framework of CARAFE upsampling in the embodiment provided by the present invention. DETAILED DESCRIPTION
[0047] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0048] Specifically, the present invention provides a wine bottle defect detection method based on improved YOLO, such as Figure 1 As shown, the method comprises the following steps:
[0049] S1: Build a machine vision inspection platform to collect wine bottle sample information from multiple angles;
[0050] Specifically, a machine vision inspection platform is constructed, which includes a suspended clamping and conveying mechanism, a multi-view imaging system and a signal processing unit. The suspended clamping and conveying mechanism is used to stably fix the wine bottle on the conveyor belt and ensure that the wine bottle can rotate 360 degrees during the conveying process, so that the wine bottle can be photographed by cameras at multiple angles during the movement. The multi-view imaging system works closely with the suspended clamping and conveying mechanism. When the wine bottle passes through the conveyor belt, multiple cameras shoot the wine bottle to capture images of the wine bottle at various angles. The signal processing unit receives and processes the image data from the multi-view imaging system.
[0051] S2: preprocessing the collected wine bottle image sample data to obtain a wine bottle defect image sample data set;
[0052] Specifically, Figure 2 As shown in the figure, when performing wine bottle defect detection, it is first necessary to collect wine bottle image sample data and preprocess these collected wine bottle image samples to build an image sample data set containing wine bottle defects. Wine bottle sample image data can be obtained from a large number of existing wine bottle images, but since these collected images may contain some invalid data that does not meet the requirements, in order to ensure the reliability of the subsequent training of the deep learning network model based on the wine bottle image sample data, it is necessary to preprocess these image sample data to remove invalid data.
[0053] In this embodiment, the preprocessing of the collected wine bottle image sample data specifically includes the following steps:
[0054] S21: performing data cleaning on the collected wine bottle image sample data, removing the wine bottle image sample data without defects, and retaining the image sample data with defects;
[0055] S22: Automatically annotate the collected image data using Segment Anything Model (SAM) and Label Studio software to generate preliminary annotation results;
[0056] S23: Manually correct the automatic annotation results to ensure the accuracy and completeness of the annotations, and finally generate a high-quality annotation dataset for training.
[0057] S3: Perform data augmentation on the wine bottle defect image sample dataset;
[0058] Specifically, considering the impact of complex environmental factors on the captured illumination of each production line, random brightness change and random contrast change operations were implemented. Taking into account the possible mutual occlusion between adjacent bottles in a specific scene, the image data was randomly erased (Mask) with a probability of 10%. Considering the sudden start and stop of the conveyor belt on the production line, as well as the increase and decrease of speed, some images were motion blurred. Considering the influence of air humidity during the unique "return to the south" climate in the southern region, an additional 200 images of wine bottles immersed in water (wine bottles with water droplets on the surface) were collected to enrich our dataset. In addition, random cropping, random rotation, and various sample random splicing operations were used to enhance the robustness of the model.
[0059] S4: Build an improved YOLO network model;
[0060] Specifically, YOLO is used as a basic network model to avoid the complex steps of generating a large number of candidate regions in the two-stage algorithm, reduce the calculation time and time complexity, and the improved YOLO network model includes a backbone network Backbone, a neck network Neck and a detection head Head, wherein the functions of the backbone network Backbone, the neck network Neck and the detection head Head are as follows:
[0061] The Backbone network is the basic feature extractor for the wine bottle defect detection task. The main task of wine bottle defect detection is to take an image as input and output a feature map corresponding to the input image.
[0062] The neck network Neck is used to connect the backbone network Backbone and the detection head Head. Its main function is to reduce the dimension and adjust the features from the backbone network Backbone to achieve feature fusion in order to better meet the detection needs.
[0063] The detection head Head is used to perform defect detection on the image features obtained after feature fusion through the neck network Neck, thereby realizing the recognition and classification of defects and outputting the corresponding defect detection results.
[0064] In this embodiment, the construction process of the improved YOLO network model includes the following steps:
[0065] S41: Build the traditional YOLO network model;
[0066] Specifically, the traditional YOLO network model includes a backbone network Backbone, a neck network Neck and a detection head Head, the backbone network Backbone and the neck network Neck each include a plurality of C2f modules and a plurality of convolution modules Conv, and the neck network Neck also includes a plurality of tensor connection modules Concat;
[0067] S42: Optimize the backbone network of the traditional YOLO network and replace the C2f module in the original backbone network with the C2f_NDCN module;
[0068] Specifically, if Figure 3 As shown in the figure, a deformable convolution is introduced in the backbone network Backbone to replace the original C2f module. The C2f_NDCN module is constructed by replacing the original Bottleneck module with two deformable convolution layers connected in sequence. Compared with the traditional convolution layer, the deformable convolution layer can adaptively adjust the shape and size of the receptive field according to the different input features. This adaptive feature enables the C2f_NDCN module to extract features more accurately when dealing with defects with irregular shapes and complex textures, and improve the model's detection ability for small targets and complex defects. For different stages, different feature maps, and even different pixels, there may be their optimal convolution kernel structures. By adding an offset to expand the receptive field, the sampling can be closer to the shape and size of the defect, making it more robust.
[0069] Figure 4 The deformable convolution module is shown. First, a bias field with 2N channels is obtained by performing a convolution operation on the input feature map, and then a bias 1pn is formed by the bias matrix of the pixels on the bias field.
[0070] Assume that x represents the input feature map, y represents the output feature map, and p 0 is the position in y, then the output features of traditional convolution and deformable convolution are as follows:
[0071]
[0072] Γ={(-1,-1),(-1,0),…,(0,1),(1,1)}.
[0073] p n is the coordinate in 0, and w represents the weight of the sampling point. However, decimals usually appear at the position after adding the offset, which does not match the actual pixel point. Therefore, an interpolation method is needed to get the offset pixel value. In order to solve the above problem, bilinear interpolation is usually selected.
[0074]
[0075] Among them, I represents the pixel value, I x′y′ Indicates the offset pixel value.
[0076] In the YOLO network, the backbone network Backbone is mainly used to better understand and describe images. It is usually composed of multiple convolutional layers, and different levels of features can be extracted by using different convolutional layer structures. By fusing and integrating features at different levels, more comprehensive and accurate image features can be obtained, thereby improving performance. Therefore, in order to enable the detection model to adaptively adjust the receptive field of the object, consider introducing a deformable convolution module in the backbone of YOLO. First, connect two deformable convolutional layers in sequence to construct a D_Bottleneck module, such as Figure 6 Then, the C2f_DCN module is reconstructed from D_Bottleneck, as Figure 5 Finally, the C2f_DCN module is introduced into the backbone network to replace the original C2f module, as shown in Figure 3 shown.
[0077] S43: Add the multi-head attention mechanism to the backbone network of the YOLO network;
[0078] Specifically, the self-attention (SA) mechanism is a mechanism that effectively captures the dependencies and correlations between different positions in a sequence, improving the performance and generalization ability of the model. SA treats each position in the input sequence as a vector and determines the importance of each position to other positions by calculating the similarity between these vectors. By applying a weighted average based on this similarity, a weighted vector representation is obtained that reflects the importance and contextual information of each position in the sequence. SA consists of three components: query (Q), key (K), and value (V). The formula of SA is expressed as follows:
[0079]
[0080] O = concat(Head 1 ,Head 2 ,...,Head H )
[0081] In the case of multi-head self-attention, the matrices Q, K, and V are obtained from the input data and learned hyperparameters. Assume Q∈R L×D ,K=V∈R L×D ,d K =D, MHSA first performs linear projection on Q, K and V, and obtains
[0082]
[0083] Then, the self-attention operation is performed H times. The outputs of these attention heads are concatenated together. Here
[0084]
[0085] Figure 7 A schematic diagram of an example multi-head self-attention module is shown. By incorporating MHSA into the backbone network of YOLO to parallelly calculate multiple self-attention heads to extract contextual information from input features, the ability of feature representation is enhanced. S44: Optimize the neck network of the traditional YOLO network and use the CARAFE upsampling method for sampling;
[0086] Specifically, traditional upsampling methods usually rely on nearest neighbor interpolation or bilinear interpolation. Although these methods are simple to calculate, they are prone to losing the semantic information and details of the image when processing complex images, especially when detecting subtle defects in wine bottles, which may lead to a decrease in detection accuracy. In order to solve this problem, the present invention adopts the CARAFE upsampling method in the neck structure of the YOLO network. This method dynamically adjusts the upsampling position and generates a content-aware recombinant kernel based on the semantic information and contextual relationship of the input image to better capture the shape and texture characteristics of the defect, such as Figure 8 shown.
[0087] When dealing with wine bottle defects, the CARAFE upsampling method has the following advantages over the nearest neighbor interpolation method:
[0088] 1. CARAFE upsampling can dynamically adjust the interpolation position according to the semantic information and context of the input image, and can better capture the shape and texture features of defects in a wide field of view, while the nearest neighbor interpolation upsampling simply copies the closest pixel value without considering the semantic structure and context information of the image;
[0089] 2. CARAFE upsampling utilizes the idea of deformable convolution, which can dynamically adjust the interpolation position according to the characteristic structure of the defect image;
[0090] 3. CARAFE upsampling better preserves image detail information, especially at the edges and details, by dynamically adjusting the interpolation position.
[0091] S45: Combining the optimized backbone network Backbone, neck network Neck and detection head Head to obtain the improved YOLO network model.
[0092] S5: Use the wine bottle defect image sample dataset to train the improved YOLO network model to obtain a wine bottle defect detection model;
[0093] Specifically, step S5 includes the following steps:
[0094] S51: Divide the wine bottle defect image sample dataset into a training set, a validation set, and a test set in a ratio of 8:1:1;
[0095] S52: input the training set into the improved YOLO network model for training to obtain the optimal parameters of the model;
[0096] Specifically, when training the improved YOLO network model, Wise-IoU based on the dynamic non-monotonic focusing mechanism is used as the bounding box regression loss function.
[0097] In this embodiment, a loss function is used to obtain the error between the predicted box and the true value to evaluate the performance of the target detection model; the loss function Loss consists of three parts, including the boundary loss function loss box , confidence loss function loss obj And classification loss function loss cls ; The overall loss function is as follows:
[0098] Loss = λ box loss box +λ obj loss obj +λ cls loss cls
[0099] In the formula, λ box , obj and λ cls They represent the positioning loss weight, confidence loss weight, and classification loss weight respectively.
[0100] The boundary loss function uses Wise-IoU based on a dynamic non-monotonic focusing mechanism as the bounding box regression loss function to weaken the influence of geometric factors on anchor box regression and accelerate the training and reasoning speed of the network. The WIoU loss function is calculated as follows:
[0101] L WIoUv1 =R WIoU L IoU
[0102]
[0103] L WIoU =kL WIoUv1
[0104] Among them, L IoU The number loU, R, representing the bounding box loss WIoU represents the distance attention, x and y are the horizontal and vertical coordinates of the center point of the prediction box, respectively. gt ,y gt are the horizontal and vertical coordinates of the center point of the real frame, W g , H gare the width and height of the minimum bounding rectangle of the predicted box and the true box, respectively. * indicates a separation operation, which helps to eliminate factors that hinder convergence and thus improve the convergence speed. k is the non-monotonic focusing coefficient.
[0105] S53: Input the optimal parameters and validation set data into the improved YOLO network model, calculate the prediction accuracy of the model, and adjust the hyperparameters of the model based on this, and finally select the model with the highest prediction accuracy in the validation set as the optimal improved YOLO model;
[0106] S54: Finally, the test set data is input into the optimized YOLO model, its prediction accuracy is calculated, and the final wine bottle defect detection model is determined based on the results of the test set.
[0107] S6: Perform defect detection on the image of the wine bottle to be inspected through the wine bottle defect detection model to obtain the wine bottle defect detection result.
[0108] Specifically, defect detection is performed on the image of the wine bottle to be inspected through the wine bottle defect detection model, that is, the image of the wine bottle to be inspected is input into the wine bottle defect detection model, the wine bottle defect detection model detects and identifies the image of the wine bottle to be inspected, selects the defect position, and identifies the specific type of the defect, and then outputs the corresponding wine bottle defect detection result.
[0109] Furthermore, the present invention also provides a wine bottle defect detection device based on improved YOLO, comprising a processor and a memory for storing executable instructions of the processor, wherein the processor is configured to execute the wine bottle defect detection method based on improved YOLO as described above by executing the executable instructions.
[0110] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A wine bottle defect detection method based on improved YOLO, characterized in that: The method comprises the following steps: Build a machine vision inspection platform to collect wine bottle sample information from multiple angles; Preprocess the collected wine bottle image sample data to obtain a wine bottle defect image sample data set; Perform data augmentation on the wine bottle defect image sample dataset; Build and improve the YOLO network model; The improved YOLO network model is trained using the wine bottle defect image sample dataset to obtain a wine bottle defect detection model; The wine bottle defect detection model is used to perform defect detection on the image of the wine bottle to be inspected, and the wine bottle defect detection result is obtained.
2. The wine bottle defect detection method based on improved YOLO according to claim 1 is characterized in that: In the step of building a machine vision inspection platform and collecting wine bottle sample information from multiple angles, the vision inspection platform includes a suspended clamping and conveying mechanism, a multi-view imaging system and a signal processing unit. The suspended clamping and conveying mechanism is used to stably fix the wine bottle on the conveyor belt and ensure that the wine bottle can rotate 360 degrees during the conveying process, so that the wine bottle can be photographed by cameras at multiple angles during the movement; the multi-view imaging system cooperates with the suspended clamping and conveying mechanism, and when the wine bottle passes through the conveyor belt, multiple cameras photograph the wine bottle to capture images of the wine bottle at various angles; the signal processing unit receives and processes image data from the multi-view imaging system.
3. The wine bottle defect detection method based on improved YOLO according to claim 1 is characterized in that: The step of preprocessing the collected wine bottle image sample data to obtain a wine bottle defect image sample data set specifically includes: Performing data cleaning on the collected wine bottle image sample data, removing the wine bottle image sample data without defects, and retaining the image sample data with defects; Automatically annotate the collected image data using the Segment Anything Model and Label Studio software to generate preliminary annotation results; The automatic annotation results are manually corrected to ensure the accuracy and completeness of the annotations, and finally a high-quality annotation dataset is generated for training.
4. The wine bottle defect detection method based on improved YOLO according to claim 1 is characterized in that: The steps of constructing an improved YOLO network model specifically include: Constructing a traditional YOLO network model, wherein the traditional YOLO network model includes a backbone network Backbone, a neck network Neck and a detection head Head, wherein the backbone network Backbone and the neck network Neck both include multiple C2f modules and multiple convolution modules Conv; The backbone network of the traditional YOLO network is optimized, and the C2f_NDCN module replaces the C2f module in the original backbone network; Add the multi-head attention mechanism to the backbone network of the YOLO network; The neck network of the traditional YOLO network is optimized and sampled using the CARAFE upsampling method; The optimized backbone network Backbone, neck network Neck and detection head Head are combined to obtain the improved YOLO network model.
5. The wine bottle defect detection method based on improved YOLO according to claim 4 is characterized in that: In the step of optimizing the backbone network of the traditional YOLO network and replacing the C2f module in the original backbone network with the C2f_NDCN module, the C2f_NDCN module is constructed by replacing the original Bottleneck module with two sequentially connected deformable convolutional layers. Compared with the traditional convolutional layer, the deformable convolutional layer can adaptively adjust the shape and size of the receptive field according to different input features.
6. The wine bottle defect detection method based on improved YOLO according to claim 4 is characterized in that: In the step of adding the multi-head attention mechanism to the backbone network of the YOLO network, the multi-head attention mechanism is added to the backbone network of the YOLO network to calculate multiple self-attention heads in parallel, so as to extract context information from the input features and enhance the ability of feature representation.
7. The wine bottle defect detection method based on improved YOLO according to claim 4 is characterized in that: The steps of optimizing the neck network of the traditional YOLO network and using the CARAFE upsampling method for sampling specifically include: using the CARAFE upsampling method in the neck network for upsampling, and dynamically adjusting the upsampling position to better retain the detailed information of the image, especially at the edges and subtle defect areas, thereby improving the detection accuracy of wine bottle defects.
8. The wine bottle defect detection method based on improved YOLO according to claim 1, characterized in that: In the step of training the improved YOLO network model using the wine bottle defect image sample dataset to obtain the wine bottle defect detection model, a loss function is used to obtain the error between the predicted box and the true value to evaluate the performance of the target detection model. The loss function Loss consists of three parts, including the boundary loss function loss box , confidence loss function loss obj And classification loss function loss cls ; The overall loss function is as follows: Loss=λ box loss box +λ obj loss obj +λ cls loss cls In the formula, λ box , obj and λ cls They represent the positioning loss weight, confidence loss weight, and classification loss weight respectively.
9. The wine bottle defect detection method based on improved YOLO according to claim 8, characterized in that: The boundary loss function uses Wise-IoU based on a dynamic non-monotonic focusing mechanism as the bounding box regression loss function to weaken the influence of geometric factors on anchor box regression and accelerate the training and reasoning speed of the network. The calculation method of the WIoU loss function is: L WIoUv1 =R WIoU L IoU L WIoU =kL WIoUv1 Among them, L IoU The number loU, R, representing the bounding box loss WIoU represents the distance attention, x and y are the horizontal and vertical coordinates of the center point of the prediction box, respectively. gt ,y gt are the horizontal and vertical coordinates of the center point of the real frame, W g , H g are the width and height of the minimum bounding rectangle of the predicted box and the true box, respectively. * indicates a separation operation, which helps to eliminate factors that hinder convergence and thus improve the convergence speed. k is the non-monotonic focusing coefficient.
10. A wine bottle defect detection device based on improved YOLO, characterized in that: The device includes a processor and a memory for storing executable instructions of the processor, and the processor is configured to execute the wine bottle defect detection method based on improved YOLO according to any one of claims 1 to 9 by executing the executable instructions.