Counterfeit bill recognition method, device, processor and electronic device
By introducing automatically learned sample weight parameters and data augmentation techniques during the training process of the counterfeit currency identification model, the loss function is optimized, the problems of sample dataset label errors and imbalance are solved, and the accuracy and robustness of the counterfeit currency identification model are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2023-01-12
- Publication Date
- 2026-05-26
AI Technical Summary
In existing technologies, when training counterfeit currency recognition models, there are problems such as incorrect sample dataset labels and data imbalance, resulting in low accuracy in recognizing counterfeit currency.
By introducing automatically learned sample weight parameters and data augmentation techniques, the loss function is optimized, the counterfeit currency identification model is trained, sample weights are automatically adjusted, and the sample dataset is augmented, thereby reducing the impact of noise and data imbalance.
The model improved the accuracy and noise robustness of the counterfeit currency identification model, and enhanced its ability to identify different currencies.
Smart Images

Figure CN116311185B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and more specifically, to a method, apparatus, processor, and electronic device for counterfeit currency identification. Background Technology
[0002] Currently, when identifying counterfeit currency in images, the high cost and long processing time of manual currency image identification necessitate the use of deep learning to train counterfeit currency detection models on sample datasets. These models are then used to identify different currencies within images. During model training, the quality of the sample labels in the dataset significantly impacts the model's accuracy in identifying counterfeit currency. At present, it is difficult to obtain large sample datasets through professional labeling of currency images. Therefore, crowdsourced labeled sample datasets are commonly used for training. However, these datasets often contain a large number of mislabeled samples, introducing noise that causes the model to overfit to the noise distribution, resulting in low accuracy in counterfeit currency identification. Furthermore, the imbalanced sample data for different currencies in crowdsourced labeled datasets further contributes to the model's low accuracy in identifying counterfeit currency. In addition, existing technologies generally use manual adjustment of the weights of the training set to train the counterfeit currency recognition model. However, manually adjusting the weights of the sample dataset often fails to achieve optimal weight parameter values, resulting in a low accuracy rate for the counterfeit currency recognition model.
[0003] There is currently no effective solution to the problem that in related technologies, when training counterfeit currency recognition models, the weights of the sample datasets are manually adjusted, and the training is performed on sample datasets with labeling errors and data imbalance. This results in low accuracy of the counterfeit currency recognition models for images of different currencies. Summary of the Invention
[0004] The main objective of this application is to provide a counterfeit currency identification method, device, processor, and electronic device to solve the problem in related technologies where the weights of sample datasets are manually adjusted during the training of counterfeit currency identification models. This results in training on sample datasets with labeling errors and data imbalances, leading to low accuracy in identifying counterfeit currency images of different currencies.
[0005] To achieve the above objectives, according to one aspect of this application, a counterfeit currency identification method is provided. The method includes: acquiring an image of a target currency to be identified; using a counterfeit currency identification model to predict the probability that the target currency is counterfeit, wherein the counterfeit currency identification model is a model obtained by training an augmented sample dataset using a target loss function, and the target loss function includes parameters of sample weights automatically learned during the training of the counterfeit currency identification model.
[0006] Further, the counterfeit currency identification model is obtained through the following steps: S1, acquiring a sample dataset, wherein the sample dataset includes image data information of various currencies; S2, substituting the sample dataset into a first loss function for calculation to optimize the sample weights of the first loss function, thereby obtaining an optimized first loss function, wherein the first loss function is the loss function used when training the sample dataset; S3, augmenting the sample dataset to obtain an augmented sample dataset; S4, configuring a second loss function based on the optimized first loss function and the augmented sample dataset; S5, substituting the augmented sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function, thereby obtaining an optimized second loss function; repeating steps S2 to S5 for iterative calculation, when the value of the optimized second loss function reaches a local optimum, or when the number of iterations reaches a preset number of iterations, the model obtained after training using the optimized second loss function is used as the counterfeit currency identification model.
[0007] Further, substituting the sample dataset into the first loss function for calculation, to optimize the sample weights of the first loss function to obtain the optimized first loss function includes: configuring the first loss function as... Where, x i Let y represent the i-th image in the sample dataset. i Represents sample data x i The label, Φ(x) i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i;Θ)) is the weighted cross-entropy loss function of the sample dataset; the sample dataset is substituted into the first loss function for training, and training is stopped when the value of the first loss function reaches a local optimum, and the optimized first loss function is obtained.
[0008] Further, the sample dataset is augmented to obtain an augmented sample dataset, which includes: configuring the formula for calculating the pseudo-label of each sample in the sample dataset as follows: in, Pr i Pr represents the k-th random amplification sample of sample i in the sample dataset. j This represents the k-th random amplification sample of sample j in the sample dataset. Let Φ(x) represent the sample with the smallest amplified value in k data amplifications, and let Φ(x) be the predicted probability value of sample x. It is an amplified sample The predicted probability value, g(x,Φ). i The probability that sample x is the i-th type of currency is represented by τ, which is the scaling factor parameter of the softmax function. The value of the pseudo-label corresponding to each sample is calculated according to the formula of the pseudo-label. The augmented sample dataset is obtained based on the original label and the pseudo-label of each sample in the sample dataset, wherein the original label is the annotation result corresponding to a sample data in the sample dataset.
[0009] Further, configuring the second loss function based on the optimized first loss function and the amplified sample dataset includes: configuring the second loss function as follows based on the amplified sample dataset. Where, x i Φ(x) represents the i-th image in the sample dataset. i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset, λ i It is to calculate the weight parameter w between the pseudo-label and the original label. i The sample weights y are the optimized first loss function. i Represents sample data x i The pseudo-label, g(x,Φ)i Let x represent the probability that sample x is of the i-th type of currency. It is for λ i Differentiable functions.
[0010] Further, substituting the amplified sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function and obtain the optimized second loss function includes: substituting the amplified sample dataset into the second loss function for training; stopping training when the value of the second loss function reaches a local optimum, and obtaining the optimized second loss function; backpropagating the sample weights of the optimized second loss function to the sample weights of the optimized first loss function to obtain the second optimized first loss function, wherein the second optimized first loss function is used as the function to calculate the first loss function in the next iteration.
[0011] Further, obtaining the sample dataset includes: obtaining a manually labeled sample dataset and a crowdsourced labeled sample dataset, wherein the manually labeled sample dataset is a sample dataset in which samples are labeled manually, and the crowdsourced labeled sample dataset is a sample dataset in which samples are crowdsourced and have incorrect labeling results, and the number of samples in the manually labeled sample dataset is less than the number of samples in the crowdsourced labeled sample dataset; randomly flipping and rotating the images in the manually labeled sample dataset and the crowdsourced labeled sample dataset to obtain processed images; scaling the processed images to a preset size and cropping them according to the original aspect ratio of the images before processing to obtain cropped images; and normalizing the pixel values of the cropped images to obtain the sample dataset used to train the counterfeit currency recognition model.
[0012] To achieve the above objectives, according to another aspect of this application, a counterfeit currency identification device is provided. The device includes: a first acquisition unit for acquiring an image of a target currency to be identified; and a second acquisition unit for using a counterfeit currency identification model to predict the probability that the target currency is counterfeit, wherein the counterfeit currency identification model is a model obtained by training an amplified sample dataset using a target loss function, and the target loss function includes parameters of sample weights automatically learned during the training of the counterfeit currency identification model.
[0013] Further, the second acquisition unit is obtained through the following steps: a first acquisition subunit, used to acquire a sample dataset, wherein the sample dataset includes data information of images of various currencies; a first calculation subunit, used to substitute the sample dataset into a first loss function for calculation to optimize the sample weights of the first loss function and obtain an optimized first loss function, wherein the first loss function is the loss function used when training the sample dataset; a second acquisition subunit, used to augment the sample dataset to obtain an augmented sample dataset; a configuration subunit, used to configure a second loss function based on the optimized first loss function and the augmented sample dataset; a second calculation subunit, used to substitute the augmented sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function and obtain an optimized second loss function; a third acquisition subunit, used to repeatedly execute the steps in the first to second calculation subunits for iterative calculation, and when the number of iterations reaches a local optimum, or when the value of the optimized second loss function reaches a preset number of iterations, the model obtained after training with the optimized second loss function is used as the counterfeit currency recognition model.
[0014] Furthermore, the first computational subunit includes: a first configuration module, configured to configure the first loss function as... Where, x i Let y represent the i-th image in the sample dataset. i Represents sample data x i The label, Φ(x) i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset; the first acquisition module is used to substitute the sample dataset into the first loss function for training, and stop training when the value of the first loss function reaches a local optimum, and acquire the optimized first loss function.
[0015] Further, the second acquisition subunit includes: a second configuration module, used to configure the calculation formula for the pseudo-label of each sample in the sample dataset as follows: in, Pr iPr represents the k-th random amplification sample of sample i in the sample dataset. j This represents the k-th random amplification sample of sample j in the sample dataset. Let Φ(x) represent the sample with the smallest amplified value in k data amplifications, and let Φ(x) be the predicted probability value of sample x. It is an amplified sample The predicted probability value, g(x,Φ). i The probability that sample x is the i-th type of currency is represented by τ, which is the scaling factor parameter of the softmax function; the calculation module is used to calculate the value of the pseudo-label corresponding to each sample according to the calculation formula of the pseudo-label; the second acquisition module is used to acquire the amplified sample dataset according to the original label and the pseudo-label of each sample in the sample dataset, wherein the original label is the annotation result corresponding to a sample data in the sample dataset.
[0016] Furthermore, the configuration subunit includes: a third configuration module, configured to, based on the amplified sample dataset, set the second loss function as follows: Where, x i Φ(x) represents the i-th image in the sample dataset. i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset, λ i It is to calculate the weight parameter w between the pseudo-label and the original label. i The sample weights y are the optimized first loss function. i Represents sample data x i The pseudo-label, g(x,Φ) i Let x represent the probability that sample x is of the i-th type of currency. It is for λ i Differentiable functions.
[0017] Further, the second calculation subunit includes: a third acquisition module, used to substitute the amplified sample dataset into the second loss function for training, and stop training when the value of the second loss function reaches a local optimum, thereby acquiring the optimized second loss function; and a fourth acquisition module, used to backpropagate the sample weights of the optimized second loss function to the sample weights of the optimized first loss function to obtain the second-optimized first loss function, wherein the second-optimized first loss function is used as the function to calculate the first loss function in the next iteration.
[0018] Further, the first acquisition subunit includes: a fifth acquisition module, used to acquire a manually labeled sample dataset and a crowdsourced labeled sample dataset, wherein the manually labeled sample dataset is a sample dataset in which samples are labeled manually, and the crowdsourced labeled sample dataset is a sample dataset in which samples are crowdsourced and have incorrect labeling results, and the number of samples in the manually labeled sample dataset is less than the number of samples in the crowdsourced labeled sample dataset; a sixth acquisition module, used to randomly flip and rotate the images in the manually labeled sample dataset and the crowdsourced labeled sample dataset to obtain processed images; a seventh acquisition module, used to scale the processed images to a preset size and crop them according to the original aspect ratio of the images before processing to obtain cropped images; and an eighth acquisition module, used to normalize the pixel values of the cropped images to obtain the sample dataset used to train the counterfeit currency recognition model.
[0019] To achieve the above objectives, according to one aspect of this application, a processor is provided for running a program, wherein the program executes any of the above-described counterfeit currency identification methods during runtime.
[0020] To achieve the above objectives, according to one aspect of this application, an electronic device is provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the above-described counterfeit currency identification method.
[0021] This application employs the following steps: acquiring an image of the target currency to be identified; using a counterfeit currency identification model to predict the probability that the target currency is counterfeit; wherein the counterfeit currency identification model is a model obtained by training an augmented sample dataset using a target loss function, the target loss function including parameters of sample weights automatically learned during the training process of the counterfeit currency identification model. This solves the problem in existing technologies where manual adjustment of sample dataset weights is used during the training of counterfeit currency identification models, resulting in training on sample datasets with labeling errors and data imbalances, leading to low accuracy in identifying counterfeit currency images of different currencies. By introducing automatically learned sample weight parameters during the training process of the counterfeit currency identification model, the optimal sample weight parameters are obtained. Simultaneously, data augmentation of the original sample dataset reduces the impact of imbalance in the number of samples of different currency types in the sample dataset, improving the accuracy of the counterfeit currency identification model, thereby increasing the accuracy of the counterfeit currency identification model and enhancing its noise robustness. Attached Figure Description
[0022] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0023] Figure 1 This is a flowchart of a counterfeit currency identification method provided according to an embodiment of this application;
[0024] Figure 2 This is a schematic diagram of a counterfeit currency identification device provided according to an embodiment of this application;
[0025] Figure 3 This is a schematic diagram of a counterfeit currency identification electronic device provided according to an embodiment of this application. Detailed Implementation
[0026] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0027] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] The present invention will now be described in conjunction with preferred implementation steps. Figure 1 This is a flowchart of a counterfeit currency identification method provided according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0030] Step S101: Obtain an image of the target currency to be identified.
[0031] Step S102: Use a counterfeit currency identification model to predict the probability that the target currency is counterfeit. The counterfeit currency identification model is a model obtained by training the augmented sample dataset using a target loss function. The target loss function includes parameters of sample weights that are automatically learned during the training of the counterfeit currency identification model.
[0032] Existing sample datasets used for training counterfeit currency detection models often contain incorrectly labeled samples. This introduces noise into the dataset, leading to model overfitting during training. To mitigate the impact of overfitting on the trained counterfeit currency detection model, this embodiment incorporates automatically learned and updated sample weights into the loss function of the training model. This assigns different weights to different sample data. For example, regarding the issue of incorrectly labeled samples, since a smaller loss function value indicates a higher probability that the sample data has an accurate label, samples with smaller loss function values should be assigned larger weights. Similarly, to address the imbalance in the number of samples from different currencies, since a larger loss function value indicates a higher probability that the sample data belongs to a currency type with only a small number of samples, samples with larger loss function values should be assigned larger weights. Furthermore, to further address the imbalance in the number of samples from different currencies in the sample dataset, an approach of augmenting the original sample dataset is employed.
[0033] In summary, the counterfeit currency identification method provided in this application acquires an image of the target currency to be identified; a counterfeit currency identification model is used to predict the probability that the target currency is counterfeit. The counterfeit currency identification model is obtained by training an augmented sample dataset using a target loss function. This target loss function includes parameters of sample weights automatically learned during the training process. This solves the problem in existing technologies where manual adjustment of sample dataset weights is used during model training, resulting in training on datasets with labeling errors and data imbalances. This method leads to low accuracy in identifying counterfeit currency images of different currencies. By introducing automatically learned sample weight parameters during model training, the optimal sample weight parameters are obtained. Simultaneously, data augmentation of the original sample dataset reduces the impact of sample imbalance between different currency types, improving the accuracy of the counterfeit currency identification model. This, in turn, enhances both the accuracy and noise robustness of the counterfeit currency identification model.
[0034] Optionally, in the counterfeit currency identification method provided in this application embodiment, the counterfeit currency identification model is obtained through the following steps: S1, obtaining a sample dataset, wherein the sample dataset includes data information of images of various currencies; S2, substituting the sample dataset into a first loss function for calculation to optimize the sample weights of the first loss function, thereby obtaining an optimized first loss function, wherein the first loss function is the loss function used when training the sample dataset; S3, performing data augmentation on the sample dataset to obtain an augmented sample dataset; S4, configuring a second loss function based on the optimized first loss function and the augmented sample dataset; S5, substituting the augmented sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function, thereby obtaining an optimized second loss function; repeating steps S2 to S5 for iterative calculation, when the value of the optimized second loss function reaches a local optimum, or when the number of iterations reaches a preset number of iterations, the model obtained after training using the optimized second loss function is used as the counterfeit currency identification model.
[0035] To mitigate the impact of incorrect labels and imbalanced distribution of currency images in the sample dataset on the accuracy of the counterfeit currency identification model, this embodiment introduces automatically learned and updated sample weight parameters into the loss function for training the counterfeit currency identification model. Furthermore, the model is trained using an augmented sample dataset, and the automatically learned and updated sample weight parameters are backpropagated during iterative calculations to achieve higher accuracy in the trained counterfeit currency identification model. The specific process of training the counterfeit currency detection model is as follows: S1, obtain the sample dataset; S2, introduce automatically learned sample weight parameters into the loss function, configure the loss function for training the counterfeit currency detection model (i.e., the first loss function), and simultaneously learn and update the sample weight parameters in the first loss function during iterative training of the counterfeit currency detection model, continuously optimizing the sample weight parameters in the first loss function to obtain a first loss function with a smaller value (i.e., the optimized first loss function). The initial training model for training the counterfeit currency detection model can be configured as Densenet-121, or other models can be configured as the initial training model depending on the actual situation of training the counterfeit currency detection model; S3, then perform data augmentation on the sample dataset; S4, based on the augmented sample data... The first loss function is improved, and the parameters of the sample weights in the second loss function are configured according to the parameters of the sample weights in the optimized first loss function; S5, then during the training of the counterfeit currency identification model, the parameters of the sample weights in the second loss function and other model parameters are automatically learned and updated to obtain a second loss function with a smaller value (i.e., the optimized second loss function); the steps in S2 to S5 are repeated for iterative calculation until the value of the second loss function after each iteration reaches a local optimum, or the number of iterations reaches a preset number of iterations, then the iterative calculation is stopped. Among at least one counterfeit currency identification model obtained from multiple iterations, the counterfeit currency identification model with the smallest value of the second loss function is used as the counterfeit currency identification model for predicting whether different currencies are counterfeit.
[0036] By introducing parameters for automatically learning and updating sample weights during the training of the counterfeit currency recognition model, and configuring the first loss function for training the model, this method effectively controls the impact of different sample data in the sample dataset on the training of the counterfeit currency recognition model. This avoids the problem of manually designing sample weight parameters and failing to achieve optimal sample weights. Furthermore, by augmenting the sample dataset, the method reduces the overfitting effect caused by incorrect labels in the dataset and mitigates the impact of imbalanced sample sizes of different currency images in the dataset. This improves the noise robustness of the counterfeit currency recognition model, thereby enhancing its accuracy in identifying counterfeit currency.
[0037] Optionally, in the counterfeit currency identification method provided in this application embodiment, substituting the sample dataset into the first loss function for calculation to optimize the sample weights of the first loss function and obtain the optimized first loss function includes: configuring the first loss function as... Where, x i Let y represent the i-th image in the sample dataset. i Represents sample data x i The label, Φ(x) i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset; the sample dataset is substituted into the first loss function for training, and training is stopped when the value of the first loss function reaches a local optimum, and the optimized first loss function is obtained.
[0038] To avoid the problem of manually designing sample weight parameters and failing to achieve optimal sample weight parameters, this embodiment introduces the sample weight parameter w when configuring the first loss function. i The formula for calculating the first loss function is shown below:
[0039]
[0040] Where, x i Let y represent the i-th image in the sample dataset. i Represents sample data x i The label, Φ(x) i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i Θ)) is the weighted cross-entropy loss function of the sample dataset. During the training of the counterfeit currency detection model, the parameter w of the sample weights is continuously learned and updated. iThe process of optimizing the sample weight parameters in the first loss function continues until the value of the first loss function reaches a local optimum, at which point the optimization of the first loss function ends, and the optimized first loss function is obtained.
[0041] By incorporating the parameters of the sample weights into the first loss function, the parameters of the sample weights can be continuously learned and updated during the training of the counterfeit currency recognition model, resulting in an optimized first loss function. This avoids the problem that manually designing the parameters of the sample weights makes it difficult to achieve the optimal parameters, thereby improving the accuracy of the counterfeit currency recognition model in identifying counterfeit currency.
[0042] Optionally, in the counterfeit currency identification method provided in this application embodiment, data augmentation of the sample dataset to obtain the augmented sample dataset includes: configuring the calculation formula for the pseudo-label of each sample in the sample dataset as follows: in, Pr i Pr represents the k-th random amplification of sample i in the sample dataset. j This represents the k-th random amplification of sample j in the sample dataset. Let Φ(x) represent the sample with the smallest amplified value in k data amplifications, and let Φ(x) be the predicted probability value of sample x. It is an amplified sample The predicted probability value, g(x,Φ). i τ represents the probability that sample x is the i-th type of currency, and τ is the scaling factor parameter of the softmax function; calculate the value of the pseudo-label corresponding to each sample according to the formula for calculating the pseudo-label; obtain the amplified sample dataset based on the original label and pseudo-label of each sample in the sample dataset, where the original label is the annotation result corresponding to a sample data in the sample dataset.
[0043] Currently, the sample datasets used to train counterfeit currency detection models often contain sample data with incorrect original labels. To reduce the impact of overfitting caused by incorrect labels in the sample dataset during the training process, this embodiment amplifies pseudo-labels based on the sample data having only the original labels. Specifically, the predicted average value calculated in the Kth iteration (i.e., the Kth data amplification) during the training of the counterfeit currency detection model is used as the initial estimate of the pseudo-label, as shown in the following formula:
[0044]
[0045]
[0046] Among them, Pr i Pr represents the k-th random amplification sample of sample i in the sample dataset. jThis represents the k-th random amplification sample of sample j in the sample dataset. Let Φ(x) represent the sample with the smallest amplified value in k data amplifications, and let Φ(x) be the predicted probability value of sample x. It is an amplified sample The predicted probability value, where τ is the scaling factor parameter of the softmax function, g(x,Φ). i Let x represent the probability that sample x is of the i-th currency class. After amplifying pseudo-labels for the sample data in the sample dataset, the sample data in the sample dataset has both original labels and pseudo-labels, thus completing the data amplification process for the sample dataset. In subsequent calculations on the sample data in the sample dataset, the optimal label will be selected from the original labels and pseudo-labels for calculation. This aims to reduce the impact of incorrect labels in the sample dataset on the overfitting of the model caused by incorrect labels during the training of the counterfeit currency recognition model.
[0047] Optionally, in the counterfeit currency identification method provided in this application embodiment, configuring the second loss function based on the optimized first loss function and the amplified sample dataset includes: configuring the second loss function as follows based on the amplified sample dataset. Where, x i Φ(x) represents the i-th image in the sample dataset. i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset, λ i It is the weight parameter for calculating the pseudo-labels and the original labels, w i These are the sample weights of the optimized first loss function, y i Represents sample data x i The pseudo-label, g(x,Φ) i Let x represent the probability that sample x is of the i-th type of currency. It is for λ i Differentiable functions.
[0048] After augmenting the sample dataset, the formula for calculating the label of the sample data by combining the original label and pseudo label is as follows:
[0049]
[0050] in, It is for λ i Differentiable function, λ i It is a weight parameter combining pseudo-labels and original labels, λ. i The parameters y are automatically learned and updated by continuously minimizing the value of the second loss function. i Represents sample data x i The original label, g(x,Φ) i Let x represent the probability that sample x is of the i-th currency class. Because the labels of the sample data change after data augmentation, the first loss function needs to be improved for subsequent calculations by introducing a parameter to calculate the label weights of the pseudo-labels and original labels of the sample data. Furthermore, the formula for calculating the second loss function is as follows:
[0051]
[0052] Where, x i Φ(x) represents the i-th image in the sample dataset. i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset.
[0053] By automatically learning and updating the label weight parameters of pseudo-labels and original labels during the training of the counterfeit currency recognition model, the influence of erroneous labels in the sample dataset on the training of the counterfeit currency recognition model is reduced. This avoids the problem that manually designing the sample weight parameters in the sample dataset is difficult to achieve the optimal sample weight parameters.
[0054] Optionally, in the counterfeit currency identification method provided in this application embodiment, substituting the amplified sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function and obtain the optimized second loss function includes: substituting the amplified sample dataset into the second loss function for training; stopping training when the value of the second loss function reaches a local optimum to obtain the optimized second loss function; and backpropagating the sample weights of the optimized second loss function to the sample weights of the optimized first loss function to obtain the second optimized first loss function, wherein the second optimized first loss function is the function used as the first loss function for calculation in the next iteration.
[0055] In order to calculate the parameters of sample weights that make the counterfeit currency training model more accurate in recognizing the sample dataset after augmentation, in this embodiment, a second loss function is used to calculate the augmented sample dataset. The calculation stops when the value of the second loss function reaches a local optimum, and the optimized second loss function is obtained.
[0056] In addition, in order to continuously learn and update the parameters of the sample weights in the sample dataset during the training process, after obtaining the optimized second loss function, the parameters of the sample weights in the optimized second loss function need to be backpropagated to the first loss function to update the parameters of the sample weights in the first loss function, so as to obtain the second optimized first loss function. This allows the counterfeit currency recognition model to be trained with the better parameters of the sample weights in the next iteration, thereby improving the accuracy of the counterfeit currency recognition model in recognizing counterfeit currency.
[0057] Optionally, in the counterfeit currency identification method provided in this application embodiment, obtaining the sample dataset includes: obtaining a manually labeled sample dataset and a crowdsourced labeled sample dataset, wherein the manually labeled sample dataset is a sample dataset in which samples are labeled manually, and the crowdsourced labeled sample dataset is a sample dataset in which samples are crowdsourced and have incorrect labeling results, and the number of samples in the manually labeled sample dataset is less than the number of samples in the crowdsourced labeled sample dataset; randomly flipping and rotating the images in the manually labeled sample dataset and the crowdsourced labeled sample dataset to obtain processed images; scaling the processed images to a preset size and cropping them according to the original aspect ratio of the images before processing to obtain cropped images; and normalizing the pixel values of the cropped images to obtain a sample dataset for training the counterfeit currency identification model.
[0058] Currently, obtaining large sample datasets by having professionals accurately label currency types is costly. Therefore, the sample datasets used to train counterfeit currency detection models are often crowdsourced labeled datasets. In crowdsourced labeled datasets, the labels on the sample data are often incorrect, introducing noise into the dataset. During the training process, the model tends to fit the noise distribution in the sample dataset, resulting in a low accuracy rate in identifying counterfeit currency.
[0059] To avoid the counterfeit currency identification model's accuracy being reduced due to noise in the sample dataset, this embodiment introduces a manually labeled sample dataset containing accurate and unbiased labels to guide the training process of the counterfeit currency identification model: the crowdsourced labeled sample dataset is used as the training sample set, and the manually labeled sample dataset is used as the validation sample set. The loss function values of the training samples and the validation samples are calculated by performing calculations on the minimum batch (i.e., Mini Batch) of training samples in the training sample set and the minimum batch of validation samples in the validation sample set. The calculated loss function values of the training samples are used to constrain and update other model parameters, while the calculated loss function values of the validation samples are used to constrain and update the sample weight parameters of the counterfeit currency identification model. The number of samples in the manually labeled sample dataset containing accurate and unbiased labels is less than the number of samples in the crowdsourced labeled sample dataset.
[0060] By expanding the sample dataset used to train the counterfeit currency identification model—that is, in addition to using the crowdsourced labeled sample dataset as the sample dataset, also introducing the manually labeled sample dataset as the validation sample dataset—the parameters of the sample weights in the loss function of the counterfeit currency identification model are constrained and optimized. This reduces the impact of erroneous labels in the crowdsourced labeled sample dataset on the training of the counterfeit currency identification model and improves the robustness of the counterfeit currency identification model to erroneous labels, thereby improving the accuracy of the counterfeit currency identification model in identifying counterfeit currency.
[0061] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0062] This application also provides a counterfeit currency identification device. It should be noted that the counterfeit currency identification device of this application can be used to execute the counterfeit currency identification method provided in this application. The counterfeit currency identification device provided in this application is described below.
[0063] Figure 2 This is a schematic diagram of a counterfeit currency identification device according to an embodiment of this application. Figure 2 As shown, the device includes: a first acquisition unit 201 and a second acquisition unit 202.
[0064] Specifically, the first acquisition unit 201 is used to acquire an image of the target currency to be identified.
[0065] The second acquisition unit 202 is used to predict the probability that the target currency is counterfeit by using a counterfeit currency recognition model. The counterfeit currency recognition model is a model obtained by training the amplified sample dataset using a target loss function. The target loss function includes parameters of sample weights that are automatically learned during the training of the counterfeit currency recognition model.
[0066] The counterfeit currency identification device provided in this application includes a first acquisition unit 201 for acquiring an image of the target currency to be identified, and a second acquisition unit 202 for using a counterfeit currency identification model to predict the probability that the target currency is counterfeit. The counterfeit currency identification model is a model obtained by training an augmented sample dataset using a target loss function. The target loss function includes parameters of sample weights automatically learned during the training of the counterfeit currency identification model. This solves the problem in existing technologies where the weights of the sample dataset are manually adjusted during training, resulting in training on sample datasets with label errors and data imbalances. This method leads to low accuracy in identifying counterfeit currency images of different currencies. By introducing automatically learned sample weight parameters during the training of the counterfeit currency identification model, the optimal sample weight parameters are obtained. Simultaneously, data augmentation of the original sample dataset reduces the impact of imbalanced sample numbers for different currency types, improving the accuracy of the counterfeit currency identification model. This, in turn, improves the accuracy of the counterfeit currency identification model in identifying counterfeit currency and enhances its noise robustness.
[0067] Optionally, in the counterfeit currency identification device provided in this application embodiment, the second acquisition unit 202 is obtained through the following steps: a first acquisition subunit, used to acquire a sample dataset, wherein the sample dataset includes data information of images of various currencies; a first calculation subunit, used to substitute the sample dataset into a first loss function for calculation, so as to optimize the sample weights of the first loss function and obtain an optimized first loss function, wherein the first loss function is the loss function used when training the sample dataset; a second acquisition subunit, used to augment the sample dataset to obtain an augmented sample dataset; a configuration subunit, used to configure a second loss function based on the optimized first loss function and the augmented sample dataset; a second calculation subunit, used to substitute the augmented sample dataset into the second loss function for calculation, so as to optimize the parameters of the sample weights of the second loss function and obtain an optimized second loss function; a third acquisition subunit, used to repeatedly execute the steps in the first calculation subunit to the second calculation subunit for iterative calculation, and when the number of iterations reaches a local optimum, or when the value of the optimized second loss function reaches a preset number of iterations, the model obtained after training with the optimized second loss function is used as a counterfeit currency identification model.
[0068] Optionally, in the counterfeit currency identification device provided in this application embodiment, the first calculation subunit includes: a first configuration module, used to configure the first loss function as... Where, x i Let y represent the i-th image in the sample dataset. i Represents sample data x i The label, Φ(x) i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset; the first acquisition module is used to substitute the sample dataset into the first loss function for training. When the value of the first loss function reaches a local optimum, training stops and the optimized first loss function is obtained.
[0069] Optionally, in the counterfeit currency identification device provided in this application embodiment, the second acquisition subunit includes: a second configuration module, used to configure the calculation formula for the pseudo-label of each sample in the sample dataset as follows: in, Pr iPr represents the k-th random amplification of sample i in the sample dataset. j This represents the k-th random amplification of sample j in the sample dataset. Let Φ(x) represent the sample with the smallest amplified value in k data amplifications, and let Φ(x) be the predicted probability value of sample x. It is an amplified sample The predicted probability value, g(x,Φ). i The first module represents the probability that sample x is the i-th type of currency, and τ is the scaling factor parameter of the softmax function; the second module is used to calculate the value of the pseudo-label corresponding to each sample according to the calculation formula of the pseudo-label; the third module is used to obtain the amplified sample dataset according to the original label and pseudo-label of each sample in the sample dataset, where the original label is the annotation result corresponding to a sample data in the sample dataset.
[0070] Optionally, in the counterfeit currency identification device provided in this application embodiment, the above-mentioned configuration subunit includes: a third configuration module, used to configure a second loss function based on the amplified sample dataset. Where, x i Φ(x) represents the i-th image in the sample dataset. i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset, λ i It is the weight parameter for calculating the pseudo-labels and the original labels, w i These are the sample weights of the optimized first loss function, y i Represents sample data x i The pseudo-label, g(x,Φ) i Let x represent the probability that sample x is of the i-th type of currency. It is for λ i Differentiable functions.
[0071] Optionally, in the counterfeit currency identification device provided in this application embodiment, the second calculation subunit includes: a third acquisition module, used to substitute the amplified sample dataset into the second loss function for training, and stop training when the value of the second loss function reaches a local optimum, thereby acquiring the optimized second loss function; and a fourth acquisition module, used to backpropagate the sample weights of the optimized second loss function to the sample weights of the optimized first loss function to obtain the second optimized first loss function, wherein the second optimized first loss function is the function used as the first loss function for calculation in the next iteration.
[0072] Optionally, in the counterfeit currency identification device provided in this application embodiment, the first acquisition subunit includes: a fifth acquisition module, used to acquire a manually labeled sample dataset and a crowdsourced labeled sample dataset, wherein the manually labeled sample dataset is a sample dataset in which samples are labeled manually, and the crowdsourced labeled sample dataset is a sample dataset in which samples are crowdsourced and have incorrect labeling results, and the number of samples in the manually labeled sample dataset is less than the number of samples in the crowdsourced labeled sample dataset; a sixth acquisition module, used to randomly flip and rotate the images in the manually labeled sample dataset and the crowdsourced labeled sample dataset to obtain processed images; a seventh acquisition module, used to scale the processed images to a preset size and crop them according to the original aspect ratio of the images before processing to obtain cropped images; and an eighth acquisition module, used to normalize the pixel values of the cropped images to obtain a sample dataset for training a counterfeit currency identification model.
[0073] The counterfeit currency identification device includes a processor and a memory, as well as the first acquisition unit 201 and the second acquisition unit 202.
[0074] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured; adjusting kernel parameters can improve the accuracy of the counterfeit currency detection model.
[0075] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0076] This invention provides a computer-readable storage medium storing a program that, when executed by a processor, implements a counterfeit currency identification method.
[0077] This invention provides a processor for running a program, wherein the program executes a counterfeit currency identification method during runtime.
[0078] like Figure 3As shown, this embodiment of the invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: using a counterfeit currency recognition model to predict the probability that the target currency is counterfeit. The counterfeit currency recognition model is a model obtained by training an amplified sample dataset using a target loss function. The target loss function includes parameters of sample weights that are automatically learned during the training of the counterfeit currency recognition model.
[0079] The processor executes the program and also performs the following steps: The above counterfeit currency recognition model is obtained through the following steps: S1, acquiring a sample dataset, wherein the sample dataset includes image data information of various currencies; S2, substituting the sample dataset into the first loss function for calculation to optimize the sample weights of the first loss function, thereby obtaining the optimized first loss function, wherein the first loss function is the loss function used when training the sample dataset; S3, augmenting the sample dataset to obtain the augmented sample dataset; S4, configuring the second loss function based on the optimized first loss function and the augmented sample dataset; S5, substituting the augmented sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function, thereby obtaining the optimized second loss function; repeating steps S2 to S5 for iterative calculation, when the value of the optimized second loss function reaches a local optimum, or when the number of iterations reaches the preset number of iterations, the model obtained after training with the optimized second loss function is used as the counterfeit currency recognition model.
[0080] The processor also performs the following steps when executing the program: substituting the sample dataset into the first loss function for calculation, to optimize the sample weights of the first loss function to obtain the optimized first loss function, including: configuring the first loss function as... Where, x i Let y represent the i-th image in the sample dataset. i Represents sample data x i The label, Φ(x) i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset; the sample dataset is substituted into the first loss function for training, and training is stopped when the value of the first loss function reaches a local optimum, and the optimized first loss function is obtained.
[0081] The processor also performs the following steps when executing the program: augmenting the sample dataset to obtain the augmented sample dataset, which includes: configuring the formula for calculating the pseudo-label of each sample in the sample dataset as follows: in, Pr i Pr represents the k-th random amplification of sample i in the sample dataset. j This represents the k-th random amplification of sample j in the sample dataset. Let Φ(x) represent the sample with the smallest amplified value in k data amplifications, and let Φ(x) be the predicted probability value of sample x. It is an amplified sample The predicted probability value, g(x,Φ). i Let τ represent the probability that sample x is the i-th type of currency, and τ be the scaling factor parameter of the softmax function. Calculate the value of the pseudo-label corresponding to each sample according to the formula for calculating the pseudo-label. Obtain the amplified sample dataset based on the original label and pseudo-label of each sample in the sample dataset, where the original label is the annotation result corresponding to a sample data in the sample dataset.
[0082] The processor also performs the following steps when executing the program: Based on the optimized first loss function and the augmented sample dataset, configure the second loss function, including: configuring the second loss function as follows based on the augmented sample dataset. Where, x i Φ(x) represents the i-th image in the sample dataset. i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset, λ i It is the weight parameter for calculating the pseudo-labels and the original labels, w i These are the sample weights of the optimized first loss function, y i Represents sample data x i The pseudo-label, g(x,Φ) i Let x represent the probability that sample x is of the i-th type of currency. It is for λ i Differentiable functions.
[0083] The processor also performs the following steps when executing the program: substituting the amplified sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function, and obtaining the optimized second loss function includes: substituting the amplified sample dataset into the second loss function for training, stopping training when the value of the second loss function reaches a local optimum, and obtaining the optimized second loss function; backpropagating the sample weights of the optimized second loss function to the sample weights of the optimized first loss function to obtain the second-optimized first loss function, wherein the second-optimized first loss function is the function used as the first loss function for calculation in the next iteration.
[0084] The processor also performs the following steps when executing the program: Obtaining the sample dataset includes: obtaining a manually labeled sample dataset and a crowdsourced labeled sample dataset, wherein the manually labeled sample dataset is a dataset in which samples are labeled manually, and the crowdsourced labeled sample dataset is a dataset in which samples are crowdsourced and contain incorrect labeling results; the number of samples in the manually labeled sample dataset is less than the number of samples in the crowdsourced labeled sample dataset; randomly flipping and rotating the images in the manually labeled sample dataset and the crowdsourced labeled sample dataset to obtain processed images; scaling the processed images to a preset size and cropping them according to the original aspect ratio of the images before processing to obtain cropped images; normalizing the pixel values of the cropped images to obtain the sample dataset used to train the counterfeit currency recognition model.
[0085] The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0086] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: using a counterfeit currency recognition model to predict the probability that the target currency is counterfeit, wherein the counterfeit currency recognition model is a model obtained by training an augmented sample dataset using a target loss function, and the target loss function includes parameters of sample weights automatically learned during the training of the counterfeit currency recognition model.
[0087] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: The above counterfeit currency recognition model is obtained through the following steps: S1, obtain a sample dataset, wherein the sample dataset includes data information of images of various currencies; S2, substitute the sample dataset into the first loss function for calculation to optimize the sample weights of the first loss function, thereby obtaining an optimized first loss function, wherein the first loss function is the loss function used when training the sample dataset; S3, augment the sample dataset to obtain an augmented sample dataset; S4, configure a second loss function based on the optimized first loss function and the augmented sample dataset; S5, substitute the augmented sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function, thereby obtaining an optimized second loss function; repeat steps S2 to S5 for iterative calculation, and when the value of the optimized second loss function reaches a local optimum, or when the number of iterations reaches a preset number of iterations, the model obtained after training with the optimized second loss function will be used as the counterfeit currency recognition model.
[0088] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: substituting the sample dataset into the first loss function for calculation, to optimize the sample weights of the first loss function to obtain the optimized first loss function, including: configuring the first loss function as... Where, x i Let y represent the i-th image in the sample dataset. i Represents sample data x i The label, Φ(x) i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset; the sample dataset is substituted into the first loss function for training, and training is stopped when the value of the first loss function reaches a local optimum, and the optimized first loss function is obtained.
[0089] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: augmenting the sample dataset to obtain an augmented sample dataset, including: configuring the formula for calculating the pseudo-label of each sample in the sample dataset as follows: in, Pr iPr represents the k-th random amplification of sample i in the sample dataset. j This represents the k-th random amplification of sample j in the sample dataset. Let Φ(x) represent the sample with the smallest amplified value in k data amplifications, and let Φ(x) be the predicted probability value of sample x. It is an amplified sample The predicted probability value, g(x,Φ). i Let τ represent the probability that sample x is the i-th type of currency, and τ be the scaling factor parameter of the softmax function. Calculate the value of the pseudo-label corresponding to each sample according to the formula for calculating the pseudo-label. Obtain the amplified sample dataset based on the original label and pseudo-label of each sample in the sample dataset, where the original label is the annotation result corresponding to a sample data in the sample dataset.
[0090] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: Based on the optimized first loss function and the amplified sample dataset, configure the second loss function as follows: Where, x i Φ(x) represents the i-th image in the sample dataset. i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset, λ i It is the weight parameter for calculating the pseudo-labels and the original labels, w i These are the sample weights of the optimized first loss function, y i Represents sample data x i The pseudo-label, g(x,Φ) i Let x represent the probability that sample x is of the i-th type of currency. It is for λ i Differentiable functions.
[0091] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: substituting the amplified sample dataset into the second loss function for calculation to optimize the parameters of the sample weights of the second loss function, and obtaining the optimized second loss function includes: substituting the amplified sample dataset into the second loss function for training, stopping training when the value of the second loss function reaches a local optimum, and obtaining the optimized second loss function; backpropagating the sample weights of the optimized second loss function to the sample weights of the optimized first loss function to obtain the second-optimized first loss function, wherein the second-optimized first loss function is the function used as the first loss function for calculation in the next iteration.
[0092] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: obtaining a sample dataset includes: obtaining a manually labeled sample dataset and a crowdsourced labeled sample dataset, wherein the manually labeled sample dataset is a sample dataset in which samples are labeled by humans, and the crowdsourced labeled sample dataset is a sample dataset in which samples are crowdsourced and have incorrect labeling results, and the number of samples in the manually labeled sample dataset is less than the number of samples in the crowdsourced labeled sample dataset; randomly flipping and rotating the images in the manually labeled sample dataset and the crowdsourced labeled sample dataset to obtain processed images; scaling the processed images to a preset size and cropping them according to the original aspect ratio of the images before processing to obtain cropped images; normalizing the pixel values of the cropped images to obtain a sample dataset for training a counterfeit currency recognition model.
[0093] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0094] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.
[0095] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0096] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0097] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0098] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0099] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0100] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0101] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0102] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for identifying counterfeit currency, characterized in that, include: Obtain an image of the target currency to be identified; A counterfeit currency identification model is used to predict the probability that the target currency is counterfeit by using an image of the target currency. The counterfeit currency identification model is a model obtained by training an augmented sample dataset using a target loss function. The target loss function includes parameters of sample weights that are automatically learned during the training of the counterfeit currency identification model. The counterfeit currency identification model is obtained through the following steps: S1, Obtain a sample dataset, wherein the sample dataset includes data information of images of various currencies; S2, substitute the sample dataset into the first loss function for calculation to optimize the sample weights of the first loss function and obtain the optimized first loss function, wherein the first loss function is the loss function used when training the sample dataset, and the value of the optimized first loss function is less than a preset value. S3, perform data augmentation on the sample dataset to obtain an augmented sample dataset, including: configuring the calculation formula for the pseudo-label of each sample in the sample dataset as follows: in, Pr i Pr represents the k-th random amplification sample of sample i in the sample dataset. j This represents the k-th random amplification sample of sample j in the sample dataset. Let Φ(x) represent the sample with the smallest amplified value in k data amplifications, and let Φ(x) be the predicted probability value of sample x. It is an amplified sample The predicted probability value, g(x,Φ). i The probability that sample x is the i-th type of currency is represented by τ, which is the scaling factor parameter of the softmax function. The value of the pseudo-label corresponding to each sample is calculated according to the formula of the pseudo-label. The augmented sample dataset is obtained according to the original label and the pseudo-label of each sample in the sample dataset, wherein the original label is the annotation result corresponding to a sample data in the sample dataset. S4, configuring a second loss function based on the optimized first loss function and the amplified sample dataset includes: configuring the second loss function based on the amplified sample dataset as follows: Where, x i Φ(x) represents the i-th image in the sample dataset. i ;Θ) is the objective network function for predicting the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) is the cross-entropy loss function used to predict the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) is the weighted cross-entropy loss function of the sample dataset, 0≤λ i ≤1, λ i It is to calculate the weight parameter w between the pseudo-label and the original label. i The sample weights y are the optimized first loss function. i Represents sample data x i The pseudo-label, g(x,Φ) i Let x represent the probability that sample x is of the i-th type of currency. It is for λ i Differentiable functions; S5, substitute the amplified sample dataset into the second loss function for calculation, so as to optimize the sample weights of the second loss function and obtain the optimized second loss function; Repeat steps S2 to S5 for iterative calculation. When the value of the optimized second loss function reaches a local optimum, or when the number of iterations reaches a preset number of iterations, the model obtained by training with the optimized second loss function will be used as the counterfeit currency identification model.
2. The method according to claim 1, characterized in that, The sample dataset is substituted into the first loss function for calculation to optimize the sample weights of the first loss function, resulting in the optimized first loss function, which includes: Configure the first loss function as Where, x i Let y represent the i-th image in the sample dataset. i Represents sample data x i The label, Φ(x) i ;Θ) represents the objective network function that predicts the probability that the currency in the image is counterfeit, L(y i ,Φ(x i ;Θ)) represents the cross-entropy loss function that predicts the probability that the currency in the image is counterfeit, w i The parameter w represents the sample weights in the sample dataset. i L(y i ,Φ(x i ;Θ)) represents the weighted cross-entropy loss function of the sample dataset; The sample dataset is substituted into the first loss function for training. Training stops when the value of the first loss function reaches a local optimum, and the optimized first loss function is obtained.
3. The method according to claim 1, characterized in that, The amplified sample dataset is substituted into the second loss function for calculation to optimize the parameters of the sample weights in the second loss function, resulting in the optimized second loss function, which includes: The amplified sample dataset is substituted into the second loss function for training. Training is stopped when the value of the second loss function reaches a local optimum, and the optimized second loss function is obtained. The sample weights of the optimized second loss function are backpropagated to the sample weights of the optimized first loss function to obtain the first loss function after secondary optimization. The first loss function after secondary optimization is the function used to calculate the first loss function in the next iteration.
4. The method according to claim 1, characterized in that, Obtaining the sample dataset includes: Obtain a manually labeled sample dataset and a crowdsourced labeled sample dataset, wherein the manually labeled sample dataset is a sample dataset in which samples are labeled by humans, and the crowdsourced labeled sample dataset is a sample dataset in which samples are labeled by crowdsourcing and have incorrect labeling results, and the number of samples in the manually labeled sample dataset is less than the number of samples in the crowdsourced labeled sample dataset. The images in the manually labeled sample dataset and the crowdsourced labeled sample dataset are randomly flipped and rotated to obtain the processed images. Based on the original aspect ratio of the image before processing, the processed image is scaled to a preset size and cropped to obtain the cropped image; The pixel values of the cropped image are normalized to obtain the sample dataset used to train the counterfeit currency recognition model.
5. A counterfeit currency identification device, characterized in that, The method applied to any one of claims 1 to 4 includes: The first acquisition unit is used to acquire an image of the target currency to be identified; The second acquisition unit is used to predict the probability that the target currency is counterfeit by using a counterfeit currency recognition model. The counterfeit currency recognition model is a model obtained by training the amplified sample dataset using a target loss function. The target loss function includes parameters of sample weights that are automatically learned during the training of the counterfeit currency recognition model. The second acquisition unit is obtained through the following steps: a first acquisition subunit, used to acquire a sample dataset, wherein the sample dataset includes data information of images of various currencies; The first calculation subunit is used to substitute the sample dataset into the first loss function for calculation, so as to optimize the sample weights of the first loss function and obtain the optimized first loss function. The first loss function is the loss function used when training the sample dataset, and the value of the optimized first loss function is less than a preset value. The second acquisition subunit is used to augment the sample dataset to obtain an augmented sample dataset. A configuration subunit is configured to configure a second loss function based on the optimized first loss function and the amplified sample dataset; The second calculation subunit is used to substitute the amplified sample dataset into the second loss function for calculation, so as to optimize the sample weights of the second loss function and obtain the optimized second loss function; The third acquisition subunit is used to repeatedly execute steps S2 to S5 for iterative calculation. When the value of the optimized second loss function reaches a local optimum, or when the number of iterations reaches a preset number of iterations, the model obtained after training with the optimized second loss function will be used as the counterfeit currency identification model.
6. A processor, characterized in that, The processor is used to run a program, wherein the program executes the counterfeit currency identification method according to any one of claims 1 to 4.
7. An electronic device, characterized in that, The device includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the counterfeit currency identification method according to any one of claims 1 to 4.