Seal desensitization model establishing method and device and seal desensitization method and device
By establishing a seal desensitization model, using the detection model to segment and generate synthetic seal logos, and performing fuzzy processing, the problem of difficult to efficiently and low-cost in the existing technology of seal desensitization is solved, and the basic structure of the seal is retained is realized. Efficient seal desensitization effect.
Patent Information
- Application Number
- CN202411413036.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-02-07
AI Technical Summary
Existing seal desensitization solutions are difficult to achieve efficient and low-cost seal desensitization while retaining the basic structure of the seal.
By obtaining the target image and background image, using the pre-trained detection model to segment the seal logo, generate the synthetic seal logo and perform Gaussian blur processing, fuse it into the background image, establish a generator and Markov discriminator, and iterative training to obtain the seal desensitization Model.
It realizes the seal blurring process on the image with the seal efficiently and accurately under the premise of preserving the basic structure of the seal, achieving low-cost seal desensitization.
Smart Images

Figure CN119399055A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a seal desensitization model establishment method, a seal desensitization method and a seal desensitization device. Background Art
[0002] Processing sensitive information such as identity information can protect privacy and prevent sensitive information from being illegally stolen. As an important carrier of identity information, seals usually contain sensitive information such as names, seal numbers, company names and mobile phone numbers. Financial companies or institutions such as banks, insurance and securities must take corresponding security measures when processing sensitive information in seals. As an effective security protection measure, desensitizing sensitive seal information helps companies or institutions operate in compliance and avoid property damage and legal disputes caused by data leaks.
[0003] Existing seal desensitization solutions generally include mosaic covering, data encryption, physical occlusion, and AI smart erasing. However, the use of mosaic covering may destroy the basic structure of the seal, and if the covering is not fine, the seal after mosaic covering is still easy to be cracked by reverse engineering. Data encryption technology is an efficient and highly confidential processing method. Even if the original data is leaked, it is difficult to directly read sensitive information, but the encryption and decryption process may increase the system performance burden, and complex encryption algorithms will also greatly increase the difficulty and cost of implementation. The method of using physical occlusion to process sensitive seal information is simple and efficient, but the implementation cost is also high. It is not suitable for large-scale applications and is not universal. Using AI smart erasing is a relatively good method, but AI smart erasing completely destroys the data value of the seal itself and cannot maintain the relevance of the data.
[0004] Therefore, there is an urgent need for a method to establish a seal desensitization model so that the established seal desensitization model can achieve efficient and low-cost desensitization of the seal while maintaining the basic structure of the seal. Summary of the invention
[0005] In view of the fact that the current seal desensitization scheme is difficult to achieve efficient and low-cost seal desensitization while retaining the basic structure of the seal, this scheme is proposed to overcome the above problem or at least partially solve the above problem.
[0006] On the one hand, the purpose of some embodiments of this specification is to provide a method for establishing a seal desensitization model, the method comprising:
[0007] Acquire a target image with a seal and a background image without a seal;
[0008] Using a pre-trained detection model, segmenting the target image to obtain a seal mark;
[0009] Determine a corresponding candidate set according to the seal identification, and generate a corresponding synthetic seal identification based on the candidate set;
[0010] Performing Gaussian blur processing on the synthetic seal mark to obtain a blurred seal mark;
[0011] Using the background image as a background, fusing the synthetic seal mark into the background image, and fusing the blurred seal mark into the background image to obtain paired training samples;
[0012] Build the generator and the Markov discriminator;
[0013] The generator and the Markov discriminator are trained separately and iteratively using the paired training samples to obtain trained generators and Markov discriminators; the trained generators and Markov discriminators are seal desensitization models used for seal blurring processing.
[0014] Furthermore, using a pre-trained detection model, segmenting the target image to obtain the seal mark includes:
[0015] Using a pre-trained detection model, detect whether a seal mark exists in the target image to obtain a detection result;
[0016] The seal mark is obtained by segmenting the target image according to the detection result.
[0017] Furthermore, the pre-trained detection model is trained in the following manner:
[0018] Marking the seal mark in the target image to obtain label information;
[0019] Constructing a training sample set according to the label information and the background image;
[0020] Randomly select batch samples from the training sample set;
[0021] Inputting the batch samples into the backbone network of the detection model to extract the corresponding feature graph;
[0022] The convolutional neural network in the detection model is used to predict the feature maps respectively to obtain corresponding heat maps, position offsets and target boxes;
[0023] Calculate the loss value using a preset loss function according to the heat map, position offset and target frame;
[0024] Updating network parameters in the detection model based on the loss value;
[0025] Repeat the above steps of updating the network parameters according to the training sample set until a preset convergence condition is reached.
[0026] Further, determining a corresponding candidate set according to the seal identification, and generating a corresponding synthetic seal identification based on the candidate set, includes:
[0027] Determine corresponding multiple sets of seal text information and seal appearance information according to the seal identification; wherein the seal text information includes one or more of font format, font size, text content, text angle, and character spacing, and the seal appearance information includes one or more of seal size, frame thickness, shape, and color;
[0028] Arrange and combine the multiple sets of seal text information and seal appearance information to obtain seal combination information, and establish the candidate set according to the seal combination information;
[0029] Randomly select multiple seal combination information from the candidate set;
[0030] Generate a corresponding composite seal logo according to the selected seal combination information.
[0031] Furthermore, the background image is used as the background, the synthetic seal mark is fused into the background image, and the blurred seal mark is fused into the background image to obtain paired training samples, including:
[0032] Acquire pixel coordinate information and pixel information corresponding to the composite seal mark, and pixel coordinate information and pixel information corresponding to the fuzzy seal mark;
[0033] Determine, according to the pixel coordinate information corresponding to the composite seal mark, a first area to be fused in the background image and pixel information corresponding to the first area to be fused;
[0034] Determine, according to the pixel coordinate information corresponding to the fuzzy seal mark, the second area to be fused in the background image and the pixel information corresponding to the second area to be fused;
[0035] The background image is used as the background, and in the first area to be fused, pixel information corresponding to the synthetic seal mark and pixel information corresponding to the first area to be fused are linearly operated according to a preset coefficient to obtain a first fused image;
[0036] The background image is used as the background, and in the second area to be fused, the pixel information corresponding to the fuzzy seal mark and the pixel information corresponding to the second area to be fused are linearly operated according to a preset coefficient to obtain a second fused image;
[0037] Paired training samples are constructed based on the first fused image and the second fused image.
[0038] Furthermore, the encoder in the generator is used for down-sampling layer by layer, and the decoder in the generator is used for up-sampling layer by layer. The upsampling layer in the encoder and the downsampling layer in the decoder are symmetrical to each other, and every two symmetrical layers are connected in a jump connection manner.
[0039] Furthermore, the generator and the Markov discriminator are trained separately and iteratively using the paired training samples to obtain the trained generator and the Markov discriminator, including:
[0040] Inputting the training sample into the generator to generate a generated image corresponding to the training sample;
[0041] Inputting the generated image and the training sample into the Markov discriminator to determine whether the generated image matches the training sample and obtain a determination result;
[0042] Calculating the loss according to the judgment result, and updating the parameters of the generator and the Markov discriminator using a back propagation algorithm based on the loss;
[0043] Repeat the above steps of updating the parameters of the generator and the Markov discriminator according to the training samples until a preset number of convergences is reached to obtain a trained generator and a Markov discriminator; the trained generator and Markov discriminator are a seal desensitization model.
[0044] On the other hand, some embodiments of this specification also provide a seal desensitization model establishment device, the device comprising:
[0045] On the other hand, based on the same inventive concept, some embodiments of this specification also provide a seal desensitization method, the method comprising:
[0046] receiving an image to be desensitized;
[0047] The image to be desensitized is input into the seal desensitization model trained by the method described in any of the aforementioned embodiments to obtain a desensitized image.
[0048] On the other hand, based on the same inventive concept, some embodiments of this specification also provide a seal desensitization device, the device comprising:
[0049] A receiving module, used for receiving the image to be desensitized;
[0050] The desensitization module is used to input the image to be desensitized into the seal desensitization model trained by the method described in any of the aforementioned embodiments to obtain a desensitized image.
[0051] On the other hand, some embodiments of the present specification further provide a computer device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the instructions of the above method are executed.
[0052] On the other hand, some embodiments of the present specification further provide a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor of a computer device, the instructions of the above method are executed.
[0053] On the other hand, some embodiments of the present specification further provide a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor of a computer device, the instructions of the above method are executed.
[0054] One or more technical solutions provided by some embodiments of this specification have at least the following technical effects:
[0055] The embodiments of the present specification first automatically acquire a target image with a seal and a background image without a seal, and use a pre-trained detection model to quickly segment the target image to obtain a seal logo. Since the number and richness of the seal logos obtained by segmentation may not meet the needs of training a seal desensitization model, a corresponding synthetic seal logo is generated according to a candidate set corresponding to the seal logo to expand and enrich the original seal logo. The synthetic seal logo is then Gaussian blurred to obtain a fuzzy seal logo, and the synthetic seal logo and the fuzzy seal logo are fused into the background image, thereby quickly obtaining paired training samples. The paired training samples are used to iteratively train a generator and a Markov discriminator to obtain a trained generator and a Markov discriminator. The trained generator and Markov discriminator are the seal desensitization model, which can efficiently and accurately perform seal blurring on images with seals while preserving the basic structure of the seal, thereby achieving low-cost seal desensitization.
[0056] The above description is only an overview of the technical solutions of some embodiments of this specification. In order to more clearly understand the technical means of some embodiments of this specification, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of some embodiments of this specification more obvious and easy to understand, the specific implementation methods of some embodiments of this specification are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate some embodiments of this specification or technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:
[0058] Figure 1 A schematic diagram of an implementation system of a seal desensitization model establishment method in some embodiments of this specification is shown;
[0059] Figure 2 A flow chart of a method for establishing a seal desensitization model in some embodiments of this specification is shown;
[0060] Figure 3 A schematic diagram of the steps of segmenting and obtaining a seal mark in some embodiments of this specification;
[0061] Figure 4 A schematic diagram of steps for generating a composite seal mark in some embodiments of this specification;
[0062] Figure 5a is a first schematic diagram of paired training samples in some embodiments of this specification;
[0063] Figure 5b A second schematic diagram of paired training samples in some embodiments of this specification;
[0064] Figure 6 A flow chart of a seal desensitization method in some embodiments of this specification is shown;
[0065] Figure 7 This is a structural schematic diagram of a seal desensitization model establishment device in some embodiments of this specification;
[0066] Figure 8 This is a structural schematic diagram of a seal desensitization device in some embodiments of this specification;
[0067] Fig. 9 This is a schematic diagram of the computer device structure provided in some embodiments of this specification.
[0068] [Description of Reference Numerals]
[0069] 101. Terminal;
[0070] 102. Server;
[0071] 701. Get module;
[0072] 702, segmentation module;
[0073] 703, synthesis module;
[0074] 704, fuzzy module;
[0075] 705, fusion module;
[0076] 706. Establish module;
[0077] 707, training module;
[0078] 801, receiving module;
[0079] 802, desensitization module;
[0080] 902. Computer equipment;
[0081] 904, processor;
[0082] 906. Memory;
[0083] 908, driving mechanism;
[0084] 910, input / output interface;
[0085] 912. Input device;
[0086] 914. Output device;
[0087] 916. Presentation equipment;
[0088] 918. Graphical user interface;
[0089] 920, network interface;
[0090] 922, communication link;
[0091] 924. Communication bus. DETAILED DESCRIPTION
[0092] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in some embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on some embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0093] It should be noted that the terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0094] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with the relevant provisions of relevant laws and regulations.
[0095] It should be noted that in the embodiments of this specification, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of this application, but it does not mean that the applicant has or will necessarily use the solution.
[0096] like Figure 1 The schematic diagram of the implementation system of a seal desensitization model establishment method according to an embodiment of the present invention is shown, which may include: a terminal 101 and a server 102, wherein the terminal 101 and the server 102 communicate with each other through a network, and the network may include a local area network (LAN), a wide area network (WAN), the Internet or a combination thereof, and is connected to a website, a user device (such as a computing device) and a back-end system. A staff member may send a seal desensitization model establishment request to the server 102 through the terminal 101, and after receiving the seal desensitization model establishment request, the server 102 calls the data in the database for calculation and processing, obtains the seal desensitization model establishment result, and sends the seal desensitization model establishment result to the terminal 101, so that the staff member processes the business according to the seal desensitization model establishment result.
[0097] In the embodiments of this specification, the server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms.
[0098] In an optional embodiment, the terminal 101 may include but is not limited to electronic devices such as self-service terminal devices, desktop computers, tablet computers, laptop computers, smart wearable devices, etc. Optionally, the operating system running on the electronic device may include but is not limited to Android system, IOS system, Linux, Windows, etc. Of course, the terminal 101 is not limited to the above-mentioned electronic devices with a certain entity, and it can also be software running in the above-mentioned electronic devices.
[0099] In addition, it should be noted that Figure 1 What is shown is only an application environment provided by the present disclosure. In actual application, multiple terminals 101 may be included, and this specification does not limit this.
[0100] Figure 2 It is a flowchart of a seal desensitization model establishment method provided in some embodiments of this specification. This specification provides method operation steps as described in the embodiments or flowcharts, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or device product is executed, it can be executed in the order or in parallel according to the method shown in the embodiments or drawings. Specifically, Figure 2 As shown, applied to the above-mentioned server side, the method may include:
[0101] S201: Acquire a target image with a seal and a background image without a seal;
[0102] Specifically, the target image includes one or more seals of different styles, and the background image may be a text background image, a pattern background image, etc., which is not limited in this document.
[0103] S202: using a pre-trained detection model to segment the target image to obtain a seal mark;
[0104] Before constructing the paired training samples for training the seal desensitization model, it is necessary to pre-identify and segment the seal logo in the target image to construct the paired training samples. Figure 3 The schematic diagram of the steps of segmenting and obtaining the seal mark is shown. In some embodiments, segmenting and obtaining the seal mark from the target image using a pre-trained detection model may include:
[0105] S301: Using a pre-trained detection model, detecting whether a seal mark exists in the target image, and obtaining a detection result;
[0106] S302: Segment the target image to obtain a seal mark according to the detection result.
[0107] It can be understood that, in some embodiments, the detection model is an image segmentation detection model. Further, in some embodiments, the pre-trained detection model is trained in the following manner:
[0108] Marking the seal mark in the target image to obtain label information;
[0109] Constructing a training sample set according to the label information and the background image;
[0110] Randomly select batch samples from the training sample set;
[0111] Inputting the batch samples into the backbone network of the detection model to extract the corresponding feature graph;
[0112] The convolutional neural network in the detection model is used to predict the feature maps respectively to obtain corresponding heat maps, position offsets and target boxes;
[0113] Calculate the loss value using a preset loss function according to the heat map, position offset and target frame;
[0114] Updating network parameters in the detection model based on the loss value;
[0115] Repeat the above steps of updating the network parameters according to the training sample set until a preset convergence condition is reached.
[0116] Specifically, in some embodiments, when constructing a training sample set based on the label information and the background image, a positive sample is established based on the label information, and a negative sample is established based on the background image, so as to construct a training sample set with a preset ratio of positive samples to negative samples, so as to ensure a balance between positive and negative samples, which is beneficial to improving the accuracy of the detection model. In some embodiments, the resolution of the feature map is often greater than the preset resolution, that is, the output result of the backbone network is a high-resolution feature map, so as to ensure that the subsequent convolution process is carried out smoothly and effectively.
[0117] Seal detection does not belong to small target detection. Seal marks often occupy obvious and visible areas in documents or bills. The purpose of seal detection is to completely and accurately detect the position and appearance of the seal mark. Therefore, in order to improve the detection accuracy, after the backbone network extracts the corresponding feature map, it is also necessary to use the convolutional neural network to predict the heat map, position offset and target box from three different prediction dimensions.
[0118] Accordingly, the subsequent loss function includes three parts. In some embodiments, the process of calculating the loss value using the preset loss function can be expressed as:
[0119] L det =L k +λ size L size +λ off L off
[0120] Among them, L det Represents the loss value, L k represents the target center point heat map loss, λ size The loss parameter representing the target box size, L size represents the loss of target box size, λ off Represents the loss parameter of the target center point offset, L off represents the loss of target center point deviation. And, in some embodiments, L size and L off Often only the loss corresponding to the positive sample (ie label information) is calculated.
[0121] S203: determining a corresponding candidate set according to the seal identification, and generating a corresponding synthetic seal identification based on the candidate set;
[0122] Since it is difficult to construct sufficiently rich paired training samples with seal identifiers alone, it is also necessary to generate synthetic seal identifiers to enrich the training samples. Figure 4 In some embodiments, determining a corresponding candidate set according to the seal identification, and generating a corresponding synthetic seal identification based on the candidate set may include:
[0123] S401: Determine corresponding multiple sets of seal text information and seal appearance information according to the seal identification;
[0124] S402: Arrange and combine the multiple sets of seal text information and seal appearance information to obtain seal combination information, and establish the candidate set according to the seal combination information;
[0125] S403: randomly selecting a plurality of seal combination information from the candidate set;
[0126] S404: Generate a corresponding composite seal identifier according to the selected seal combination information.
[0127] It can be understood that, in some embodiments, the seal text information includes one or more of font format, font size, text content, text angle, and character spacing, and the seal appearance information includes one or more of seal size, frame thickness, shape, and color. Among them, the seal appearance information determines the appearance of the seal, and the seal text information is filled into the seal mark of the to-be-filled text generated by the seal appearance information to obtain a synthetic seal mark.
[0128] By arranging and combining multiple groups of seal text information and seal appearance information, seal combination information can be obtained. Each seal combination information includes seal text information and seal appearance information. The candidate set established according to the seal combination information can be used to generate richer synthetic seal logos. Among them, the text content of the seal text information in the seal combination information can be obtained by randomly generating characters, avoiding the use of seal text content of real enterprises, institutions, etc., to ensure the compliance of the seal combination information.
[0129] In some embodiments, when a plurality of seal combination information is randomly selected from a candidate set, chaotic mapping may be used for random selection to ensure that the selected seal combination information can fully cover a variety of seal combination situations.
[0130] Specifically, the shapes of seals include oval seals, round seals, square seals and triangular seals, and the text angle refers to the rotation angle of the seal text in the seal (especially round seals and oval seals).
[0131] In some embodiments, for the synthesis process of the round seal and the elliptical seal, the font format, text content, character spacing, arc radius, and text preset coordinates and other information are known. The total width and height of the text can be calculated according to the font size and character spacing, and the horizontal slice length is obtained according to the total text width and character spacing, so as to calculate the center angle of the circle with each character width and character height. The center angle calculation formula is as follows:
[0132] arcLen=textWidth+wordSpace×(wordNum-1)
[0133]
[0134] Among them, arcLen is the horizontal slice length, textWidth is the total text width, wordSpace is the character spacing, wordNum is the character number, aPer is the center angle of the circle, textLen is the text width, r is the arc radius, and textHeight is the text height.
[0135] Afterwards, the rotation angle of each character can be obtained according to the angle of the center of the circle, so that the text is bent and rotated to obtain the bent and rotated text in the seal mark.
[0136] In some embodiments, for horizontal text in a seal mark, horizontal text can be quickly generated based on information such as font format, text content, and character spacing, so that the curved rotated text and horizontal text can be filled into the seal mark of the text to be filled using preset text coordinates, thereby generating a corresponding composite seal mark based on the seal combination information.
[0137] S204: performing Gaussian blur processing on the composite seal mark to obtain a blurred seal mark;
[0138] In some embodiments, the Gaussian kernel size is set to 15 and the standard deviation is set to 5, which can basically ensure that all seal text is blurred and unrecognizable to the human eye. Of course, other Gaussian kernel sizes and standard deviations can also be used, which is not limited in this article.
[0139] S205: using the background image as a background, fusing the synthetic seal mark into the background image, and fusing the blurred seal mark into the background image to obtain paired training samples;
[0140] In some embodiments, the paired training samples include pictures with clear seal marks and pictures with blurred seal marks, and the pictures may have diverse backgrounds. Specifically, the background image is used as the background, the synthetic seal mark is fused into the background image, and the blurred seal mark is fused into the background image to obtain paired training samples, including:
[0141] Acquire pixel coordinate information and pixel information corresponding to the composite seal mark, and pixel coordinate information and pixel information corresponding to the fuzzy seal mark;
[0142] Determine, according to the pixel coordinate information corresponding to the composite seal mark, a first area to be fused in the background image and pixel information corresponding to the first area to be fused;
[0143] Determine, according to the pixel coordinate information corresponding to the fuzzy seal mark, the second area to be fused in the background image and the pixel information corresponding to the second area to be fused;
[0144] The background image is used as the background, and in the first area to be fused, pixel information corresponding to the synthetic seal mark and pixel information corresponding to the first area to be fused are linearly operated according to a preset coefficient to obtain a first fused image;
[0145] The background image is used as the background, and in the second area to be fused, the pixel information corresponding to the fuzzy seal mark and the pixel information corresponding to the second area to be fused are linearly operated according to a preset coefficient to obtain a second fused image;
[0146] Paired training samples are constructed based on the first fused image and the second fused image.
[0147] It can be understood that in some embodiments, referring to the attached Figure 5a And attached Figure 5b The diagram of paired training samples is shown in Figure 5a And attached Figure 5bThe same background image is used. The background images in the figure are all white with black text. In some embodiments, the commonly used size of the training sample is 256*256, which is not limited in this article. Figure 5a The construction process is as follows: after obtaining the synthetic seal logo, since the synthetic seal logo can be a white background image or a backgroundless image, whether the pixel is zero can be used as a judgment condition to quickly obtain the pixel coordinate information and pixel information corresponding to the synthetic seal logo. Afterwards, according to the pixel coordinate information corresponding to the synthetic seal logo, the first area to be fused (which can be understood as the area where the background and the seal overlap when stamping) can be determined in the background image. The specific determination method can be to use the central pixel point of the background image as a reference, and overlap the central pixel point corresponding to the synthetic seal logo with the central pixel point of the background image, so that the area covered by the synthetic seal logo on the background image is used as the first area to be fused. Then, the background image is used as the background, and in the first area to be fused, the pixel information corresponding to the synthetic seal logo and the pixel information corresponding to the first area to be fused are linearly operated according to preset coefficients. The commonly used preset coefficients for the pixel information corresponding to the synthetic seal logo and the pixel information corresponding to the first area to be fused can be 0.5 and 0.5, which are not limited in this article, so as to obtain the first fused image, as shown in the attached figure. Figure 5a Attached Figure 5b The construction process is the same as the attached Figure 5a , which will not be elaborated in this paper. Accordingly, the second fused image is as shown in the attached figure. Figure 5b As shown, according to the first fused image and the second fused image, effective paired training samples are quickly constructed.
[0148] S206: Establish a generator and a Markov discriminator;
[0149] In some embodiments, the encoder in the generator is used for down-sampling layer by layer, and the decoder in the generator is used for up-sampling layer by layer. The upsampling layers in the encoder and the downsampling layers in the decoder are symmetrical to each other, and every two symmetrical layers are connected by jump connections.
[0150] It can be understood that in some embodiments, the generator adopts a U-Net network structure, the upsampling layer in the encoder and the downsampling layer in the decoder are symmetrical to each other, and each two symmetrical layers are connected in a jump connection manner, which can fuse the underlying information and high-level information in the generator, avoid the loss of underlying information, and achieve rapid convergence of the generator model. The Markov discriminator is suitable for images that require high resolution and high-definition details. The Markov discriminator can pay attention to image details during training to ensure the accuracy of the seal desensitization model.
[0151] It should be noted that the generator and the Markov discriminator are two independent models, and the training of the generator and the Markov discriminator is achieved through separate alternating iterative training.
[0152] S207: Using the paired training samples to individually and alternately iterate the generator and the Markov discriminator to obtain trained generator and Markov discriminator; the trained generator and Markov discriminator are seal desensitization models used for seal blurring processing.
[0153] In some embodiments, using the paired training samples to individually and alternately iterate the generator and the Markov discriminator to obtain the trained generator and the Markov discriminator may include:
[0154] Inputting the training sample into the generator to generate a generated image corresponding to the training sample;
[0155] Inputting the generated image and the training sample into the Markov discriminator to determine whether the generated image matches the training sample and obtain a determination result;
[0156] Calculating the loss according to the judgment result, and updating the parameters of the generator and the Markov discriminator using a back propagation algorithm based on the loss;
[0157] Repeat the above steps of updating the parameters of the generator and the Markov discriminator according to the training samples until a preset number of convergences is reached to obtain a trained generator and a Markov discriminator; the trained generator and Markov discriminator are a seal desensitization model.
[0158] It can be understood that, in some embodiments, the task of the generator is to generate samples similar to real data from random noise. The generator attempts to "cheat" the discriminator so that the discriminator cannot distinguish between the generated data and the real data. The task of the discriminator is to distinguish between the real data and the forged data generated by the generator. The discriminator reduces the probability of the generator deceiving it by improving its discrimination ability, so that the samples generated by the generator are closer and closer to the distribution of real samples, and ultimately achieves the effect that the generated data is almost indistinguishable from the real data.
[0159] Specifically, first, the training sample is input into the generator so that the generator generates a generated image corresponding to the fifth fused image in the training sample, and the generated image and the training sample are input into the Markov discriminator so that the Markov discriminator determines whether the generated image matches the sixth fused image in the training sample, and obtains a judgment result, which can be understood as a probability. Then, the loss is calculated according to the judgment result, and based on the loss, the parameters of the generator and the Markov discriminator are updated using the back propagation algorithm, thereby repeating the steps of updating the parameters of the generator and the Markov discriminator according to the training sample as above until a preset number of convergences is reached, and a trained generator and a Markov discriminator are obtained. In some embodiments, according to the judgment result, the loss can be calculated using the following formula:
[0160]
[0161] Among them, G* is the loss, is the variable value when maximizing D and minimizing G, is the conditional Gan loss, λ is a parameter, is the pixel difference loss between the real image and the predicted image, G is the generator output, D is the Markov discriminator output, x is the input, y is the real value, z is the conditional input, is the mathematical expectation.
[0162] The embodiments of the present specification first automatically acquire a target image with a seal and a background image without a seal, and use a pre-trained detection model to quickly segment the target image to obtain a seal logo. Since the number and richness of the seal logos obtained by segmentation may not meet the needs of training a seal desensitization model, a corresponding synthetic seal logo is generated according to a candidate set corresponding to the seal logo to expand and enrich the original seal logo. The synthetic seal logo is then Gaussian blurred to obtain a fuzzy seal logo, and the synthetic seal logo and the fuzzy seal logo are fused into the background image, thereby quickly obtaining paired training samples. The paired training samples are used to iteratively train a generator and a Markov discriminator to obtain a trained generator and a Markov discriminator. The trained generator and Markov discriminator are the seal desensitization model, which can efficiently and accurately perform seal blurring on images with seals while preserving the basic structure of the seal, thereby achieving low-cost seal desensitization.
[0163] Based on the same inventive concept, some embodiments of this specification also provide a seal desensitization method, referring to Figure 6 A flow chart of a seal desensitization method is shown. In some embodiments, the method may include:
[0164] S601: receiving an image to be desensitized;
[0165] S602: Input the image to be desensitized into the seal desensitization model trained by the method described in any of the aforementioned embodiments to obtain a desensitized image.
[0166] It should be noted that, although the operations of the method of the present invention are described in a specific order in the above embodiments and the accompanying drawings, this does not require or imply that the operations must be performed in the specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0167] Corresponding to the above-mentioned seal desensitization model establishment method, some embodiments of this specification also provide a seal desensitization model establishment device, referring to Figure 7 The schematic diagram of the structure of a seal desensitization model establishment device is shown. In some embodiments, the device may include:
[0168] An acquisition module 701 is used to acquire a target image with a seal and a background image without a seal;
[0169] A segmentation module 702 is used to segment the target image to obtain the seal mark by using a pre-trained detection model;
[0170] A synthesis module 703, used to determine a corresponding candidate set according to the seal identification, and generate a corresponding synthetic seal identification based on the candidate set;
[0171] A blur module 704 is used to perform Gaussian blur processing on the composite seal mark to obtain a blurred seal mark;
[0172] A fusion module 705 is used to use the background image as the background, fuse the synthetic seal mark into the background image, and fuse the blurred seal mark into the background image to obtain paired training samples;
[0173] Establishing module 706, for establishing a generator and a Markov discriminator;
[0174] The training module 707 is used to use the paired training samples to individually and alternately iterate the training of the generator and the Markov discriminator to obtain the trained generator and the Markov discriminator; the trained generator and the Markov discriminator are seal desensitization models used for seal blurring processing.
[0175] Based on the same inventive concept, corresponding to the above-mentioned seal desensitization method, some embodiments of this specification also provide a seal desensitization device, referring to Figure 8 As shown, in some embodiments, the apparatus may include:
[0176] A receiving module 801 is used to receive an image to be desensitized;
[0177] The desensitization module 802 is used to input the image to be desensitized into the seal desensitization model trained by the method described in any of the above embodiments to obtain a desensitized image.
[0178] For the convenience of description, the above device is described by dividing it into various units according to its functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0179] It should be noted that in the embodiments of this specification, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user and fully authorized by all parties.
[0180] It should be noted that the computer program product described in this specification is a software product that mainly implements the method described in this specification through a computer program.
[0181] The embodiments of this specification also provide a computer device. Fig. 9 As shown, in some embodiments of the present specification, the computer device 902 may include one or more processors 904, such as one or more central processing units (CPUs) or graphics processing units (GPUs), and each processing unit may implement one or more hardware threads. The computer device 902 may also include any memory 906, which is used to store any kind of information such as code, settings, data, etc. In a specific embodiment, the computer program on the memory 906 and can be run on the processor 904, when the computer program is run by the processor 904, the instructions of the method described in any of the above embodiments may be executed. Non-limiting, for example, the memory 906 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 902. In one case, when the processor 904 executes an associated instruction stored in any memory or a combination of memories, the computer device 902 may perform any operation of the associated instruction. The computer device 902 also includes one or more drive mechanisms 908 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.
[0182] The computer device 902 may also include an input / output interface 910 (I / O) for receiving various inputs (via input devices 912) and for providing various outputs (via output devices 914). A specific output mechanism may include a presentation device 916 and an associated graphical user interface 918 (GUI). In other embodiments, the input / output interface 910 (I / O), input device 912, and output device 914 may not be included, and the computer device 902 may be used as a computer device in a network. The computer device 902 may also include one or more network interfaces 920 for exchanging data with other devices via one or more communication links 922. One or more communication buses 924 couple the components described above together.
[0183] The communication link 922 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 922 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.
[0184] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), computer-readable storage media, and computer program products of some embodiments of the present specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processor to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processor generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0185] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processor to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0186] These computer program instructions can also be loaded onto a computer or other programmable data processor so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0187] In a typical configuration, a computer device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0188] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0189] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computer device. As defined in this specification, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0190] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, the embodiments of this specification may take the form of complete hardware embodiments, complete software embodiments or embodiments combining software and hardware. Moreover, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0191] The present specification embodiments may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present specification embodiments may also be practiced in distributed computing environments where tasks are performed by remote processors connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0192] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0193] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0194] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of this specification. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0195] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for establishing a seal desensitization model, characterized in that: The method comprises: Acquire a target image with a seal and a background image without a seal; Using a pre-trained detection model, segmenting the target image to obtain a seal mark; Determine a corresponding candidate set according to the seal identification, and generate a corresponding synthetic seal identification based on the candidate set; Performing Gaussian blur processing on the synthetic seal mark to obtain a blurred seal mark; Using the background image as a background, fusing the synthetic seal mark into the background image, and fusing the blurred seal mark into the background image to obtain paired training samples; Build the generator and the Markov discriminator; The generator and the Markov discriminator are trained separately and iteratively using the paired training samples to obtain trained generators and Markov discriminators; the trained generators and Markov discriminators are seal desensitization models used for seal blurring processing.
2. The method according to claim 1, characterized in that Using the pre-trained detection model, the seal mark is segmented from the target image, including: Using a pre-trained detection model, detect whether a seal mark exists in the target image to obtain a detection result; The seal mark is obtained by segmenting the target image according to the detection result.
3. The method according to claim 2, characterized in that The pre-trained detection model is trained in the following way: Marking the seal mark in the target image to obtain label information; Constructing a training sample set according to the label information and the background image; Randomly select batch samples from the training sample set; Inputting the batch samples into the backbone network of the detection model to extract the corresponding feature graph; The convolutional neural network in the detection model is used to predict the feature maps respectively to obtain corresponding heat maps, position offsets and target boxes; Calculate the loss value using a preset loss function according to the heat map, position offset and target frame; Updating network parameters in the detection model based on the loss value; Repeat the above steps of updating the network parameters according to the training sample set until a preset convergence condition is reached.
4. The method according to claim 1, characterized in that: Determining a corresponding candidate set according to the seal identification, and generating a corresponding synthetic seal identification based on the candidate set, including: Determine corresponding multiple sets of seal text information and seal appearance information according to the seal identification; wherein the seal text information includes one or more of font format, font size, text content, text angle, and character spacing, and the seal appearance information includes one or more of seal size, frame thickness, shape, and color; Arrange and combine the multiple sets of seal text information and seal appearance information to obtain seal combination information, and establish the candidate set according to the seal combination information; Randomly select multiple seal combination information from the candidate set; Generate a corresponding composite seal logo according to the selected seal combination information.
5. The method according to claim 1, characterized in that The background image is used as a background, the synthetic seal mark is fused into the background image, and the blurred seal mark is fused into the background image to obtain paired training samples, including: Acquire pixel coordinate information and pixel information corresponding to the composite seal mark, and pixel coordinate information and pixel information corresponding to the fuzzy seal mark; Determine, according to the pixel coordinate information corresponding to the composite seal mark, a first area to be fused in the background image and pixel information corresponding to the first area to be fused; Determine, according to the pixel coordinate information corresponding to the fuzzy seal mark, the second area to be fused in the background image and the pixel information corresponding to the second area to be fused; The background image is used as the background, and in the first area to be fused, pixel information corresponding to the synthetic seal mark and pixel information corresponding to the first area to be fused are linearly operated according to a preset coefficient to obtain a first fused image; The background image is used as the background, and in the second area to be fused, the pixel information corresponding to the fuzzy seal mark and the pixel information corresponding to the second area to be fused are linearly operated according to a preset coefficient to obtain a second fused image; Paired training samples are constructed based on the first fused image and the second fused image.
6. The method according to claim 1, characterized in that The encoder in the generator is used for down-sampling layer by layer, and the decoder in the generator is used for up-sampling layer by layer. The up-sampling layer in the encoder and the down-sampling layer in the decoder are symmetrical to each other, and every two symmetrical layers are connected in a jump connection manner.
7. The method according to claim 6, characterized in that The generator and the Markov discriminator are trained separately and iteratively using the paired training samples to obtain the trained generator and the Markov discriminator, including: Inputting the training sample into the generator to generate a generated image corresponding to the training sample; Inputting the generated image and the training sample into the Markov discriminator to determine whether the generated image matches the training sample and obtain a determination result; Calculating the loss according to the judgment result, and updating the parameters of the generator and the Markov discriminator using a back propagation algorithm based on the loss; Repeat the above steps of updating the parameters of the generator and the Markov discriminator according to the training samples until a preset number of convergences is reached to obtain a trained generator and a Markov discriminator; the trained generator and Markov discriminator are a seal desensitization model.
8. A seal desensitization method, characterized in that: The method comprises: receiving an image to be desensitized; The image to be desensitized is input into a seal desensitization model trained by the method according to any one of claims 1 to 7 to obtain a desensitized image.
9. A seal desensitization model building device, characterized in that: The device comprises: An acquisition module, used for acquiring a target image with a seal and a background image without a seal; A segmentation module, used for segmenting the target image to obtain the seal mark by using a pre-trained detection model; A synthesis module, used for determining a corresponding candidate set according to the seal identification, and generating a corresponding synthetic seal identification based on the candidate set; A fuzzy module, used for performing Gaussian fuzzy processing on the composite seal mark to obtain a fuzzy seal mark; A fusion module, used to use the background image as a background, fuse the synthetic seal mark into the background image, and fuse the blurred seal mark into the background image to obtain paired training samples; Establish a module for establishing the generator and the Markov discriminator; A training module is used to use the paired training samples to individually and alternately iterate and train the generator and the Markov discriminator to obtain a trained generator and a Markov discriminator; the trained generator and the Markov discriminator are a seal desensitization model used for seal blurring processing.
10. A seal desensitization device, characterized in that: The device comprises: A receiving module, used for receiving the image to be desensitized; A desensitization module is used to input the image to be desensitized into a seal desensitization model trained by the method according to any one of claims 1 to 7 to obtain a desensitized image.
11. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that: When the computer program is executed by the processor, the computer program executes the instructions of the method according to any one of claims 1 to 8.
12. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor of a computer device, the computer program executes the instructions of the method according to any one of claims 1 to 8.
13. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the instructions of the method according to any one of claims 1 to 8 are executed.