Text tampering identification method and device, computer device and readable storage medium
By introducing prior conditions into the text tampering recognition model and combining image and text features for feature stacking and processing, the problems of low efficiency and high cost of multi-character tampering recognition in the existing technology are solved, and efficient and accurate text tampering recognition is achieved.
Patent Information
- Application Number
- CN202310675608.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-08
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-06-08
AI Technical Summary
Existing text tampering recognition models are inefficient and costly when identifying multi-character tampering, and have difficulty discovering the generalized features of character tampering. In addition, the coarse-grained detection model has insufficient recall capability and cannot effectively identify fine tampering.
The prior conditions are determined by obtaining the text recognition results of the image to be identified, and are input together with the image to be identified into a pre-trained text tampering recognition model for text tampering recognition. The prior conditions are used to guide the model to perform text tampering recognition, extract image and prior features for feature stacking and processing, and output a binary classification vector to confirm the text tampering result.
It improves the accuracy and efficiency of text tampering identification, can effectively identify multi-character tampering, reduces manpower and time costs, and enhances risk control capabilities in online business scenarios.
Smart Images

Figure CN116682116B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, specifically the field of computer vision and deep learning technology, and in particular to a method, apparatus, computer device and readable storage medium for identifying text tampering. Background Art
[0002] Leveraging the development of new technologies such as big data, cloud computing, and artificial intelligence, internet finance has seen rapid expansion, and innovative financial products are constantly emerging. For example, OCR (optical character recognition) is used to perform text recognition on user-submitted images (such as invoices and documents) to convert image information into usable computer input.
[0003] Existing text tampering recognition models are generally single-task models. When they identify tampering of multiple characters in a text area with anomalies (such as handwriting tampering), multiple text tampering recognition models are required to perform text tampering recognition on different characters respectively in order to achieve relatively accurate recognition of multi-character tampering. However, the recognition efficiency of multi-character text tampering recognition in this way is low and the recognition cost is high. Summary of the Invention
[0004] Based on this, it is necessary to provide a text tampering identification method, device, computer equipment and readable storage medium that can improve the efficiency and accuracy of text tampering identification in order to address the above technical problems.
[0005] In order to solve the above technical problems, in a first aspect, a method for identifying text tampering is provided, the method comprising:
[0006] Obtaining an image to be recognized and at least one priori condition corresponding to the image to be recognized, where the priori condition is determined based on a text recognition result of the image to be recognized;
[0007] The image to be identified and at least one priori condition corresponding to the image to be identified are input into a pre-trained text tampering identification model to perform text tampering identification, and obtain a text tampering identification result of the image to be identified.
[0008] In one embodiment, obtaining at least one prior condition corresponding to the image to be recognized includes:
[0009] Perform text recognition on the image to be recognized, and obtain the text information and text position of the image to be recognized;
[0010] Extracting the pixel position of each character in the text position of the image to be recognized and the text information of each character in the text information of the image to be recognized;
[0011] The pixel position of each character and the text information of each character are matched to obtain at least one priori condition corresponding to the image to be recognized.
[0012] In one embodiment, the image to be identified and at least one prior condition corresponding to the image to be identified are input into a pre-trained text tampering identification model to perform text tampering identification, and the text tampering identification result of the image to be identified includes:
[0013] Inputting the image to be identified and at least one prior condition corresponding to the image to be identified into a pre-trained text tampering identification model;
[0014] The pre-trained text tampering recognition model is used to extract the image features of the image to be recognized and the prior features of the prior conditions;
[0015] Perform feature stacking on image features and prior features to obtain stacked features;
[0016] The stacked features are processed and output as a binary classification vector, and the text tampering recognition results are confirmed based on the binary classification vector.
[0017] In one embodiment, the training process of the pre-trained text tampering identification model includes:
[0018] Obtaining a portion of training images in a training set and a label of each training image in the portion of training images, wherein the label of the training image represents a type of the training image, and the training image type includes a tampered training image and an untampered training image;
[0019] Taking the training image as input, the image features of the training image are extracted through the extraction network layer of the text tampering recognition model to be trained; the image features are input into the detection network layer of the image tampering recognition model to obtain the tampering recognition result of the training image, and the tampering recognition result is output using the output layer of the image tampering recognition model;
[0020] The loss function is calculated for the tampering recognition results and the labels of the training images. The parameters of the text tampering recognition model are optimized according to the calculated loss function results and the training is continued until the preset conditions are met.
[0021] In one embodiment, obtaining a training image set includes:
[0022] Get the original image, which is the image that has not been tampered with;
[0023] The original image is subjected to data augmentation to obtain an augmented original image, and the augmented original image is used as an untampered training image;
[0024] The tampering operation includes one or a combination of several operations such as elastic transformation, image distortion, pixel shift, and pixel pasting.
[0025] In one of the embodiments, the prior condition is input into the text tampering recognition model in the form of One-Hot encoding together with the image to be recognized.
[0026] In one of the embodiments, the prior condition is determined based on the text recognition result of the image to be recognized, including: performing text recognition on the image to be recognized by using an OCR technology to determine the prior condition corresponding to the image to be recognized.
[0027] To solve the above technical problems, the second aspect provides a text tampering recognition device, the device comprising:
[0028] The acquisition module is configured to acquire an image to be recognized and at least one prior condition corresponding to the image to be recognized, the prior condition being determined based on a text recognition result of the image to be recognized;
[0029] The processing module is configured to input the image to be recognized and the prior condition corresponding to the image to be recognized into a pre-trained text tampering recognition model to perform tampering recognition.
[0030] The output module is configured to output a tampering recognition result of the image to be recognized.
[0031] To solve the above technical problems, the third aspect provides a computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method of the first aspect when executing the computer program.
[0032] To solve the above technical problems, the fourth aspect provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is executable by a processor to implement the steps of the method of the first aspect.
[0033] The present application has the following advantages: Different from the prior art, the present application determines the prior condition based on the text recognition result of the image to be recognized, and inputs the at least one prior condition and the image to be recognized into a pre-trained text tampering recognition model to perform text tampering recognition. In this way, the prior condition is used to guide the text tampering recognition model to recognize the text to be recognized, which can improve the accuracy of text tampering recognition. Furthermore, the one or more prior conditions and the image to be recognized are input into the pre-trained text tampering recognition model to perform text tampering recognition, which can realize multi-task classification and improve the efficiency of text tampering recognition. BRIEF DESCRIPTION OF DRAWINGS
[0034] Figure 1 An application environment diagram of a Chinese text tampering recognition method according to an embodiment;
[0035] Figure 2 A flowchart of a Chinese text tampering recognition method according to an embodiment;
[0036] Figure 3 A flowchart of a corresponding process of acquiring prior conditions in step S201 according to an embodiment;
[0037] Figure 4 A flowchart of a training process of a Chinese text tampering recognition model according to another embodiment;
[0038] Figure 5 A flowchart of a Chinese text tampering recognition method according to an embodiment;
[0039] Figure 6 A structural diagram of a Chinese text tampering recognition model according to an embodiment;
[0040] Figure 7 A structural block diagram of a Chinese text tampering recognition device according to an embodiment;
[0041] Figure 8 An internal structure diagram of a computer device according to an embodiment. DETAILED DESCRIPTION
[0042] In order to make the objects, technical solutions and advantages of the present application clearer, further detailed description will be made to the present application in combination 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 not used to limit the present application.
[0043] The OCR technology can recognize the image containing the text, and convert the text into searchable information. That is, search the text area in the image, and recognize it as text information that can be represented by a computer. The OCR technology is usually applied in the fields of public opinion monitoring, document retrieval, subtitle recognition, screenshot recognition, network picture recognition, literature retrieval, paperless office and manuscript editing and proofreading. After integrating the OCR recognition technology in the company office process, not only the work efficiency is improved, but also the electronic storage and management are facilitated, including later review and retrieval, editing and management, etc.
[0044] At present, with the development of new technologies such as big data, cloud computing, and artificial intelligence, target detection or semantic segmentation models can be used to detect abnormal text areas (such as handwriting tampering). In the process of realizing the present invention, the inventor found that there are at least the following problems in the prior art: in the related art, multiple single-task models are usually used to identify tampering of multiple characters, but the overall process of this method is bloated, and it is difficult to find the generalized characteristics of character tampering, which makes the model prone to overfitting and thus affects the recognition accuracy; in addition, since the methods of handwriting tampering are ever-changing and will not destroy the text background, the recall ability of the coarse-grained detection model is insufficient. For example, criminals will use ink to tamper with the text handwriting before image acquisition to achieve the purpose of illegal profit. If the detection model is used to identify text tampering with finely tampered text, it will have high requirements for the construction of the data set during the early model training. It is necessary to manually design and collect a large number of tampered samples and complete the corresponding annotation to obtain a good recognition effect, which requires more manpower and time costs.
[0045] To this end, this application proposes a text tampering recognition method, which improves the efficiency and accuracy of text tampering recognition by inputting the prior conditions determined based on the text recognition results of the image to be recognized into a pre-trained text tampering recognition model with the image to be recognized.
[0046] The text tampering identification method proposed in this application can be applied to Figure 1 In the application environment shown. Among them, the terminal 10 communicates with the server 11 through the network. The above-mentioned text tampering recognition method can be applied to the server 11, and the server can adopt an independent server or a server cluster. Specifically, the server 11 can obtain the image to be recognized and at least one prior condition corresponding to the image to be recognized, wherein the prior condition is determined based on the text recognition result of the image to be recognized. The image to be recognized and at least one prior condition corresponding to the image to be recognized are input into a pre-trained text tampering recognition model to perform text tampering recognition, obtain the text tampering recognition result of the image to be recognized, and display the text tampering recognition result of the image to be recognized on the terminal 10. The above-mentioned text tampering recognition method can use the prior condition to guide the text tampering recognition model to perform text tampering recognition on the image to be recognized, so as to improve the text tampering recognition efficiency and text tampering recognition accuracy.
[0047] The terminal 10 may be, but is not limited to, various electronic devices such as personal computers, laptops, smart phones, and tablet computers.
[0048] See also Figure 2 , Figure 2 1 is a flow chart of an embodiment of a method for identifying text tampering according to the present invention, the method comprising:
[0049] Step S201: Obtain an image to be identified and at least one prior condition corresponding to the image to be identified.
[0050] Specifically, an image to be identified and one or more prior conditions corresponding to the image to be identified are obtained. The image to be identified is an image containing text. For example, the image to be identified can be an image containing text captured by an image acquisition device, such as an image of a document containing text captured in an online identity verification scenario. The image to be identified can also be an image containing text downloaded from the internet, uploaded by a user, or obtained in other ways. The present invention does not limit the source of the image to be identified.
[0051] In addition, the text here may include languages, punctuation marks, numbers, etc. The present invention does not limit the type of text in the image to be recognized.
[0052] In this embodiment, the prior condition is determined based on the text recognition result of the image to be recognized. Figure 3 , Figure 3 2 is a flow chart of obtaining a priori conditions corresponding to step S201 in one embodiment.
[0053] Step S301: Perform text recognition on the image to be recognized to obtain the text information and text position of the image to be recognized.
[0054] Optionally, OCR technology may be used to perform text recognition on the image to be recognized. Specifically, the image to be recognized may be segmented into lines to extract line text information and line text positions of the image to be recognized.
[0055] Existing OCR technology is already very mature. It is recorded in relevant technologies that when using OCR technology for text recognition, for any text detection line, it will form multiple small boxes of a certain width, and perform template matching on the content in the small boxes. During the recognition process, the index, content and confidence information of each small box will be output, and then the text will be recognized and output based on this information.
[0056] Step S302: extracting the pixel position of each character in the text position of the image to be recognized and the text information of each character in the text information of the image to be recognized.
[0057] Since the unit of precision for text segmentation in OCR technology is "line", in order to achieve accurate segmentation of each character in the text, the present invention is designed to use the CRAFT model to perform fine segmentation and extraction of line characters after obtaining the line text information of the image to be recognized and the line text position of the image to be recognized, so as to obtain the pixel position of each character in the text position of the image to be recognized and the text information of each character in the text information of the image to be recognized.
[0058] Step S303: Match the pixel position of each character and the text information of each character to obtain at least one prior condition corresponding to the image to be recognized.
[0059] Specifically, the pixel position of each character in the text position of the image to be identified and the text information of each character in the text information of the image to be identified are matched to obtain the information of each character. The information of each character at this time includes the text information and position information of each character. The matching method can be the KMP algorithm, Boyer-Moore algorithm, Rabin-Karp algorithm, etc. The information of each character is then converted into the form of a vector matrix. In this way, the prior conditions corresponding to the image to be identified are obtained. The prior conditions can be set according to actual needs. The number of prior conditions can be one or more, and the present invention does not impose any restrictions on this.
[0060] Optionally, the prior condition can be input into the text tampering recognition model together with the image to be recognized in the form of One-Hot encoding. One-Hot encoding, also known as "unique hot encoding". In fact, it is to encode N states with an N-bit state register. Each state has an independent register bit, and only one of these register bits is valid, that is, there can only be one state. Here, the prior condition can be converted into a One-Hot encoding (one-bit valid encoding) form of multiple columns, directly using 0 and 1 to represent yes or no, that is, the final vector is composed of discrete values 0 and 1, which plays the role of expanding features to a certain extent, and solves the problem of difficulty in classifiers processing discrete data, which is conducive to improving the accuracy of text tampering recognition.
[0061] Of course, it is also possible to use binarization, connected component analysis, projection analysis, etc. to perform row segmentation on the image to be recognized to obtain a row character image containing row characters. Then, the pixel position of each character in the row character image and the text information of each character are extracted from the row character image containing row characters.
[0062] In one embodiment, the obtained pixel position of each character and the text information of each character may be size normalized, which facilitates the dimensionality control of feature information when subsequently using a convolutional neural network to extract features from the normalized information of each character.
[0063] Step S202: Inputting the image to be identified and at least one prior condition corresponding to the image to be identified into a pre-trained text tampering identification model to perform text tampering identification, and obtaining a text tampering identification result of the image to be identified.
[0064] After obtaining the image to be identified and the prior conditions corresponding to the image to be identified in the above manner, they are input together into a pre-trained text tampering recognition model. Different from the prior art, the present invention uses the prior conditions to guide the model to perform text tampering recognition. The prior conditions are a vector matrix containing the text information and position information of each character of the image to be identified. Specifically, in actual applications, if the text information of the image to be identified is "0", "1", "2", "3", "4", "5", "6", "7", "8", and "9", a total of 10 digital characters; these 10 characters are converted into a 1×10 vector matrix. If you want to identify whether the digital character "5" has been tampered with, then in the 1×10 vector matrix, the vector corresponding to the text position of the digital character "5" is represented by 1, and the vectors corresponding to the text positions other than the digital character "5" are represented by 0. In this way, when the text tampering recognition model is used for subsequent recognition, it is only necessary to judge whether the text position of the digital character "5" (vector is 1) has been tampered with. This is different from the existing technology that requires first finding the text position of the text information to be recognized, and then identifying whether the text information at this position has been tampered with. This can improve the efficiency of text tampering recognition.
[0065] In one embodiment, when there are multiple prior conditions, the text tampering recognition operation can be performed on each prior condition in order until the last prior condition is executed and the operation ends. For example, when the text information of the image to be recognized is "0", "1", "2", "3", "4", "5", "6", "7", "8", and "9", a total of 10 digital characters, these 10 characters are converted into a 1×10 vector matrix. If you want to identify whether the digital character "5" and the digital character "8" have been tampered with, then in the 1×10 vector matrix, the vectors of the text positions corresponding to the digital character "5" and the digital character "8" are represented by 1, and the vectors of the text positions other than the digital character "5" and the digital character "8" are represented by 0. When the text tampering recognition is performed subsequently, the text position of the digital character "5" (vector is 1) is first judged to determine whether the text information at this position has been tampered with, and then the text position of the digital character "8" (vector is 1) is judged to determine whether the text information at this position has been tampered with.
[0066] In actual applications, the text tampering recognition model identifies text tampering in images uploaded by users and outputs the text tampering recognition results. When the text tampering recognition results of the images uploaded by users show that the text in the image is tampered with, the images with tampered text are manually reviewed or directly rejected for recognition, which can enhance the risk control capabilities of online business scenarios.
[0067] Optionally, before performing step S102 , the image to be identified may be processed so that the size of the processed image to be identified is the same as the input size of the pre-trained text tampering identification model. For example, the image to be identified may be resized.
[0068] See also Figure 4 In one embodiment, the training process of the pre-trained text tampering recognition model includes:
[0069] Step S401: Obtain some training images in a training set and labels of each training image in the training set, wherein the labels of the training images represent the types of the training images, and the types of the training images include tampered training images and untampered training images.
[0070] Specifically, the training image set includes a large number of training images used to train and generate a text tampering recognition model. The training images can be images containing text in various image formats. For example, the training images can be images containing text captured by an image acquisition device, such as images of documents containing text captured in an online identity verification scenario. The training images can also be images containing text downloaded from the internet, uploaded by users, or obtained in other ways. The present invention does not impose any restrictions on the source of the training images.
[0071] Optionally, the training images can be labeled manually or automatically, where the labels can represent the type of training image. For example, the labels can be in the form of (0,1) or (1,0). When the first position is "1" and the second position is "0", it indicates that the training image is not tampered with; when the first position is "0" and the second position is "1", it indicates that the training image is tampered with. Of course, the form of the label is not limited to this, as long as it can distinguish between tampered and untampered training images.
[0072] Step S402: Using the training image as input, extract the image features of the training image through the extraction network layer of the text tampering recognition model to be trained; input the image features into the detection network layer of the text tampering recognition model to obtain the tampering recognition result of the training image; and use the output layer of the text tampering recognition model to output the tampering recognition result.
[0073] Specifically, after obtaining a portion of training images and a label of each training image in the portion of training images, the obtained training images are input into a text tampering recognition model to be trained. The text tampering recognition model to be trained may be a text tampering recognition model based on OCR technology. Image features of the training images are extracted through multiple convolution kernels and pooling layers in the extraction network layer of the text tampering recognition model, wherein the image features may be image texture features, image steganographic features, and the like. Image texture features are used to characterize the texture information of the image, and image steganographic features are used to characterize digital image tampering information.
[0074] The detection network layer of the text tampering model is used to identify the image features of the training image to obtain a tampering identification result of the training image, and the output layer of the text tampering identification model is used to output the image tampering identification result, wherein the tampering identification result indicates whether the training image is a tampered image. The detection network layer of the image tampering identification model can be constructed based on a deep neural network, such as a CNN, Backbone, YOLO, Fast-RCNN, FRCNN or MaskRCNN network. Preferably, the detection network layer in this embodiment includes a network based on a Backbone network combined with Softmax.
[0075] Preferably, the form of the tampering recognition result output by the text tampering recognition model can be consistent with the form of the label of the training image, so as to facilitate subsequent optimization of the text tampering recognition model based on the tampering recognition result.
[0076] Step S403: Calculate the loss function for the tampering recognition result and the label of the training image, optimize the parameters of the text tampering recognition model according to the calculated loss function result, and continue training until the preset conditions are met and the training is terminated.
[0077] Specifically, a loss function is calculated based on the tampering recognition result of the training image and the label of the training image to obtain a loss function value, and the parameters of the text tampering recognition model are determined according to the loss function value and the text tampering recognition model is optimized, and step S401 to step S403 are re-entered, and the training is terminated by repeated optimization iterations until the loss function converges (meets the preset conditions). The convergence of the loss function indicates that the predicted result (tampering recognition result) of the text tampering recognition model is gradually consistent with the true result (label of the training image), that is, a trained text tampering recognition model is obtained. The calculation of the loss function value can be achieved by mean square error or cross entropy.
[0078] In a preferred embodiment, the above-mentioned training image set can be generated online by a text tampering recognition model, specifically including: obtaining the original image, which is an untampered image; performing a data augmentation operation on the original image to obtain an augmented original image, and using the augmented original image as the untampered training image; performing a tampering operation on the untampered training image to obtain a tampered training image, wherein the tampering operation includes one or a combination of operations such as elastic transformation, image distortion, pixel offset, and pixel pasting.
[0079] Specifically, the original image is first obtained. The original image can be an untampered image containing text in various image formats. The text tampering recognition model is used to perform text recognition on the original image to obtain the text information and text position of the original image, and each character in the original image is extracted to form a positive sample data set.
[0080] In order to improve the generalization ability and robustness of subsequent models, the positive sample data set is expanded. Specifically, the characters of each original image in the positive sample data set can be resized, subjected to random noise, random rotation offset, Gaussian, dynamic blur, color, contrast jitter, etc. to obtain a large number of positive samples, which is conducive to the subsequent training of the text tampering recognition model.
[0081] Based on the expanded positive sample data set, each character contained therein is subjected to a random tampering operation, such as image distortion, elastic transformation, pixel pasting and other data augmentation operations, to generate corresponding negative samples to form a negative sample data set. It can be understood that each character in the positive sample data set has a corresponding relationship with each character in the negative sample data set. In this embodiment, the text tampering recognition model obtains a positive sample data set based on the original image, and performs a tampering operation on the positive sample data set to generate a negative sample data set online. On the one hand, it can avoid manual data collection and labeling, greatly reducing the investment in labor costs; on the other hand, the use of sample pairs to supervise the training of the classification model can achieve the effect of comparative learning, thereby improving the accuracy of model training and suppressing the occurrence of overfitting.
[0082] See also Figure 5 In one embodiment, the image to be identified and at least one prior condition corresponding to the image to be identified are input into a pre-trained text tampering identification model to perform text tampering identification, and the text tampering identification result of the image to be identified is as follows:
[0083] Step S501: Input the image to be identified and at least one prior condition corresponding to the image to be identified into a pre-trained text tampering recognition model.
[0084] Step S502: Utilize a pre-trained text tampering recognition model to extract the image features of the image to be recognized and the prior features of the prior conditions.
[0085] After the text tampering recognition model is trained in the above method, the text tampering recognition model can be used to perform text tampering recognition operations on the image to be recognized.
[0086] First, the image to be identified and at least one prior condition corresponding to the image to be identified are input into the text tampering recognition model, and the image features of the image to be identified and the prior features of the prior conditions are respectively extracted through the extraction network layer of the text tampering recognition model. The extraction network layer may include a CNN convolution layer, wherein the convolution layer can be used to perform an inner product operation on the pixels of an image block according to a plurality of certain weights (i.e., convolution kernels), and its output is one of the extracted features. The CNN layer can be used to extract a feature sequence from the input image. Of course, the extraction network layer may include multiple convolution layers, wherein different convolution kernels can be used to extract different features, such as the first convolution kernel is used to extract steganographic features, the second convolution kernel is used to extract texture features, and the third convolution kernel is used to extract boundary features, corner features, etc.
[0087] For example, taking the text information of the image to be identified as "0", "1", "2", "3", "4", "5", "6", "7", "8", and "9", a total of 10 digital characters, as an example, first generate a priori condition based on the text information of the image to be identified. The priori condition is a vector matrix with a shape of 1×1×10. The priori condition is input into the text tampering recognition model together with the image to be identified. Here, when the image to be identified is input into the text tampering model, a vector matrix of h×w×3 is generated. The priori condition is input into the text tampering model, and the original 1×1×10 vector matrix is broadcast to h×w×10, where h represents the height of the vector matrix and w represents the width of the vector matrix, so that the output feature dimension becomes larger. The above two vector matrices are then convolved through the CNN layer to obtain the corresponding image features and priori features respectively.
[0088] Step S503: stack the image features and the prior features to obtain stacked features.
[0089] Step S504: Process the stacked features and output a binary classification vector, and confirm the text tampering recognition result based on the binary classification vector.
[0090] Specifically, the image features and prior features obtained through the above steps are stacked. The stacking operation here is to splice the channels of the features, and does not fuse the image features and the prior features. After obtaining the stacked features, the stacked features are processed. This can be done using Backbone and Softmax functions. The Backbone layer includes multiple convolutional layers and pooling layers. As it processes the stacked features, a 1×2 binary classification vector (i.e., the tampering recognition result) is obtained, and the tampering recognition result is output through the output layer of the text tampering recognition model.
[0091] See also Figure 6 , Figure 6 It is a structural diagram of an implementation method of a text tampering identification model. Figure 6 The left side is the existing text tampering recognition model (single-task model). Figure 6 The right side of the text tampering recognition model (multi-task model) of the present invention is Figure 6 It can be seen that the improved model (the text tampering recognition model of the present invention) has added a conditional branch (prior condition), which can provide a priori conditions at the input end of the text tampering recognition model to distinguish the character information currently tampered with and avoid interference between different characters.
[0092] Please refer to Table 1, which shows the average recognition results of multiple characters by the existing text tampering recognition model and the text tampering recognition model provided by the present invention. The sample is 5000 images of each of the characters "0" to "9".
[0093]
[0094] As can be seen from Table 1, when using the existing text tampering recognition model (single-task model) to perform multi-character tampering recognition, multiple text tampering recognition models are required to perform text tampering recognition on different characters respectively in order to achieve relatively accurate recognition of multi-character tampering. However, the text tampering recognition model provided by the present invention can achieve accurate recognition of multi-character tampering using only one model.
[0095] It should be understood that although Figure 2-5 The steps in the flowchart are shown in the order indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2-5At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0096] In one embodiment, Figure 7 As shown, a text tampering identification device is provided, comprising: an acquisition module, a processing module and an output module, wherein:
[0097] The acquisition module is used to acquire the image to be recognized and at least one priori condition corresponding to the image to be recognized, where the priori condition is determined based on the text recognition result of the image to be recognized.
[0098] The processing module is used to input the image to be identified and the prior conditions corresponding to the image to be identified into a pre-trained text tampering identification model to perform tampering identification.
[0099] The output module is used to output the tampering recognition result of the image to be recognized.
[0100] For the specific definition of the text tampering identification device, please refer to the definition of the text tampering identification method above, and will not be repeated here. The various modules in the above-mentioned text tampering identification device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0101] In one embodiment, another implementation of the method for identifying text tampering that can be implemented by the above-mentioned device includes the following specific steps:
[0102] Obtaining at least one prior condition corresponding to the image to be recognized includes:
[0103] Step S301: Perform text recognition on the image to be recognized to obtain text information and text position of the image to be recognized;
[0104] Step S302: extracting the pixel position of each character in the text position of the image to be recognized and the text information of each character in the text information of the image to be recognized;
[0105] Step S303: Match the pixel position of each character and the text information of each character to obtain at least one prior condition corresponding to the image to be recognized.
[0106] In one embodiment, the aforementioned prior conditional One-Hot encoding form is input into a text tampering recognition model together with the image to be recognized.
[0107] In one embodiment, another implementation of the method for identifying text tampering that can be implemented by the above-mentioned device includes the following specific steps:
[0108] The training process of the pre-trained text tampering detection model includes:
[0109] Step S401: obtaining a portion of training images in a training image set and a label of each training image in the portion of training images, wherein the label of the training image represents the type of the training image, and the training image type includes tampered training images and untampered training images;
[0110] Step S402: Using the training image as input, extracting image features of the training image through the extraction network layer of the text tampering recognition model to be trained; inputting the image features into the detection network layer of the text tampering recognition model to obtain tampering recognition results of the training image; and outputting the tampering recognition results using the output layer of the text tampering recognition model;
[0111] Step S403: Calculate the loss function for the tampering recognition result and the label of the training image, optimize the parameters of the text tampering recognition model according to the calculated loss function result, and continue training until the preset conditions are met and the training is terminated.
[0112] In one embodiment, another implementation of the method for identifying text tampering that can be implemented by the above-mentioned device includes the following specific steps:
[0113] Obtaining a training image set includes:
[0114] Get the original image, which is the image that has not been tampered with;
[0115] The original image is subjected to data augmentation to obtain an augmented original image, and the augmented original image is used as an untampered training image;
[0116] A tampering operation is performed on an untampered training image to obtain a tampered training image, wherein the tampering operation includes one or a combination of operations such as elastic transformation, image distortion, pixel shift, pixel pasting, etc.
[0117] In one embodiment, another implementation of the method for identifying text tampering that can be implemented by the above-mentioned device includes the following specific steps:
[0118] Inputting the image to be identified and at least one prior condition corresponding to the image to be identified into a pre-trained text tampering identification model to perform text tampering identification, and obtaining a text tampering identification result of the image to be identified includes:
[0119] Step S501: inputting the image to be identified and at least one prior condition corresponding to the image to be identified into a pre-trained text tampering identification model;
[0120] Step S502: using a pre-trained text tampering recognition model to extract image features of the image to be recognized and prior features of the prior conditions;
[0121] Step S503: stacking the image features and the prior features to obtain stacked features;
[0122] Step S504: Process the stacked features and output a binary classification vector, and confirm the text tampering recognition result based on the binary classification vector.
[0123] In one embodiment, another implementation of the method for identifying text tampering that can be implemented by the above-mentioned device includes the following specific steps:
[0124] The prior conditions are determined based on the text recognition results of the image to be recognized and include:
[0125] Use OCR technology to perform text recognition on the image to be recognized and determine the prior conditions corresponding to the image to be recognized.
[0126] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. 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 and a computer program. 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 via a network connection. When the computer program is executed by the processor, a method for identifying text tampering is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0127] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the 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 component arrangement.
[0128] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0129] Step S201: obtaining an image to be recognized and at least one prior condition corresponding to the image to be recognized.
[0130] Step S202: inputting the image to be recognized and the at least one prior condition corresponding to the image to be recognized into a pre-trained text tampering recognition model to perform text tampering recognition, and obtaining a text tampering recognition result of the image to be recognized.
[0131] In one embodiment, another implementation of the text tampering recognition method implemented by the above device is provided, and the specific steps are as follows:
[0132] Obtaining at least one prior condition corresponding to the image to be recognized comprises:
[0133] Step S301: performing text recognition on the image to be recognized to obtain text information and a text position of the image to be recognized, respectively;
[0134] Step S302: extracting a pixel position of each character in the text position of the image to be recognized and text information of each character in the text information of the image to be recognized;
[0135] Step S303: matching the pixel position of each character and the text information of each character to obtain at least one prior condition corresponding to the image to be recognized.
[0136] In one embodiment, the prior condition is input into the text tampering recognition model in the form of One-Hot encoding together with the image to be recognized.
[0137] In one embodiment, another implementation of the text tampering recognition method implemented by the above device is provided, and the specific steps are as follows:
[0138] The training process of the pre-trained text tampering recognition model comprises:
[0139] Step S401: obtaining part of training images in a training image set and a label of each training image in the part of training images, wherein the label of the training image represents a type of the training image, and the type of the training image comprises a tampered training image and an un-tampered training image;
[0140] Step S402: Using the training image as input, extracting image features of the training image through the extraction network layer of the text tampering recognition model to be trained; inputting the image features into the detection network layer of the text tampering recognition model to obtain tampering recognition results of the training image; and outputting the tampering recognition results using the output layer of the text tampering recognition model;
[0141] Step S403: Calculate the loss function for the tampering recognition result and the label of the training image, optimize the parameters of the text tampering recognition model according to the calculated loss function result, and continue training until the preset conditions are met and the training is terminated.
[0142] In one embodiment, another implementation of the method for identifying text tampering that can be implemented by the above-mentioned device includes the following specific steps:
[0143] Obtaining a training image set includes:
[0144] Get the original image, which is the image that has not been tampered with;
[0145] The original image is subjected to data augmentation to obtain an augmented original image, and the augmented original image is used as an untampered training image;
[0146] A tampering operation is performed on an untampered training image to obtain a tampered training image, wherein the tampering operation includes one or a combination of operations such as elastic transformation, image distortion, pixel shift, pixel pasting, etc.
[0147] In one embodiment, another implementation of the method for identifying text tampering that can be implemented by the above-mentioned device includes the following specific steps:
[0148] Inputting the image to be identified and at least one prior condition corresponding to the image to be identified into a pre-trained text tampering identification model to perform text tampering identification, and obtaining a text tampering identification result of the image to be identified includes:
[0149] Step S501: inputting the image to be identified and at least one prior condition corresponding to the image to be identified into a pre-trained text tampering identification model;
[0150] Step S502: using a pre-trained text tampering recognition model to extract image features of the image to be recognized and prior features of the prior conditions;
[0151] Step S503: stacking the image features and the prior features to obtain stacked features;
[0152] Step S504: Process the stacked features and output a binary classification vector, and confirm the text tampering recognition result based on the binary classification vector.
[0153] In one embodiment, another implementation of the method for identifying text tampering that can be implemented by the above-mentioned device includes the following specific steps:
[0154] The prior conditions are determined based on the text recognition results of the image to be recognized and include:
[0155] Use OCR technology to perform text recognition on the image to be recognized and determine the prior conditions corresponding to the image to be recognized.
[0156] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. 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 memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0157] The technical features of the above embodiments can 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.
[0158] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for identifying text tampering, characterized in that: include: Obtaining an image to be recognized and at least one prior condition corresponding to the image to be recognized, the prior condition being determined based on a text recognition result of the image to be recognized; the prior condition comprising a vector matrix of text information and position information of each character in the image to be recognized; wherein a vector of a text position corresponding to a character to be recognized in the image to be recognized is represented by 1, and a vector of a text position corresponding to a non-character to be recognized in the image to be recognized is represented by 0; Inputting the image to be identified and at least one prior condition corresponding to the image to be identified into a pre-trained text tampering identification model, and using the pre-trained text tampering identification model to extract image features of the image to be identified and prior features of the prior condition respectively; and stacking the image features and the prior features to obtain stacked features; The stacked features are processed to obtain a binary classification vector as output, and a text tampering recognition result of the image to be recognized is confirmed based on the binary classification vector.
2. The method according to claim 1, characterized in that Obtaining at least one priori condition corresponding to the image to be recognized includes: Performing text recognition on the image to be recognized to obtain text information and text position of the image to be recognized; Extracting the pixel position of each character in the text position of the image to be recognized and the text information of each character in the text information of the image to be recognized; The pixel position of each character and the text information of each character are matched to obtain at least one priori condition corresponding to the image to be recognized.
3. The method according to claim 1, characterized in that The training process of the pre-trained text tampering recognition model includes: Obtaining a portion of training images in a training image set and a label of each training image in the portion of training images, wherein the label of the training image represents a type of the training image, and the training image type includes a tampered training image and an untampered training image; Taking a training image as input, extracting image features of the training image through the extraction network layer of the text tampering recognition model to be trained; inputting the image features into the detection network layer of the text tampering recognition model to obtain a tampering recognition result of the training image; and outputting the tampering recognition result using the output layer of the text tampering recognition model; A loss function is calculated for the tampering recognition result and the label of the training image, and the parameters of the text tampering recognition model are optimized according to the calculated loss function result, and training is continued until the training is terminated when a preset condition is met.
4. The method according to claim 3, characterized in that The acquiring of the training image set comprises: Acquire an original image, where the original image is an untampered image; Performing a data augmentation operation on the original image to obtain an augmented original image, and using the augmented original image as an untampered training image; A tampering operation is performed on the untampered training image to obtain a tampered training image, wherein the tampering operation includes one or a combination of elastic transformation, image distortion, pixel shift, and pixel pasting operations.
5. The method according to claim 1, wherein The prior conditions are input into the text tampering recognition model together with the image to be recognized in the form of One-Hot encoding.
6. The method according to claim 1, characterized in that The priori condition is determined based on the text recognition result of the image to be recognized, which includes: performing text recognition on the image to be recognized using OCR technology to determine the priori condition corresponding to the image to be recognized.
7. A text tampering identification device, characterized in that: The device comprises: an acquisition module, configured to acquire an image to be recognized and at least one prior condition corresponding to the image to be recognized, the prior condition being determined based on a text recognition result of the image to be recognized; the prior condition comprising a vector matrix of text information and position information for each character in the image to be recognized; wherein a vector corresponding to a text position of a character to be recognized in the image to be recognized is represented by 1, and a vector corresponding to a text position of a non-character to be recognized in the image to be recognized is represented by 0; a processing module configured to input the image to be identified and the prior conditions corresponding to the image to be identified into a pre-trained text tampering identification model, extract image features of the image to be identified and prior features of the prior conditions using the pre-trained text tampering identification model; perform feature stacking on the image features and the prior features to obtain stacked features; process the stacked features to output a binary classification vector, and confirm a text tampering identification result of the image to be identified based on the binary classification vector; The output module is used to output the tampering identification result of the image to be identified.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, 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.
Citation Information
Patent Citations
Image tampering recognition model training method and device and image tampering recognition method and device
CN111368342A
Character recognition method and device, and electronic equipment
CN112396057A
Tampered image identification method and device
CN113706636A
Image tampering detection method and device
CN114743205A
Image processing method and device, electronic equipment and readable medium
CN114821588A