Bank card number identification method and device, equipment, storage medium and program product

By dividing the bank card image into image blocks and using the feature extraction network of the multi-head attention mechanism, the problem of low accuracy of the traditional bank card number recognition method is solved, and more efficient and accurate bank card number recognition is achieved.

CN118609134APending Publication Date: 2024-09-06INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410903838.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

The accuracy of traditional bank card number identification methods is low and difficult to meet the needs of modern financial services for fast and accurate entry and processing.

Method used

By dividing the bank card image to be detected into multiple image blocks, and using the feature extraction network of the multi-head attention mechanism to extract the features of the image block data, the feature data is input into the recognition model to obtain the bank card number recognition results.

Benefits of technology

It improves the accuracy and efficiency of bank card number recognition, reduces the waste of computing power, adapts to bank card images of different sizes, and reduces the complexity and the impact of background noise.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118609134A
    Figure CN118609134A
Patent Text Reader

Abstract

The invention relates to a bank card number identification method and device, equipment, a storage medium and a program product, and relates to the technical field of artificial intelligence. The method comprises the following steps: dividing a to-be-detected bank card image, determining a plurality of image block data corresponding to the to-be-detected bank card image, inputting each image block data into a feature extraction network to obtain feature data of each image block data, and then inputting the feature data of each image block data into an identification model to identify the to-be-detected bank card image. And obtaining a bank card number identification result of the to-be-detected bank card image. According to the embodiment of the invention, the to-be-detected bank card image is partitioned, and the features of the image block data are extracted based on the feature extraction network of the multi-head attention mechanism, so that the accuracy of feature extraction can be improved, the accuracy of bank card recognition based on the features of the image block data is improved, and the accuracy of bank card recognition is improved. The time for identifying the bank card can be shortened, the identification efficiency is improved, and the computing power waste is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a bank card number recognition method, device, equipment, storage medium and program product. Background Art

[0002] With the rise of new financial services such as mobile payment and online banking, the demand for fast and accurate entry and processing of bank card number information is becoming increasingly urgent. The traditional manual input method is not only inefficient but also prone to errors, and it is difficult to meet the needs of modern financial services. Therefore, the research and application of bank card number recognition technology is particularly important.

[0003] However, when identifying a bank card number based on a traditional bank card number identification method, there is a problem of low identification accuracy. Summary of the invention

[0004] Based on this, it is necessary to provide a bank card number recognition method, device, equipment, storage medium and program product that can improve recognition accuracy in response to the above technical problems.

[0005] In a first aspect, the present application provides a bank card number recognition method. The method comprises:

[0006] By dividing the bank card image to be detected, a plurality of image block data corresponding to the bank card image to be detected is determined;

[0007] Inputting each image block data into a feature extraction network to obtain feature data of each image block data, the feature extraction network adopts a multi-head attention mechanism;

[0008] The feature data of each image block data is input into the recognition model to obtain the bank card number recognition result of the bank card image to be detected.

[0009] In one embodiment, the inputting of each image block data into a feature extraction network to obtain feature data of each image block data includes:

[0010] According to the weight matrix of the target head Head and the image block data, determine the query matrix, key matrix, and value matrix of each image block data in the target head Head; the target head Head is any one of the multiple heads of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix;

[0011] Determine first feature data of each image block data in the target head Head according to the query matrix, the key matrix, and the value matrix of each image block data in the target head Head;

[0012] The first feature data output by the target head Head is concatenated with the second feature data output by other heads Head to obtain feature data of each image block data; the other heads Head are heads Head among the multiple heads Head except the target head Head.

[0013] In one embodiment, determining the first feature data of each image block data in the target head Head according to the query matrix, the key matrix, and the value matrix of each image block data in the target head Head includes:

[0014] Input the query matrix and the key matrix into the activation function to obtain the attention weight of each image block data in the target head Head;

[0015] The attention weight is multiplied by a value matrix of each image block data in the target head Head to obtain first feature data of each image block data in the target head Head.

[0016] In one embodiment, the method of dividing the bank card image to be detected to determine a plurality of image block data corresponding to the bank card image to be detected includes:

[0017] Dividing the bank card image to be detected into multiple image blocks;

[0018] The multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

[0019] In one embodiment, the multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected, including:

[0020] Embedding a category coding vector at the head position of the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0021] The category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

[0022] In one embodiment, the multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected, including:

[0023] Embedding a position coding vector in a vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0024] The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

[0025] In a second aspect, the present application also provides a bank card number recognition device. The device comprises:

[0026] A division module, used for determining a plurality of image block data corresponding to the bank card image to be detected by dividing the bank card image to be detected;

[0027] A feature extraction module is used to input each image block data into a feature extraction network to obtain feature data of each image block data, and the feature extraction network adopts a multi-head attention mechanism;

[0028] The recognition module is used to input the feature data of each image block data into the recognition model to obtain the bank card number recognition result of the bank card image to be detected.

[0029] In one embodiment, the feature extraction module includes:

[0030] A first determination unit is used to determine the query matrix, key matrix, and value matrix of each image block data in the target head Head according to the weight matrix of the target head Head and each image block data; the target head Head is any one of the multiple heads Head of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix;

[0031] A second determining unit, configured to determine first feature data of each image block data in the target head Head according to a query matrix, a key matrix, and a value matrix of each image block data in the target head Head;

[0032] The splicing unit is used to splice the first feature data output by the target head Head with the second feature data output by other heads Head to obtain the feature data of each image block data; the other heads Head are the heads Head among the multiple heads Head except the target head Head.

[0033] In one embodiment, the second determining unit includes:

[0034] A first determination subunit is used to input the query matrix and the key matrix into an activation function to obtain an attention weight of each image block data in the target head Head;

[0035] The second determination subunit is used to multiply the attention weight by the value matrix of each image block data in the target head Head to obtain the first feature data of each image block data in the target head Head.

[0036] In one embodiment, the partitioning module includes:

[0037] A dividing unit, used for dividing the bank card image to be detected into a plurality of image blocks;

[0038] The third determining unit is used to convert the multiple image blocks into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

[0039] In one embodiment, the third determination unit is specifically used to embed a category coding vector at the head position of the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0040] The category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

[0041] In one embodiment, the third determining unit is specifically used to embed a position coding vector in a vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0042] The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

[0043] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0044] By dividing the bank card image to be detected, a plurality of image block data corresponding to the bank card image to be detected is determined;

[0045] Inputting each image block data into a feature extraction network to obtain feature data of each image block data, the feature extraction network adopts a multi-head attention mechanism;

[0046] The feature data of each image block data is input into the recognition model to obtain the bank card number recognition result of the bank card image to be detected.

[0047] In one of the embodiments, according to the weight matrix of the target head Head and each of the image block data, the query matrix, key matrix, and value matrix of each of the image block data in the target head Head are determined; the target head Head is any one of the multiple heads Head of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix;

[0048] Determine first feature data of each image block data in the target head Head according to the query matrix, the key matrix, and the value matrix of each image block data in the target head Head;

[0049] The first feature data output by the target head Head is concatenated with the second feature data output by other heads Head to obtain feature data of each image block data; the other heads Head are heads Head among the multiple heads Head except the target head Head.

[0050] In one embodiment, the query matrix and the key matrix are input into an activation function to obtain the attention weight of each image block data in the target head Head;

[0051] The attention weight is multiplied by a value matrix of each image block data in the target head Head to obtain first feature data of each image block data in the target head Head.

[0052] In one of the embodiments, the bank card image to be detected is divided into a plurality of image blocks;

[0053] The multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

[0054] In one embodiment, a category coding vector is embedded at the head position of the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0055] The category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

[0056] In one embodiment, a position coding vector is embedded in a vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0057] The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

[0058] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of any of the above methods when executed by a processor.

[0059] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of any of the above methods when executed by a processor.

[0060] The bank card number recognition method, device, equipment, storage medium and program product described above divide the bank card image to be detected, determine multiple image block data corresponding to the bank card image to be detected, input each image block data into a feature extraction network to obtain feature data of each image block data, and then input the feature data of each image block data into a recognition model to obtain a bank card number recognition result of the bank card image to be detected. In the embodiment of the present application, the bank card image to be detected is divided into blocks, and the features of each image block data are extracted by a feature extraction network based on a multi-head attention mechanism, which can improve the accuracy of feature extraction, thereby improving the accuracy of bank card recognition based on the features of each image block data, and can shorten the time of bank card recognition, improve recognition efficiency, and reduce waste of computing power. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] FIG1 is an internal structure diagram of a computer device provided in an embodiment of the present application;

[0062] FIG2 is a flow chart of a bank card number recognition method provided in an embodiment of the present application;

[0063] FIG3 is a schematic diagram of a flow chart of a method for acquiring characteristic data provided in an embodiment of the present application;

[0064] FIG4 is a schematic diagram of a flow chart of a first feature data acquisition method provided in an embodiment of the present application;

[0065] FIG5 is a schematic diagram of a flow chart of a method for acquiring image block data provided in an embodiment of the present application;

[0066] FIG6 is a flow chart of a bank card number recognition method based on a target detection algorithm provided in an embodiment of the present application;

[0067] FIG. 7 is a structural block diagram of a bank card number recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0068] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0069] With the rise of new financial services such as mobile payment and online banking, the demand for fast and accurate entry and processing of bank card number information is becoming increasingly urgent. The traditional manual input method is not only inefficient but also prone to errors, and it is difficult to meet the needs of modern financial services. Therefore, the research and application of bank card number recognition technology is particularly important.

[0070] However, when identifying a bank card number based on a traditional bank card number identification method, there is a problem of low identification accuracy.

[0071] The bank card number recognition method provided in the embodiment of the present application can be applied in the application environment as shown in Figure 1. Figure 1 is an internal structure diagram of a computer device provided in the embodiment of the present application. The computer device can be a server, and its internal structure diagram can be as shown in Figure 1. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a bank card number recognition method is implemented.

[0072] Those skilled in the art will understand that the structure shown in FIG. 1 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0073] In one embodiment, as shown in FIG. 2 , FIG. 2 is a flow chart of a bank card number recognition method provided in an embodiment of the present application. The method can be applied to the computer device in FIG. 1 . The method includes the following steps:

[0074] S201, determining a plurality of image block data corresponding to the bank card image to be detected by dividing the bank card image to be detected.

[0075] In a possible implementation, an initial bank card image to be detected can be obtained, and the initial bank card image to be detected can be grayed using a weighted average method to obtain a bank card image to be detected. Then, the bank card image to be detected can be divided into multiple image blocks. Since the data format of the image block is a three-dimensional matrix, and the input of the feature extraction network should be a two-dimensional matrix, it is necessary to convert the image block into a corresponding vector sequence, and use the vector sequence corresponding to each image block as the image block data.

[0076] Exemplarily, the initial bank card image to be detected can be grayed out in the following manner: weighted average processing is performed on the R, G, and B components of the initial bank card image to be detected according to formula (1):

[0077] (1)

[0078] In formula (1), Indicates the initial bank card image to be detected The gray value of , , is the initial bank card image to be detected R, G, and B components.

[0079] In addition, in addition to the weighted average method mentioned above, the maximum value method, average value method, etc. can also be used to grayscale the initial bank card image to be detected.

[0080] Optionally, a type code may be embedded in the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected. Alternatively, a position code may be embedded in the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected. Alternatively, a type code and a position code may be embedded in the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected.

[0081] S202, inputting each image block data into a feature extraction network to obtain feature data of each image block data.

[0082] Among them, the feature extraction network adopts a multi-head attention mechanism.

[0083] In the embodiment of the present application, the image block data can be mapped to multiple heads of the feature extraction network, and feature extraction is performed on the multiple heads in parallel. The weight matrices of different heads are different.

[0084] In one embodiment, each image block data input to the feature extraction network is linearly transformed to obtain an initial query matrix of each image block data. , initial bond matrix , initial value matrix . The initial query matrix of each image block data , initial bond matrix , initial value matrix The feature dimensions are evenly divided into multiple heads of the feature extraction network. Then, the query matrix of each image block data is calculated independently in each head. , key matrix , value matrix , and based on the query matrix of each image block data , key matrix , value matrix Determine the feature data of each image block data in each head Head. Finally, concatenate the feature data of each image block data in multiple heads Head to obtain the feature data of each image block data.

[0085] For example, if the initial query matrix of the image block data is , initial bond matrix , initial value matrix The feature dimension is , the number of heads in the feature extraction network is , then the initial query matrix of each image block data is , initial bond matrix , initial value matrix The feature dimensions are evenly divided into multiple heads of the feature extraction network, and the query matrix of the image block data in each head is , key matrix , value matrix The characteristic dimension .

[0086] S203, inputting the feature data of each image block data into a recognition model to obtain a bank card number recognition result of the bank card image to be detected.

[0087] Exemplarily, the recognition model may be a multi-layer perception (MLP) model.

[0088] In one embodiment, the feature data of each image block data may be input into a pre-trained recognition model to obtain a bank card number recognition result of the bank card image to be detected output by the recognition model.

[0089] Optionally, during the process of identifying the bank card image to be detected, the parameters of the recognition model can be fine-tuned according to the bank card number recognition result of the bank card image to be detected, so as to continuously optimize the recognition model and improve the accuracy of bank card number recognition.

[0090] In the embodiment of the present application, by dividing the bank card image to be detected, a plurality of image block data corresponding to the bank card image to be detected are determined, each image block data is input into a feature extraction network to obtain the feature data of each image block data, and then the feature data of each image block data is input into a recognition model to obtain the bank card number recognition result of the bank card image to be detected. Due to the embodiment of the present application, the bank card image to be detected is divided into blocks, the complexity of feature extraction can be reduced, the influence of background noise on the feature extraction result in complex scenes is reduced, and the bank card image to be detected is divided into blocks, the bank card recognition method can be improved to better adapt to the bank card images to be detected of different sizes, and the accuracy of feature extraction is improved. At the same time, in the embodiment of the present application, the feature extraction network based on the multi-head attention mechanism is also used to extract the features of each image block data, the key features of each image block data in different spaces can be captured, the feature data is enriched, and different key features are extracted in parallel by the feature extraction network of the multi-head attention mechanism, the efficiency and accuracy of feature extraction can be improved, thereby improving the accuracy of bank card recognition based on the features of each image block data.

[0091] Referring to FIG. 3 , FIG. 3 is a flow chart of a method for acquiring feature data provided by an embodiment of the present application. This embodiment relates to a possible implementation method of how to input each image block data into a feature extraction network to obtain feature data of each image block data. Based on the above embodiment, the above S202 includes the following steps:

[0092] S301, determining a query matrix, a key matrix, and a value matrix of each image block data in the target head Head according to the weight matrix of the target head Head and each image block data.

[0093] Among them, the target head Head is any one of the multiple heads Head of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix.

[0094] In one embodiment, if the query weight matrix of the target head Head is , the key weight matrix is , the value weight matrix is , then the image block data The query matrix It can be expressed as , key matrix It can be expressed as , value matrix It can be expressed as Among them, the target head Head is the first of the multiple heads of the feature extraction network. indivual.

[0095] S302, determining first feature data of each image block data in the target head Head according to the query matrix, the key matrix, and the value matrix of each image block data in the target head Head.

[0096] Optionally, the attention weight of each image block data in the target head Head can be determined according to the query matrix and the key matrix of each image block data in the target head Head. Then, the first feature data of each image block data in the target head Head is determined according to the attention weight and the value matrix of each image block data in the target head Head.

[0097] In an embodiment of the present application, a dot product operation can be performed on each query vector in the query matrix and each key vector in the key matrix to obtain a similarity score matrix. The similarity score matrix is ​​then scaled, and the scaled similarity score matrix is ​​converted into an attention weight matrix, i.e., the above-mentioned attention weight. Among them, the similarity score matrix is ​​used to characterize the similarity between the query vector and the key vector.

[0098] S303: splice the first feature data output by the target head Head with the second feature data output by other heads Head to obtain feature data of each image block data.

[0099] Among them, other heads Head are heads Head other than the target head Head among the multiple heads Head.

[0100] In a possible implementation, the first feature data of each image block data in the target head Head can be determined according to the query matrix, key matrix, and value matrix of each image block data in the target head Head, and then the second feature data of each image block data in other heads Head can be determined according to the query matrix, key matrix, and value matrix of each image block data in other heads Head. Then, the first feature data and the second feature data are spliced ​​according to the feature dimension to obtain the feature data of each image block data.

[0101] In an embodiment of the present application, a query matrix, a key matrix, and a value matrix of each image block data in the target head Head are determined according to the weight matrix of the target head Head and each image block data; a first feature data of each image block data in the target head Head is determined according to the query matrix, the key matrix, and the value matrix of each image block data in the target head Head; the first feature data output by the target head Head and the second feature data output by other heads Head are spliced ​​to obtain feature data of each image block data, thereby enabling parallel processing through multiple heads Head, shortening the feature extraction time, improving the feature extraction efficiency, and reducing the waste of computing power; and a feature extraction network based on a multi-head attention mechanism extracts features of each image block data, thereby improving the accuracy of feature extraction.

[0102] Referring to FIG. 4 , FIG. 4 is a flow chart of a method for obtaining first feature data provided by an embodiment of the present application. This embodiment relates to a possible implementation method of determining the first feature data of each image block data in the target head Head according to the query matrix, key matrix, and value matrix of each image block data in the target head Head. Based on the above embodiment, the above S302 includes the following steps:

[0103] S401, input the query matrix and the key matrix into the activation function to obtain the attention weight of each image block data in the target head Head.

[0104] In an embodiment of the present application, each query vector in the query matrix may be dot-producted with each key vector in the key matrix to obtain a similarity score matrix. The similarity score matrix is ​​scaled to obtain a scaled similarity score matrix, and then the scaled similarity score matrix is ​​input into the activation function to obtain the attention weight of each image block data in the target head Head.

[0105] S402, multiplying the attention weight by the value matrix of each image block data in the target head Head to obtain the first feature data of each image block data in the target head Head.

[0106] Optionally, the attention weight may be multiplied by a value matrix of each image block data in the target head Head to obtain a weighted value matrix, and the weighted value matrix is ​​used as the first feature data of each image block data in the target head Head.

[0107] In an embodiment of the present application, the query matrix and the key matrix are input into the activation function to obtain the attention weights of each image block data in the target head Head, and the attention weights are multiplied by the value matrix of each image block data in the target head Head to obtain the first feature data of each image block data in the target head Head, so that multiple heads can be processed in parallel, which shortens the feature extraction time, improves the feature extraction efficiency, reduces the waste of computing power, and extracts the features of each image block data based on the feature extraction network of the multi-head attention mechanism, which can improve the accuracy of feature extraction.

[0108] Referring to FIG. 5 , FIG. 5 is a flow chart of a method for acquiring image block data provided by an embodiment of the present application. This embodiment relates to a possible implementation method of how to determine a plurality of image block data corresponding to a bank card image to be detected by dividing the bank card image to be detected. Based on the above embodiment, the above S201 includes the following steps:

[0109] S501, dividing the bank card image to be detected into multiple image blocks.

[0110] S502: Convert multiple image blocks into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

[0111] Optionally, the bank card image to be detected can be a data format of That is, the size of the bank card image to be detected is . The bank card image to be detected can be transformed into a The sequence of bank card images to be detected is divided into image blocks, and then Flatten the image blocks to get the corresponding vector sequence.

[0112] The sequence contains a total of image blocks, each of which has a dimension of .in, is the size of the image block, is the number of channels.

[0113] In an embodiment of the present application, the bank card image to be detected is divided into multiple image blocks, and the multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected, so that the feature data of each image block can be extracted, which shortens the feature extraction time, improves the feature extraction efficiency, reduces the waste of computing power, and can improve the accuracy of feature extraction.

[0114] Based on the above embodiment, the above S502 can be implemented by the following steps:

[0115] The category coding vector is embedded in the head position of the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected.

[0116] Among them, the category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

[0117] Optionally, a randomly generated learnable category coding vector can be embedded into the head position of the vector sequence corresponding to each image block, that is, the category coding vector is added to the front of the vector sequence, and the vector sequence embedded with the category coding vector is used as multiple image block data corresponding to the bank card image to be detected.

[0118] In one embodiment, the information of each image block data can be aggregated through a category coding vector, that is, feature aggregation, so as to characterize the category information of the image block, so as to facilitate the recognition model to recognize the bank card number.

[0119] In an embodiment of the present application, a category coding vector is embedded in the head position of the vector sequence corresponding to each image block to obtain multiple image block data corresponding to the bank card image to be detected, so that the information of each image block data can be aggregated through the category coding vector, which facilitates the recognition model to recognize the bank card number and improves the accuracy of bank card number recognition.

[0120] Based on the above embodiment, the above S502 can be implemented by the following steps:

[0121] The position coding vector is embedded in the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected.

[0122] The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

[0123] Optionally, a position coding vector may be embedded in a vector sequence corresponding to each image block, and the vector sequence embedded with the position coding vector is used as a plurality of image block data corresponding to the bank card image to be detected.

[0124] In one possible implementation, a randomly generated learnable category coding vector can be embedded into the head position of a vector sequence corresponding to each image block, and then a position coding vector can be embedded into a random position of the vector sequence, and the vector sequence of embedded category coding vectors and position coding vectors can be used as multiple image block data corresponding to the bank card image to be detected.

[0125] In an embodiment of the present application, a position coding vector is embedded in a vector sequence corresponding to each image block to obtain multiple image block data corresponding to the bank card image to be detected. The position coding vector is used to represent the position information of the image block in the bank card image to be detected, thereby avoiding interference from the position information during feature extraction, facilitating the recognition model to recognize the bank card number, and thus improving the accuracy of bank card number recognition.

[0126] Referring to FIG. 6 , FIG. 6 is a flow chart of a bank card number recognition method based on a target detection algorithm provided in an embodiment of the present application. The method comprises the following steps:

[0127] S601, obtaining an initial bank card image to be detected.

[0128] S602, graying the initial bank card image to be detected to obtain a bank card image to be detected.

[0129] S603: Divide the bank card image to be detected into multiple image blocks.

[0130] S604, converting the multiple image blocks into corresponding vector sequences, embedding the category coding vector and the position coding vector into the vector sequence corresponding to each image block, and obtaining multiple image block data.

[0131] S605: Input each image block data into a feature extraction network to obtain feature data of each image block data.

[0132] S606: Input the feature data of each image block data into a recognition model to obtain a bank card number recognition result of the bank card image to be detected.

[0133] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0134] Based on the same inventive concept, the embodiment of the present application also provides a bank card number recognition device for implementing the bank card number recognition method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more bank card number recognition device embodiments provided below can refer to the limitations of the bank card number recognition method above, and will not be repeated here.

[0135] In one embodiment, as shown in FIG. 7 , FIG. 7 is a structural block diagram of a bank card number recognition device provided in an embodiment of the present application, and the device 700 includes:

[0136] The division module 701 is used to determine a plurality of image block data corresponding to the bank card image to be detected by dividing the bank card image to be detected.

[0137] The feature extraction module 702 is used to input each image block data into the feature extraction network to obtain feature data of each image block data. The feature extraction network adopts a multi-head attention mechanism.

[0138] The recognition module 703 is used to input the feature data of each image block data into the recognition model to obtain the bank card number recognition result of the bank card image to be detected.

[0139] In one embodiment, the feature extraction module 702 includes:

[0140] The first determination unit is used to determine the query matrix, key matrix, and value matrix of each image block data in the target head Head according to the weight matrix of the target head Head and each image block data; the target head Head is any one of the multiple heads Head of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix.

[0141] The second determining unit is used to determine the first feature data of each image block data in the target head Head according to the query matrix, the key matrix and the value matrix of each image block data in the target head Head.

[0142] The splicing unit is used to splice the first feature data output by the target head Head with the second feature data output by other heads Head to obtain feature data of each image block data; other heads Head are heads Head except the target head Head among the multiple heads Head.

[0143] In one embodiment, the second determining unit includes:

[0144] The first determination subunit is used to input the query matrix and the key matrix into the activation function to obtain the attention weight of each image block data in the target head Head.

[0145] The second determination subunit is used to multiply the attention weight by the value matrix of each image block data in the target head Head to obtain the first feature data of each image block data in the target head Head.

[0146] In one embodiment, the partitioning module 701 includes:

[0147] The dividing unit is used to divide the bank card image to be detected into multiple image blocks.

[0148] The third determining unit is used to convert the multiple image blocks into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

[0149] In one of the embodiments, the third determination unit is specifically configured to embed a category coding vector at the head position of a vector sequence corresponding to each image block, so as to obtain a plurality of image block data corresponding to the bank card image to be detected.

[0150] Among them, the category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

[0151] In one of the embodiments, the third determination unit is specifically configured to embed a position coding vector in a vector sequence corresponding to each image block, so as to obtain a plurality of image block data corresponding to the bank card image to be detected.

[0152] The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

[0153] Each module in the bank card number recognition device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0154] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0155] By dividing the bank card image to be detected, a plurality of image block data corresponding to the bank card image to be detected are determined;

[0156] Input each image block data into the feature extraction network to obtain the feature data of each image block data. The feature extraction network adopts a multi-head attention mechanism;

[0157] The feature data of each image block data is input into the recognition model to obtain the bank card number recognition result of the bank card image to be detected.

[0158] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0159] According to the weight matrix of the target head Head and the data of each image block, determine the query matrix, key matrix, and value matrix of each image block data in the target head Head; the target head Head is any one of the multiple heads Head of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix;

[0160] Determine first feature data of each image block data in the target head Head according to the query matrix, key matrix, and value matrix of each image block data in the target head Head;

[0161] The first feature data output by the target head Head is concatenated with the second feature data output by other heads Head to obtain feature data of each image block data; the other heads Head are heads Head other than the target head Head among the multiple heads Head.

[0162] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0163] Input the query matrix and key matrix into the activation function to obtain the attention weight of each image block data in the target head;

[0164] The attention weight is multiplied by the value matrix of each image block data in the target head Head to obtain the first feature data of each image block data in the target head Head.

[0165] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0166] Divide the bank card image to be detected into multiple image blocks;

[0167] The multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

[0168] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0169] Embed the category coding vector at the head position of the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0170] Among them, the category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

[0171] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0172] Embedding a position coding vector in a vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0173] The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

[0174] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0175] By dividing the bank card image to be detected, a plurality of image block data corresponding to the bank card image to be detected are determined;

[0176] Input each image block data into the feature extraction network to obtain the feature data of each image block data. The feature extraction network adopts a multi-head attention mechanism;

[0177] The feature data of each image block data is input into the recognition model to obtain the bank card number recognition result of the bank card image to be detected.

[0178] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0179] According to the weight matrix of the target head Head and the data of each image block, determine the query matrix, key matrix, and value matrix of each image block data in the target head Head; the target head Head is any one of the multiple heads Head of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix;

[0180] Determine first feature data of each image block data in the target head Head according to the query matrix, key matrix, and value matrix of each image block data in the target head Head;

[0181] The first feature data output by the target head Head is concatenated with the second feature data output by other heads Head to obtain feature data of each image block data; the other heads Head are heads Head other than the target head Head among the multiple heads Head.

[0182] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0183] Input the query matrix and key matrix into the activation function to obtain the attention weight of each image block data in the target head;

[0184] The attention weight is multiplied by the value matrix of each image block data in the target head Head to obtain the first feature data of each image block data in the target head Head.

[0185] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0186] Divide the bank card image to be detected into multiple image blocks;

[0187] The multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

[0188] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0189] Embed the category coding vector at the head position of the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0190] Among them, the category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

[0191] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0192] Embedding a position coding vector in a vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0193] The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

[0194] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0195] By dividing the bank card image to be detected, a plurality of image block data corresponding to the bank card image to be detected are determined;

[0196] Input each image block data into the feature extraction network to obtain the feature data of each image block data. The feature extraction network adopts a multi-head attention mechanism;

[0197] The feature data of each image block data is input into the recognition model to obtain the bank card number recognition result of the bank card image to be detected.

[0198] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0199] According to the weight matrix of the target head Head and the data of each image block, determine the query matrix, key matrix, and value matrix of each image block data in the target head Head; the target head Head is any one of the multiple heads Head of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix;

[0200] Determine first feature data of each image block data in the target head Head according to the query matrix, key matrix, and value matrix of each image block data in the target head Head;

[0201] The first feature data output by the target head Head is concatenated with the second feature data output by other heads Head to obtain feature data of each image block data; the other heads Head are heads Head other than the target head Head among the multiple heads Head.

[0202] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0203] Input the query matrix and key matrix into the activation function to obtain the attention weight of each image block data in the target head;

[0204] The attention weight is multiplied by the value matrix of each image block data in the target head Head to obtain the first feature data of each image block data in the target head Head.

[0205] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0206] Divide the bank card image to be detected into multiple image blocks;

[0207] The multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

[0208] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0209] Embed the category coding vector at the head position of the vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0210] Among them, the category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

[0211] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0212] Embedding a position coding vector in a vector sequence corresponding to each image block to obtain a plurality of image block data corresponding to the bank card image to be detected;

[0213] The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

[0214] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0215] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0216] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A bank card number recognition method, characterized in that: The method comprises: By dividing the bank card image to be detected, a plurality of image block data corresponding to the bank card image to be detected are determined; Inputting each of the image block data into a feature extraction network to obtain feature data of each of the image block data, wherein the feature extraction network adopts a multi-head attention mechanism; The feature data of each of the image block data is input into a recognition model to obtain a bank card number recognition result of the bank card image to be detected.

2. The method according to claim 1, characterized in that Inputting each of the image block data into a feature extraction network to obtain feature data of each of the image block data includes: Determine the query matrix, key matrix, and value matrix of each of the image block data in the target head Head according to the weight matrix of the target head Head and each of the image block data; the target head Head is any one of the multiple heads Head of the feature extraction network, and the weight matrix includes a query weight matrix, a key weight matrix, and a value weight matrix; Determine first feature data of each image block data in the target head Head according to a query matrix, a key matrix, and a value matrix of each image block data in the target head Head; The first feature data output by the target head Head is concatenated with the second feature data output by other heads Head to obtain feature data of each image block data; the other heads Head are heads Head among the multiple heads Head except the target head Head.

3. The method according to claim 2, characterized in that The determining, according to the query matrix, the key matrix, and the value matrix of each of the image block data in the target head Head, the first feature data of each of the image block data in the target head Head comprises: Inputting the query matrix and the key matrix into an activation function to obtain the attention weight of each image block data in the target head Head; The attention weight is multiplied by a value matrix of each of the image block data in the target head Head to obtain first feature data of each of the image block data in the target head Head.

4. The method according to any one of claims 1 to 3, characterized in that: The step of dividing the bank card image to be detected to determine a plurality of image block data corresponding to the bank card image to be detected includes: Dividing the bank card image to be detected into a plurality of image blocks; The multiple image blocks are converted into corresponding vector sequences to obtain multiple image block data corresponding to the bank card image to be detected.

5. The method according to claim 4, characterized in that The step of converting the plurality of image blocks into corresponding vector sequences to obtain a plurality of image block data corresponding to the bank card image to be detected includes: Embedding a category coding vector at the head position of the vector sequence corresponding to each of the image blocks to obtain a plurality of image block data corresponding to the bank card image to be detected; The category encoding vector is a randomly generated learnable embedding vector used to represent the category information of the image block.

6. The method according to claim 4, characterized in that The step of converting the plurality of image blocks into corresponding vector sequences to obtain a plurality of image block data corresponding to the bank card image to be detected includes: Embedding a position coding vector in a vector sequence corresponding to each of the image blocks to obtain a plurality of image block data corresponding to the bank card image to be detected; The position encoding vector is an embedding vector determined based on the position of the image block in the bank card image to be detected.

7. A bank card number recognition device, characterized in that: The device comprises: A division module, used for determining a plurality of image block data corresponding to the bank card image to be detected by dividing the bank card image to be detected; A feature extraction module, used for inputting each of the image block data into a feature extraction network to obtain feature data of each of the image block data, wherein the feature extraction network adopts a multi-head attention mechanism; The recognition module is used to input the feature data of each image block data into the recognition model to obtain the bank card number recognition result of the bank card image to be detected.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.