Recognition model training method and device, commodity recognition method and device and storage medium
By introducing Diverse Branch Block and Faster Block module layers into the recognition model, extracting and fusion features, the problem of insufficient feature extraction capabilities of existing recognition models is solved, and the recognition accuracy and generalization capabilities are improved, ensuring that the model remains in the learning of new types. Efficient identification capability.
Patent Information
- Application Number
- CN202411144229.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-12-27
AI Technical Summary
The feature extraction capability of existing recognition models is insufficient, resulting in the inability to accurately and efficiently identify specific products. As the types of learning increase, the model accuracy gradually decreases.
A recognition model training method is adopted, including the first convolutional layer, the first Diverse Branch Block multivariate branch module layer, the second convolutional layer, the second Diverse Branch Block multivariate branch module layer, the third convolutional layer, and the first FasterBlock The lightweight module layer, the fourth convolutional layer, the second FasterBlock lightweight module layer, and the global average pooling layer, extract and fuse features through these levels, calculate the cross entropy loss function and backpropagate the training model until converge.
The recognition accuracy and accuracy of the model are improved, and the feature maps of different dimensions are spliced and mixed spatially, which enhances the feature expression and generalization ability, so that the model still maintains high accuracy in the process of learning new types.
Smart Images

Figure CN119206684A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a recognition model training method, a commodity recognition method, a device and a storage medium. Background Art
[0002] In the related technology, the existing traditional recognition models have insufficient feature extraction capabilities and are thus unable to accurately and efficiently identify specific products. As the number of types learned increases, the model accuracy will gradually decrease.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a recognition model training method, device and storage medium, aiming to improve the model recognition precision and accuracy.
[0005] To achieve the above-mentioned purpose, an embodiment of the present application proposes a recognition model training method and a commodity recognition method, wherein the recognition model includes a first convolutional layer, a first Diverse Branch Block multivariate branch module layer, a second convolutional layer, a second Diverse Branch Block multivariate branch module layer, a third convolutional layer, a first FasterBlock lightweight module layer, a fourth convolutional layer, a second FasterBlock lightweight module layer and a global average pooling layer, and the method includes the following steps:
[0006] Extracting input data through the first convolutional layer to obtain first 32-channel data, wherein the input data includes an actual label;
[0007] The first 32-channel data is segmented and merged through the first Diverse Branch Block multivariate branch module layer to obtain second 32-channel data;
[0008] Extracting the second 32-channel data through the second convolutional layer to obtain the first 64-channel data;
[0009] The first 64-channel data is segmented and merged through the second Diverse Branch Block multivariate branch module layer to obtain second 64-channel data;
[0010] Extracting the second 64-channel data through the third convolutional layer to obtain the first 128-channel data;
[0011] The first 128-channel data is segmented and spatially mixed through the first Faster Block lightweight module layer to obtain second 128-channel data;
[0012] The second 128-channel data is extracted through the fourth convolutional layer to obtain the first 256-channel data;
[0013] The first 256-channel data is segmented and spatially mixed by the second Faster Block lightweight module layer to obtain second 256-channel data;
[0014] The second 256-channel data mapping is integrated and converted into a 256-dimensional feature vector through the global average pooling layer, and the 256-dimensional feature vector is passed to the fully connected layer to generate the prediction probability of each category;
[0015] The cross entropy loss function is calculated by the difference between the predicted probability of each category and the actual label, and the recognition model is trained by back propagation until the recognition model converges to obtain a target recognition model.
[0016] In some embodiments, the segmenting and merging of the first 32-channel data by the first Diverse Branch Block layer to obtain the second 32-channel data includes:
[0017] dividing the first 32-channel data into a first original feature map and a first to-be-processed feature map;
[0018] Processing the first to-be-processed feature map through two convolutional layers of the first Diverse Branch Block multivariate branch module layer body to obtain a first feature map;
[0019] Adding the first feature map to the first original feature map to obtain a second feature map;
[0020] The second feature map is dimensionally spliced and fused with the first original feature map to obtain second 32-channel data.
[0021] In some embodiments, the segmenting and merging of the first 64-channel data by the second Diverse Branch Block layer to obtain the second 64-channel data includes:
[0022] Dividing the first 64-channel data into a second original feature map and a second feature map to be processed;
[0023] Processing the second to-be-processed feature map through two convolutional layers of the second Diverse Branch Block multivariate branch module layer body to obtain a third feature map;
[0024] Adding the third feature map to the second original feature map to obtain a fourth feature map;
[0025] The fourth feature map is dimensionally spliced and fused with the second original feature map to obtain second 64-channel data.
[0026] In some embodiments, the segmenting and spatially mixing the first 128-channel data by the first Faster Block lightweight module layer to obtain the second 128-channel data includes:
[0027] Dividing the first 128-channel data into a third original feature map and a third to-be-processed feature map;
[0028] Performing spatial mixing processing on the third feature map to be processed through three convolutional layers of the first Faster Block lightweight module layer body to obtain a fifth feature map;
[0029] Adding the fifth feature map to the third original feature map to obtain a sixth feature map;
[0030] The sixth feature map is concatenated and fused with the third original feature map by dimensional residual to obtain second 128-channel data.
[0031] In some embodiments, the segmenting and spatially mixing the first 256-channel data by the second Faster Block lightweight module layer to obtain the second 256-channel data includes:
[0032] dividing the first 256-channel data into a fourth original feature map and a fourth to-be-processed feature map;
[0033] Performing spatial mixing processing on the fourth feature map to be processed through three convolutional layers of the second Faster Block lightweight module layer body to obtain a seventh feature map;
[0034] Adding the seventh feature map to the fourth original feature map to obtain an eighth feature map;
[0035] The eighth feature map is concatenated and fused with the fourth original feature map by dimensional residual to obtain second 256-channel data.
[0036] In some embodiments, the three convolution layers of the first Faster Block lightweight module layer body include a first module convolution layer, a second module convolution layer and a third module convolution layer, the first module convolution layer uses a 3x3 convolution kernel, the second module convolution layer and the third module convolution layer use a 1x1 convolution kernel, and the third feature map to be processed is spatially mixed by the three convolution layers of the first FasterBlock lightweight module layer body to obtain a fifth feature map, including:
[0037] dividing the third feature map to be processed into a first part of feature maps and a second part of feature maps;
[0038] Processing the first portion of feature maps through the first module convolutional layer;
[0039] The processed first part of the feature map and the second part of the feature map are spatially spliced and mixed to obtain a first mixed feature map;
[0040] The first mixed feature map is processed by the second module convolution layer and the third module convolution layer to obtain a fifth feature map.
[0041] To achieve the above object, one aspect of an embodiment of the present application provides a commodity identification method, the method comprising the following steps:
[0042] Obtaining a target recognition model through the above recognition model training method;
[0043] Convert the target recognition model into ONNX format and delete the classification network layer of the target recognition model;
[0044] Constructing a new output node and connecting the node to the global average pooling layer of the object recognition model;
[0045] Get product images;
[0046] Inputting the commodity image into the target recognition model to obtain an output feature value;
[0047] The target category closest to the output feature value is determined in the category feature library through the Euclidean distance.
[0048] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application proposes a recognition model training device, wherein the recognition model includes a first convolutional layer, a first Diverse Branch Block multi-branch module layer, a second convolutional layer, a second Diverse Branch Block multi-branch module layer, a third convolutional layer, a first FasterBlock lightweight module layer, a fourth convolutional layer, a second FasterBlock lightweight module layer and a global average pooling layer, and the device includes:
[0049] A first convolution module, configured to extract input data through the first convolution layer to obtain first 32-channel data, wherein the input data includes an actual label;
[0050] A first fusion module, configured to segment and fuse the first 32-channel data through the first Diverse Branch Block layer to obtain second 32-channel data;
[0051] A second convolution module, used for extracting second 32-channel data through the second convolution layer to obtain first 64-channel data;
[0052] A second fusion module, configured to segment and fuse the first 64-channel data through the second Diverse Branch Block multivariate branch module layer to obtain second 64-channel data;
[0053] A third convolutional layer module, used for extracting the second 64-channel data through the third convolutional layer to obtain the first 128-channel data;
[0054] A third fusion module is used to segment and spatially mix the first 128-channel data through the first Faster Block lightweight module layer to obtain second 128-channel data;
[0055] A fourth convolution module, used for extracting the second 128-channel data through a fourth convolution layer to obtain the first 256-channel data;
[0056] a fourth fusion module, configured to segment and spatially mix the first 256-channel data through the second Faster Block lightweight module layer to obtain second 256-channel data;
[0057] A category prediction module, configured to map and integrate the second 256-channel data into a 256-dimensional feature vector through the global average pooling layer, and pass the 256-dimensional feature vector to a fully connected layer to generate a prediction probability for each category;
[0058] The back propagation module is used to calculate the cross entropy loss function through the difference between the predicted probability of each category and the actual label and to train the recognition model through back propagation until the recognition model converges to obtain a target recognition model.
[0059] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned recognition model training method when executing the computer program.
[0060] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the recognition model training method described above is implemented.
[0061] The embodiments of the present application include at least the following beneficial effects: The present application provides a recognition model training method, device and storage medium, which extracts input data through a first convolutional layer to obtain first 32-channel data; divides and fuses the first 32-channel data through a first Diverse Branch Block multi-branch module layer to obtain second 32-channel data; extracts the second 32-channel data through a second convolutional layer to obtain first 64-channel data; divides and fuses the first 64-channel data through a second DiverseBranch Block multi-branch module layer to obtain second 64-channel data, and gradually extracts more complex feature representations by splicing feature maps of different dimensions, which is helpful for gradient flow and model training; extracts the second 64-channel data through a third convolutional layer to obtain first 128-channel data; divides and spatially mixes the first 128-channel data through a first Faster Block lightweight module layer to obtain second 128-channel data; extracts the second 128-channel data through a fourth convolutional layer to obtain first 256-channel data; and The Block lightweight module layer divides and spatially mixes the first 256-channel data to obtain the second 256-channel data, enhances the expressiveness and generalization capabilities of the features, and improves the diversity of features through partial convolution and learnable layer scaling; the second 256-channel data is mapped, integrated and converted into a 256-dimensional feature vector through the global average pooling layer, and the 256-dimensional feature vector is passed to the fully connected layer to generate the predicted probability of each category; the cross-entropy loss function is calculated by the difference between the predicted probability and the actual label of each category, and the recognition model is trained by backpropagation until the recognition model converges to obtain the target recognition model. The model filters out redundant feature values and retains feature values that are conducive to recognition, so that the model still maintains high accuracy in the process of learning new categories.
[0062] The present application provides a commodity identification method, which obtains a target identification model through a recognition model training method; converts the target identification model into an ONNX format, and deletes the classification network layer of the target identification model; constructs a new output node, and connects the node to the global average pooling layer of the target identification model; obtains a commodity image; inputs the commodity image into the target identification model to obtain an output feature value; determines the target category closest to the output feature value in a category feature library through Euclidean distance, thereby realizing a feature-based commodity identification task, which is conducive to quickly and accurately identifying the category of the commodity. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 is a flow chart of the recognition model training method provided in an embodiment of the present application;
[0064] Figure 2 yes Figure 1 Flow chart of step S102 in FIG.
[0065] Figure 3 yes Figure 1 Flow chart of step S106 in FIG.
[0066] Figure 4 yes Figure 3 Flow chart of step S302 in FIG.
[0067] Figure 5 It is a structural diagram of the recognition model training method provided in the embodiment of the present application applied to the commodity recognition model;
[0068] Figure 6 It is a schematic diagram of the DBB_Block network layer provided in an embodiment of the present application;
[0069] Figure 7 It is a schematic diagram of the Faster_Block network layer provided in an embodiment of the present application;
[0070] Figure 8 is a flow chart of a commodity identification method provided in an embodiment of the present application;
[0071] Fig. 9 It is a structural diagram of a recognition model training device provided in an embodiment of the present application;
[0072] Fig.10 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0073] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0074] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0075] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0076] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0077] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0078] 1) Number of input channels (in_channels): This depends on the nature of your input data. For example, for a color RGB image, the number of input channels is 3 (red, green, and blue channels).
[0079] 2) Number of output channels (out_channels): The number of feature maps output by the convolutional layer.
[0080] 3) Kernel size (kernel_size): The size of the convolution kernel determines the size of the receptive field, that is, the size of the area that the convolution kernel can see at one time when sliding over the input data.
[0081] 4) Stride: The stride determines the step size of the convolution kernel sliding on the input data. When the stride is 1, the convolution kernel will slide pixel by pixel; when the stride is greater than 1, the convolution kernel will skip some pixels when sliding.
[0082] 5) Padding: Padding is the process of adding extra zero values around the boundaries of the input data in order to keep the size of the output data unchanged after the convolution operation.
[0083] 6) Bias: Whether to add a bias term to the convolution kernel.
[0084] 7) Mosaic enhancement is a special data enhancement method that expands the dataset by cropping and splicing multiple images into a new image.
[0085] 8) Mixup: Mix two images and their labels together through linear interpolation to generate new training samples.
[0086] 9) Random perspective: randomly change or perturb the image’s perspective.
[0087] 10) Color augmentation (HSV augment) enhances the data by changing the color space of the image (such as HSV space). HSV stands for hue, saturation, and value.
[0088] In the related technology, the existing traditional recognition models have insufficient feature extraction capabilities and are thus unable to accurately and efficiently identify specific products. As the number of types learned increases, the model accuracy will gradually decrease.
[0089] In summary, the technical problems existing in the relevant technologies need to be improved.
[0090] In view of this, an embodiment of the present application provides a recognition model training method, device and storage medium, which extracts input data through a first convolutional layer to obtain first 32-channel data; segments and fuses the first 32-channel data through a first Diverse Branch Block multi-branch module layer to obtain second 32-channel data; extracts the second 32-channel data through a second convolutional layer to obtain first 64-channel data; segments and fuses the first 64-channel data through a second Diverse Branch Block multi-branch module layer to obtain second 64-channel data, and gradually extracts more complex feature representations by splicing feature maps of different dimensions with each other, which is helpful for gradient flow and model training; extracts the second 64-channel data through a third convolutional layer to obtain first 128-channel data; segments and spatially mixes the first 128-channel data through a first Faster Block lightweight module layer to obtain second 128-channel data; extracts the second 128-channel data through a fourth convolutional layer to obtain first 256-channel data; and The Block lightweight module layer divides and spatially mixes the first 256-channel data to obtain the second 256-channel data, enhances the expressiveness and generalization capabilities of the features, and improves the diversity of features through partial convolution and learnable layer scaling; the second 256-channel data is mapped, integrated and converted into a 256-dimensional feature vector through the global average pooling layer, and the 256-dimensional feature vector is passed to the fully connected layer to generate the predicted probability of each category; the cross-entropy loss function is calculated by the difference between the predicted probability and the actual label of each category, and the recognition model is trained by backpropagation until the recognition model converges to obtain the target recognition model. The model filters out redundant feature values and retains feature values that are conducive to recognition, so that the model still maintains high accuracy in the process of learning new categories.
[0091] A commodity identification method is provided in an embodiment of the present application. The scheme obtains a target recognition model through a recognition model training method; converts the target recognition model into an ONNX format, and deletes the classification network layer of the target recognition model; constructs a new output node, and connects the node to the global average pooling layer of the target recognition model; obtains a commodity image; inputs the commodity image into the target recognition model to obtain an output feature value; determines the target category closest to the output feature value in a category feature library through Euclidean distance, thereby realizing a feature-based commodity identification task, which is conducive to quickly and accurately identifying the category of the commodity.
[0092] The recognition model training method and commodity identification method provided in the embodiments of the present application relate to the field of computer technology. The recognition model training method and commodity identification method provided in the embodiments of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but are not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The cloud server, the server can also be a node server in the blockchain network; the software can be an application that implements the recognition model training method and the commodity identification method, but is not limited to the above forms.
[0093] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0094] Figure 1 is an optional flowchart of the recognition model training method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S110.
[0095] Step S101, extracting input data through the first convolutional layer to obtain first 32-channel data.
[0096] Specifically, the recognition model includes a first convolutional layer, a first Diverse Branch Block multi-branch module layer, a second convolutional layer, a second Diverse Branch Block multi-branch module layer, a third convolutional layer, a first FasterBlock lightweight module layer, a fourth convolutional layer, a second FasterBlock lightweight module layer and a global average pooling layer, and the input data includes actual labels.
[0097] Among them, the first convolution layer, the second convolution layer, the third convolution layer and the fourth convolution layer are ordinary convolution layers. The backbone of the ordinary convolution layer is composed of n ordinary convolution layers using the Sigmoid activation function.
[0098] The present application does not make any specific limitation on the input data, and it can be flexibly selected in combination with actual training needs. For example, the input data can be a training set or an actual product image. It is understandable that when the input data is a training set, the actual label of the input data is the preset real label of the training set, and when the input data is an actual product image, the actual label of the input data is the real label of the actual product image.
[0099] In some embodiments, in order to obtain the first 32-channel data through the first convolutional layer, appropriate convolutional layer parameters need to be set.
[0100] Among them, the convolution layer parameters include the number of input channels, the number of output channels, the convolution kernel size, the step size, the padding and the bias.
[0101] It can be understood that when the RGB image is extracted through the first convolutional layer to obtain the first 32-channel data, the number of input channels is 3 (red, green, and blue channels), and the number of output channels is 32.
[0102] In this embodiment, the input data is extracted through the first convolutional layer to obtain the first 32-channel data, which helps the model learn more data characteristics, thereby improving the performance of the model in performing recognition tasks.
[0103] Step S102 , segmenting and merging the first 32-channel data through a first Diverse Branch Block layer to obtain second 32-channel data.
[0104] Specifically, the first Diverse Branch Block multi-branch module layer consists of four convolutional layers, in which there is a convolutional layer (1x1 convolution kernel) before and after the main body of the module layer to adjust the spatial feature dimension, and the main body consists of two convolutional layers (3x3 convolution kernel).
[0105] In some embodiments, the first 32-channel data is divided into a first original feature map and a first feature map to be processed, the first feature map to be processed is processed by two convolutional layers of the first Diverse Branch Block multi-branch module layer body to obtain a first feature map, the first feature map is added to the first original feature map to obtain a second feature map, the second feature map is dimensionally spliced and fused with the first original feature map to obtain a second 32-channel data.
[0106] The first feature map is added to the first original feature map by adding an addition operation to obtain a second feature map.
[0107] In this embodiment, the first 32-channel data is segmented and fused through the first Diverse Branch Block multi-branch module layer to obtain the second 32-channel data. The feature maps of different dimensions are spliced with each other to gradually extract more complex feature representations, which is conducive to the flow of gradients and the training of the model.
[0108] Step S103, extracting the second 32-channel data through the second convolutional layer to obtain the first 64-channel data.
[0109] In some embodiments, in order to obtain the first 64-channel data through the second convolutional layer, appropriate convolutional layer parameters need to be set.
[0110] It can be understood that when the second 32-channel data is extracted through the second convolutional layer to obtain the first 64-channel data, the number of input channels is 32 and the number of output channels is 64.
[0111] In this embodiment, the second 32-channel data is extracted through the second convolutional layer to obtain the first 64-channel data. The higher layer can learn more advanced and complex features, which helps the model learn more data characteristics, thereby improving the performance of the model in recognition tasks.
[0112] Step S104, segmenting and merging the first 64-channel data through a second Diverse Branch Block layer to obtain second 64-channel data.
[0113] Specifically, the second Diverse Branch Block multi-branch module layer consists of four convolutional layers, in which there is a convolutional layer (1x1 convolution kernel) before and after the main body of the module layer to adjust the spatial feature dimension, and the main body consists of two convolutional layers (3x3 convolution kernel).
[0114] In some embodiments, the first 64-channel data is divided into a second original feature map and a second feature map to be processed; the second feature map to be processed is processed by two convolutional layers of the second Diverse Branch Block multi-branch module layer body to obtain a third feature map; the third feature map is added to the second original feature map to obtain a fourth feature map; the fourth feature map is dimensionally spliced and fused with the second original feature map to obtain a second 64-channel data.
[0115] The third feature map is added to the second original feature map by adding an addition operation to obtain a fourth feature map.
[0116] In this embodiment, the first 64-channel data is segmented and fused through the second Diverse Branch Block multi-branch module layer to obtain the second 64-channel data. The feature maps of different dimensions are spliced with each other to gradually extract more complex feature representations, which is conducive to the flow of gradients and the training of the model.
[0117] Step S105, extracting the second 64-channel data through the third convolutional layer to obtain the first 128-channel data.
[0118] In some embodiments, in order to obtain the first 128-channel data through the third convolutional layer, appropriate convolutional layer parameters need to be set.
[0119] It can be understood that when the second 64-channel data is extracted through the third convolutional layer to obtain the first 128-channel data, the number of input channels is 64 and the number of output channels is 128.
[0120] In this embodiment, the second 64-channel data is extracted through the third convolutional layer to obtain the first 128-channel data. Higher layers can learn more advanced and complex features, which helps the model learn more data characteristics, thereby improving the performance of the model in recognition tasks.
[0121] Step S106 , dividing and spatially mixing the first 128-channel data through the first Faster Block lightweight module layer to obtain second 128-channel data.
[0122] Specifically, the first Faster Block lightweight module layer is composed of five convolutional layers. There is a convolutional layer (1x1 convolution kernel) before and after the main body of the Faster Block lightweight module layer to adjust the spatial feature dimension. The main part of the first Faster_Block lightweight module layer includes the first module convolution layer, the second module convolution layer and the third module convolution layer. The first module convolution layer uses a 3x3 convolution kernel, and the second module convolution layer and the third module convolution layer use a 1x1 convolution kernel.
[0123] In some embodiments, the first 128-channel data is divided into a third original feature map and a third feature map to be processed; the third feature map to be processed is spatially mixed through the three convolutional layers of the first Faster Block lightweight module layer body to obtain a fifth feature map; the fifth feature map is added to the third original feature map to obtain a sixth feature map; the sixth feature map is dimensionally residually spliced and fused with the third original feature map to obtain a second 128-channel data.
[0124] Among them, the third feature map to be processed is divided into a first part feature map and a second part feature map; the first part feature map is processed by the first module convolution layer; the processed first part feature map and the second part feature map are spatially spliced and mixed to obtain a first mixed feature map; the first mixed feature map is processed by the second module convolution layer and the third module convolution layer to obtain a fifth feature map.
[0125] Optionally, the fifth feature map is added to the third original feature map through an add operation to obtain a sixth feature map.
[0126] In this embodiment, the first 128-channel data is segmented and spatially mixed through the first Faster Block lightweight module layer to obtain the second 128-channel data, thereby enhancing the expressiveness and generalization capabilities of the features, and improving the diversity of features through partial convolution and learnable layer scaling without significantly increasing the computational burden.
[0127] Step S107, extracting the second 128-channel data through the fourth convolutional layer to obtain the first 256-channel data.
[0128] In some embodiments, in order to obtain the first 256-channel data through the fourth convolutional layer, appropriate convolutional layer parameters need to be set.
[0129] It can be understood that when the second 128-channel data is extracted through the fourth convolutional layer to obtain the first 256-channel data, the number of input channels is 128 and the number of output channels is 256.
[0130] In this embodiment, the second 128-channel data is extracted through the fourth convolutional layer to obtain the first 256-channel data. Higher layers can learn more advanced and complex features, which helps the model learn more data characteristics, thereby improving the performance of the model in recognition tasks.
[0131] Step S108, dividing and spatially mixing the first 256-channel data through a second Faster Block lightweight module layer to obtain second 256-channel data.
[0132] Specifically, the second Faster Block lightweight module layer consists of five convolutional layers. There is a convolutional layer (1x1 convolution kernel) before and after the main body of the Faster Block lightweight module layer to adjust the spatial feature dimension. The main part of the second Faster_Block lightweight module layer includes the fourth module convolution layer, the fifth module convolution layer and the sixth module convolution layer. The fourth module convolution layer uses a 3x3 convolution kernel, and the fifth module convolution layer and the sixth module convolution layer use a 1x1 convolution kernel.
[0133] In some embodiments, the first 256-channel data is divided into a fourth original feature map and a fourth feature map to be processed; the fourth feature map to be processed is spatially mixed through the three convolutional layers of the second Faster Block lightweight module layer body to obtain a seventh feature map; the seventh feature map is added to the fourth original feature map to obtain an eighth feature map; the eighth feature map is dimensionally residually spliced and fused with the fourth original feature map to obtain the second 256-channel data.
[0134] Among them, the fourth feature map to be processed is divided into a first part feature map and a second part feature map; the first part feature map is processed by the fourth module convolution layer; the processed first part feature map and the second part feature map are spatially spliced and mixed to obtain a second mixed feature map; the second mixed feature map is processed by the fifth module convolution layer and the sixth module convolution layer to obtain a seventh feature map.
[0135] Optionally, the seventh feature map is added to the fourth original feature map through an add operation to obtain an eighth feature map.
[0136] In this embodiment, the first 256-channel data is segmented and spatially mixed through the second Faster Block lightweight module layer to obtain the second 256-channel data, thereby enhancing the expressiveness and generalization capabilities of the features, and improving the diversity of features through partial convolution and learnable layer scaling without significantly increasing the computational burden.
[0137] Step S109, the second 256-channel data mapping is integrated and converted into a 256-dimensional feature vector through a global average pooling layer, and the 256-dimensional feature vector is passed to the fully connected layer to generate the predicted probability of each category.
[0138] Specifically, the recognition model also includes a fully connected layer.
[0139] In some embodiments, the second 256-channel data mapping is integrated and converted into a 256-dimensional feature vector through a global average pooling layer and a fully connected layer, and the 256-dimensional feature vector is then passed to the fully connected layer to generate a predicted probability for each category.
[0140] Among them, the global average pooling layer first reduces the spatial dimension of each feature map to a scalar (i.e., the average value), and then the fully connected layer takes the average value as input, performs a linear transformation through the weight matrix, and processes it through the activation function to output the predicted probability of each category.
[0141] Step S110, calculate the cross entropy loss function through the difference between the predicted probability and the actual label of each category and train the recognition model by back propagation until the recognition model converges to obtain the target recognition model.
[0142] Specifically, during the training process, the gradient of each parameter is reversely calculated according to the cross entropy loss function, and the SGD optimization algorithm is used to update the model parameters.
[0143] Here, the predicted probability of each category is compared with the actual label of the input data, and the cross entropy loss function is calculated.
[0144] The back-propagation algorithm is used to calculate the gradient of the loss function with respect to the model parameters, and then the model parameters are updated according to the optimization algorithm (such as stochastic gradient descent) to reduce the loss function and optimize the model.
[0145] Optionally, the input data is expanded during the training process by data augmentation techniques, which include, but are not limited to, mosaic augmentation, mixup augmentation, random perspective augmentation, and HSV augmentation.
[0146] Furthermore, by introducing the dropout regularization technology, the risk of overfitting of the model on the training set is reduced, thereby improving the performance and robustness of the overall model.
[0147] In this embodiment, the cross entropy loss function is calculated by the difference between the predicted probability and the actual label of each category, and the recognition model is trained by back propagation until the recognition model converges to obtain the target recognition model. The accuracy and generalization ability of the recognition model are improved by continuously optimizing the model.
[0148] In steps S101 to S110 shown in the embodiment of the present application, the input data is extracted through the first convolution layer to obtain the first 32-channel data; the first 32-channel data is segmented and fused through the first Diverse Branch Block multi-branch module layer to obtain the second 32-channel data; the second 32-channel data is extracted through the second convolution layer to obtain the first 64-channel data; the first 64-channel data is segmented and fused through the second Diverse Branch Block multi-branch module layer to obtain the second 64-channel data, and the feature maps of different dimensions are spliced with each other to gradually extract more complex feature representations, which is helpful for the flow of gradients and the training of models; the second 64-channel data is extracted through the third convolution layer to obtain the first 128-channel data; the first 128-channel data is segmented and spatially mixed through the first Faster Block lightweight module layer to obtain the second 128-channel data; the second 128-channel data is extracted through the fourth convolution layer to obtain the first 256-channel data; The Block lightweight module layer divides and spatially mixes the first 256-channel data to obtain the second 256-channel data, enhances the expressiveness and generalization capabilities of the features, and improves the diversity of features through partial convolution and learnable layer scaling; the second 256-channel data is mapped, integrated and converted into a 256-dimensional feature vector through the global average pooling layer, and then the 256-dimensional feature vector is passed to the fully connected layer to generate the predicted probability of each category; the cross-entropy loss function is calculated by the difference between the predicted probability and the actual label of each category, and the recognition model is trained by backpropagation until the recognition model converges to obtain the target recognition model. The model filters out redundant feature values and retains feature values that are conducive to recognition, so that the model still maintains high accuracy in the process of learning new categories.
[0149] See also Figure 2 In some embodiments, step S102 may include but is not limited to steps S201 to S204:
[0150] Step S201, dividing the first 32-channel data into a first original feature map and a first to-be-processed feature map.
[0151] In step S201 of some embodiments, the first 32-channel data is divided into a first original feature map and a first to-be-processed feature map by splitting.
[0152] Step S202, processing the first feature map to be processed through the two convolutional layers of the first Diverse Branch Block multivariate branch module layer body to obtain a first feature map.
[0153] In step S202 of some embodiments, the first feature map to be processed is transformed and feature extracted through two convolutional layers of the first Diverse Branch Block multivariate branch module layer body to output a first feature map.
[0154] Step S203: Add the first feature map to the first original feature map to obtain a second feature map.
[0155] In step S203 of some embodiments, the first feature map is added to the first original feature map through an add operation.
[0156] Step S204: Dimensionally merge the second feature map with the first original feature map to obtain second 32-channel data.
[0157] In step S204 of some embodiments, the second feature map is concatenated with the first original feature map in terms of dimension to enrich the feature representation, thereby facilitating improving the performance of the model.
[0158] See also Figure 3 In some embodiments, step S106 may include but is not limited to steps S301 to S304:
[0159] Step S301, dividing the first 128-channel data into a third original feature map and a third to-be-processed feature map.
[0160] In step S301 of some embodiments, the first 128-channel data is divided into a third original feature map and a third to-be-processed feature map by splitting.
[0161] Step S302: Perform spatial mixing processing on the third feature map to be processed through the three convolutional layers of the first Faster Block lightweight module layer body to obtain a fifth feature map.
[0162] In step S302 of some embodiments, the third feature map to be processed is divided into a first partial feature map and a second partial feature map, the first partial feature map is processed by the first module convolution layer, the processed first partial feature map and the second partial feature map are spatially spliced and mixed to obtain a first mixed feature map, and the first mixed feature map is processed by the second module convolution layer and the third module convolution layer to obtain a fifth feature map.
[0163] Step S303: Add the fifth feature map to the third original feature map to obtain a sixth feature map.
[0164] In step S303 of some embodiments, the fifth feature map is added to the third original feature map through an add operation to obtain a sixth feature map.
[0165] Step S304: perform dimensional residual splicing and fusion on the sixth feature map and the third original feature map to obtain second 128-channel data.
[0166] In step S304 of some embodiments, during the feature fusion process, the feature dimensions of the sixth feature map and the third original feature map are transformed, and the processed sixth feature map and the third original feature map are concatenated to obtain second 128-channel data.
[0167] See also Figure 4 In some embodiments, step S302 may include but is not limited to steps S401 to S404:
[0168] Step S401: dividing the third feature map to be processed into a first part of feature maps and a second part of feature maps.
[0169] Specifically, the first part of the feature map needs to be processed by a convolution layer with a 3x3 convolution kernel, and the second part of the feature map needs to be processed by a convolution layer with two 1x1 convolution kernels.
[0170] Step S402, processing the first part of the feature map through the first module convolution layer.
[0171] Specifically, the main parts of the first Faster Block lightweight module layer and the second Faster Block lightweight module layer each include three convolution layers. Exemplarily, the first Faster Block lightweight module layer includes a first module convolution layer, a second module convolution layer and a third module convolution layer, the first module convolution layer uses a 3x3 convolution kernel, and the second module convolution layer and the third module convolution layer use a 1x1 convolution kernel.
[0172] In step S402 of some embodiments, the first portion of the feature map is input into a first module convolutional layer to obtain a processed first portion of the feature map.
[0173] Step S403: spatially concatenate and mix the processed first part feature map with the second part feature map to obtain a first mixed feature map.
[0174] In step S403 of some embodiments, the processed first part of the feature map and the second part of the feature map are spliced in the spatial dimension to obtain a first mixed feature map.
[0175] Step S404: Process the first mixed feature map through the second module convolution layer and the third module convolution layer to obtain a fifth feature map.
[0176] In step S404 of some embodiments, the first mixed feature map is input into the second module convolution layer and the third module convolution layer to obtain a fifth feature map.
[0177] In some embodiments, the recognition model training method provided in the embodiments of the present application is applied to a commodity recognition model. The structural diagram of the commodity recognition model is as follows: Figure 5 As shown, the product recognition model includes Conv-1, Conv-2, Conv-3, Conv-4, Conv-DBB-1, Conv-DBB-2, Conv-Faster-1, Conv-Faster-2, and GlobalAveragePool. The training method of the product recognition model may include but is not limited to the following steps:
[0178] Step 1, extract input data through Conv-1 to obtain the first 32-channel data;
[0179] Specifically, Conv-1 is the first convolutional layer, and the input data includes the actual label.
[0180] It should be noted that Conv-1, Conv-2, Conv-3, and Conv-4 are ordinary convolution layers, and the backbone of the ordinary convolution layer is composed of n ordinary convolution layers using the Sigmoid activation function.
[0181] Step 2, segmenting and fusing the first 32-channel data through Conv-DBB-1 to obtain the second 32-channel data;
[0182] Specifically, Conv-DBB-1 is the first Diverse Branch Block multi-branch module layer.
[0183] In some embodiments, the DBB_Block main module (i.e., Diverse Branch Block multi-branch module layer) is composed of two convolutional layers (3x3 convolution kernels), which divide the input features into the original feature map and the feature map processed by the DBB main convolution through Split, and the output after being processed by the two DBB convolutional layers is added to the original feature map through the add operation, and then dimensionally concatenated and fused with the original feature map and output to the next layer. Among them, the DBB_Block main module has two types, Conv-DBB-1 and Conv-DBB-2, which correspond to the specific parameters of the first and second Diverse Branch Block multi-branch module layers respectively.
[0184] For example, the DBB_Block network layer diagram is as follows: Figure 6 As shown in the figure, the DBB_Block network layer is the DiverseBranch Block multi-branch module layer, the Conv-DBB-1 input and output data are 32 channels, and the Conv-DBB-2 input and output data are 64 channels.
[0185] In this embodiment, the Diverse Branch Block multi-branch module layer splices feature maps of different dimensions to each other, gradually extracting more complex feature representations, which is conducive to the flow of gradients and the training of the model.
[0186] Step 3, extract the second 32-channel data through Conv-2 to obtain the first 64-channel data;
[0187] Specifically, Conv-2 is the second convolutional layer.
[0188] Step 4, segmenting and fusing the first 64-channel data through Conv-DBB-2 to obtain the second 64-channel data;
[0189] Specifically, Conv-DBB-2 is the second Diverse Branch Block multi-branch module layer.
[0190] Step 5, extract the second 64-channel data through Conv-3 to obtain the first 128-channel data;
[0191] Specifically, Conv-3 is the third convolutional layer.
[0192] Step 6, segmenting and spatially mixing the first 128-channel data through Conv-Faster-1 to obtain the second 128-channel data;
[0193] Specifically, Conv-Faster-1 is the first Faster Block lightweight module layer.
[0194] In some embodiments, the Faster_Block main module (i.e., the Faster Block lightweight module layer) is composed of three convolutional layers, which split the input features into the original feature map and the feature map to be entered into the Faster_Block main body. After entering the Faster_Block main body, the features are divided into two parts by splitting. The first part of the features is processed by the first convolutional layer `partial_conv3` convolutional layer (3x3 convolution kernel), and then spliced and mixed with the second part of the feature space and output to the two convolutional layers (1x1 convolution kernel) of the MLP layer, and then added to the original feature map with the add addition operation, and then spliced and fused with the original feature map for dimensional residual, and output to the next layer. Among them, the Faster_Block main module has two types, Conv-Faster-1 and Conv-Faster-2, which correspond to the specific parameters of the first and second Faster Block lightweight module layers respectively.
[0195] For example, the Faster_Block network layer diagram is as follows: Figure 7 As shown in the figure, the Faster_Block network layer is the Faster Block lightweight module layer, the Conv-Faster-1 input and output data are 128 channels, and the Conv-Faster-2 input and output data are 256 channels.
[0196] In this embodiment, the Faster_Block main module enhances the expressiveness and generalization of features through spatial mixing (partial_conv3), multi-layer perception mechanism (MLP) and residual connection. Without significantly increasing the computational burden, the diversity of features is improved through partial convolution and learnable layer scaling.
[0197] Step 7, extract the second 128-channel data through Conv-4 to obtain the first 256-channel data;
[0198] Specifically, Conv-4 is the fourth convolutional layer.
[0199] Step 8: Use Conv-Faster-2 to segment and spatially mix the first 256-channel data to obtain second 256-channel data; specifically, Conv-Faster-2 is the second Faster Block lightweight module layer.
[0200] Step 9: Map and integrate the processed second 256-channel data into a 256-dimensional feature vector through GlobalAveragePool, and pass the 256-dimensional feature vector to the fully connected layer to generate the predicted probability of each category;
[0201] Specifically, GlobalAveragePool is the global average pooling layer, and in order to adapt to the size of the feature map, GlobalAveragePool comes with an adaptive convolution layer to modify the spatial dimension for subsequent processing.
[0202] In some embodiments, different feature maps are integrated and converted into prediction probabilities for each category by a global average pooling layer and a fully connected layer.
[0203] Step 10, calculate the cross entropy loss function through the difference between the predicted probability and the actual label of each category and back-propagate the training of the recognition model until the recognition model converges to obtain the target recognition model.
[0204] Specifically, during the training process, the gradient of each parameter is reversely calculated according to the cross entropy loss function, and the SGD optimization algorithm is used to update the model parameters.
[0205] Optionally, data enhancement methods include: mosaic enhancement (Mosaic), mixed enhancement (Mixup), random perturbation (random perspective) and color perturbation (HSV augment).
[0206] It is understandable that in order to reduce the risk of overfitting, regularized dropout is used, and illustratively, the value is set to 0.1.
[0207] Figure 8 is an optional flowchart of the commodity identification method provided in the embodiment of the present application. Figure 8 The method may include but is not limited to steps S801 to S806.
[0208] Step S801, obtaining a target recognition model through a recognition model training method.
[0209] Step S802: convert the target recognition model into ONNX format and delete the classification network layer of the target recognition model.
[0210] In step S802 of some embodiments, the .pt file of the target recognition model is converted into ONNX format, and the last classification network layer of the target recognition model is deleted.
[0211] Step S803, construct a new output node and connect the node to the global average pooling layer of the target recognition model.
[0212] In step S803 of some embodiments, a new network node is constructed to connect to the previous node and enable it to output characteristic values.
[0213] Step S804, obtaining product images.
[0214] Step S805: input the product image into the target recognition model to obtain output feature values.
[0215] In step S805 of some embodiments, the model is deployed by building the OpenCV and onnxruntime framework, and the onnx file can be loaded to perform product image inference and output feature values.
[0216] Step S806: Determine the target category closest to the output feature value in the category feature library through the Euclidean distance.
[0217] In step S806 of some embodiments, a category feature library is constructed, and the feature value and the closest category name in the feature library are output and returned using the Euclidean distance metric.
[0218] See also Fig. 9 The embodiment of the present application further provides a recognition model training device, which can implement the above-mentioned recognition model training method and commodity recognition method, and the device includes:
[0219] A first convolution module 901 is used to extract input data through a first convolution layer to obtain first 32-channel data, where the input data includes actual labels;
[0220] A first fusion module 902 is used to segment and fuse the first 32-channel data through a first Diverse Branch Block layer to obtain second 32-channel data;
[0221] A second convolution module 903 is used to extract the second 32-channel data through the second convolution layer to obtain the first 64-channel data;
[0222] A second fusion module 904 is used to segment and fuse the first 64-channel data through a second Diverse Branch Block multivariate branch module layer to obtain second 64-channel data;
[0223] A third convolutional layer module 905 is used to extract the second 64-channel data through the third convolutional layer to obtain the first 128-channel data;
[0224] The third fusion module 906 is used to segment and spatially mix the first 128-channel data through the first Faster Block lightweight module layer to obtain second 128-channel data;
[0225] A fourth convolution module 907, configured to extract the second 128-channel data through a fourth convolution layer to obtain the first 256-channel data;
[0226] A fourth fusion module 908 is used to segment and spatially blend the first 256-channel data through a second Faster Block lightweight module layer to obtain second 256-channel data;
[0227] A category prediction module 909 is used to map and integrate the second 256-channel data into a 256-dimensional feature vector through a global average pooling layer, and pass the 256-dimensional feature vector to a fully connected layer to generate a prediction probability for each category;
[0228] The back propagation module 910 is used to calculate the cross entropy loss function through the difference between the predicted probability and the actual label of each category and to train the recognition model through back propagation until the recognition model converges to obtain the target recognition model.
[0229] It can be understood that the contents of the above-mentioned recognition model training method embodiment are applicable to the present device embodiment, the functions specifically implemented by the present device embodiment are the same as those in the above-mentioned recognition model training method embodiment, and the beneficial effects achieved are also the same as those achieved by the above-mentioned recognition model training method embodiment.
[0230] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned recognition model training method and commodity recognition method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0231] It can be understood that the contents of the above-mentioned recognition model training method embodiment are all applicable to the present device embodiment, the functions specifically implemented by the present device embodiment are the same as those in the above-mentioned recognition model training method embodiment, and the beneficial effects achieved are also the same as those achieved by the above-mentioned recognition model training method embodiment.
[0232] See also Fig.10 , Fig.10 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0233] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0234] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the recognition model training method and the commodity recognition method of the embodiments of this application;
[0235] Input / output interface 1003, used to implement information input and output;
[0236] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0237] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );
[0238] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .
[0239] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned recognition model training method and product recognition method are implemented.
[0240] It can be understood that the contents of the above-mentioned recognition model training method embodiment are all applicable to the present storage medium embodiment, the functions specifically implemented by the present storage medium embodiment are the same as those of the above-mentioned recognition model training method embodiment, and the beneficial effects achieved are also the same as those achieved by the above-mentioned recognition model training method embodiment.
[0241] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0242] The recognition model training method, recognition model training device, electronic device and storage medium provided in the embodiments of the present application extract input data through the first convolution layer to obtain first 32-channel data; segment and fuse the first 32-channel data through the first DiverseBranch Block multi-branch module layer to obtain second 32-channel data; extract the second 32-channel data through the second convolution layer to obtain first 64-channel data; segment and fuse the first 64-channel data through the second Diverse Branch Block multi-branch module layer to obtain second 64-channel data, and gradually extract more complex feature representations by splicing feature maps of different dimensions to facilitate gradient flow and model training; extract the second 64-channel data through the third convolution layer to obtain first 128-channel data; segment and spatially mix the first 128-channel data through the first Faster Block lightweight module layer to obtain second 128-channel data; extract the second 128-channel data through the fourth convolution layer to obtain first 256-channel data; and segment and spatially mix the first 128-channel data through the second Faster Block lightweight module layer. The Block lightweight module layer divides and spatially mixes the first 256-channel data to obtain the second 256-channel data, enhances the expressiveness and generalization capabilities of the features, and improves the diversity of features through partial convolution and learnable layer scaling; the second 256-channel data is mapped, integrated and converted into a 256-dimensional feature vector through the global average pooling layer, and the 256-dimensional feature vector is passed to the fully connected layer to generate the predicted probability of each category; the cross entropy loss function is calculated by the difference between the predicted probability of each category and the actual label, and the recognition model is trained by back propagation until the recognition model converges to obtain a target recognition model, and the model is used to screen out redundant feature values and retain feature values that are conducive to recognition, so that the model still maintains high accuracy in the process of learning new categories.
[0243] The commodity identification method provided in the embodiment of the present application obtains a target recognition model through a recognition model training method; converts the target recognition model into an ONNX format, and deletes the classification network layer of the target recognition model; constructs a new output node, and connects the node to the global average pooling layer of the target recognition model; obtains a commodity image; inputs the commodity image into the target recognition model to obtain an output feature value; determines the target category closest to the output feature value in a category feature library through Euclidean distance, thereby realizing a feature-based commodity identification task, which is conducive to quickly and accurately identifying the category of the commodity.
[0244] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0245] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0246] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0247] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0248] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0249] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0250] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0251] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0252] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0253] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0254] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A recognition model training method, characterized in that: The recognition model includes a first convolutional layer, a first DiverseBranch Block multi-branch module layer, a second convolutional layer, a second Diverse Branch Block multi-branch module layer, a third convolutional layer, a first FasterBlock lightweight module layer, a fourth convolutional layer, a second FasterBlock lightweight module layer and a global average pooling layer, and the method includes the following steps: Extracting input data through the first convolutional layer to obtain first 32-channel data, wherein the input data includes an actual label; The first 32-channel data is segmented and merged through the first Diverse Branch Block multivariate branch module layer to obtain second 32-channel data; Extracting the second 32-channel data through the second convolutional layer to obtain the first 64-channel data; The first 64-channel data is segmented and merged through the second Diverse Branch Block multivariate branch module layer to obtain second 64-channel data; Extracting the second 64-channel data through the third convolutional layer to obtain the first 128-channel data; The first 128-channel data is segmented and spatially mixed by the first FasterBlock lightweight module layer to obtain second 128-channel data; The second 128-channel data is extracted through the fourth convolutional layer to obtain the first 256-channel data; The first 256-channel data is segmented and spatially mixed by the second FasterBlock lightweight module layer to obtain second 256-channel data; The second 256-channel data mapping is integrated and converted into a 256-dimensional feature vector through the global average pooling layer, and the 256-dimensional feature vector is passed to the fully connected layer to generate the prediction probability of each category; The cross entropy loss function is calculated by the difference between the predicted probability of each category and the actual label, and the recognition model is trained by back propagation until the recognition model converges to obtain a target recognition model.
2. The method according to claim 1, characterized in that The step of segmenting and fusing the first 32-channel data through the first Diverse Branch Block layer to obtain second 32-channel data includes: dividing the first 32-channel data into a first original feature map and a first to-be-processed feature map; Processing the first to-be-processed feature map through two convolutional layers of the first Diverse Branch Block multivariate branch module layer main body to obtain a first feature map; Adding the first feature map to the first original feature map to obtain a second feature map; The second feature map is dimensionally spliced and fused with the first original feature map to obtain second 32-channel data.
3. The method according to claim 1, characterized in that: The step of segmenting and fusing the first 64-channel data through the second Diverse Branch Block layer to obtain second 64-channel data includes: Dividing the first 64-channel data into a second original feature map and a second feature map to be processed; Processing the second to-be-processed feature map through two convolutional layers of the second Diverse Branch Block multivariate branch module layer main body to obtain a third feature map; Adding the third feature map to the second original feature map to obtain a fourth feature map; The fourth feature map is dimensionally spliced and fused with the second original feature map to obtain second 64-channel data.
4. The method according to claim 1, characterized in that: The step of dividing and spatially mixing the first 128-channel data through the first Faster Block lightweight module layer to obtain second 128-channel data includes: Dividing the first 128-channel data into a third original feature map and a third to-be-processed feature map; Performing spatial mixing processing on the third feature map to be processed through three convolutional layers of the first Faster Block lightweight module layer body to obtain a fifth feature map; Adding the fifth feature map to the third original feature map to obtain a sixth feature map; The sixth feature map is concatenated and fused with the third original feature map by dimensional residual to obtain second 128-channel data.
5. The method according to claim 1, characterized in that The step of dividing and spatially mixing the first 256-channel data by the second Faster Block lightweight module layer to obtain second 256-channel data includes: dividing the first 256-channel data into a fourth original feature map and a fourth to-be-processed feature map; Performing spatial mixing processing on the fourth feature map to be processed through three convolutional layers of the second Faster Block lightweight module layer body to obtain a seventh feature map; Adding the seventh feature map to the fourth original feature map to obtain an eighth feature map; The eighth feature map is concatenated and fused with the fourth original feature map by dimensional residual to obtain second 256-channel data.
6. The method according to claim 4, characterized in that The three convolution layers of the first Faster Block lightweight module layer body include a first module convolution layer, a second module convolution layer and a third module convolution layer, the first module convolution layer uses a 3x3 convolution kernel, the second module convolution layer and the third module convolution layer use a 1x1 convolution kernel, and the third feature map to be processed is spatially mixed by the three convolution layers of the first Faster Block lightweight module layer body to obtain a fifth feature map, including: dividing the third feature map to be processed into a first part of feature maps and a second part of feature maps; Processing the first portion of feature maps through the first module convolutional layer; The processed first part of the feature map and the second part of the feature map are spatially spliced and mixed to obtain a first mixed feature map; The first mixed feature map is processed by the second module convolution layer and the third module convolution layer to obtain a fifth feature map.
7. A commodity identification method, characterized in that: The method comprises the following steps: Obtaining a target recognition model by the recognition model training method according to any one of claims 1 to 6; Convert the target recognition model into ONNX format and delete the classification network layer of the target recognition model; Constructing a new output node and connecting the node to the global average pooling layer of the object recognition model; Get product images; Inputting the commodity image into the target recognition model to obtain an output feature value; The target category closest to the output feature value is determined in the category feature library through the Euclidean distance.
8. A recognition model training device, characterized in that: The recognition model includes a first convolutional layer, a first DiverseBranch Block multi-branch module layer, a second convolutional layer, a second Diverse Branch Block multi-branch module layer, a third convolutional layer, a first FasterBlock lightweight module layer, a fourth convolutional layer, a second FasterBlock lightweight module layer and a global average pooling layer, and the device includes: A first convolution module, configured to extract input data through the first convolution layer to obtain first 32-channel data, wherein the input data includes an actual label; A first fusion module, configured to segment and fuse the first 32-channel data through the first Diverse Branch Block layer to obtain second 32-channel data; A second convolution module, used for extracting second 32-channel data through the second convolution layer to obtain first 64-channel data; A second fusion module, configured to segment and fuse the first 64-channel data through the second Diverse Branch Block multivariate branch module layer to obtain second 64-channel data; A third convolutional layer module, used for extracting the second 64-channel data through the third convolutional layer to obtain the first 128-channel data; A third fusion module is used to segment and spatially mix the first 128-channel data through the first Faster Block lightweight module layer to obtain second 128-channel data; A fourth convolution module, used for extracting the second 128-channel data through a fourth convolution layer to obtain the first 256-channel data; a fourth fusion module, configured to segment and spatially mix the first 256-channel data through the second Faster Block lightweight module layer to obtain second 256-channel data; A category prediction module, configured to map and integrate the second 256-channel data into a 256-dimensional feature vector through the global average pooling layer, and pass the 256-dimensional feature vector to a fully connected layer to generate a prediction probability for each category; The back propagation module is used to calculate the cross entropy loss function through the difference between the predicted probability of each category and the actual label and to train the recognition model through back propagation until the recognition model converges to obtain a target recognition model.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the recognition model training method according to any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.