Commodity type identification method based on improved YOLOv5n

By introducing jump connections and convolutional attention mechanism modules into YOLOv5n, the feature extraction and regression formulas are optimized to solve the problem of low product recognition accuracy and achieve more accurate recognition results.

CN118692064APending Publication Date: 2024-09-24CHANGCHUN UNIV OF SCI & TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410687427.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

YOLOv5n has poor recognition accuracy in the same category of products and needs to be used in conjunction with other recognition methods to achieve the desired effect.

Method used

The jump connection operation and convolution attention mechanism module are introduced into the YOLOv5n target detection algorithm, the feature extraction layer and target frame regression formula are adjusted, the CIOU_Loss loss function is used, and iterative training is performed through Sign in to Roboflow data enhancement and cosine annealing algorithm.

Benefits of technology

It improves the accuracy of product recognition, solves the problem of fuzzy features and invalid features affecting recognition accuracy, and achieves better recognition results without increasing training costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118692064A
    Figure CN118692064A
Patent Text Reader

Abstract

The invention discloses a commodity type identification method based on an improved YOLOv5n model, and belongs to the technical field of target identification in deep learning. According to the technical scheme, the method comprises the following steps: S1, collecting target image sample data, and carrying out category labeling on each commodity picture; and S2, the YOLOv5n model is improved. The method comprises the following steps: firstly, adding a new feature extraction layer in a feature fusion network of YOLOv5n; secondly, an EMA attention mechanism module is introduced, and interference of invalid features is reduced; the improvements jointly improve the performance of the YOLOv5n model in a commodity type identification task. And S3, inputting the enhanced target image data set into the improved YOLOv5n model by adopting a data enhancement technology, and carrying out iterative training to obtain a trained improved YOLOv5n model. And S4, carrying out commodity category detection, and finally obtaining an identification result. Through the improved feature extraction layer and the EMAS attention mechanism, the model can more accurately capture the recognition features of the target in the same test image, and a better recognition effect is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of deep learning target recognition, and in particular to a commodity category recognition method based on improved YOLOv5n. Background Art

[0002] With the continuous development of science and technology, photo recognition of objects, self-service vending machines and unmanned supermarkets are gradually entering our lives. For products related to self-service vending machines, if the detection results are wrong or the goods are not recognized directly when selling goods, there will be very big problems. Therefore, the accuracy of product detection must be judged by high standards when identifying. In the past, the detection of goods was done manually, but this would consume a lot of manpower and material resources. Nowadays, image recognition based on deep learning convolutional neural networks is widely used and plays an extremely important role in various fields, so it is also used to identify goods. Among them, target detection algorithms are divided into end-to-end detection algorithms and non-end-to-end detection algorithms. The detection speed of end-to-end is faster than that of non-end-to-end, but the detection accuracy is not as high as that of non-end-to-end. YOLOv5n is an end-to-end real-time target detection method. YOLOv5n can perform real-time detection tasks. It applies a single convolutional neural network to the entire image, divides the image into grids, and predicts the class probability and bounding box of each grid, and finally obtains the class probability information and location information of the detected target. However, YOLOv5n has poor recognition accuracy for products of the same category, so it needs to be used in conjunction with other recognition methods, such as fine-grained recognition algorithms such as bilinear convolutional neural networks, to achieve the desired effect. Summary of the invention

[0003] In view of the defects in the prior art, the present invention provides a commodity status recognition method based on improved YOLOv5n target detection. The purpose of the present invention is to achieve the above purpose, and the technical solution adopted by the present invention is:

[0004] To achieve the above object, the present invention provides the following technical solutions:

[0005] A commodity status recognition method based on improved YOLOv5n target detection, comprising:

[0006] Step S1: Collect target image sample data, and use Sign in to Roboflow data enhancement to obtain a dataset to be identified;

[0007] Step S2: improving the target detection algorithm YOLOv5n to obtain an improved YOLOv5n target detection algorithm;

[0008] Step S3: Add a new feature extraction layer to the YOLOv5n feature fusion network, and adjust the target box regression formula of the YOLOv5n network to improve the loss function;

[0009] Step S4: Send the target pattern dataset after the Sign in to Roboflow data enhancement into the YOLOv5n network for iterative training, and use the cosine annealing algorithm to adjust the learning rate;

[0010] Step S5: After the training is completed, the target image is sent to the best model obtained after training to detect the target category and position, and finally obtain the recognition result.

[0011] In step S1, collecting target image sample data includes: controlling the camera to rotate through a remote control system to achieve time-sharing collection and obtain image sample data containing different features.

[0012] In step S2, the target detection algorithm YOLOv5n is improved by adding a jump connection operation and a convolutional attention mechanism module to the SPPF backbone network and the Neck network on the basis of the original YOLOv5n model, and performing weighted feature fusion.

[0013] In step S3, the target box regression formula of the YOLOv5n network, where the output end of YOLOv5n uses CIOU_Loss as the loss function of the Bounding box, is calculated as follows:

[0014]

[0015]

[0016] The jump connection operation directly transmits shallow information features to the deep network, reducing the impact of deep network feature ambiguity on recognition accuracy; the convolutional attention mechanism module is used for the attention module of the convolutional neural network, which infers the attention map along two independent dimensions in sequence, and multiplies the attention map with the input feature map to perform adaptive feature optimization.

[0017] Compared with the prior art, the present invention has the following beneficial effects: the YOLOv5n target detection algorithm is improved, and clear target features are transmitted to the deep network by designing jump connection operations, thereby solving the feature fuzziness problem of commodity images in different application scenarios; the convolutional attention mechanism module is introduced, so that the model pays more attention to the classification features related to recognition, thereby solving the problem that invalid features affect the recognition accuracy, and the recognition features of the target can be captured more accurately in the same test image, and better recognition effect can be achieved without increasing the training cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for describing the embodiments are briefly introduced below.

[0019] Figure 1 This is a schematic diagram of commodity category detection based on the improved YOLOv5n model of the present invention;

[0020] Figure 2 It is a diagram of the improved YOLOv5n network structure in the present invention;

[0021] Figure 3 This is a diagram of the improved attention mechanism module of the present invention; DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0023] See also Figure 1 , a commodity status recognition method based on improved YOLOv5n target detection, comprising:

[0024] Step S1: Collect target image sample data, and use Sign in to Roboflow data enhancement to the collected target pattern data set, that is, use multiple pictures to randomly crop, randomly arrange, and randomly scale, and then combine them into one picture to obtain the data set to be identified, and then annotate all images according to the product information. The specific annotation information is the type and location of the product;

[0025] Step S2: improving the target detection algorithm YOLOv5n to obtain an improved YOLOv5n target detection algorithm;

[0026] Step S3: Add a new feature extraction layer to the YOLOv5n feature fusion network, and adjust the target box regression formula of the YOLOv5n network to improve the loss function;

[0027] Step S4: Send the target pattern dataset after data enhancement to the YOLOv5n network for iterative training, and adjust the learning rate using the cosine annealing algorithm;

[0028] Step S5: After the training is completed, the target image is sent to the best model obtained after training to detect the target category and position, and finally obtain the recognition result.

[0029] Specifically, in step S1, collecting target image sample data includes: randomly cropping and randomly offsetting the sample data set, which improves the model's ability to detect small targets to a certain extent.

[0030] Specifically, in step S2, the target detection algorithm YOLOv5n is improved by adding a jump connection operation and an EMA attention mechanism module based on the original YOLOv5n model, and performing weighted feature fusion.

[0031] The YOLOv5 target detection algorithm is a new generation algorithm that inherits the essence of the YOLO series of algorithms. It has different degrees of improvement in weight files, reasoning time, and training time compared to YOLOv3 and YOLOv4. In the YOLOv5 official code, there are a total of 4 versions in the target detection network given, namely YOLOv5s, YOLOv5m, YOLOv5n, and YOLOv5x. The four models are deepened and widened on the basis of YOLOv5n. Considering that commodity identification detection is applied to the Raspberry Pi system, the present invention selects the lightweight network YOLOv5n, and its structure is mainly divided into four parts, input end, SPPF backbone network, Neck network, and output end.

[0032] The input end mainly processes the images of the input model in a unified manner through three methods: Sign in to Roboflow data enhancement, adaptive anchor box calculation, and adaptive image size.

[0033] The main function of the SPPF backbone network is to extract features. The Focus module periodically extracts pixels from the input image and reconstructs them into a low-resolution image, that is, stacking four adjacent positions of the image to increase the receptive field of each point, reduce the loss of original information, reduce the amount of calculation and speed up the process.

[0034] PANET in the Neck network is based on the Mask R-CNN and FPN frameworks, which strengthens information propagation and has the ability to accurately retain spatial information, which helps to properly locate pixels to form masks.

[0035] The output end is mainly the detection part, which applies the anchor box on the feature map and generates the classification probability, confidence and the final vector of the target anchor box.

[0036] When dealing with practical problems, since the length and width of different images are usually different, common object detection algorithms uniformly scale the initial image to a certain standard size before sending it to the detection network. YOLOv5n adopts the method of adaptively filling the initial image with the least black border to minimize information redundancy and speed up the inference speed.

[0037] In the SPPF part of YOLOv5n, a residual network structure is designed, and the slicing operation is used to process the initial image. Taking the YOLOv5n model used in this work as an example, its residual network uses 32 convolution kernels.

[0039] Specifically, in step S3, the target box regression formula of the YOLOv5n network, where the output end of YOLOv5n uses CIOU_Loss as the loss function of the Bounding box, is calculated as follows:

[0040]

[0041]

[0042] When detecting a target, it is usually necessary to perform nms operations to screen many target boxes. Since CIOU_Loss contains the influencing factor v, which involves ground truth information, and there is no ground truth when testing reasoning, YOLOv5n uses weighted nms to deal with this problem, so that it can handle occluded and overlapping targets without increasing the computational cost.

[0043] Specifically, the skip connection operation directly transmits shallow information features to the deep network, reducing the impact of deep network feature ambiguity on recognition accuracy; the convolutional attention mechanism module is used for the attention module of the convolutional neural network, and the convolutional attention mechanism module infers the attention map along two independent dimensions in sequence, and multiplies the attention map with the input feature map to perform adaptive feature optimization.

[0044] The network layer after introducing jump connections can fuse the feature information extracted from the shallow layer with the feature information from the deep layer, making the small-scale and medium-scale feature information richer and effectively improving the recognition accuracy.

[0045] The basic parameters of training are epoch 300, batch size 16, image size 640×640, initial learning rate 0.01, termination learning rate 0.2, momentum 0.937, weight decay 0.0005, and random gradient descent strategy is used for random decay.

[0046] In summary: the present invention improves the YOLOv5n target detection algorithm and transmits clear target features to the deep network by designing jump connection operations, thereby solving the feature fuzziness problem of commodity images in different application scenarios; the convolutional attention mechanism module is introduced to make the model pay more attention to the classification features related to recognition, thereby solving the problem that invalid features affect the recognition accuracy, and can more accurately capture the recognition features of the target in the same test image, and achieve better recognition effect without increasing the training cost.

[0047] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A commodity status recognition method based on improved YOLOv5n target detection, characterized in that: include: Step S1: Obtain various product image data taken in real scenes, and use Sign into Roboflow to perform data enhancement and annotation on all images based on product information. The annotation content includes the type and price of the product. Step S2: improving the target detection algorithm YOLOv5n to obtain an improved YOLOv5n target detection algorithm; Step S3: Add a new feature extraction layer to the YOLOv5n feature fusion network, adjust the target box regression formula of the YOLOv5n network, and improve the loss function; add an EMA attention mechanism module before the SPPF module in the Backbone layer of YOLOv5n. The EMA module will infer the attention map along the two independent dimensions of channel and space in sequence, and then multiply the attention map with the input feature map for adaptive feature optimization; Step S4: Send the labeled target pattern data set to the YOLOv5n network for iterative training, and use the cosine annealing algorithm to adjust the learning rate; Step S5: After the training is completed, the target image is sent to the best model obtained after training to detect the target category and position, and finally obtain the recognition result.

2. According to claim 1, a commodity state recognition method based on improved YOLOv5n target detection is characterized in that: In step S1, collecting target image sample data includes: obtaining a corresponding data set from Fruit Detection Dataset, and using Sign in to Roboflow to create image sample data containing different features.

3. According to claim 1, a commodity state recognition method based on improved YOLOv5n target detection is characterized in that: In step S2, the target detection algorithm YOLOv5n is improved specifically including: adding a jump connection operation and an EMA attention mechanism module to the SPPF network and the Neck network on the basis of the original YOLOv5n model, and performing weighted feature fusion.

4. According to claim 1, a commodity state recognition method based on improved YOLOv5n target detection is characterized in that: In step S3, the target box regression formula of the YOLOv5n network, where the output end of YOLOv5n adopts CIOU_Loss as the loss function of the Bounding box, is calculated as follows:

5. According to claim 3, a commodity status recognition method based on improved YOLOv5n target detection is characterized in that: The jump connection operation directly transmits shallow information features to the deep network, reducing the impact of deep network feature ambiguity on recognition accuracy; the EMA attention mechanism module is used for the attention module of the convolutional neural network, and the convolutional attention mechanism module infers the attention map along two independent dimensions in sequence, and multiplies the attention map with the input feature map to perform adaptive feature optimization.

Citation Information

Cited By

  • Double-backbone network insulator defect detection method based on YOLOv5

    CN119477877A