Method and system for identifying fine impurities in wine bottle

By combining the YOLO target detection algorithm and image key point detection algorithm, the establishment of impurities recognition and detection model in the bottle can solve the problem of low efficiency and poor accuracy of small fine impurity detection in the bottle, achieve efficient and accurate impurity recognition, reduce leakage and reduce leakage Check.

CN119379592APending Publication Date: 2025-01-28NANJING STARHELIX INTELLIGENT CO LTD +1
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411253064.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

The prior art is difficult to achieve automated, efficient and accurate detection of fine impurities in wine bottles, resulting in low detection efficiency, poor results and frequent missed inspections.

Method used

Combining the YOLO target detection algorithm and image key point detection and attitude recognition algorithm, establish a model of impurities recognition detection models, and combine the target detection and key points detection to achieve precise identification of small impurities.

Benefits of technology

It significantly improves the detection rate of small impurities, reduces the problem of missed inspection, improves the stability and reliability of the detection, improves the identification accuracy and credibility, and meets the needs of alcohol production quality monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119379592A_ABST
    Figure CN119379592A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for identifying small impurities in a wine bottle. The method comprises the following steps: acquiring picture data of the impurities in the bottle; based on a target detection algorithm and a key point detection algorithm, establishing an impurity identification detection model, and inputting the impurity picture data into the impurity identification detection model for training; combining a classification loss function, a monitoring frame loss function, a key point loss function and a key point confidence coefficient loss function, endowing each type of loss function with an adjustable weight, and evaluating the accuracy of the impurity identification detection model for impurity position, category and key point detection; and utilizing the trained and optimized impurity identification detection model to detect and obtain an impurity region and an impurity category. By combining the YOLO target detection algorithm and the image key point detection and posture recognition algorithm, accurate and automatic detection of the fine impurities in the bottled wine is innovatively realized, the detection rate of broken and small particles is remarkably improved, and the problem of a large amount of missing detection in a traditional method is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of fine impurity detection, and in particular to a method and system for identifying fine impurities in a wine bottle. Background Art

[0002] During the production process of bottled liquids (such as wine and beverages), small impurities may remain in the bottle, such as broken glass slag in unqualified bottled wine. This is a major challenge in the inspection of bottled wine. Manual inspection and ordinary machine recognition cannot meet the huge demand on the assembly line, and the inspection effect is poor, with a large degree of missed detection, which is not conducive to improving the efficiency of the entire production line. With the development and maturity of a series of target detection technologies in the field of deep learning, the problem of detecting small impurities can also be solved efficiently and accurately.

[0003] At present, the methods for automatic recognition, detection and processing of graphic images using computers mainly include the following: 1. Threshold-based segmentation method: This method uses one or several thresholds to divide the image into several classes, and believes that pixels in the same class belong to the same object. This method ignores the spatial characteristics of the image. In the experiment, there are problems such as low recall rate, poor anti-noise effect, and high requirements for the quality of the original data image. 2. Edge-detection-based method: This method is based on the discontinuity of the image for segmentation, including methods based on local image functions, image filtering, multi-scale methods, etc. This method is difficult to detect edges when processing images with rich details, and is greatly disturbed by noise. 3. Region-based method: This method extracts connected feature regions in the image according to pre-defined standards. In this method, each region to be extracted must be manually given an initial seed point, and it is also sensitive to noise changes. 4. Deep learning-based method: This method uses a multi-layer neural network to process and interpret the image, and adjusts the weights and biases between nodes for learning. It is often used in image classification, target detection and other fields, but the model is a black box and difficult to explain with a rigorous mathematical definition. Currently, there are few methods directly applied to the detection of small impurities in bottled wine, and the existing methods have a low degree of automation and require manual intervention. In addition, most algorithms are not as effective in detecting small objects as they are in detecting objects of normal size, and the detection efficiency is low and the effect is poor. Summary of the invention

[0004] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.

[0005] In view of the above existing problems, the present invention is proposed. Therefore, the present invention provides a method for identifying fine impurities in a wine bottle to solve the problem of automatic, efficient and accurate detection of fine impurities in bottled wine, improve detection efficiency and accuracy, and reduce the problems of missed detection and manual intervention.

[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0007] In a first aspect, the present invention provides a method for identifying fine impurities in a wine bottle, comprising:

[0008] Get the image data of impurities in the bottle;

[0009] Based on the target detection algorithm and the key point detection algorithm, an impurity recognition detection model is established, and the impurity image data is input into the impurity recognition detection model for training;

[0010] Combining the classification loss function, the monitoring bounding box loss function, the key point loss function and the key point confidence loss function, and assigning adjustable weights to each loss function, the accuracy of the impurity recognition and detection model for impurity position, category and key point detection is evaluated;

[0011] The impurity identification and detection model after training and optimization is used to detect the impurity area and impurity category.

[0012] As a preferred solution of the method for identifying fine impurities in a wine bottle according to the present invention, the impurity identification detection model includes:

[0013] The impurity identification and detection model uses YOLO as a model framework to extract and classify impurities;

[0014] The YOLO backbone network is used to extract the key features of the impurity image data and obtain a key feature map;

[0015] The key feature map is further extracted using the YOLO neck network to obtain the location information of the impurities;

[0016] The position information of the impurity is processed by using a bounding box and grid division to obtain a plurality of impurity candidate regions.

[0017] As a preferred solution of the method for identifying fine impurities in a wine bottle according to the present invention, the key point detection algorithm includes:

[0018] A regional key point detection algorithm is added to the YOLO head network to improve the YOLO head network;

[0019] The improved YOLO head network is used to obtain the impurity features of the impurity candidate area, and the key point positions of the impurities are obtained and the impurity categories are determined according to the impurity features.

[0020] As a preferred solution of the method for identifying fine impurities in a wine bottle according to the present invention, the key point loss function includes:

[0021] According to the key points obtained by the impurity recognition detection model, the target key point similarity of each key point is calculated to obtain the key point loss function. The key point loss function is expressed as:

[0022]

[0023] Among them, d n represents the Euclidean distance between the predicted and annotated positions of the nth key point, δ(v n ) represents the visibility flag of each key point, OKS is the target key point similarity, i, j represents the key point position, s is the scale, k is the anchor point, Nkpts is the total number of key points, and n is the key point sequence number;

[0024] The key point loss function is back-propagated to update the impurity recognition detection model to obtain the true position of the key point.

[0025] As a preferred solution of the method for identifying fine impurities inside a wine bottle according to the present invention, the monitoring frame loss function includes:

[0026] Compare the predicted bounding box predicted by the impurity recognition detection model with the actual bounding box position, obtain the union-intersection ratio, and calculate the positioning loss according to the union-intersection ratio;

[0027] Based on the positioning loss, the monitoring frame loss is calculated and expressed as:

[0028]

[0029] Among them, L box To monitor the border loss function, is the true bounding box position, is to predict the bounding box position, CIoU is the positioning loss, i, j represent the key point position, s is the scale, and k is the anchor point.

[0030] As a preferred solution of the method for identifying fine impurities inside a wine bottle according to the present invention, the key point confidence loss function includes:

[0031] Based on the binary cross entropy function, the confidence loss of the key points is calculated and expressed as:

[0032]

[0033] Among them, L kpts_conf is the key point confidence loss function, Nkpts is the total number of key points, i, j represents the key point position, s is the scale, k is the anchor point, δ(v n ) represents the visibility flag of each key point, BCE is the binary cross entropy loss, is the confidence of the nth key point.

[0034] As a preferred solution of the method for identifying fine impurities in a wine bottle according to the present invention, the impurity image data includes:

[0035] Get the impurity image data and label the key point position labels of the impurities in the impurity image data. The label format of the label file is:

[0036] (cls, x_center, y_center, w, h, px1, py1, visible)

[0037] Among them, cls is the label number, x_center is the x-coordinate of the center position of the target rectangular box, y_center is the y-coordinate of the center position of the rectangular box target, w is the width of the target rectangular box, h is the height of the target rectangular box, px1 represents the horizontal coordinate in the key point detection, py1 represents the vertical coordinate in the key point detection, and visiable is the visibility of the key point.

[0038] In a second aspect, the present invention provides a system for identifying fine impurities in a wine bottle, comprising:

[0039] A data acquisition module is used to obtain image data of impurities in the bottle;

[0040] A model training module is used to establish an impurity recognition detection model based on a target detection algorithm and a key point detection algorithm, and input the impurity image data into the impurity recognition detection model for training;

[0041] An optimization module, for combining a classification loss function, a monitoring bounding box loss function, a key point loss function, and a key point confidence loss function, and assigning adjustable weights to each type of loss function, to evaluate the accuracy of the impurity recognition detection model for impurity location, category, and key point detection;

[0042] The impurity identification module is used to detect and obtain the impurity area and impurity category using the trained and optimized impurity identification detection model.

[0043] In a third aspect, the present invention provides a computing device, comprising:

[0044] Memory and processor;

[0045] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the method for identifying fine impurities inside a wine bottle are implemented.

[0046] In a fourth aspect, the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the method for identifying fine impurities inside a wine bottle.

[0047] Compared with the prior art, the present invention has the following beneficial effects: the present invention innovatively realizes accurate and automated detection of fine impurities inside bottled wine by combining the YOLO target detection algorithm with the image key point detection and posture recognition algorithm. This method not only significantly improves the detection rate of broken small particles and solves the problem of a large number of missed detections in traditional methods, but also ensures the stability and reliability of the detection model by paying attention to the loss changes of the key points of impurity pixels; combining target detection with image key point detection technology greatly improves the recognition accuracy and credibility of fine impurities, making the output results more in line with actual production needs, providing strong technical support for wine production quality monitoring, and effectively promoting the dual improvement of production efficiency and product quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:

[0049] Figure 1 This is a schematic diagram of the overall process of a method for identifying fine impurities inside a wine bottle according to an embodiment of the present invention;

[0050] Figure 2 This is a schematic diagram of an impurity identification and detection model architecture of a method for identifying fine impurities inside a wine bottle according to an embodiment of the present invention;

[0051] Figure 3 This is a schematic diagram of a target detection pose model of a method for identifying fine impurities inside a wine bottle according to an embodiment of the present invention;

[0052] Figure 4 A schematic diagram of changes in training iteration parameters of a method for identifying fine impurities inside a wine bottle according to an embodiment of the present invention;

[0053] Figure 5 A schematic diagram of a classification confusion matrix of a method for identifying fine impurities inside a wine bottle according to an embodiment of the present invention;

[0054] Figure 6 This is a schematic diagram of the key point prediction results of the method for identifying fine impurities inside a wine bottle according to an embodiment of the present invention;

[0055] Figure 7 This is a schematic diagram of the detection results of transparent glass residues in a wine bottle according to a method for identifying fine impurities in a wine bottle according to an embodiment of the present invention. DETAILED DESCRIPTION

[0056] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.

[0057] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0058] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0059] The present invention is described in detail with reference to schematic diagrams. When describing the embodiments of the present invention, for the sake of convenience, the cross-sectional diagrams showing the device structure will not be partially enlarged according to the general scale, and the schematic diagrams are only examples, which should not limit the scope of protection of the present invention. In addition, in actual production, the three-dimensional dimensions of length, width and depth should be included.

[0060] At the same time, in the description of the present invention, it should be noted that the orientations or positional relationships indicated by the terms "upper, lower, inner and outer" are based on the orientations or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the system or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first, second or third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0061] In the present invention, unless otherwise clearly specified and limited, the terms "install, connect, connect" should be understood in a broad sense, for example: it can be a fixed connection, a detachable connection or an integral connection; it can also be a mechanical connection, an electrical connection or a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0062] Example 1

[0063] Reference Figure 1-2 , which is an embodiment of the present invention, provides a method for identifying fine impurities in a wine bottle, comprising:

[0064] S100: Obtain image data of impurities in the bottle;

[0065] In the embodiment of the present application, broken glass slag, fine millet grains, fine gravel and fine iron wire in the bottle are selected as examples for explanation;

[0066] Specifically, we took pictures of impurities in the bottle and preprocessed them. The preprocessing included: data enhancement and flipping of the impurity pictures. Considering the transparent characteristics of glass slag impurities, we used a given external normal light source to illuminate the broken glass slag in the bottle, making the imaging and refraction of the broken glass slag in the bottle more obvious, highlighting the maximum change characteristics of the pixel gradient in a small area.

[0067] Preferably, the impurity image data is obtained, and the key point position labels of the impurities in the impurity image data are annotated. The label format of the annotation file is:

[0068] (cls, x_center, y_center, w, h, px1, py1, visible)

[0069] Where cls is the label number, x_center is the x-coordinate of the center of the target rectangle, y_center is the y-coordinate of the center of the target rectangle, w is the width of the target rectangle, h is the height of the target rectangle, px1 represents the horizontal coordinate in key point detection, py1 represents the vertical coordinate in key point detection, and visiable is the visibility of the key point;

[0070] After obtaining and preprocessing the image data of impurities in the bottle, the image data is divided into a training set and a validation set, and the collected original images are annotated using data annotation tool software packages such as LabelImg and converted into a key point detection format. After the training set data is input into the subsequent impurity recognition and detection model training, the impurity area and category are obtained by using manual annotation plus impurity recognition and detection model annotation;

[0071] It should be noted that the present invention adopts manual labeling method plus machine recognition labeling method to generate high-quality label files. Compared with single automatic labeling, manual labeling can greatly improve the accuracy of the model. Compared with single manual labeling, machine participation in labeling can not only improve efficiency, but also reduce manual missed detection.

[0072] S102: Based on the target detection algorithm and the key point detection algorithm, an impurity recognition detection model is established, and the impurity image data is input into the impurity recognition detection model for training;

[0073] Preferably, the impurity recognition detection model uses YOLO as a model framework to extract and classify impurities; uses the YOLO backbone network to extract key features of impurity image data and obtain key feature maps; uses the YOLO neck network to further extract key feature maps and obtain the location information of impurities; uses the bounding box and grid division to process the location information of impurities and obtain multiple impurity candidate regions; adds a regional key point detection algorithm to the YOLO head network and improves the YOLO head network; uses the improved YOLO head network to obtain impurity features of the impurity candidate region, and obtains the key point position of the impurity and judges the impurity category according to the impurity features; the impurity recognition detection model architecture used in the present invention is as follows Figure 2 As shown;

[0074] In the embodiment of the present application, the YOLOv8 framework is preferred. This cutting-edge computer vision model has the characteristics of fast speed and high precision, and performs well in the small target detection task in complex environments. First, the yolov8l-pose.yaml configuration file is customized to nc:4, which represents four types of impurities, namely pin (iron wire), sand (gravel), glass (glass slag), and rice (millet grains); the key point parameter kpt_shape = [1,3] represents that there is a key point on each image, and the key point consists of a horizontal coordinate, a vertical coordinate, and a visibility triplet attribute; during the model training process, the features of the key point area image are continuously extracted from the image data set, and the deep image information is extracted in the layer-by-layer convolution process, and then the extracted information is used to detect and identify the key points of the image. The training optimizer uses the Adam optimizer for learning optimization, and the convergence process is fast and stable;

[0075] Specifically, the impurity image data is used as input and sent to the impurity recognition detection model built based on YOLOv8 for training. The core structure of the YOLOv8 model includes the backbone network (BackBone), the neck network (Neck) and the detection head network (Head);

[0076] The backbone network is responsible for extracting the key features of the input image and generating feature maps; the neck network further fuses these feature maps to enhance the expression of multi-scale features; and the detection head network is responsible for generating the final detection results, including the location information and classification category of impurities.

[0077] In order to meet the challenge of small impurity detection, the present invention pays special attention to the application of the YOLOv8-Pose model. This model adds a pose estimation head (Keypoints), that is, a key point detection algorithm, on the basis of YOLOv8, which can simultaneously detect the position, classification and key point information of impurities; however, it is worth noting that the impurity recognition detection model of the present invention does not mandatory include a pose estimation head. According to the needs of the actual application scenario, it can be flexibly selected whether to remove the pose estimation head. If the task only needs to detect the position and classification of impurities, removing the pose estimation head can significantly reduce the computational overhead and improve the detection efficiency without losing the necessary detection accuracy; on the contrary, if the task needs to detect the key point information of impurities, retaining the pose estimation head becomes a necessary choice.

[0078] It should be noted that when constructing the impurity recognition and detection model, the present invention not only takes into account the versatility and flexibility of the model, but also takes into account the specific needs in practical applications. Through training and optimization, a detection model is finally obtained that can efficiently and accurately identify and classify impurities in images, providing strong support for subsequent image processing and quality control.

[0079] S104: combining the classification loss function, the monitoring border loss function, the key point loss function and the key point confidence loss function, and assigning adjustable weights to each loss function, to evaluate the accuracy of the impurity recognition detection model in detecting the impurity position, category and key points;

[0080] In the embodiment of the present application, four types of loss functions with adjustable weights are expressed as:

[0081]

[0082] Among them, Loss is the total loss function of the impurity recognition detection model, L kpts is the key point loss function, L box To monitor the border loss function, L kpts_conf is the key point confidence loss function, L cls is the classification loss function, λcls, λbox, λkpts, and λkpts_conf are four given adjustable loss weight coefficients, i and j represent the key point positions, s is the scale, k is the anchor point, and Nkpts is the total number of key points;

[0083] Preferably, according to the key points obtained by the impurity recognition detection model, the target key point similarity of each key point is calculated to obtain the key point loss function, and the key point loss function is calculated as:

[0084]

[0085] Among them, L kpts is the key point loss function, d n represents the Euclidean distance between the predicted and annotated positions of the nth key point, δ(v n ) represents the visibility flag of each key point, OKS is the target key point similarity, i, j represents the key point position, s is the scale, k is the anchor point, Nkpts is the total number of key points, and n is the key point sequence number;

[0086] It should be noted that δ(v n ) has a value range of 1 / 0. For each key point, a confidence parameter is learned using the visibility mark of the key point to show whether there is a key point at that location. In the embodiment of the present application, the visibility mark of the key point is obtained by means of a marking box;

[0087] Preferably, the key point loss function is back-propagated to update the impurity recognition detection model to obtain the true position of the key point;

[0088] It should be noted that the key point loss function L about the target key point similarity (OKS) kpts The OKS loss should essentially be scale-invariant and not prone to vanishing gradients. Each bounding box stores the entire posture information, so if the annotation box matches the predicted box in position and scale, the key points relative to the anchor center are predicted. The OKS of each key point is calculated separately and the final OKS is obtained by summing them.

[0089] Preferably, the predicted bounding box predicted by the impurity recognition detection model is compared with the actual bounding box position, the union-intersection ratio is obtained, and the positioning loss is calculated according to the union-intersection ratio; based on the positioning loss, the monitoring frame loss is calculated and obtained, which is expressed as:

[0090]

[0091] Among them, L box To monitor the border loss function, is the true bounding box position, is to predict the bounding box position, CIoU is the positioning loss, i, j represents the key point position, s is the scale, and k is the anchor point;

[0092] In the embodiment of the present application, the calculation formula for calculating the cross ratio is:

[0093]

[0094] Among them, Intersection(Pred, Tag) represents the intersection area of ​​the true bounding box Tags and the predicted bounding box Prediction, and Union(Pred, Tag) represents the union area of ​​the true bounding box and the predicted bounding box.

[0095] In the embodiment of the present application, the positioning loss L is calculated CIoU The formula is:

[0096]

[0097]

[0098]

[0099] Among them, v is the consistency parameter of the predicted annotation box aspect ratio, α is the weight parameter, which represents the proportion of the predicted annotation box aspect ratio in the loss, w and h are the width and height of the real rectangular box, and w gt 、h gt is the width and height of the predicted rectangular box, b is the center point of the real rectangular box, and b gt is the center point of the predicted rectangular box, ρ is the two-dimensional Euclidean distance between the center point of the real rectangular box and the predicted rectangular box, and c is the diagonal distance between the minimum closure area of ​​the real rectangular box and the predicted rectangular box.

[0100] Preferably, based on the binary cross entropy function, the confidence loss of the key points is calculated and expressed as:

[0101]

[0102] Among them, L kpts_conf is the key point confidence loss function, Nkpts is the total number of key points, i, j represents the key point position, s is the scale, k is the anchor point, δ(v n ) represents the visibility flag of each key point, and BCE is the binary cross entropy loss;

[0103] In the embodiment of the present application, the binary cross entropy function BCE formula is:

[0104]

[0105] Among them, BCE is the binary cross entropy loss function, p represents the confidence prediction of the impurity detection and recognition model for the key point, and y represents the true label of a key point;

[0106] It should be noted that in the binary classification problem, for the probability p, the impurity detection and recognition model usually outputs a probability value between 0 and 1, indicating the possibility that the model believes that the key point exists in the image; the value of y is usually 0 or 1;

[0107] It should be noted that when constructing the impurity identification and detection model, the present invention preferably selects the classification loss function, the monitoring border loss function, the key point loss function and the key point confidence loss function to comprehensively evaluate and optimize the model performance; the key point loss function is based on OKS calculation to ensure that the model accurately predicts the key point position at different scales; the monitoring border loss adopts CIoU, which comprehensively considers the border overlap, aspect ratio and center point distance to improve the positioning accuracy; the key point confidence loss is based on BCE to evaluate the model's ability to predict the existence of key points; the selection of these loss functions is aimed at optimizing the model's accuracy in impurity position, category and key point detection. By adjusting the weights of each loss function, the model training can be flexibly adjusted according to task requirements to achieve the best detection effect. Such a design enables the model to still stably and accurately complete the impurity identification task in complex scenarios.

[0108] S106: Using the trained and optimized impurity recognition and detection model to detect and obtain the impurity area and impurity category;

[0109] In the embodiment of the present application, in order to verify whether the impurity recognition detection model plays a key role in the detection and recognition of fine impurities in wine bottles in an engineering environment, using a visual model chart to explain the important parameters of the training process is a very important reference basis;

[0110] The YOLO target detection framework provides a comprehensive chart showing the changing trends of important indicator parameters during the model training iteration process, such as the commonly used Box and Pose loss curves, precision, recall, mAP50, and mAP50-95 indicators. In addition, the YOLO target detection framework also provides a real-time classification confusion matrix drawing chart. For the detection and identification of the four types of impurities, the network model can directly detect and classify various types of small impurities through the confusion matrix.

[0111] By observing some of the annotated diagrams of the model verification process, such as Figure 5 As shown, it can be seen that the model's attention to the characteristics of the impurity area inside the wine bottle is almost consistent with the parts that are paid attention to by careful manual classification. Based on this, it can be seen that the detection and classification basis of the model trained by this method is relatively reasonable and meets production needs.

[0112] The above is a schematic scheme of a method for identifying fine impurities in a wine bottle in this embodiment. It should be noted that the technical scheme of the system for identifying fine impurities in a wine bottle and the technical scheme of the method for identifying fine impurities in a wine bottle are of the same concept. For details not described in detail in the technical scheme of the system for identifying fine impurities in a wine bottle in this embodiment, please refer to the description of the technical scheme of the method for identifying fine impurities in a wine bottle.

[0113] In this embodiment, the system for identifying fine impurities in a wine bottle includes:

[0114] A data acquisition module is used to obtain image data of impurities in the bottle;

[0115] The model training module is used to establish an impurity recognition and detection model based on the target detection algorithm and the key point detection algorithm, and input the impurity image data into the impurity recognition and detection model for training;

[0116] The optimization module is used to combine the classification loss function, the monitoring bounding box loss function, the key point loss function and the key point confidence loss function, and assign adjustable weights to each loss function to evaluate the accuracy of the impurity recognition detection model for impurity location, category and key point detection;

[0117] The impurity identification module is used to detect and obtain the impurity area and impurity category using the trained and optimized impurity identification detection model.

[0118] This embodiment also provides a computing device suitable for identifying fine impurities inside a wine bottle, including:

[0119] Memory and processor; the memory is used to store computer executable instructions, and the processor is used to execute computer executable instructions to implement the method for identifying fine impurities inside a wine bottle as proposed in the above embodiment.

[0120] This embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the method for identifying fine impurities inside a wine bottle as proposed in the above embodiment is implemented.

[0121] The storage medium proposed in this embodiment and the method for identifying fine impurities inside a wine bottle proposed in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be found in the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0122] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ReadOnly, Memory, ROM), random access memory (RandomAccess Memory, RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform the methods of various embodiments of the present invention.

[0123] Example 2

[0124] Reference Figure 3-7 , which is an embodiment of the present invention, provides a method for identifying fine impurities inside a wine bottle. In order to verify its beneficial effects, the experimental results of the present invention are provided.

[0125] In this example, there are 4 types of fine impurity images, of which 930 are used for training and 140 are used as validation sets. Since the data is obtained from video streams, there are external factors such as low image resolution. Therefore, the data is enhanced on the original training set, and rotation and flipping operations are performed. The multi-scale training strategy is introduced to improve the generalization ability of the impurity recognition and detection model;

[0126] During training, the image enhancement operation is set to degrees = 180.0, and the rotation enhancement effect is introduced. At the same time, scaling enhancement is introduced, and the scaling factor is set to 0.5. At the same time, the left-right flip probability is set to fliplr = 0.0, and the left-right symmetric key point space phenomenon is not considered.

[0127] This impurity recognition detection model uses the target detection pose model, the structure is as follows Figure 3 As shown, the target detection pose model parameters epochs training rounds, batch training batch size, imgsz training image size, multi_scale whether to adopt a multi-scale training strategy, the parameter settings are as follows:

[0128] epochs=200, batch=32, imgsz=640, multi_scale=true

[0129] The multi-scale training strategy is used to improve the performance of the model in detecting small targets or in high-resolution images, with the aim of enhancing the model's generalization ability and improving the model's robustness.

[0130] The target detection pose model will calculate the loss according to the entire loss function formula and back-propagate to update the target detection pose model parameters. Since the task type is to consider pose detection of small impurities, the calculation weight coefficient hyperparameters of the loss function must also be adjusted accordingly.

[0131] The original box loss coefficient box is set to box=0.01, the classification loss coefficient cls remains unchanged, and the regression distribution loss is set to dfl=0.01. This setting means that the loss will be largely affected by the key points rather than the box border, making the training less sensitive to differences in IoU.

[0132] After the target detection pose model is trained, it is used to detect the location of small impurities in the wine bottle. The confidence threshold confthreshold and coverage threshold iouthreshold need to be set during the target detection pose model inference prediction. The confidence threshold is the weight of the confidence loss in the model loss function. A higher confidence threshold will filter more detection frames and only retain detection frames with higher confidence probability. The coverage threshold is the intersection-over-union (IoU) loss in the model loss. The lower the coverage, the lower the tolerance for overlap between detection frames. When the coverage threshold is 0, the overlapping detection frames will not be displayed. The parameter settings in the example are as follows:

[0133] confthreshold = 0.25 (default), iouthreahold = 0.7

[0134] The final object detection pose model achieved an average precision and recall rate of more than 0.95 on the validation set of four types of impurities, and an average mAP50 of 0.972, which can accurately detect the location of small impurities.

[0135] After using the pose model to train the network model used to complete the task, it is necessary to use performance overhead, accuracy, recall and other evaluation criteria to comprehensively evaluate the final performance of the model. In order to better understand the model's predictions and understand which features play a key role in impurity classification detection, the model can be further optimized. Considering the objective situation that small object recognition is greatly affected by IoU loss, the mAP50 indicator is mainly used as an important criterion for recognition and classification in model evaluation. The training iteration parameter changes are as follows: Figure 4 As shown; the classification confusion matrix is ​​as Figure 5 As shown, Figure 5The performance of the classifier under different categories is clearly and intuitively displayed. By distinguishing true positives, true predictions, false positives, and false negatives, the confusion matrix provides key information for evaluating the accuracy, precision, and recall of the classifier. The blue bar chart highlights the number of actual true cases, while gray and black represent the classification situations where the predictions are true and false, respectively. The matrix not only reflects the performance of the classifier on each category in a quantitative way, but also helps users quickly identify possible problems and improvement directions of the model through intuitive visual comparison.

[0136] According to the method of the present invention, the prediction results of the key points of the four types of impurities are as follows: Figure 6 As shown, in Figure 6 In the experiment, the present invention successfully identified and located four different types of impurities through precise key point prediction technology. These prediction results are not only highly accurate, but also able to capture the key features of impurities, providing a solid foundation for subsequent processing. This step reflects the present invention's high sensitivity and analytical ability to subtle differences in complex environments.

[0137] Furthermore, the test results of transparent glass residue in the bottle are as follows: Figure 7 As shown, Figure 7 The practical application effect of the present invention in the detection of transparent glass slag in bottles is demonstrated. Faced with glass slag with high transparency and difficult to directly observe, the present invention realizes accurate detection and labeling of glass slag through advanced image processing and recognition algorithms.

[0138] In order to further improve the performance of the model in the actual usage environment, the posture head detection at the tail of the model skeleton is finally removed, the detection body is retained, and the posture detection model is converted into a detection model, eliminating additional overhead and obtaining a more efficient detection model for detecting fine impurity particles inside the wine bottle.

[0139] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A method for identifying fine impurities in a wine bottle, characterized in that: include: Get the image data of impurities in the bottle; Based on the target detection algorithm and the key point detection algorithm, an impurity recognition detection model is established, and the impurity image data is input into the impurity recognition detection model for training; Combining the classification loss function, the monitoring border loss function, the key point loss function and the key point confidence loss function, and assigning adjustable weights to each loss function, the accuracy of the impurity recognition and detection model for impurity position, category and key point detection is evaluated; The impurity identification and detection model after training and optimization is used to detect the impurity area and impurity category.

2. The method for identifying fine impurities in a wine bottle according to claim 1, characterized in that: Impurity identification detection models include: The impurity identification and detection model uses YOLO as a model framework to extract and classify impurities; The YOLO backbone network is used to extract the key features of the impurity image data and obtain a key feature map; The key feature map is further extracted using the YOLO neck network to obtain the location information of the impurities; The position information of the impurity is processed by using a bounding box and grid division to obtain a plurality of impurity candidate regions.

3. The method for identifying fine impurities in a wine bottle according to claim 1 or 2, characterized in that: Key point detection algorithms include, A regional key point detection algorithm is added to the YOLO head network to improve the YOLO head network; The improved YOLO head network is used to obtain the impurity features of the impurity candidate area, and the key point positions of the impurities are obtained and the impurity categories are determined according to the impurity features.

4. The method for identifying fine impurities inside a wine bottle as claimed in claim 1, characterized in that: The key point loss function includes, According to the key points obtained by the impurity recognition detection model, the target key point similarity of each key point is calculated to obtain the key point loss function. The key point loss function is expressed as: Among them, L kpts is the key point loss function, d n represents the Euclidean distance between the predicted and annotated positions of the nth key point, δ(v n ) represents the visibility flag of each key point, OKS is the target key point similarity, i, j represents the key point position, s is the scale, k is the anchor point, Nkpts is the total number of key points, and n is the key point sequence number; The key point loss function is back-propagated to update the impurity recognition detection model to obtain the true position of the key point.

5. The method for identifying fine impurities in a wine bottle according to claim 1, characterized in that: The monitoring border loss function includes, Compare the predicted bounding box predicted by the impurity recognition detection model with the actual bounding box position, obtain the union-intersection ratio, and calculate the positioning loss according to the union-intersection ratio; Based on the positioning loss, the monitoring frame loss is calculated and expressed as: Among them, L box To monitor the border loss function, is the true bounding box position, is to predict the bounding box position, CIoU is the positioning loss, i, j represent the key point position, s is the scale, and k is the anchor point.

6. The method for identifying fine impurities in a wine bottle according to claim 1, characterized in that: The key point confidence loss function includes, Based on the binary cross entropy function, the confidence loss of the key points is calculated and expressed as: Among them, L kpts_conf is the key point confidence loss function, Nkpts is the total number of key points, i, j represents the key point position, s is the scale, k is the anchor point, δ(v n ) represents the visibility flag of each key point, and BCE is the binary cross entropy loss.

7. The method for identifying fine impurities in a wine bottle as claimed in claim 1, characterized in that: Impurity image data includes: Get the impurity image data and label the key point position labels of the impurities in the impurity image data. The label format of the label file is: (cls,x_center,y_center,w,h,px1,py1,visiable) Among them, cls is the label number, x_center is the x-coordinate of the center position of the target rectangular box, y_center is the y-coordinate of the center position of the rectangular box target, w is the width of the target rectangular box, h is the height of the target rectangular box, px1 represents the horizontal coordinate in the key point detection, py1 represents the vertical coordinate in the key point detection, and visiable is the visibility of the key point.

8. A system for identifying fine impurities inside a wine bottle, characterized in that: include, A data acquisition module is used to obtain image data of impurities in the bottle; A model training module is used to establish an impurity recognition detection model based on a target detection algorithm and a key point detection algorithm, and input the impurity image data into the impurity recognition detection model for training; An optimization module, for combining a classification loss function, a monitoring bounding box loss function, a key point loss function, and a key point confidence loss function, and assigning adjustable weights to each type of loss function, to evaluate the accuracy of the impurity recognition detection model for impurity location, category, and key point detection; The impurity identification module is used to detect and obtain the impurity area and impurity category using the trained and optimized impurity identification detection model.

9. An electronic device, comprising: Memory and processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the method for identifying fine impurities inside a wine bottle as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the method for identifying fine impurities inside a wine bottle as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Unmanned aerial vehicle target intelligent identification and perception system and method based on deep learning

    CN119649254A

  • Deep Learning-Based UAV Target Intelligent Recognition and Perception System and Method

    CN119649254B

  • Method for evaluating urban space boundary recognition accuracy, medium and program product

    CN120409949A