ALLD-YOLOv6-based low-illumination transparent container liquid detection method
The optimized YOLOv6 model with EfficientRep and PANet backbone, along with a decoupled head, addresses the challenge of liquid detection in transparent containers under low-light conditions, achieving accurate and robust liquid type and content recognition.
Patent Information
- Application Number
- CN202411213698.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-27
AI Technical Summary
Existing liquid detection methods struggle to accurately distinguish between liquids and containers in transparent containers under low-light conditions, leading to false detections or missed detections, and are inadequate in complex environments.
The YOLOv6 model is optimized with a detection head and attention mechanism, enhanced by a backbone network using EfficientRep and PANet structure, and a decoupled prediction head, with a large dataset collected for training, and a decoupled prediction head to improve accuracy and robustness in low-light conditions.
The optimized model, named ALLD-YOLOv6, achieves accurate detection of liquid types and contents in transparent containers, enhancing robustness and performance in low-light environments.
Smart Images

Figure CN119206715A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of target detection, and in particular to a target detection method under low illumination conditions. Background Art
[0002] With the rapid development of modern science and technology, the detection of liquid content in transparent containers has become an important research topic in many fields, especially in application scenarios such as smart agriculture, automated laboratories, and environmental monitoring. The detection of liquid content not only directly affects product quality and safety, but also plays a key role in resource management, environmental protection, and sustainable development. However, most of the current research focuses on detection technology under good lighting conditions, which leads to unsatisfactory application results in low-light environments.
[0003] Existing liquid detection methods usually rely on image processing and machine learning techniques, but the accuracy and reliability of these methods are significantly reduced in low light conditions. Under low light conditions, the increase in image noise and the decrease in contrast blur the boundaries of liquids, making it difficult for detection algorithms to effectively identify the characteristics of liquids. Especially for transparent liquids, traditional algorithms often cannot accurately distinguish the boundary between liquids and containers, resulting in false detections or missed detections. In addition, many traditional algorithms perform poorly in complex environments and cannot meet the needs of practical applications. This situation limits the widespread application of liquid detection technology in actual scenarios, and more effective solutions need to be developed to meet the challenges under low light conditions.
[0004] In order to solve the above problems, the present invention focuses on liquid detection technology under low illumination conditions. In recent years, with the rapid development of deep learning, target detection algorithms based on convolutional neural networks (CNN) have gradually become mainstream. These algorithms can achieve higher detection accuracy in complex environments by learning features from large amounts of data. The YOLO (You Only LookOnce) series of models are widely used in target detection tasks due to their real-time and high efficiency, and have become a powerful tool for liquid detection under low illumination conditions.
[0005] The present invention optimizes the YOLOv6 model, adds a detection head specifically for detecting content, and adds an attention mechanism to the network. Through repeated experiments, the attention mechanism that performs best under low-light conditions is selected, which can achieve more accurate liquid detection under low-light conditions. These optimizations not only improve the robustness of the model in low-light environments, but also enhance its ability to recognize liquid types and contents. We named the method proposed in the present invention ALLD-YOLOv6. Through multi-task learning, this model can simultaneously identify different types of liquids and their specific contents in containers, thereby providing strong technical support for subsequent smart agricultural monitoring, laboratory automation, environmental protection and other fields.
[0006] In addition, in order to promote research in this field, it is crucial to build high-quality datasets. The diversity and accuracy of the dataset directly affect the training effect and actual application performance of the model. Therefore, for liquid detection under low-light conditions, we collected and annotated a large amount of image data in real scenes to ensure the adaptability and accuracy of the model in complex environments. Summary of the invention
[0007] In this paper, we propose a low-illumination transparent container liquid detection method based on ALLD-YOLOv6, so as to improve the current situation that the liquid content in the transparent container is difficult to detect under low illumination conditions.
[0008] The technical solution of the present invention is to improve the YOLOV6 algorithm to design two detection heads, and select the most suitable attention mechanism under low-light conditions through experiments and verification.
[0009] Low-light transparent container liquid detection framework based on ALLD-YOLOv6 Figure 1 As shown in the figure, the framework consists of Backbone, Neck, and Head of ALLD-YOLOv6.
[0010] (1) Backbone network The backbone network of YOLOv6 adopts an innovative architecture called EfficientRep. As an efficient feature extractor, it integrates multiple advanced network design concepts. The RepVGG-style module adopts a multi-branch structure in the training phase, combining 1x1 convolution, 3x3 convolution and identity mapping, and in the inference phase, these branches are merged into a single 3x3 convolution through reparameterization technology, which significantly improves the inference speed.
[0011] Feature extraction:
[0012] Input image Assume that the size of the input image X is H×W×C. After a series of convolutional layers, the generated feature map F can be expressed as:
[0013] (1)
[0014] Conv represents the convolution operation, and its size is H'×W'×C', where H' and W' are the height and width of the feature map after convolution, and C' is the number of channels of the convolution layer output.
[0015] The structure of CSPBlock divides the input feature map F into two parts, F1 and F2, which are then processed through different convolution paths and finally merged. It can be expressed as:
[0016] (2)
[0017] (3)
[0018] (4)
[0019] Concat means concatenation in the channel dimension. σ is the activation function (such as SiLU), BN is batch normalization, Wi and bi are the convolution kernel and bias. Depthwise separable convolution is used in CSPBlock to further improve computational efficiency. The output of depthwise separable convolution is expressed as:
[0020] (5)
[0021] (2) Neck network The neck network of YOLOv6 uses the PANet structure. PANet is a bidirectional pathway network that introduces a bottom-up path in addition to the top-down path, thereby enhancing the multi-scale information fusion capability of the feature map.
[0022] Feature Fusion:
[0023] In PANet, the multi-scale feature maps output by the backbone network (after different degrees of downsampling) are first upsampled and fused through a top-down path, expressed as:
[0024] (6)
[0025] Then, these fused feature maps are passed layer by layer through downsampling in the bottom-up path, expressed as:
[0026] (7)
[0027] (3) Prediction head and loss function In the prediction head, a decoupled head design is adopted. Each output branch is divided into two sub-branches: classification and regression, which are responsible for target classification and bounding box prediction respectively.
[0028] Output branch:
[0029] Each branch consists of a multi-layer convolutional module (ConvModule), including a convolutional layer, a batch normalization layer (BatchNorm), and an activation function (SiLU). Finally, a 1×1 convolutional layer is used to reduce the number of channels and generate the final output, including category prediction, bounding box regression, and target confidence.
[0030] (8)
[0031] (9)
[0032] (10)
[0033] in, , , . The final total loss function is:
[0034] (11)
[0035] in, is the target classification loss, is the bounding box regression loss, and λ is the weight coefficient of the classification loss, which is usually set to 1. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 Low-light transparent container detection framework for ALLD-YOLOv6
[0037] Figure 2 Visualize the predicted boxes
[0038] Figure 3 Test results for transparent container liquid content detection
[0039] Figure 4 Mixed MAP results for each category DETAILED DESCRIPTION
[0040] The present invention is a low-light transparent container liquid detection method based on ALLD-YOLOv6, and the specific steps are as follows:
[0041] (1) First, prepare a training dataset. The training dataset contains 10,000 low-light images taken in real life, which are accurately annotated and labeled for model training.
[0042] (2) To achieve water content detection under low illumination conditions, the constructed framework mainly uses EfficientRep as the backbone network. The network design aims to optimize the efficiency and accuracy of feature extraction while effectively reducing the consumption of computing resources. To further improve the detection performance, an attention mechanism is introduced in the backbone of the backbone network to enhance the expressiveness of features. In the head structure of the network, an extension is made based on the original design, and a branch dedicated to bottle type detection is added. Each branch consists of multiple convolutional modules, which include convolutional layers, batch normalization layers, and activation functions, forming a deep feature learning capability. This design not only improves the model's ability to recognize different types of bottles, but also enhances the robustness and accuracy of the overall detection framework in complex environments.
[0043] (3) During the training process, the batch size is set to 16, the initial learning rate is the specified value, and 500 rounds of iterative training are performed. 7130 input images are used for each round of training until the loss function no longer decreases significantly. A training checkpoint is saved every 20 rounds and each checkpoint is verified. During the evaluation process, the average precision (AP) is calculated when the intersection over union (IoU) is 0.5, 0.7, and 0.5-0.95. The threshold is set to 0.7, and when the prediction score is lower than 0.7, the sample is marked as a negative sample. Finally, the prediction file is generated and evaluated to calculate the mean average precision (mAP) for bottle type and liquid content.
[0044] (4) In order to construct a test dataset to truly reflect the situation in low-light scenes, we used a mobile phone to take each photo in a real low-light environment, covering natural lighting conditions and artificial lighting conditions indoors and outdoors. In the end, we collected a total of 7,180 accurately labeled and clear images, and divided the dataset into training and test sets in a ratio of 7:3. The dataset is divided into five categories: "few", "half", "empty", "many", and "full". The training set and test set of each category follow the selection ratio of 7:3. Among them, the training set is used for model training, while the test set is used to evaluate the performance of the model. In the testing stage, we input each image in the test set into the framework in sequence, and the output result is the predicted box of each image. Through visualization technology, we can clearly display the predicted box on the image, such as Figure 2 shown.
[0045] (5) We use the improved algorithm to predict the bottle type and liquid content at the same time and generate the corresponding prediction file. Through the prediction file, we evaluate the performance of the model, using average precision (AP) and mean average precision (mAP) as evaluation indicators. In addition, we also compare the model with several other object detection algorithms. The final results are shown in the figure. Figure 3 , 4 shown.
Claims
1. A low-light transparent container liquid detection method based on ALLD-YOLOv6 is characterized by : S1: Collect low-light transparent container liquid detection dataset, classify all images according to the target liquid content, accurately annotate each image, and generate annotation files; S2: The input of the framework is the image to be detected; S3: The framework includes the backbone network, the neck network and the prediction head; S4: The backbone network of YOLOv6 adopts an innovative architecture called EfficientRep, which is an efficient feature extractor that integrates multiple advanced network design concepts. The core of EfficientRep includes RepVGG-style blocks and CSP (Cross Stage Partial) modules. RepVGG-type blocks use a multi-branch structure (including 1x1 convolution, 3x3 convolution, and identity mapping) during training, and merge them into a single 3x3 convolution through reparameterization technology during inference, which greatly improves the inference speed. The CSP module effectively balances the computational cost and accuracy by dividing the input feature map into two parts, one part is directly passed and the other part is convolutional. The entire network usually contains multiple stages, each stage gradually reduces the feature map size and increases the number of channels, and performs convolution for downsampling. EfficientRep mainly uses SiLU activation function, and through lightweight design and scalability, it enables YOLOv6 to run efficiently on various devices while maintaining excellent detection performance. This design enables YOLOv6 to perform well in real-time target detection tasks, especially for application scenarios that require fast response. S5: The neck network (Neck) design of YOLOv6 is to effectively integrate features at different levels to improve detection accuracy and speed; the neck network of YOLOv6 adopts a structure that combines feature pyramid network (FPN) and path aggregation network (PAN) to make full use of multi-scale features from the backbone network; With this design, the neck network is able to fuse features at different scales, improve the detection capability of small objects, and enhance the contextual information of large objects; S6: In the prediction head, a dual-head design is adopted to divide the output into two independent sub-branches, classification and regression); each branch consists of multiple convolutional modules, which include convolutional layers, batch normalization layers (BatchNorm) and activation functions (SiLU); finally, a convolutional layer is used to reduce the number of channels to generate the final output, including category prediction, bounding box regression, and object confidence; S7: A special liquid content detection head is added to detect the liquid content in the container, and an identification sub-branch is added to the output branch to identify and classify the type of container; S8: The loss function used when training the model Calculated by formula (1): (1) in is the target classification loss, is the bounding box regression loss, λ is the weight coefficient of the classification loss, usually set to 1; S9: Defined by formula (2): (2) Where i traverses all grid cells, j traverses all categories, y_ij is the true label (0 or 1), and p_ij is the predicted category probability; S10: Defined by formula (3): (3) Where b_pred is the predicted bounding box, b_gt is the true bounding box (ground truth), and IoU is the intersection over union of the predicted box and the ground truth box; S11: Defined by formula (4): (4) In this formula, p represents the Euclidean distance between two rectangular boxes, v is used to measure the consistency of the relative proportions of the two rectangular boxes and is a weight coefficient; c is the diagonal length of the smallest rectangle that encloses the predicted box and the true box; S12: L_obj is defined by formula (5): (5) Where y_i is the true target confidence (0 or 1) and c_i is the predicted target confidence.
