One-dimensional barcode super-resolution model training method, device, equipment, storage medium and product
By adjusting the model parameters in combination with pixel-level and semantic feature loss values, and using pre-trained semantic feature extraction models, the problem of poor stability of one-dimensional barcode image reconstruction in the existing technology is solved, and the reconstruction effect of high-quality and accurate semantic features is achieved , improves barcode recognition performance.
Patent Information
- Application Number
- CN202411262400.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-09-10
AI Technical Summary
The existing super-resolution technology has poor stability when the PPM of one-dimensional barcode images is small and the image quality is poor, and one-dimensional barcode distortion is prone to one-dimensional barcode distortion, resulting in a degradation of barcode recognition performance.
By combining pixel-level loss values and barcode semantic feature loss values, the model parameters of the initial reconstruction model are adjusted, and the pre-trained semantic feature extraction model is used for semantic extraction to ensure the accuracy of pixel-level and semantic features of the reconstructed image.
The stability of the super-resolution model is improved, ensuring that high-resolution images with high-quality and accurate semantic features are output in the case of small PPM of the input one-dimensional barcode image, and the barcode recognition performance is improved.
Smart Images

Figure CN118799185B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to one-dimensional barcode super-resolution model training methods, devices, equipment, storage media and products. Background Art
[0002] The 1D barcode scanning process will be affected by many physical factors, such as ambient light, scanning distance, scanning angle, 1D code printing quality and barcode reader imaging quality, which will lead to a lower recognition rate. When the scanning distance is far or the 1D code printing pattern is small, the minimum unit width pixel (PPM) of the barcode image after imaging will be very small, resulting in a lower barcode recognition rate.
[0003] Currently, there are super-resolution methods that can reconstruct low-quality, small PPM one-dimensional barcode images into high-quality, large PPM one-dimensional barcode images. However, the existing super-resolution technology has poor stability when the PPM of the one-dimensional barcode image is very small and the image quality is poor. It is prone to problems such as one-dimensional barcode distortion (that is, the number of spaces or width of the one-dimensional barcode deviates from the standard value), resulting in reduced barcode recognition performance. Summary of the invention
[0004] The main purpose of this application is to provide a one-dimensional barcode super-resolution model training method, device, equipment, storage medium and product, aiming to solve the technical problem that one-dimensional barcode distortion is easily caused when the prior art super-resolution technology is used to reconstruct one-dimensional barcode images.
[0005] To achieve the above objectives, the present application proposes a one-dimensional barcode super-resolution model training method, the one-dimensional barcode super-resolution model training method comprising:
[0006] Predicting the first one-dimensional barcode image in each group of training data according to the initial reconstruction model to obtain a predicted barcode image corresponding to each group of training data, wherein a group of training data includes a first one-dimensional barcode image and a second one-dimensional barcode image, wherein the first one-dimensional barcode image and the second one-dimensional barcode image correspond to the same one-dimensional barcode, the second one-dimensional barcode image is a pixel-level true value image of the corresponding one-dimensional barcode, and the image quality of the first one-dimensional barcode image is lower than the image quality of the second one-dimensional barcode image, and the image quality of the predicted barcode image is higher than the image quality of the first one-dimensional barcode image;
[0007] Determine a pixel-level loss value according to the second one-dimensional barcode image in each group of training data and the predicted barcode image corresponding to each group of training data;
[0008] Semantic extraction is performed on the second one-dimensional barcode images in each group of training data to obtain high-quality image semantic features corresponding to each training data, and semantic extraction is performed on the predicted barcode images corresponding to each group of training data to obtain predicted image semantic features corresponding to each group of training data;
[0009] Determine the barcode semantic feature loss value according to the high-quality image semantic features and predicted image semantic features corresponding to each group of training data;
[0010] Adjusting the model parameters of the initial reconstruction model according to the pixel-level loss value and the barcode semantic feature loss value, and detecting whether the initial reconstruction model meets a preset convergence condition;
[0011] If the initial reconstruction model meets the preset convergence condition, the initial reconstruction model is used as the one-dimensional code reconstruction model.
[0012] In a possible implementation of the present application, the semantic extraction of the second one-dimensional barcode images in each group of training data is performed to obtain the high-quality image semantic features corresponding to each training data, and the semantic extraction of the predicted barcode images corresponding to each group of training data is performed to obtain the predicted image semantic features corresponding to each group of training data, including:
[0013] Acquire a semantic feature extraction model, where the semantic feature extraction model is a pre-trained model for extracting semantic features, where the semantic features include a bar width feature and an index semantic feature;
[0014] The semantic feature extraction model is used to perform semantic extraction on the second one-dimensional barcode image in each group of training data to obtain high-quality image semantic features corresponding to each training data, and the semantic feature extraction model is used to perform semantic extraction on the predicted barcode image corresponding to each group of training data to obtain predicted image semantic features corresponding to each group of training data.
[0015] In a possible implementation of the present application, before acquiring the semantic feature extraction model, the method further includes:
[0016] The second one-dimensional barcode image in each group of recognition training data is predicted by the initial barcode recognition model to obtain the index sequence prediction result corresponding to each group of recognition training data, wherein a group of recognition training data includes the second one-dimensional barcode image and the true value of the index sequence corresponding to the second one-dimensional barcode image, and the initial barcode recognition model includes a feature extraction model and an index prediction model;
[0017] Construct a sequence prediction loss value according to the true value of the index sequence in each group of recognition training data and the prediction result of the index sequence corresponding to each group of recognition training data;
[0018] Adjusting the model parameters of the initial barcode recognition model according to the sequence prediction loss value, and detecting whether the initial barcode recognition model meets a preset convergence condition;
[0019] If the initial barcode recognition model meets the preset convergence condition, the initial barcode recognition model is used as a one-dimensional barcode recognition model;
[0020] The obtaining of the semantic feature extraction model comprises:
[0021] A feature extraction model is extracted from the one-dimensional barcode recognition model to obtain a semantic feature extraction model.
[0022] In a possible implementation of the present application, the method further includes: predicting the second one-dimensional barcode image in each group of recognition training data by using the initial barcode recognition model to obtain the index sequence prediction result corresponding to each group of recognition training data.
[0023] Acquire a one-dimensional barcode super-resolution dataset, wherein the one-dimensional barcode super-resolution dataset includes a plurality of sample pairs, wherein the sample pairs include a first one-dimensional barcode image, a second one-dimensional barcode image, and a true value of an index sequence corresponding to the one-dimensional barcode;
[0024] Extracting multiple sample pairs from the one-dimensional barcode super-resolution dataset;
[0025] The first one-dimensional barcode image in the plurality of sample pairs is removed to obtain a plurality of groups of recognition training data.
[0026] In a possible implementation of the present application, adjusting the model parameters of the initial reconstruction model according to the pixel-level loss value and the barcode semantic feature loss value includes:
[0027] Find the loss impact factors corresponding to the pixel-level loss value and the barcode semantic feature loss value respectively, wherein the loss impact factor is used to characterize the impact ratio of the loss value on the overall loss;
[0028] Constructing a final loss value according to the loss impact factor, the pixel-level loss value and the barcode semantic feature loss value;
[0029] Determine the error gradient corresponding to each layer of the network in the initial reconstruction model according to the final loss value;
[0030] Derived the weight gradient and bias gradient corresponding to each layer of the network in the initial reconstruction model according to the error gradient;
[0031] Obtaining a model learning rate corresponding to the initial reconstruction model;
[0032] The weight parameters of each layer of the network in the initial reconstruction model are adjusted according to the model learning rate and the weight gradient, and the bias parameters of each layer of the network in the initial reconstruction model are adjusted according to the model learning rate and the bias parameter.
[0033] In a possible implementation of the present application, before predicting the first one-dimensional barcode image in each set of training data according to the initial reconstruction model to obtain the predicted barcode image corresponding to each set of training data, the method further includes:
[0034] Acquire a one-dimensional barcode super-resolution dataset, wherein the one-dimensional barcode super-resolution dataset includes a plurality of sample pairs, wherein the sample pairs include a first one-dimensional barcode image, a second one-dimensional barcode image, and a true value of an index sequence corresponding to the one-dimensional barcode;
[0035] Extracting multiple sample pairs from the one-dimensional barcode super-resolution dataset;
[0036] The true values of the index sequences in the multiple sample pairs are removed to obtain multiple groups of training data.
[0037] In a possible implementation of the present application, if the initial reconstruction model satisfies a preset convergence condition, then after using the initial reconstruction model as a one-dimensional code reconstruction model, the method further includes:
[0038] Inputting the one-dimensional barcode image to be reconstructed into the one-dimensional code reconstruction model for processing to generate a reconstructed one-dimensional barcode image;
[0039] The one-dimensional barcode image to be reconstructed is an image containing a one-dimensional barcode but having such low image quality that the true value of the one-dimensional barcode is difficult to identify; the reconstructed one-dimensional barcode image is an image containing the same one-dimensional barcode as the one-dimensional barcode image to be reconstructed but having higher image quality than the one-dimensional barcode image to be reconstructed.
[0040] In addition, to achieve the above purpose, the present application also proposes a model training device, which includes:
[0041] An image prediction module is used to predict the first one-dimensional barcode image in each group of training data according to the initial reconstruction model to obtain a predicted barcode image corresponding to each group of training data, wherein a group of training data includes a first one-dimensional barcode image and a second one-dimensional barcode image, wherein the first one-dimensional barcode image and the second one-dimensional barcode image correspond to the same one-dimensional barcode, and the image quality of the first one-dimensional barcode image is lower than the image quality of the second one-dimensional barcode image, and the image quality of the predicted barcode image is higher than the image quality of the first one-dimensional barcode image;
[0042] A first loss module, used to determine a pixel-level loss value according to the second one-dimensional barcode image in each group of training data and the predicted barcode image corresponding to each group of training data;
[0043] A semantic extraction module is used to perform semantic extraction on the second one-dimensional barcode images in each group of training data to obtain high-quality image semantic features corresponding to each training data, and to perform semantic extraction on the predicted barcode images corresponding to each group of training data to obtain predicted image semantic features corresponding to each group of training data;
[0044] The second loss module is used to determine the barcode semantic feature loss value according to the high-quality image semantic features and the predicted image semantic features corresponding to each group of training data;
[0045] A parameter adjustment module, used to adjust the model parameters of the initial reconstruction model according to the pixel level loss value and the barcode semantic feature loss value, and detect whether the initial reconstruction model meets the preset convergence condition;
[0046] The model determination module is used to use the initial reconstruction model as the one-dimensional code reconstruction model if the initial reconstruction model meets a preset convergence condition.
[0047] In addition, to achieve the above-mentioned purpose, the present application also proposes a model training device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program is configured to implement the steps of the one-dimensional barcode super-resolution model training method as described above.
[0048] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the one-dimensional barcode super-resolution model training method as described above are implemented.
[0049] In addition, to achieve the above-mentioned purpose, the present application also proposes a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the one-dimensional barcode super-resolution model training method as described above.
[0050] One or more technical solutions proposed in this application have at least the following technical effects:
[0051] Since the model parameters are adjusted by combining the pixel-level loss value and the barcode semantic feature loss value when training the initial reconstruction model, the pixel-level loss of the reconstructed image and the loss of semantic features are fully considered. The one-dimensional code reconstruction model trained in this way can ensure the accuracy of the reconstructed image quality and semantic features even when the PPM of the input one-dimensional barcode image is very small and / or the quality is poor, thereby outputting a high-resolution image with accurate bar and space width, improving the stability of the super-resolution model, and improving the performance of barcode recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0053] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0054] Figure 1 A flowchart of the first embodiment of the one-dimensional barcode super-resolution model training method of the present application is provided;
[0055] Figure 2 A flowchart diagram of the second embodiment of the one-dimensional barcode super-resolution model training method of the present application;
[0056] Figure 3 A schematic diagram of the complete model training process of an embodiment of the present application;
[0057] Figure 4 This is a schematic diagram of the execution flow of the first pre-training module according to an embodiment of the present application;
[0058] Figure 5 This is a schematic diagram of the execution flow of the second pre-training module in one embodiment of the present application;
[0059] Figure 6 This is a schematic diagram of the module structure of the model training device in the embodiment of the present application;
[0060] Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the one-dimensional barcode super-resolution model training method in the embodiment of the present application.
[0061] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0062] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0063] The present application embodiment provides a one-dimensional barcode super-resolution model training method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the one-dimensional barcode super-resolution model training method of the present application.
[0064] In this embodiment, the one-dimensional barcode super-resolution model training method includes steps S10 to S60:
[0065] Step S10: predicting the first one-dimensional barcode image in each group of training data according to the initial reconstruction model to obtain a predicted barcode image corresponding to each group of training data.
[0066] It should be noted that the execution subject of this embodiment may be a model training device with data processing, network communication and program running functions, and the model training device may be an electronic device such as a tablet computer, a personal computer, a mobile phone, or other electronic devices capable of realizing the above functions. In this embodiment and the following embodiments, the one-dimensional barcode super-resolution model training method of this application is described by taking the model training device as an example.
[0067] It should be noted that a set of training data may include a first one-dimensional barcode image and a second one-dimensional barcode image, the first one-dimensional barcode image and the second one-dimensional barcode image correspond to the same one-dimensional barcode, the second one-dimensional barcode image is a pixel-level true value image of the corresponding one-dimensional barcode, and the image quality of the first one-dimensional barcode image is lower than that of the second one-dimensional barcode image, that is, the first one-dimensional barcode image and the second one-dimensional barcode image are two images with different image qualities obtained by image acquisition of the same one-dimensional barcode, and the second one-dimensional barcode image is an image with a pixel-level clarity, and the recognition thereof can normally identify the true value contained in the one-dimensional barcode. The initial reconstruction model may be a model that can perform super-resolution processing on a low-quality one-dimensional barcode image and reconstruct it into a high-quality one-dimensional barcode image, but at this time the initial reconstruction model may not have completed training, and the reconstruction effect and reconstruction quality of the initial reconstruction model may be poor. Among them, the initial reconstruction model may be a Realesrgan model, or other models with similar functions.
[0068] In actual use, the first one-dimensional barcode image in each set of training data can be input into the initial reconstruction model respectively. At this time, the initial reconstruction model will perform super-resolution processing on the input first one-dimensional barcode image, predict and output the corresponding reconstructed predicted barcode image, thereby obtaining the predicted barcode image corresponding to each set of training data. Among them, the image quality of the predicted barcode image corresponding to the training data is higher than the image quality of the first one-dimensional barcode image in the training data.
[0069] In a specific implementation, in order to quickly construct training data, before step S10 in this embodiment, the following may also be included:
[0070] Obtain a one-dimensional barcode super-resolution dataset;
[0071] Extracting multiple sample pairs from the one-dimensional barcode super-resolution dataset;
[0072] The true values of the index sequences in the multiple sample pairs are removed to obtain multiple groups of training data.
[0073] It should be noted that the one-dimensional barcode super-resolution dataset may include multiple sample pairs, each of which may include a first one-dimensional barcode image, a second one-dimensional barcode image, and an index sequence true value corresponding to a one-dimensional barcode. The index sequence true value may be the real index sequence data corresponding to the one-dimensional barcode.
[0074] It can be understood that the sample pair includes the first one-dimensional barcode image, the second one-dimensional barcode image and the true value of the index sequence, which can facilitate the verification of the semantic extraction algorithm used in the training process, thereby ensuring the selection of an appropriate semantic extraction algorithm. When training the initial reconstruction model, it is actually only necessary to use the first one-dimensional barcode image and the second one-dimensional barcode image corresponding to the one-dimensional barcode. Therefore, after extracting multiple sample pairs from the one-dimensional barcode super-resolution data set, the true value of the index sequence in each sample pair can be removed, and a sample pair with a removed index sequence true value can be used as a set of training data, thereby obtaining multiple sets of training data.
[0075] When extracting multiple sample pairs from a one-dimensional barcode super-resolution data set, the number of extracted sample pairs can be pre-set by the administrator of the model training device.
[0076] Step S20: determining a pixel-level loss value according to the second one-dimensional barcode image in each set of training data and the predicted barcode image corresponding to each set of training data.
[0077] It should be noted that the second one-dimensional barcode image is an image corresponding to the first one-dimensional barcode image, and is an image of higher quality for the same one-dimensional barcode image. By comparing the second one-dimensional barcode image in a set of training data with the predicted barcode image corresponding to the set of training data, the image quality difference between the image reconstructed by the initial reconstruction model after super-resolution processing and the actual high-quality image can be determined. By comparing the second one-dimensional barcode image in each set of training data with the predicted barcode image corresponding to each set of training data, the overall difference can be obtained, thereby obtaining the pixel-level loss value.
[0078] In actual use, a preset loss algorithm can be used to calculate the pixel-level loss value according to the second one-dimensional barcode image in each group of training data and the predicted barcode image corresponding to each group of training data. The preset loss algorithm can be pre-set by the administrator of the model training device, for example: the preset loss algorithm is set to an absolute error loss algorithm (MAE, or L1 loss), a mean square error algorithm (MSE, or L2 loss), of course, other loss algorithms can also be used, such as Huber loss, which is not limited in this embodiment.
[0079] Step S30: semantic extraction is performed on the second one-dimensional barcode images in each group of training data to obtain high-quality image semantic features corresponding to each training data, and semantic extraction is performed on the predicted barcode images corresponding to each group of training data to obtain predicted image semantic features corresponding to each group of training data.
[0080] It should be noted that, in order to ensure the comparison effect of the subsequent semantic features, the same semantic extraction algorithm can be used to perform semantic extraction on the second one-dimensional barcode image in each group of training data and the predicted barcode image corresponding to each group of training data. At this time, the preset semantic extraction algorithm can be used to perform semantic extraction on the second one-dimensional barcode image in each group of training data to obtain the high-quality image semantic features corresponding to each training data, and the preset semantic extraction algorithm can be used to perform semantic extraction on the predicted barcode image corresponding to each group of training data to obtain the predicted image semantic features corresponding to each group of training data. Among them, the preset semantic extraction algorithm can be an algorithm capable of extracting the bar and space width features of the one-dimensional barcode and the index semantic features.
[0081] Step S40: determining the barcode semantic feature loss value according to the high-quality image semantic features and the predicted image semantic features corresponding to each set of training data.
[0082] In actual use, by comparing the semantic features of high-quality images corresponding to a set of training data with the semantic features of predicted images, the difference between the semantic features of the image reconstructed by the initial reconstruction model after super-resolution processing and the actual high-quality image can be determined, thereby determining the semantic loss caused by the initial reconstruction model when performing super-resolution processing and image reconstruction. By comparing the semantic features of high-quality images corresponding to each set of training data with the semantic features of predicted images, the overall difference can be obtained, thereby obtaining the barcode semantic feature loss value.
[0083] In actual use, a second preset loss algorithm can be used to determine the barcode semantic feature loss value according to the high-quality image semantic features and predicted image semantic features corresponding to each group of training data. The second preset loss algorithm can be pre-set by the administrator of the model training device, for example: the second preset loss algorithm is set to the absolute error loss algorithm (MAE, or L1 loss), the mean square error algorithm (MSE, or L2 loss). Of course, other loss algorithms can also be used, such as Huber loss, which is not limited in this embodiment. The preset loss algorithm can be the same algorithm as the second preset loss algorithm, or it can be a different algorithm, which is not limited in this embodiment.
[0084] Step S50: adjusting the model parameters of the initial reconstruction model according to the pixel-level loss value and the barcode semantic feature loss value, and detecting whether the initial reconstruction model meets a preset convergence condition.
[0085] It should be noted that the preset convergence condition can be a judgment condition for determining whether the initial reconstruction model has been trained, and can be set in advance by the administrator of the model training device. When setting the preset convergence condition, it can be set according to the training rounds and / or loss value changes of the model. For example: the preset convergence condition is set to n (n is a preset positive integer, which can be calibrated by the administrator of the model training device according to actual needs) rounds of training, and then it is determined that the preset convergence condition is met; in the most recent multiple rounds of training, the rate of change of the pixel-level loss value and the barcode semantic feature loss value is less than the preset change threshold (the preset change threshold can be set by the administrator of the model training device according to actual needs).
[0086] In actual use, adjusting the model parameters of the initial reconstruction model according to the pixel level loss value and the barcode semantic feature loss value can be to adjust the model parameters of the initial reconstruction model with the goal of reducing both the pixel level loss value and the barcode semantic feature loss value.
[0087] In a possible implementation of this embodiment, in order to ensure the rationality of parameter adjustment, the step of adjusting the model parameters of the initial reconstruction model according to the pixel-level loss value and the barcode semantic feature loss value in this embodiment may include:
[0088] Find the loss impact factors corresponding to the pixel-level loss value and the barcode semantic feature loss value respectively;
[0089] Constructing a final loss value according to the loss impact factor, the pixel-level loss value and the barcode semantic feature loss value;
[0090] The model parameters of the initial reconstruction model are adjusted according to the final loss value.
[0091] It should be noted that the loss impact factor can be used to characterize the proportion of the impact of the loss value on the overall loss. The loss impact factors corresponding to the pixel-level loss value and the barcode semantic feature loss value can be pre-set by the manager of the model training equipment according to actual needs. For example: if the final trained model focuses on the quality of the reconstructed image, the loss impact factor corresponding to the pixel-level loss value can be set to a larger value; similarly, if the final trained model focuses on the integrity of the barcode semantic features, the loss impact factor corresponding to the barcode semantic feature loss value can be set to a larger value.
[0092] In actual use, the pixel-level loss value and the barcode semantic feature loss value can be multiplied by their corresponding loss impact factors, and the products are added together, and the sum is used as the final loss value. For example: Assuming that the pixel-level loss value is Loss1, the barcode semantic feature loss value is Loss2, and the loss impact factors corresponding to the pixel-level loss value and the barcode semantic feature loss value are a and b respectively, then the final loss value Lf=a*Loss1+b*Loss2.
[0093] In a specific implementation, the model parameters can be divided into two categories: weight parameters and bias parameters. In order to reasonably adjust the model parameters, the step of adjusting the model parameters of the initial reconstruction model according to the final loss value in this embodiment may include:
[0094] Determine the error gradient corresponding to each layer of the network in the initial reconstruction model according to the final loss value;
[0095] Derived the weight gradient and bias gradient corresponding to each layer of the network in the initial reconstruction model according to the error gradient;
[0096] Obtaining a model learning rate corresponding to the initial reconstruction model;
[0097] The weight parameters of each layer of the network in the initial reconstruction model are adjusted according to the model learning rate and the weight gradient, and the bias parameters of each layer of the network in the initial reconstruction model are adjusted according to the model learning rate and the bias parameter.
[0098] It should be noted that after determining the final loss value, reverse deduction can be performed to determine the error gradient corresponding to each layer of the network in the initial reconstruction model based on the final loss value. Then, the error gradient is decomposed to deduce and determine the weight gradient and bias gradient corresponding to each layer of the network in the initial reconstruction model. Finally, the weight parameters of each layer of the network in the initial reconstruction model are adjusted according to the model learning rate corresponding to the initial reconstruction model combined with the weight gradient, and the bias parameters of each layer of the network in the initial reconstruction model are adjusted according to the model learning rate corresponding to the initial reconstruction model combined with the bias parameter.
[0099] Among them, the model learning rate corresponding to the initial reconstruction model is used to characterize the step size used when updating the model parameters in each iteration. It can be set in advance by the manager of the model training equipment according to actual needs. For example, if the model training speed needs to be faster, the model learning rate can be set to a larger value; if it is necessary to ensure that the optimal solution is obtained as much as possible during the model training process, the model learning rate can be set to a smaller value.
[0100] Step S60: If the initial reconstruction model meets a preset convergence condition, the initial reconstruction model is used as a one-dimensional code reconstruction model.
[0101] In actual use, if the initial reconstruction model does not meet the preset convergence conditions, it means that the initial reconstruction model has not been trained yet. At this time, the initial reconstruction model after adjusting the model parameters can be used as a new initial reconstruction model, and return to step S10 to continue training the initial reconstruction model.
[0102] If the initial reconstruction model meets the preset convergence conditions, it means that the initial reconstruction model has been trained. When performing super-resolution reconstruction on one-dimensional barcode images, it has high stability and can accurately perform super-resolution processing to reconstruct one-dimensional barcode images with high image quality. Therefore, the initial reconstruction model can be used as a one-dimensional code reconstruction model.
[0103] Among them, the one-dimensional code reconstruction model can perform super-resolution processing on the input one-dimensional barcode image with low image quality, and reconstruct a one-dimensional barcode image with high image quality.
[0104] In a possible implementation of this embodiment, after the one-dimensional code reconstruction model is obtained, the one-dimensional code reconstruction model can be used to reconstruct the one-dimensional barcode image with poor image quality. In this case, after step S60 in this embodiment, the following may also be included:
[0105] The one-dimensional barcode image to be reconstructed is input into the one-dimensional code reconstruction model for processing to generate a reconstructed one-dimensional barcode image.
[0106] It should be noted that the one-dimensional barcode image to be reconstructed is an image that contains a one-dimensional barcode, but the image quality is so low that it is difficult to identify the true value of the one-dimensional barcode. The reconstructed one-dimensional barcode image is an image that contains the same one-dimensional barcode as the one-dimensional barcode image to be reconstructed, but the image quality is higher than that of the one-dimensional barcode image to be reconstructed.
[0107] In actual use, the one-dimensional barcode image to be reconstructed is input into the one-dimensional barcode reconstruction model, and the one-dimensional barcode can perform super-resolution processing on the one-dimensional barcode in the one-dimensional barcode image to be reconstructed, and generate a reconstructed one-dimensional barcode image with higher image quality, thereby ensuring that the reconstructed one-dimensional barcode image can be recognized and the barcode true value of the one-dimensional barcode can be obtained.
[0108] It can be understood that, since the pixel-level loss value and the barcode semantic feature loss value are combined to adjust the model parameters when training the initial reconstruction model, the pixel-level loss of the reconstructed image and the loss of semantic features are fully considered. The one-dimensional code reconstruction model thus trained can ensure that even when the PPM of the input one-dimensional barcode image is very small and / or the quality is poor, the reconstructed image quality and semantic features are accurate, thereby outputting high-resolution images with accurate bar and space widths, improving the stability of the super-resolution model, and improving the performance of barcode recognition.
[0109] The present embodiment provides a one-dimensional barcode super-resolution model training method. Since the model parameters are adjusted in combination with the pixel-level loss value and the barcode semantic feature loss value when the initial reconstruction model is trained, the pixel-level loss of the reconstructed image and the loss of the semantic features are fully considered. The one-dimensional code reconstruction model thus trained can ensure the accuracy of the reconstructed image quality and semantic features even when the PPM of the input one-dimensional barcode image is very small and / or the quality is poor, thereby outputting a high-resolution image with accurate bar and space width, improving the stability of the super-resolution model, and improving the performance of barcode recognition.
[0110] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 The step S30 includes steps S301 and S302:
[0111] Step S301: Acquire a semantic feature extraction model;
[0112] Step S302: Semantically extract the second one-dimensional barcode images in each group of training data through the semantic feature extraction model to obtain high-quality image semantic features corresponding to each training data, and semantically extract the predicted barcode images corresponding to each group of training data through the semantic feature extraction model to obtain predicted image semantic features corresponding to each group of training data.
[0113] It should be noted that the semantic feature extraction model is a pre-trained model for extracting semantic features. The semantic features may include bar width features and index semantic features. If necessary, other features may also be included, which is not limited in this embodiment.
[0114] It is understandable that using a pre-trained semantic feature extraction model for semantic feature extraction is more robust and may be more accurate than using a fixed semantic feature extraction algorithm. It can make the extracted high-quality image semantic features and the predicted image semantic features more in line with the actual situation, thereby ensuring better training results for the subsequent initial reconstruction model.
[0115] In a possible implementation of this embodiment, in order to ensure that the semantic feature extraction model can be quickly trained, before step S301 in this embodiment, the following may also be included:
[0116] Predicting the second one-dimensional barcode image in each group of recognition training data by using the initial barcode recognition model to obtain the index sequence prediction result corresponding to each group of recognition training data;
[0117] Construct a sequence prediction loss value according to the true value of the index sequence in each group of recognition training data and the prediction result of the index sequence corresponding to each group of recognition training data;
[0118] Adjusting the model parameters of the initial barcode recognition model according to the sequence prediction loss value, and detecting whether the initial barcode recognition model meets a preset convergence condition;
[0119] If the initial barcode recognition model meets the preset convergence condition, the initial barcode recognition model is used as a one-dimensional barcode recognition model;
[0120] The obtaining of the semantic feature extraction model comprises:
[0121] A feature extraction model is extracted from the one-dimensional barcode recognition model to obtain a semantic feature extraction model.
[0122] It should be noted that a set of recognition training data includes a second one-dimensional barcode image and the true value of the index sequence corresponding to the second one-dimensional barcode image, and the initial barcode recognition model includes a feature extraction model and an index prediction model, wherein the feature extraction model can be a Resnet model, or other similar models, for extracting semantic features; the index prediction model can be an LSTM model, or other similar models, for classifying the extracted semantic features.
[0123] In actual use, if a single feature extraction model is trained, it is actually difficult to determine the specific extraction effect of its feature extraction, and it is difficult to construct training data for such a single feature extraction model (if a single feature extraction model is trained, the training samples need to include standard extraction features, and it is difficult to manually construct extraction features). Therefore, in order to ensure that the semantic feature extraction model can be quickly trained, the initial barcode recognition model jointly constructed by the feature extraction model and the index prediction model can be trained. Because of the joint training, it can be ensured that the constructed recognition training data only contains the second one-dimensional barcode image with higher image quality and its corresponding index sequence true value.
[0124] In actual use, when constructing the sequence prediction loss value according to the true value of the index sequence in each group of recognition training data and the index sequence prediction result corresponding to each group of recognition training data, the implementation process is similar to the above-mentioned pixel-level loss value and barcode semantic feature loss value, but the loss algorithm used may be different, which will not be repeated here.
[0125] In actual application, the setting method of the preset convergence condition corresponding to the initial barcode recognition model is similar to the setting method of the preset convergence condition corresponding to the initial reconstruction model. The specific setting method can refer to the description of the above embodiment and will not be repeated here. Among them, the preset convergence conditions set for the initial barcode recognition model and the initial reconstruction model can be the same or different, and this embodiment does not limit this.
[0126] Similarly, when adjusting the model parameters of the initial barcode recognition model according to the sequence prediction loss value, the specific adjustment process is similar to the implementation process of adjusting the model parameters of the initial reconstruction model according to the final loss value. The specific implementation can refer to the above description and will not be repeated here.
[0127] In a possible implementation of this embodiment, in order to quickly construct training data, before the step of predicting the second one-dimensional barcode image in each group of recognition training data by using the initial barcode recognition model to obtain the index sequence prediction result corresponding to each group of recognition training data, the following may also be included:
[0128] Acquire a one-dimensional barcode super-resolution dataset, wherein the one-dimensional barcode super-resolution dataset includes a plurality of sample pairs, wherein the sample pairs include a first one-dimensional barcode image, a second one-dimensional barcode image, and a true value of an index sequence corresponding to the one-dimensional barcode;
[0129] Extracting multiple sample pairs from the one-dimensional barcode super-resolution dataset;
[0130] The first one-dimensional barcode image in the plurality of sample pairs is removed to obtain a plurality of groups of recognition training data.
[0131] It should be noted that the one-dimensional barcode super-resolution dataset may include multiple sample pairs, each of which may include a first one-dimensional barcode image, a second one-dimensional barcode image, and an index sequence true value corresponding to a one-dimensional barcode. The index sequence true value may be the real index sequence data corresponding to the one-dimensional barcode.
[0132] It can be understood that the sample pair includes a first one-dimensional barcode image, a second one-dimensional barcode image and a true value of the index sequence, but when training the initial barcode recognition model, it is actually only necessary to use the second one-dimensional barcode image corresponding to the one-dimensional barcode and the true value of the index sequence. Therefore, after extracting multiple sample pairs from the one-dimensional barcode super-resolution data set, the first one-dimensional barcode image in each sample pair and a sample pair with the first one-dimensional barcode image removed can be used as a set of recognition training data, thereby obtaining multiple sets of recognition training data.
[0133] When extracting multiple sample pairs from a one-dimensional barcode super-resolution data set, the number of extracted sample pairs can be pre-set by the administrator of the model training device.
[0134] For ease of understanding, now combined Figure 3 , 4 and 5 are used to illustrate, but not to limit this solution. Figure 3 This is a schematic diagram of the complete model training process of this embodiment. Figure 4 This is a schematic diagram of the execution flow of the first pre-training module of this embodiment. Figure 5 This is a schematic diagram of the execution flow of the second pre-training module of this embodiment.
[0135] like Figure 3 As shown, the complete model training process of this application includes:
[0136] 1. Establish a one-dimensional barcode image super-resolution dataset under real degradation conditions, including a large number of sample pairs, each sample pair contains a low-quality one-dimensional barcode image (i.e., the first one-dimensional barcode image), a high-quality one-dimensional barcode image (i.e., the second one-dimensional barcode image) and the true value of the one-dimensional barcode corresponding index sequence;
[0137] 2. The first pre-training module uses high-quality one-dimensional barcode images and one-dimensional barcode corresponding index true values in the one-dimensional barcode image super-resolution dataset to train a one-dimensional barcode recognition module (i.e., an initial barcode recognition model); the one-dimensional barcode recognition module consists of a barcode semantic feature extraction module (i.e., a feature extraction model) and a barcode index prediction module (index prediction model); after the training is completed, the pre-training weights of the barcode semantic feature extraction module are obtained (the semantic feature extraction model can be constructed based on the pre-training weights).
[0138] 3. The second pre-training module uses low-quality one-dimensional barcode images and high-quality one-dimensional barcode images to train the one-dimensional barcode super-resolution module model (i.e., the initial reconstruction model). The barcode semantic feature extraction module (i.e., the semantic feature extraction model) loaded with pre-trained weights is used to extract the barcode semantic features of the one-dimensional barcode super-resolution model prediction image (i.e., the predicted barcode image) as supervisory information to assist in training the one-dimensional barcode super-resolution model, which is used to improve the stability of the one-dimensional barcode super-resolution model. The barcode semantic features include bar space width features and index semantic features. The one-dimensional barcode super-resolution model (i.e., the one-dimensional code reconstruction model) obtained after the training is completed has good stability, can accurately reconstruct high-quality one-dimensional barcode images, output accurate bar space widths, and reduce the probability of barcode distortion.
[0139] 4. Obtain a low-quality one-dimensional barcode image to be tested, input the one-dimensional barcode super-resolution module (i.e., one-dimensional code reconstruction model) loaded with pre-trained weights, and obtain the corresponding high-quality one-dimensional barcode reconstructed image.
[0140] The specific execution process of the first pre-training module can be as follows: Figure 4 As shown, the following steps are included:
[0141] 1. Obtain training data from the one-dimensional barcode super-resolution dataset. High-quality one-dimensional barcode images and corresponding index sequence true values constitute a set of training data; training set Ω REC Multiple sets of training data may be included.
[0142] 2. Configure the network parameters for the initial one-dimensional barcode recognition network model as θ 0 REC , that is, the parameter set is θ 0 REC , and set the high-level parameters related to training (such as learning rate, related parameters of the gradient descent algorithm, etc.).
[0143] 3. Based on the network parameters θ 0 REC The initial network model of the training set Ω REC The high-quality one-dimensional barcode image is forward calculated to obtain the barcode index sequence prediction result. REC The true value of the index sequence and the predicted result of the index sequence determine the loss value L REC (i.e., the sequence prediction loss value).
[0144] 4. Based on the loss value L REC Using the back propagation algorithm, θ 0 REC Adjust to obtain θ l REC .
[0145] 5. Repeat steps (3) to (4) until the network model converges and the output parameter θ final REC , and based on the parameter θ final REC The network model composed of is the trained network model.
[0146] Among them, the one-dimensional barcode semantic feature extraction module and the one-dimensional barcode index prediction module of the one-dimensional barcode recognition module are jointly trained. final REC In, θ final feature and θ final cls They are the network weights of the one-dimensional barcode semantic feature extraction module and the one-dimensional barcode index prediction module. The trained one-dimensional barcode recognition module has the ability to distinguish the bar width in the input one-dimensional barcode image and classify the barcode index type, thereby realizing the prediction of the one-dimensional barcode index sequence. Among them, the image features extracted by the trained one-dimensional barcode semantic feature extraction module (i.e., semantic feature extraction model) include bar width features and index semantic features.
[0147] The specific execution process of the second pre-training module can be as follows Figure 5 As shown, the following steps are included:
[0148] 1. Obtain training data from the one-dimensional barcode super-resolution dataset. High-quality one-dimensional barcode images and low-quality one-dimensional barcode images form a set of training data; training set Ω SR Multiple sets of training data may be included.
[0149] 2. Configure the network parameters for the initial one-dimensional barcode super-resolution network model to be θ 0 SR , that is, the parameter set is θ 0 SR , and set the high-level parameters related to training (such as learning rate, related parameters of the gradient descent algorithm, etc.).
[0150] 3. Configure the network parameters θ provided by the first pre-training module after training for the one-dimensional barcode semantic feature extraction module final feature , thus obtaining a semantic feature extraction model.
[0151] 4. Based on the network parameters θ 0 SR The initial network model (i.e., the initial reconstruction model) of the training set Ω SR The low-quality one-dimensional barcode images are forward calculated to obtain the high-quality one-dimensional barcode image prediction results. SR The pixel-level loss value L is determined by the true value and prediction result of the medium-high quality one-dimensional barcode image. pixel .
[0152] 5. Based on the trained one-dimensional barcode semantic feature extraction module, forward calculations are performed on the true value and prediction results of the high-quality one-dimensional barcode image to obtain a feature map F containing bar width features and index semantic features. GT and F pred Based on F GT and F pred Determine the barcode semantic feature loss value L feature .
[0153] 6. Pixel-level loss value L pixel and the barcode semantic feature loss value L feature Determine the final loss value L total , based on the final loss value L total Using the back propagation algorithm, θ 0 SR Adjust to obtain θ i SR .
[0154] 7. Repeat steps (4) to (6) until the network model converges and the output parameter θ finalSR , and based on the parameter θ final SR The composed network model is the trained network model (i.e., the one-dimensional code reconstruction model).
[0155] The present embodiment provides a one-dimensional barcode super-resolution model training method. By jointly training the feature extraction model and the index prediction model in advance, it is ensured that a semantic feature extraction model that can be used for semantic extraction can be quickly acquired. Compared with using a fixed semantic feature extraction algorithm, it has stronger robustness and may also be more accurate. It can make the extracted high-quality image semantic features and the predicted image semantic features more in line with the actual situation, thereby ensuring better training results for the subsequent initial reconstruction model.
[0156] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the one-dimensional barcode super-resolution model training method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0157] This application also provides a model training device, please refer to Figure 6 , the model training device comprises:
[0158] An image prediction module 10 is used to predict the first one-dimensional barcode image in each group of training data according to the initial reconstruction model to obtain a predicted barcode image corresponding to each group of training data, wherein a group of training data includes a first one-dimensional barcode image and a second one-dimensional barcode image, wherein the first one-dimensional barcode image and the second one-dimensional barcode image correspond to the same one-dimensional barcode, and the image quality of the first one-dimensional barcode image is lower than the image quality of the second one-dimensional barcode image, and the image quality of the predicted barcode image is higher than the image quality of the first one-dimensional barcode image;
[0159] A first loss module 20, used to determine a pixel-level loss value according to the second one-dimensional barcode image in each set of training data and the predicted barcode image corresponding to each set of training data;
[0160] The semantic extraction module 30 is used to perform semantic extraction on the second one-dimensional barcode images in each group of training data to obtain the high-quality image semantic features corresponding to each training data, and to perform semantic extraction on the predicted barcode images corresponding to each group of training data to obtain the predicted image semantic features corresponding to each group of training data;
[0161] The second loss module 40 is used to determine the barcode semantic feature loss value according to the high-quality image semantic features and the predicted image semantic features corresponding to each set of training data;
[0162] A parameter adjustment module 50, used to adjust the model parameters of the initial reconstruction model according to the pixel level loss value and the barcode semantic feature loss value, and detect whether the initial reconstruction model meets a preset convergence condition;
[0163] The model determination module 60 is configured to use the initial reconstruction model as a one-dimensional code reconstruction model if the initial reconstruction model meets a preset convergence condition.
[0164] The model training device provided by the present application adopts the one-dimensional barcode super-resolution model training method in the above embodiment, which can solve the technical problem that one-dimensional barcode distortion is easy to occur when the prior art super-resolution technology reconstructs the one-dimensional barcode image. Compared with the prior art, the beneficial effects of the model training device provided by the present application are the same as the beneficial effects of the one-dimensional barcode super-resolution model training method provided by the above embodiment, and the other technical features in the model training device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0165] The present application provides a model training device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the one-dimensional barcode super-resolution model training method in the above-mentioned embodiment one.
[0166] Reference below Figure 7 , which shows a schematic diagram of the structure of a model training device suitable for implementing the embodiment of the present application. The model training device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The model training device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0167] like Figure 7As shown, the model training device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the model training device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the model training device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a model training device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0168] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0169] The model training device provided by the present application adopts the one-dimensional barcode super-resolution model training method in the above embodiment, which can solve the technical problem that one-dimensional barcode distortion is easy to occur when the prior art super-resolution technology reconstructs the one-dimensional barcode image. Compared with the prior art, the beneficial effects of the model training device provided by the present application are the same as the beneficial effects of the one-dimensional barcode super-resolution model training method provided by the above embodiment, and the other technical features in the model training device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0170] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0171] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0172] The present application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the one-dimensional barcode super-resolution model training method in the above-mentioned embodiment.
[0173] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0174] The above-mentioned computer-readable storage medium may be included in the model training device; or it may exist independently without being assembled into the model training device.
[0175] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the model training device, the model training device: predicts the first one-dimensional barcode image in each group of training data according to the initial reconstruction model to obtain the predicted barcode image corresponding to each group of training data, a group of training data includes a first one-dimensional barcode image and a second one-dimensional barcode image, the first one-dimensional barcode image and the second one-dimensional barcode image correspond to the same one-dimensional barcode, and the image quality of the first one-dimensional barcode image is lower than the image quality of the second one-dimensional barcode image, and the image quality of the predicted barcode image is higher than the image quality of the first one-dimensional barcode image; according to the second one-dimensional barcode image in each group of training data and the first one-dimensional barcode image in each group of training data, the predicted barcode image is obtained. The pixel-level loss value is determined according to the predicted barcode image; semantic extraction is performed on the second one-dimensional barcode image in each group of training data to obtain the high-quality image semantic features corresponding to each training data, and semantic extraction is performed on the predicted barcode image corresponding to each group of training data to obtain the predicted image semantic features corresponding to each group of training data; the barcode semantic feature loss value is determined according to the high-quality image semantic features and the predicted image semantic features corresponding to each group of training data; the model parameters of the initial reconstruction model are adjusted according to the pixel-level loss value and the barcode semantic feature loss value, and it is detected whether the initial reconstruction model meets the preset convergence condition; if the initial reconstruction model meets the preset convergence condition, the initial reconstruction model is used as the one-dimensional code reconstruction model.
[0176] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0177] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0178] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0179] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned one-dimensional barcode super-resolution model training method, and can solve the technical problem that one-dimensional barcode distortion is easy to occur when the prior art super-resolution technology reconstructs the one-dimensional barcode image. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the one-dimensional barcode super-resolution model training method provided by the above-mentioned embodiment, and will not be repeated here.
[0180] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the one-dimensional barcode super-resolution model training method as described above.
[0181] The computer program product provided in this application can solve the technical problem of model training. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the one-dimensional barcode super-resolution model training method provided in the above embodiment, which will not be repeated here.
[0182] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A one-dimensional barcode super-resolution model training method, characterized in that: The one-dimensional barcode super-resolution model training method comprises: Predicting the first one-dimensional barcode image in each group of training data according to the initial reconstruction model to obtain a predicted barcode image corresponding to each group of training data, wherein a group of training data includes a first one-dimensional barcode image and a second one-dimensional barcode image, wherein the first one-dimensional barcode image and the second one-dimensional barcode image correspond to the same one-dimensional barcode, the second one-dimensional barcode image is a pixel-level true value image of the corresponding one-dimensional barcode, and the image quality of the first one-dimensional barcode image is lower than the image quality of the second one-dimensional barcode image, and the image quality of the predicted barcode image is higher than the image quality of the first one-dimensional barcode image; Determine a pixel-level loss value according to the second one-dimensional barcode image in each group of training data and the predicted barcode image corresponding to each group of training data; Semantic extraction is performed on the second one-dimensional barcode images in each group of training data to obtain high-quality image semantic features corresponding to each training data, and semantic extraction is performed on the predicted barcode images corresponding to each group of training data to obtain predicted image semantic features corresponding to each group of training data; Determine the barcode semantic feature loss value according to the high-quality image semantic features and predicted image semantic features corresponding to each group of training data; Adjusting the model parameters of the initial reconstruction model according to the pixel-level loss value and the barcode semantic feature loss value, and detecting whether the initial reconstruction model meets a preset convergence condition; If the initial reconstruction model meets the preset convergence condition, the initial reconstruction model is used as the one-dimensional code reconstruction model; The steps of performing semantic extraction on the second one-dimensional barcode images in each group of training data to obtain high-quality image semantic features corresponding to each training data, and performing semantic extraction on the predicted barcode images corresponding to each group of training data to obtain predicted image semantic features corresponding to each group of training data include: Acquire a semantic feature extraction model, where the semantic feature extraction model is a pre-trained model for extracting semantic features, where the semantic features include a bar width feature and an index semantic feature; The semantic feature extraction model is used to perform semantic extraction on the second one-dimensional barcode image in each group of training data to obtain high-quality image semantic features corresponding to each training data, and the semantic feature extraction model is used to perform semantic extraction on the predicted barcode image corresponding to each group of training data to obtain predicted image semantic features corresponding to each group of training data.
2. The one-dimensional barcode super-resolution model training method according to claim 1, characterized in that: Before acquiring the semantic feature extraction model, the method further includes: The second one-dimensional barcode image in each group of recognition training data is predicted by the initial barcode recognition model to obtain the index sequence prediction result corresponding to each group of recognition training data, wherein a group of recognition training data includes the second one-dimensional barcode image and the true value of the index sequence corresponding to the second one-dimensional barcode image, and the initial barcode recognition model includes a feature extraction model and an index prediction model; Construct a sequence prediction loss value according to the true value of the index sequence in each group of recognition training data and the prediction result of the index sequence corresponding to each group of recognition training data; Adjusting the model parameters of the initial barcode recognition model according to the sequence prediction loss value, and detecting whether the initial barcode recognition model meets a preset convergence condition; If the initial barcode recognition model meets the preset convergence condition, the initial barcode recognition model is used as a one-dimensional barcode recognition model; The obtaining of the semantic feature extraction model comprises: A feature extraction model is extracted from the one-dimensional barcode recognition model to obtain a semantic feature extraction model.
3. The one-dimensional barcode super-resolution model training method according to claim 2, characterized in that: Before predicting the second one-dimensional barcode image in each group of recognition training data by using the initial barcode recognition model to obtain the index sequence prediction result corresponding to each group of recognition training data, the method further includes: Acquire a one-dimensional barcode super-resolution dataset, wherein the one-dimensional barcode super-resolution dataset includes a plurality of sample pairs, wherein the sample pairs include a first one-dimensional barcode image, a second one-dimensional barcode image, and a true value of an index sequence corresponding to the one-dimensional barcode; Extracting multiple sample pairs from the one-dimensional barcode super-resolution dataset; The first one-dimensional barcode image in the plurality of sample pairs is removed to obtain a plurality of groups of recognition training data.
4. The one-dimensional barcode super-resolution model training method according to claim 1, characterized in that: The adjusting the model parameters of the initial reconstruction model according to the pixel level loss value and the barcode semantic feature loss value includes: Find the loss impact factors corresponding to the pixel-level loss value and the barcode semantic feature loss value respectively, wherein the loss impact factor is used to characterize the impact ratio of the loss value on the overall loss; Constructing a final loss value according to the loss impact factor, the pixel-level loss value and the barcode semantic feature loss value; Determine the error gradient corresponding to each layer of the network in the initial reconstruction model according to the final loss value; Derived weight gradients and bias gradients corresponding to each layer of the network in the initial reconstruction model according to the error gradient; Obtaining a model learning rate corresponding to the initial reconstruction model; The weight parameters of each layer of the network in the initial reconstruction model are adjusted according to the model learning rate and the weight gradient, and the bias parameters of each layer of the network in the initial reconstruction model are adjusted according to the model learning rate and the bias gradient.
5. The one-dimensional barcode super-resolution model training method according to claim 1, characterized in that: Before predicting the first one-dimensional barcode image in each group of training data according to the initial reconstruction model to obtain the predicted barcode image corresponding to each group of training data, the method further includes: Acquire a one-dimensional barcode super-resolution dataset, wherein the one-dimensional barcode super-resolution dataset includes a plurality of sample pairs, wherein the sample pairs include a first one-dimensional barcode image, a second one-dimensional barcode image, and a true value of an index sequence corresponding to the one-dimensional barcode; Extracting multiple sample pairs from the one-dimensional barcode super-resolution dataset; The true values of the index sequences in the multiple sample pairs are removed to obtain multiple groups of training data.
6. The one-dimensional barcode super-resolution model training method according to any one of claims 1 to 5, characterized in that: If the initial reconstruction model satisfies the preset convergence condition, after using the initial reconstruction model as the one-dimensional code reconstruction model, the method further includes: Inputting the one-dimensional barcode image to be reconstructed into the one-dimensional code reconstruction model for processing to generate a reconstructed one-dimensional barcode image; The one-dimensional barcode image to be reconstructed is an image containing a one-dimensional barcode but having such low image quality that the true value of the one-dimensional barcode is difficult to identify; the reconstructed one-dimensional barcode image is an image containing the same one-dimensional barcode as the one-dimensional barcode image to be reconstructed but having higher image quality than the one-dimensional barcode image to be reconstructed.
7. A model training device, characterized in that: The device comprises: An image prediction module is used to predict the first one-dimensional barcode image in each group of training data according to the initial reconstruction model to obtain a predicted barcode image corresponding to each group of training data, wherein a group of training data includes a first one-dimensional barcode image and a second one-dimensional barcode image, wherein the first one-dimensional barcode image and the second one-dimensional barcode image correspond to the same one-dimensional barcode, the second one-dimensional barcode image is a pixel-level true value image of the corresponding one-dimensional barcode, and the image quality of the first one-dimensional barcode image is lower than the image quality of the second one-dimensional barcode image, and the image quality of the predicted barcode image is higher than the image quality of the first one-dimensional barcode image; A first loss module, used to determine a pixel-level loss value according to the second one-dimensional barcode image in each group of training data and the predicted barcode image corresponding to each group of training data; A semantic extraction module is used to perform semantic extraction on the second one-dimensional barcode images in each group of training data to obtain high-quality image semantic features corresponding to each training data, and to perform semantic extraction on the predicted barcode images corresponding to each group of training data to obtain predicted image semantic features corresponding to each group of training data; The second loss module is used to determine the barcode semantic feature loss value according to the high-quality image semantic features and the predicted image semantic features corresponding to each group of training data; A parameter adjustment module, used to adjust the model parameters of the initial reconstruction model according to the pixel level loss value and the barcode semantic feature loss value, and detect whether the initial reconstruction model meets the preset convergence condition; A model determination module, configured to use the initial reconstruction model as a one-dimensional code reconstruction model if the initial reconstruction model satisfies a preset convergence condition; Among them, the semantic extraction module is also used to obtain a semantic feature extraction model, which is a pre-trained model for extracting semantic features, and the semantic features include bar space width features and index semantic features; the second one-dimensional barcode images in each group of training data are semantically extracted by the semantic feature extraction model to obtain high-quality image semantic features corresponding to each training data, and the predicted barcode images corresponding to each group of training data are semantically extracted by the semantic feature extraction model to obtain predicted image semantic features corresponding to each group of training data.
8. A model training device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the one-dimensional barcode super-resolution model training method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the one-dimensional barcode super-resolution model training method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the steps of the one-dimensional barcode super-resolution model training method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Text image super-resolution network training method and device and storage medium
CN116342385A
