A deep learning-based magnetizing label detection method
Patent Information
- Application Number
- CN202410227357.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-29
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2044-02-29
AI Technical Summary
其中,机器视觉技术利用图像处理和识别算法来自动读取和验证标签信息,这种方法可以大大提高检测的准确性和效率,但需要高配置硬件和复杂的软件算法支持;对于RFID标签,可以采用RFID读取器直接读取标签信息,无需可视可见,这种方法在一定范围内具有较好的效果,但受限于读取距离和方向,且成本较高;对于条形码和二维码标签,可以利用专门的扫描设备或机器视觉技术进行识别,这种方法在许多场景下都得到了广泛应用,但需要保证标签的清晰度和完整性
[0051]本发明提供的上述基于深度学习的充磁标签检测方法,通过深度学习方法,可以自动学习和提取标签表面的特征,并有效处理灰尘等干扰因素,从而显著提高充磁标签的识别准确性和稳定性,尤其对于较小目标的识别效果更好,可以更好地满足充磁标签识别的实际应用需求。利用深度学习的训练过程,能够自动学习、提取和识别标签的特征,实现准确的标签分类和定位,这不仅能减少人工干预,降低因人为因素导致的漏检或误检的可能性,还能提高标签检测的效率,降低人力成本,从而提高标签检测的准确性和效率。在深度学习训练过程中,通过在批标准化层之前添加L1正则化,将CBS层中低于阈值的权重置为0或者移除权重低于阈值的CBS层的通道或卷积核,有助于确定非重要参数层,通过将这些非重要参数层的权重趋近于零,可以降低模型的复杂性,提高模型的泛化能力,减小噪声和干扰对检测结果的影响。采用迁移学习方法,利用多个预训练模型进行初始化,并通过训练得到多个深度学习模型,通过稀疏训练删除模型中影响因子较小的层,使得模型更加专注于学习真正重要的特征,从而可以提高模型的预测准确性和泛化能力。通过在颈部网络和预测网络之间引入坐标注意力机制,可以提取标签的位置信息,实现准确地定位标签的位置。综上,基于深度学习的标签检测方法可以准确、快速地识别标签,通过优化深度学习模型的架构和参数,可以显著提高标签检测的准确性和速度,降低生产成本和管理成本,并且,深度学习模型具有良好的扩展性和可靠性,通过增加训练数据或调整模型结构,可以扩展标签检测能力和规模,满足不断变化的实际应用需求。
Smart Images

Figure CN118095314B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of label detection and deep learning technology, and in particular to a deep learning-based method for detecting magnetized labels. Background Technology
[0002] Tag inspection is an automated technology used to identify, read, and verify tag information. It is an indispensable part of modern industry and commerce, mainly used to identify, verify, and manage various tags. With the development of technology, the types and uses of tags are becoming increasingly widespread, such as RFID tags, barcode tags, and magnetic tags. These tags are widely used in logistics, manufacturing, retail, and medical fields for tracking goods, managing inventory, and improving production efficiency.
[0003] Currently, tag inspection mainly faces the following challenges: First, with the increase in the number of tags, the efficiency and accuracy of manual inspection can no longer meet the needs of large-scale production; second, some tags may be difficult to identify accurately due to various reasons (such as contamination, damage, blurriness, etc.); in addition, for some special types of tags, such as RFID tags, the reading distance and direction will affect the accuracy of detection, and magnetized tags are small in size and easily attract dust, which will lead to a decrease in the accuracy and stability of identification.
[0004] To address the aforementioned issues, existing label inspection technologies are mainly divided into two categories: manual inspection and automatic inspection. Manual inspection primarily involves visually inspecting labels. While simple and easy to implement, this method is inefficient, error-prone, costly, and difficult to scale in large-scale production environments. Automatic inspection technologies, on the other hand, rely heavily on various sensors and machine vision technologies, including machine vision inspection, radio frequency identification (RFID), and barcode and QR code recognition. Machine vision technology utilizes image processing and recognition algorithms to automatically read and verify label information, significantly improving accuracy and efficiency, but requiring high-configuration hardware and complex software algorithms. For RFID tags, RFID readers can directly read the label information without visual inspection; this method performs well within a certain range but is limited by reading distance and direction and is costly. For barcode and QR code labels, specialized scanning equipment or machine vision technology can be used for identification. This method is widely used in many scenarios, but the clarity and integrity of the labels must be guaranteed.
[0005] In summary, existing label detection methods are not suitable for magnetized labels. Furthermore, with the rapid development of industries such as the Internet and intelligent manufacturing, the number of labels is constantly increasing, and the requirements for the accuracy and efficiency of label detection are becoming increasingly stringent. Therefore, how to quickly and accurately detect large-scale magnetized labels is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] In view of this, the present invention provides a deep learning-based method for detecting magnetized tags, which can quickly and accurately detect large-scale magnetized tags.
[0007] Therefore, this invention provides a deep learning-based method for detecting magnetized tags, comprising the following steps:
[0008] S11: Collect the data of the tags to be detected and preprocess the data of the tags to be detected;
[0009] S12: Input the processed label data to be detected into the pre-trained deep learning model to achieve label detection;
[0010] The training process of deep learning models is as follows:
[0011] S21: Collect label image data and label the label image data;
[0012] S22: Preprocess the label image data;
[0013] S23: The processed labeled image data is divided into training and test sets. The training set is input into the deep learning network for training to obtain a deep learning model. The test set is used to calculate and optimize the deep learning model. The DIOU loss function is used to evaluate and optimize the deep learning model. Before training, a transfer learning method is used to initialize the model with N pre-trained models. Through N training iterations, N deep learning models corresponding to the pre-trained models are obtained, where N is a positive integer. The deep learning network is built by introducing a coordinate attention mechanism between the neck network and the prediction network and adding L1 regularization before the batch normalization layer.
[0014] In one possible implementation, in the deep learning-based magnetized tag detection method provided by the present invention, step S11, collecting tag data to be detected and preprocessing the tag data to be detected, specifically includes the following steps:
[0015] S111: Select OpenCV to obtain the video stream of the image of the label to be detected. Open the video stream using the cv2.VideoCapture() function and pass the video stream source as the parameter. Use a while loop to continuously acquire each frame of the video stream until the acquisition fails or is manually interrupted.
[0016] S112: Adjust the size and resolution of the label image to be detected, and perform noise reduction, image distortion removal, contrast enhancement, and normalization on the label image to be detected.
[0017] In one possible implementation, in the deep learning-based magnetization tag detection method provided by the present invention, step S12, which involves inputting the processed tag data to be detected into a pre-trained deep learning model to achieve tag detection, specifically includes the following steps:
[0018] S121: Based on the ambient light, number of arrows, and arrow size of the input image, select a deep learning model, perform image recognition based on the pt file generated by the selected deep learning model, and label the category and coordinates of the tags in the output image;
[0019] S122: After completing the tag detection, save the detected tag information, including the tag's coordinates, size, category, and credibility.
[0020] In one possible implementation, in the deep learning-based magnetization tag detection method provided by the present invention, step S21, acquiring tag image data and labeling the tag image data, specifically includes the following steps:
[0021] S211: Collect multiple tag images of different sizes, angles, and lighting conditions from the magnetization site, including arrows in two directions;
[0022] S212: Label the collected label image data, including the type, location, and size of the labels.
[0023] In one possible implementation, in the deep learning-based magnetized tag detection method provided by the present invention, step S22, preprocessing the tag image data, specifically includes: adjusting the size and resolution of the tag image, performing noise reduction processing, image distortion removal processing, contrast enhancement processing, and normalization processing on the tag image.
[0024] In one possible implementation, in the deep learning-based magnetized tag detection method provided by this invention, step 23 introduces a coordinate attention mechanism between the neck network and the prediction network, specifically including:
[0025] By using a pair of 1x1 convolution operations F h and f h The features of channel c of the input image along the height h direction are aggregated into a single numerical value g. h By using a pair of 1x1 convolution operations F w and f wThe features of channel c of the input image along the width w direction are aggregated into a single numerical value g. w And scaled using the sigmoid activation function σ:
[0026] g h =σ(F h (f h )) (1)
[0027] g w =σ(F w (f w (2)
[0028] The output of the coordinate attention mechanism is:
[0029]
[0030] Where L represents the length of the input sequence, x j Let i represent the feature vector corresponding to position j in the input sequence, and Attention(i,j) represent the attention weights between positions i and j in the input sequence.
[0031] In one possible implementation, in the deep learning-based magnetization tag detection method provided by this invention, step 23, adding L1 regularization before the batch normalization layer, specifically includes:
[0032] The expression for L1 regularization is:
[0033]
[0034] Where k represents the regularization strength, controlling the contribution of the regularization term to the total loss; n represents the number of weight parameters; |w s | represents the absolute value of the weight parameter at position s;
[0035] The parameters for the batch normalization layer are calculated as follows:
[0036]
[0037]
[0038] Where x^ represents the normalized input, z in μ represents the unnormalized input. B This represents the mean of the batch. Let z represent the variance of the batch, ò be a constant, and z be a constant. out This represents the output of the batch normalization layer, where α represents the learned scaling parameter and β represents the learned offset parameter. This represents the normalized input of the batch normalization layer;
[0039] After adding L1 regularization before the batch normalization layer, the total loss function expression is:
[0040]
[0041] in, It is the network loss function. γ represents the regularization of the scaling factor; x represents the training input, y represents the training result, and W represents the training weights; f(x,W) represents the output of the deep learning model, which is the predicted value calculated by the deep learning model using the training weights W on the training input x; γ represents the scaling factor, g(γ) represents the penalty induced by the sparsity of the scaling factor γ, and λ represents the penalty sparsity parameter that determines the size of the penalty term.
[0042] In one possible implementation, in the deep learning-based magnetized tag detection method provided by the present invention, step 23, where the deep learning network is constructed by introducing a coordinate attention mechanism between the neck network and the prediction network and adding L1 regularization before the batch normalization layer, further includes:
[0043] Downsampling uses depthwise separable convolution, while upsampling uses transposed convolution.
[0044] In one possible implementation, in the deep learning-based magnetization tag detection method provided by the present invention, step 23, before training, further includes the following step:
[0045] S231: Determine whether there are missing values in the label image data; if yes, proceed to step S232 and then step S233; if no, proceed to step S233.
[0046] S232: Interpolate at missing locations;
[0047] S233: Determine whether there is duplicate data in the label image data; if yes, proceed to step S234 and then to step S235; if no, proceed to step S235.
[0048] S234: Delete duplicate data;
[0049] S235: Determine if there are outliers in the label image data; if yes, proceed to step S236 and enter the training process; if no, proceed to the training process.
[0050] S236: Replace outliers.
[0051] The deep learning-based magnetized label detection method provided by this invention can automatically learn and extract features from the label surface and effectively handle interference factors such as dust, thereby significantly improving the accuracy and stability of magnetized label recognition. It is particularly effective for recognizing smaller targets and better meets the practical application needs of magnetized label recognition. The deep learning training process automatically learns, extracts, and recognizes label features, achieving accurate label classification and positioning. This not only reduces manual intervention and the possibility of missed or false detections due to human factors but also improves label detection efficiency and reduces labor costs, thus enhancing the accuracy and efficiency of label detection. During deep learning training, adding L1 regularization before the batch normalization layer resets the weights below the threshold in the CBS layer to 0 or removes channels or convolutional kernels of CBS layers with weights below the threshold. This helps to identify unimportant parameter layers. By bringing the weights of these unimportant parameter layers close to zero, the complexity of the model can be reduced, the generalization ability of the model can be improved, and the impact of noise and interference on the detection results can be reduced. This study employs transfer learning, initializing the model using multiple pre-trained models and training them to obtain multiple deep learning models. Sparse training removes layers with smaller influence factors, allowing the model to focus more on learning truly important features, thus improving prediction accuracy and generalization ability. Introducing a coordinate attention mechanism between the neck network and the prediction network extracts label location information, enabling accurate label positioning. In summary, deep learning-based label detection methods can accurately and quickly identify labels. By optimizing the architecture and parameters of the deep learning models, the accuracy and speed of label detection can be significantly improved, while reducing production and management costs. Furthermore, deep learning models exhibit good scalability and reliability; by increasing training data or adjusting the model structure, label detection capabilities and scale can be expanded to meet evolving practical application needs. Attached Figure Description
[0052] Figure 1 This is a flowchart illustrating the deep learning model training process in a deep learning-based magnetized tag detection method provided by the present invention.
[0053] Figure 2 This is a schematic diagram of the YOLO target detection network in Embodiment 1 of the present invention;
[0054] Figure 3 This is a flowchart illustrating the label detection method in Embodiment 1 of the present invention. Detailed Implementation
[0055] The following detailed description, in conjunction with the accompanying drawings, illustrates a specific implementation of the deep learning-based magnetized tag detection method provided by the present invention.
[0056] Before using the deep learning-based magnetized tag detection method provided by this invention to detect the tag data, a deep learning model needs to be trained in advance. The training process of the deep learning model used in this invention will be described in detail below. Figure 1 As shown, the specific steps of the training process are as follows:
[0057] Step 1: Collect label image data and label the label image data.
[0058] Specifically, the process of collecting training and testing sets can be implemented in the following way:
[0059] (1) Collect multiple tag images of different sizes, angles and lighting conditions from the magnetization scene, including arrows in two directions; including arrows in the upward and downward directions; in this way, as many variations as possible can be covered.
[0060] (2) Label the collected label image data, including the type, location and size of the label.
[0061] Step 2: Preprocess the label image data.
[0062] Specifically, the preprocessing mainly includes adjusting the size and resolution of the label image, performing noise reduction, image distortion removal, contrast enhancement, and normalization on the label image.
[0063] Step 3: The processed labeled image data is divided into training and test sets. The training set is input into the deep learning network for training to obtain a deep learning model. The test set is used to calculate and optimize the deep learning model. The DIOU loss function is used to evaluate and optimize the deep learning model. Before training, a transfer learning method is used to initialize the model using N pre-trained models. Through N training iterations, N deep learning models corresponding to the pre-trained models are obtained, where N is a positive integer. The deep learning network is built by introducing a coordinate attention mechanism between the neck network and the prediction network, and adding L1 regularization before the batch normalization layer. Figure 1 As shown, after obtaining the deep learning model through the above training process, the obtained deep learning model can be used for label detection.
[0064] Specifically, the deep learning model can be a convolutional neural network model (such as the YOLO object detection network), or a recurrent neural network model, or other neural network models, without any restrictions.
[0065] Specifically, in the training process of the deep learning model used in this invention, the deep learning network is constructed based on introducing a coordinate attention mechanism between the neck network and the prediction network, which can be implemented in the following way: by using a pair of 1x1 convolution operations F h and f h The features of channel c of the input image along the height h direction are aggregated into a single numerical value g. h By using a pair of 1x1 convolution operations F w and f w The features of channel c of the input image along the width w direction are aggregated into a single numerical value g. w And scaled using the sigmoid activation function σ:
[0066] g h =σ(F h (f h )) (1)
[0067] g w =σ(F w (f w (2)
[0068] The output of the coordinate attention mechanism is:
[0069]
[0070] Where L represents the length of the input sequence, x j Let i represent the feature vector corresponding to position j in the input sequence, and Attention(i,j) represent the attention weights between positions i and j in the input sequence.
[0071] This invention introduces a coordinate attention mechanism between the neck network and the prediction network, which helps the model to better extract features from target objects. The coordinate attention mechanism helps the model focus on regions of interest rather than the entire image. It adjusts the attention weights of each channel using coordinate information from specific locations. Specifically, the coordinate information of each location is first extracted from the input feature map, and then mapped to a tensor with the same number of channels through multiple 1x1 convolutional layers. This tensor is used to calculate the attention weights for each channel to better focus on the region of interest. By introducing the coordinate attention mechanism, the model can better adapt to targets with different sizes and locations, achieving better performance in object detection tasks. Most existing lightweight networks employ modular attention mechanisms, considering only inter-channel information and ignoring positional information, which is crucial in many computer vision tasks such as object detection or image recognition. Although some have attempted to extract positional attention information through convolution after reducing the number of channels, convolution can only extract local relationships and lacks the ability to extract long-range relationships. This invention addresses the shortcomings of lightweight networks in processing positional information by introducing a coordinate attention mechanism between the neck network and the prediction network.
[0072] Specifically, in the training process of the deep learning model used in this invention, the deep learning network is built based on adding L1 regularization before the batch normalization layer, which can be implemented in the following way: The expression for L1 regularization is:
[0073]
[0074] Where k represents the regularization strength, controlling the contribution of the regularization term to the total loss; n represents the number of weight parameters; |w s | represents the absolute value of the weight parameter at position s;
[0075] The parameters for the batch normalization layer are calculated as follows:
[0076]
[0077]
[0078] Where x^ represents the normalized input, z in μ represents the unnormalized input. B This represents the mean of the batch. Let z represent the variance of the batch, ò be a constant, and z be a constant. out This represents the output of the batch normalization layer, where α represents the learned scaling parameter and β represents the learned offset parameter. This represents the normalized input of the batch normalization layer;
[0079] After adding L1 regularization before the batch normalization layer, the total loss function expression is:
[0080]
[0081] in, It is the network loss function. γ represents the regularization of the scaling factor; x represents the training input, y represents the training result, and W represents the training weights; f(x,W) represents the output of the deep learning model, which is the predicted value calculated by the deep learning model using the training weights W on the training input x; γ represents the scaling factor, g(γ) represents the penalty induced by the sparsity of the scaling factor γ, and λ represents the penalty sparsity parameter that determines the size of the penalty term.
[0082] L1 regularization, also known as Lasso regression, is a method that adds a regularization term to the loss function. The regularization term is the sum of the absolute values of the model parameters, which can make the model tend to select smaller parameter values, thus simplifying the model. This invention adds L1 regularization before the batch normalization (BN) layer, meaning that during model training, in addition to the normal loss function, a penalty term is added. This penalty term is proportional to the absolute value of the model parameters. This helps to identify unimportant parameter layers and bring their weights close to zero. Through sparse training, these unimportant parameter layers with weights close to zero are removed, thereby reducing model complexity, improving the model's generalization ability, and reducing the impact of noise and interference on detection results.
[0083] Specifically, before training a deep learning model, a transfer learning method is used to initialize it using N pre-trained models. Through N training iterations, N deep learning models corresponding to the pre-trained models are obtained; this is sparse training. Sparse training is a method to simplify the model by deleting or suppressing certain neurons or layers. The goal is to retain only the neurons or layers most important for a specific task. During training, the importance of each layer is determined by analyzing its activation or weight distribution. Through sparse training, layers that contribute little or almost nothing to the model can be deleted or suppressed, allowing the model to focus more on learning truly important features. This not only simplifies the model but also improves its prediction accuracy and generalization ability.
[0084] This invention addresses the performance bottleneck of deep learning models by adding L1 regularization before the batch normalization layer and implementing model pruning through sparse training. Specifically, model pruning reduces memory usage, speeds up execution, and lowers power consumption, thereby improving prediction accuracy. The most direct method of model pruning is to reduce the number of operations involved in computation, fundamentally solving the pressure on computation and memory.
[0085] It's important to note that sparse training can yield multiple deep learning models, which can be selected for different detection scenarios (such as ambient lighting, the number of arrows, and arrow size). Since variations in ambient lighting, the number of arrows in the magnetized label, and the arrow size all affect the accuracy and efficiency of label detection, sparse training allows for the selection of an appropriate deep learning model based on the ambient lighting, number of arrows, and arrow size of the input image during subsequent label detection. This significantly improves the accuracy and efficiency of label detection.
[0086] Specifically, in constructing a deep learning network, downsampling is used to reduce the size of the feature map and increase the receptive field, while upsampling is used to increase the size of the feature map for more accurate localization. Preferably, in the training process of the deep learning model used in this invention, downsampling can use depthwise separable convolution instead of standard convolution, which reduces the number of parameters and computational complexity; upsampling can use transposed convolution, which, compared to traditional upsampling (such as bilinear interpolation), can learn the upsampling process, thereby providing more accurate feature recovery.
[0087] Specifically, before training the deep learning model used in this invention, the following steps may be included: determining whether there are missing values in the label image data; if there are missing values, interpolating at the missing points and then determining whether there are duplicate data in the label image data; if there are no missing values, directly determining whether there are duplicate data in the label image data; if there are duplicate data, deleting the duplicate data and then determining whether there are outliers in the label image data; if there are no duplicate data, directly determining whether there are outliers in the label image data; if there are outliers, replacing the outliers; if there are no outliers, proceeding to the training process.
[0088] After obtaining the deep learning model through the above training process, it can be used for label detection. This invention provides a deep learning-based magnetization label detection method. Taking a PyQt5 application framework as an example, it integrates data import and result display into the user interface, enabling real-time detection of images or videos to meet practical engineering needs. Specifically, it may include the following steps:
[0089] Step 1: Collect the data of the labels to be tested and preprocess the data.
[0090] Specifically, the data acquisition and preprocessing process can be implemented in the following ways:
[0091] (1) Select OpenCV to obtain the video stream of the label image to be detected. Open the video stream using the cv2.VideoCapture() function and pass the video stream source as the parameter. Use a while loop to continuously obtain each frame of the video stream until the acquisition fails or is manually interrupted.
[0092] (2) Adjust the size and resolution of the label image to be detected, and perform noise reduction, image distortion removal, contrast enhancement and normalization on the label image to be detected.
[0093] Step 2: Input the processed label data to be detected into the pre-trained deep learning model to achieve label detection.
[0094] Specifically, the detection process for the label data to be detected can be implemented in the following way:
[0095] (1) Based on the ambient light, number of arrows and size of the input image, select a deep learning model, perform image recognition based on the pt file generated by the selected deep learning model, and label the category and coordinates of the label in the output image;
[0096] It should be noted that multiple deep learning models can be obtained through sparse training, and these models can be selected for different detection scenarios (such as ambient lighting, number of arrows, and arrow size). Because differences in ambient lighting, the number of arrows in the magnetized label, and the size of the arrows all affect the accuracy and efficiency of label detection, selecting an appropriate deep learning model based on the ambient lighting, number of arrows, and arrow size of the input image can significantly improve the accuracy and efficiency of label detection.
[0097] (2) After completing the tag detection, the detected tag information is saved, including the tag's coordinates, size, category, and confidence level. These results can be used for further analysis and applications such as target tracking, path planning, and environmental modeling.
[0098] The following specific embodiment will be used to describe in detail the implementation of the deep learning-based magnetization tag detection method provided by the present invention.
[0099] Example 1: Taking the deep learning network selection of YOLO object detection network (YOLOv7_ROW network) as an example.
[0100] The specific structure of the YOLOv7_ROW network used in Embodiment 1 of this invention is as follows: Figure 2 As shown:
[0101] The backbone module of the YOLOv7_ROW network is responsible for feature extraction. It uses a series of convolutional layers (CONV) and CBS modules to split the feature map into two parts, then merges them through a cross-stage hierarchical structure, enhancing learning capabilities. SPP (Spatial Pyramid Pooling) layers aggregate the global context by applying multiple filters. The CBS module can perform complex feature extraction and transformation tasks within the neural network. The network's performance can be further optimized by adjusting the parameters and structure of these components. The CBS module consists of convolutional layers, BN (Batch Normalization) layers, and Silu (Sigmoid Linear Unit) layers. The ELAN module consists of a series of convolutional processes. The advantage of this structure is that the input and output channels remain consistent in each branch operation, with only the first two 1x1 convolutions having channel variations. The max pooling (MP) layers are mainly divided into max pooling and CBS, where MP1 and MP2 primarily involve changes in the ratio of the number of channels. MP1 is used for spatial downsampling, followed by a 1x1 convolution to compress the channels. On the right side, a 1x1 convolution is first used to compress the channels, followed by a 3x3 convolution with a stride of 2 to complete downsampling. Finally, an upsampling operation (UP) merges the results of the two branches to obtain a feature map with the same number of channels as the input channels but with a spatial resolution reduced by half. REP is a model reparameterization technique that combines multiple computational modules into one during the inference phase, improving model efficiency and performance. ELAN-H modifies the convolutional order based on ELAN. Connectivity (CAT) is an operation that concatenates two or more tensors along a certain dimension. Coordinate attention (CA) can extract label positional information, enabling accurate label location.
[0102] The Neck module, labeled "PANet" in the YOLOv7_ROW image, is part of a neural network architecture that bridges the Backbone and Head modules. Its structure is designed to optimize feature maps for object detection. The PANet module uses a series of convolutional layers (CONV) and cross-level part (CBS) modules, along with upsampling and concatenation operations. The convolutional layers process feature maps from the backbone. The CBS module splits and merges feature maps to enhance feature representations. Upsampling increases the resolution of the feature maps, resulting in finer details. Concatenation combines the upsampled feature maps with higher-resolution feature maps from earlier layers to preserve rich detail at different scales. This structure enhances the feature hierarchy necessary for detecting objects of various sizes, making it suitable for multi-scale detection.
[0103] Head Module: The head of YOLOv7_ROW is the last part of the network. It uses 2D convolutional layers (CONV2d) to predict class probabilities, object scores, and bounding box coordinates for object detection.
[0104] A method for detecting magnetized tags based on the YOLO target detection network, such as Figure 3 As shown, it may include the following steps:
[0105] (1) Image import
[0106] Specifically, image data is read from a camera or other sensor, OpenCV is used to acquire the current image video stream, and the video stream is opened using the cv2.VideoCapture() function, with the video stream source as the parameter. A while loop is used to continuously acquire each frame of the video stream until the acquisition fails or is manually interrupted.
[0107] (2) Image Processing
[0108] After the image is input, a series of preprocessing steps are required to improve object detection. These preprocessing steps may include image resizing, resolution adjustment, noise reduction, image distortion removal, contrast enhancement, and normalization, etc., and these steps can be implemented using image processing algorithms and software tools.
[0109] (3) Image detection
[0110] Specifically, image recognition and detection are performed using pt files generated by the YOLOv7_ROW model. An appropriate weight file is selected based on the input data, and the target category and coordinates are labeled on the output image.
[0111] (4) Image saving
[0112] After object detection is completed, the labeled image needs to be displayed through a QT interface, and the detected object information needs to be saved. This information can include the object's coordinates, size, category, confidence level, etc. These results can be used for further analysis and applications such as object tracking, path planning, and environmental modeling.
[0113] The above are the main steps of the magnetized tag detection method based on the YOLO target detection network in Embodiment 1 of the present invention. The advantages of the magnetized tag detection method based on the YOLO target detection network in Embodiment 1 of the present invention will be analyzed below by comparing the YOLOv7_ROW model of Embodiment 1 of the present invention, the existing YOLOv7 model, and the existing YOLOv7x model.
[0114] Table 1 shows the average precision and recall of the three models.
[0115]
[0116] As shown in Table 1, the YOLOv7x_ROW model in Embodiment 1 of this invention achieves the best overall trade-off between average precision and recall. Specifically, the precision value of the YOLOv7x_ROW model in Embodiment 1 reaches 0.906, exceeding the precision values of existing YOLOv7 and YOLOv7x models, representing a 5% improvement over the YOLOv7 model and a 3% improvement over the YOLOv7x model. Furthermore, the recall value of the YOLOv7x_ROW model in Embodiment 1 is 0.793, also showing an improvement compared to existing YOLOv7 and YOLOv7x models. Therefore, it can be seen that the overall accuracy of the magnetized tag detection method based on the YOLO target detection network in Embodiment 1 of this invention is significantly improved.
[0117] Table 2 shows the mAP@0.5 and mAP@0.5:0.95 values for the two models.
[0118]
[0119] The mAP@0.5 and mAP@0.5:0.95 values of the YOLOv7x_ROW model in Embodiment 1 of this invention are compared with those of the existing YOLOv7 model, and the results are shown in Table 2. mAP@0.5 represents the average accuracy when the IoU value is 0.5, and mAP@0.5:0.95 represents the average accuracy when the IoU value is between 0.5 and 0.95. As can be seen from Table 2, compared with the existing YOLOv7 model, the mAP@0.5 value of the YOLOv7x_ROW model in Embodiment 1 of this invention is improved by 5.8%, and the mAP@0.5:0.95 value is improved by 5.4%. This demonstrates the effectiveness and superior performance of the magnetized tag detection method based on the YOLO target detection network in Embodiment 1 of this invention in terms of accurate detection and tag detection.
[0120] In summary, the average precision of tag detection in Embodiment 1 of this invention is 90.6%, the recall rate is 79.3%, the mAP@0.5 is 86.9%, and the mAP@0.5:0.95 is 54.1%. Obviously, the magnetized tag detection method based on the YOLO target detection network in Embodiment 1 of this invention can quickly and accurately detect magnetized tags, thereby improving production efficiency and product quality.
[0121] By adding a coordinate attention mechanism and a DIOU loss function to the existing YOLOv7 model, we obtained the YOLOv7+CA model and the YOLOv7+DIOU model. The results of comparing the YOLOv7 model, the YOLOv7+CA model, the YOLOv7+DIOU model, and the YOLOv7x_ROW model in Embodiment 1 of this invention are shown in Table 3.
[0122] Table 3
[0123] YOLOv7 0.859 0.791 81.1% 48.7% YOLOv7+CA 0.884 0.811 83.1% 51.1% YOLOv7+DIOU 0.872 0.776 86.5% 53% YOLOv7x_ROW 0.906 0.793 86.9% 54.1%
[0124] As shown in Table 3, compared with the existing YOLOv7 model, the YOLOv7+CA model improves its average accuracy, recall, mAP@0.5 value, and mAP@0.5:0.95 value by adding a coordinate attention mechanism. This allows the model to focus more on the target's positional information, thus more accurately predicting the target's position and size, thereby improving precision and recall. Table 3 also shows that compared with the existing YOLOv7 model, the YOLOv7+DIOU model improves its average accuracy, recall, mAP@0.5 value, and mAP@0.5:0.95 value by using the DIOU loss function. This allows the model to focus more on target detection, thereby improving detection performance and accuracy. Combining these two improvements, the precision and recall of the YOLOv7x_ROW model in Embodiment 1 of this invention are significantly improved.
[0125] Table 4
[0126] YOLOv7 1024×1024 138.3 YOLOv7x_ROW 1024×1024 135.6
[0127] Table 4 compares the sizes of existing YOLOv7 models and the YOLOv7x_ROW model in Embodiment 1 of this invention. As can be seen from Table 4, the trained models differ in size for the same pixel image. By using L1 regularization and sparse training, the YOLOv7x_ROW model in Embodiment 1 of this invention exhibits significant compression and pruning effects, enabling rapid and accurate detection of magnetized tags.
[0128] In summary, it can be demonstrated that the magnetized tag detection method based on the YOLO target detection network in Embodiment 1 of the present invention can quickly and accurately detect magnetized tags, thereby improving production efficiency and product quality.
[0129] This invention provides a deep learning-based method for detecting magnetized tags. Through deep learning, it can automatically learn and extract features from the tag surface and effectively handle interference factors such as dust, significantly improving the accuracy and stability of magnetized tag recognition. This is particularly effective for smaller targets, better meeting the practical application needs of magnetized tag recognition. The deep learning training process automatically learns, extracts, and recognizes tag features, achieving accurate tag classification and location. This not only reduces manual intervention and the possibility of missed or false detections due to human factors but also improves tag detection efficiency and reduces labor costs, thereby enhancing the accuracy and efficiency of tag detection. During deep learning training, adding L1 regularization before the batch normalization layer resets weights below a threshold in the CBS layer to 0 or removes channels or convolutional kernels with weights below the threshold. This helps identify unimportant parameter layers. By bringing the weights of these unimportant parameter layers close to zero, the model's complexity is reduced, its generalization ability is improved, and the impact of noise and interference on the detection results is minimized. This study employs transfer learning, initializing the model using multiple pre-trained models and training them to obtain multiple deep learning models. Sparse training removes layers with smaller influence factors, allowing the model to focus more on learning truly important features, thus improving prediction accuracy and generalization ability. Introducing a coordinate attention mechanism between the neck network and the prediction network extracts label location information, enabling accurate label positioning. In summary, deep learning-based label detection methods can accurately and quickly identify labels. By optimizing the architecture and parameters of the deep learning models, the accuracy and speed of label detection can be significantly improved, while reducing production and management costs. Furthermore, deep learning models exhibit good scalability and reliability; by increasing training data or adjusting the model structure, label detection capabilities and scale can be expanded to meet evolving practical application needs.
[0130] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A deep learning-based method for detecting magnetized tags, characterized in that, Includes the following steps: S11: Collect the data of the tags to be detected and preprocess the data of the tags to be detected; S12: Input the processed label data to be detected into the pre-trained deep learning model to achieve label detection; The training process of deep learning models is as follows: S21: Collect label image data and label the label image data; S22: Preprocess the label image data; S23: The processed labeled image data is divided into training and test sets. The training set is input into the deep learning network for training to obtain a deep learning model. The test set is used to calculate and optimize the deep learning model. The DIOU loss function is used to evaluate and optimize the deep learning model. Before training, a transfer learning method is used to initialize the model using N pre-trained models. During training, N deep learning models corresponding to the pre-trained models are obtained through N training iterations, where N is a positive integer. The deep learning network is built by introducing a coordinate attention mechanism between the neck network and the prediction network and adding L1 regularization before the batch normalization layer. During deep learning training, L1 regularization is added before the batch normalization layer to reset the weights below the threshold in the CBS layer to 0 or remove the channels or convolution kernels of the CBS layer with weights below the threshold. Layers with small influence factors in the model are also removed through sparse training.
2. The deep learning-based magnetized tag detection method as described in claim 1, characterized in that, Step S11: Collect the data of the tags to be detected and preprocess the data, which includes the following steps: S111: Select OpenCV to obtain the video stream of the image of the label to be detected. Open the video stream using the cv2.VideoCapture() function and pass the video stream source as the parameter. Use a while loop to continuously acquire each frame of the video stream until the acquisition fails or is manually interrupted. S112: Adjust the size and resolution of the label image to be detected, and perform noise reduction, image distortion removal, contrast enhancement, and normalization on the label image to be detected.
3. The deep learning-based magnetized tag detection method as described in claim 1, characterized in that, Step S12 involves inputting the processed label data to be detected into a pre-trained deep learning model to achieve label detection. This includes the following steps: S121: Based on the ambient light, number of arrows, and arrow size of the input image, select a deep learning model, perform image recognition based on the pt file generated by the selected deep learning model, and label the category and coordinates of the tags in the output image; S122: After completing the tag detection, save the detected tag information, including the tag's coordinates, size, category, and credibility.
4. The deep learning-based magnetized tag detection method as described in claim 1, characterized in that, Step S21: Collect label image data and label the label image data, specifically including the following steps: S211: Collect multiple tag images of different sizes, angles, and lighting conditions from the magnetization site, including arrows in two directions; S212: Label the collected label image data, including the type, location, and size of the labels.
5. The deep learning-based magnetized tag detection method as described in claim 1, characterized in that, Step S22 involves preprocessing the label image data, specifically including: adjusting the size and resolution of the label image, performing noise reduction, image distortion removal, contrast enhancement, and normalization on the label image.
6. The deep learning-based magnetized tag detection method as described in claim 1, characterized in that, In step S23, a coordinate attention mechanism is introduced between the neck network and the prediction network, specifically including: By using a pair of 1x1 convolution operations and , input image channels Along the height The directional features are aggregated into a single numerical value. By using a pair of 1x1 convolution operations and , input image channels Along the width The directional features are aggregated into a single numerical value. And activated by the sigmoid function Scaling: (1); (2); The output of the coordinate attention mechanism is: (3); in, Describe the length of the input sequence. Represents the position in the input sequence The corresponding feature vector, Represents the position in the input sequence and location Attention weights between them.
7. The deep learning-based magnetized tag detection method as described in claim 1, characterized in that, In step S23, L1 regularization is added before the batch normalization layer, specifically including: The expression for L1 regularization is: (4); in, This indicates the regularization strength, controlling the contribution of the regularization term to the total loss; Indicates the number of weight parameters; Indicates position The absolute value of the weight parameter at that location; The parameters for the batch normalization layer are calculated as follows: (5); (6); in, This represents the normalized input. This represents the unnormalized input. This represents the mean of the batch. This represents the variance of the batch. It is a constant. This represents the output of the batch normalization layer. This represents the learned scaling parameters. This represents the learned offset parameter. This represents the normalized input of the batch normalization layer; After adding L1 regularization before the batch normalization layer, the total loss function expression is: (7); in, It is the network loss function. It is the regularization of the scaling factor; x Indicates the training input, y Indicates the training results. Indicates the training weights; f ( x , W This represents the output of a deep learning model, which is the model's response to the training input. x Use training weights The predicted value obtained through calculation; Indicates the scaling factor. Represents the scaling factor Sparsity-induced penalty This represents the penalty sparsity parameter that determines the size of the penalty term.
8. The deep learning-based magnetized tag detection method as described in claim 1, characterized in that, In step S23, the deep learning network is constructed by introducing a coordinate attention mechanism between the neck network and the prediction network, and adding L1 regularization before the batch normalization layer. It also includes: Downsampling uses depthwise separable convolution, while upsampling uses transposed convolution.
9. The deep learning-based magnetized tag detection method as described in claim 1, characterized in that, Step S23, prior to training, also includes the following steps: S231: Determine whether there are missing values in the label image data; if yes, proceed to step S232 and then step S233; if no, proceed to step S233. S232: Interpolate at missing locations; S233: Determine whether there is duplicate data in the label image data; if yes, proceed to step S234 and then step S235; if no, proceed to step S235. S234: Delete duplicate data; S235: Determine if there are outliers in the label image data; if yes, proceed to step S236 and enter the training process; if no, proceed to the training process. S236: Replace outliers.
Citation Information
Patent Citations
Method and apparatus for detecting label quality
CN109118483A
Forward-looking sonar image small target identification method based on SSE-YOLO deep learning model
CN116863321A