Unstructured data desensitization processing method, system and device
Through text, portrait and seal erase models to identify and erase sensitive information in the image, the problems of low image desensitization efficiency and poor applicability in the prior art are solved, and efficient sensitive information processing and protection of unstructured data are achieved. .
Patent Information
- Application Number
- CN202411227992.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2025-01-14
AI Technical Summary
The prior art is difficult to desensitize the image itself to sensitive information, especially portraits and seals, and cannot adapt to non-preset layouts and angle changes, resulting in incomplete or excessive occlusion, affecting data use.
Using text erasing models, portrait detection models and seal erasing models, the model is used to generate the model to identify and erase sensitive information in the image, generate the desensitized area, and write it back to the original image to realize text and portrait and seal sensitive information detection and desensitization.
It realizes effective desensitization of sensitive information of portraits and seals in unstructured data, improves the protection effect and data availability of sensitive data, and is suitable for image processing of any layout and angle.
Smart Images

Figure CN119312382A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of financial technology, and in particular to a method, system and device for desensitizing unstructured data. Background Art
[0002] With the continuous development of information technology, the importance of information security has gradually increased, and the regulatory requirements for information security have become increasingly stringent. As an important part of information security, most current solutions for sensitive information processing focus on text processing of structured or semi-structured data, mainly using keyword judgment, fixed rule matching and entity recognition technology. After judging the text containing sensitive information, sensitive information text processing is performed according to the rules corresponding to the sensitive information category. If image desensitization is involved, it is mainly achieved by fixed template masking.
[0003] The existing technology mainly focuses on the processing of text information. For sensitive information in images, it can only extract text information and return desensitized data in text form. It is impossible to desensitize the image itself, and it is also impossible to process sensitive information of non-text types such as seals and portraits. If the image itself needs to be desensitized, it can only be modified manually one by one, or fixed areas can be blocked in batches. Manual modification processing is inefficient and cannot be applied to batch operations. The fixed area blocking method has high requirements for data preprocessing and can only process sensitive information in a preset layout. It is easy to have problems such as incomplete blocking and excessive blocking affecting data usage due to changes in image angle and layout, and it is difficult to meet the needs of partially blocking sensitive information according to rules.
[0004] This manual achieves the desensitization of portraits, seals, and texts in the data, improving the protection of sensitive data. Summary of the invention
[0005] In order to solve the problem that the prior art can only process sensitive information in a preset format and is difficult to partially mask sensitive information, the embodiments of this specification provide a method, system and device for desensitizing unstructured data.
[0006] The embodiment of the present specification provides a method for desensitizing unstructured data, the method comprising: using a text erasure model to erase sensitive text information in a text slice image, and generating a first desensitized area in the original text image, wherein the text erasure model is obtained by generating a model through a first slice sample set and a text slice sample set training condition, and the text slice image is obtained by identifying sensitive entities in the original text image; using a portrait detection model to identify key point coordinates in the original portrait image, and determining a second desensitized area in the original portrait image based on the key point coordinates, wherein the portrait detection model is based on a sample portrait. The portrait detection basic model is trained based on the key point coordinate features in the image and the sample portrait image; the key data in the seal slice image is erased by using the seal erasure model to generate a third desensitized area in the original seal image, wherein the seal erasure model is obtained by training the conditional generation model through the second slice sample set and the seal fusion sample image set, and the seal slice image is obtained by identifying the seal in the original seal image; the first desensitized area is written back to the original text image, the second desensitized area is written back to the original portrait image, and the third desensitized area is written back to the original seal image to obtain the desensitized image.
[0007] According to one aspect of an embodiment of the present specification, the first slice sample set and the text slice sample set are determined in the following manner: randomly selecting multiple sample baseboard images and multiple sample texts, the multiple sample texts having different fonts, font sizes and word counts; generating a sample baseboard slice image without text according to the font, font size, word count and the sample baseboard image of the sample text, the multiple sample baseboard slice images constitute the first slice sample set; writing each type of sample text into the corresponding sample baseboard slice image respectively, generating multiple sample text slices, the multiple sample text slices constitute the text slice sample set.
[0008] According to one aspect of an embodiment of the present specification, a text erasure model is trained by: obtaining a first slice sample set and a text slice sample set, inputting the text slice sample set into a conditional generation model, and obtaining an image output by the conditional generation model; calculating a loss value between the image output by the conditional generation model and the first slice sample set, and iteratively updating the conditional generation model based on the loss value to obtain the text erasure model.
[0009] According to one aspect of an embodiment of the present specification, a plurality of sample base plate slice images form a first slice sample set, including: writing all sample base plate slice images into a first initial blank image in a vertical arrangement; comparing the length of the longest sample base plate slice image in the first initial blank image with the sum of the heights of all sample base plate slice images after vertical arrangement, and determining the larger value; using the larger value as the side length of the first initial blank image to construct a first slice sample set; a plurality of sample text slices form a text slice sample set, including: writing all sample text slices into a second initial blank image in a vertical arrangement; comparing the length of the longest sample text slice in the second initial blank image with the sum of the heights of all sample text slices after vertical arrangement, and determining the larger value; using the larger value as the side length of the second initial blank image to construct a text slice sample set.
[0010] According to one aspect of an embodiment of the present specification, a portrait detection model is obtained by training in the following manner, including: obtaining a sample portrait image and key point coordinate features in the sample portrait image; inputting the sample portrait image into a portrait detection basic model to obtain portrait key point coordinates output by the portrait detection basic model; calculating a loss value between the portrait key point coordinates and the key point coordinate features in the sample portrait image, and iteratively updating the portrait detection basic model based on the loss value to obtain the portrait detection model.
[0011] According to one aspect of an embodiment of the present specification, determining the second desensitized area in the original portrait image based on the key point coordinates includes: determining the angle of the original portrait image according to the slope between the key point coordinates; calculating the distances between the key point coordinates and the upper and lower boundaries of the original portrait image or the distances between the key point coordinates and the left and right boundaries of the original portrait image according to the angle of the original portrait image; determining the second desensitized area based on the distances between the key point coordinates and the upper and lower boundaries of the original portrait image or the distances between the key point coordinates and the left and right boundaries of the original portrait image.
[0012] According to one aspect of an embodiment of the present specification, the distances between the key point coordinates and the upper and lower boundaries of the original portrait image, or the distances between the key point coordinates and the left and right boundaries of the original portrait image are calculated by the following formula:
[0013] dis1=abs(y 5 -min(y 1 ,y 2 ))+abs(y 6 -(min(y 1 ,y 2 ));
[0014] dis2=abs(y 5 -max(y 3 ,y4 ))+abs(y 6 -max(y 3 ,y 4 )); where dis1 represents the distance between the vertical coordinates of both eyes and the upper side of the original portrait image, dis2 represents the distance between the vertical coordinates of both eyes and the lower side of the original portrait image, and y 5 and 6 Respectively represent the ordinates of the two key points, y 1 ,y 2 and 3 ,y 4 Respectively represent the vertical coordinates of the four corners of the original portrait image;
[0015] dis3=abs(x 5 -min(x 1 ,x 2 ))+abs(y 6 -(min(x 1 ,y 2 ));
[0016] dis4=abs(x 5 -max(x 3 ,x 4 ))+abs(y 6 -max(x 3 ,x 4 )); where dis3 represents the distance between the binocular coordinates and the left side of the original portrait image, dis4 represents the distance between the binocular coordinates and the right side of the original portrait image, and x 5 and x 6 Respectively represent the horizontal coordinates of the two key points, x 1 ,x 2 and x 3 ,x 4 Represent the horizontal coordinates of the four corners of the original portrait image.
[0017] According to one aspect of an embodiment of the present specification, before writing the second desensitized area back to the original portrait image, the method also includes: determining the size of the second desensitized area based on the coordinates of the diagonal points of the second desensitized area; slicing the second desensitized area and downsampling the sliced image; and expanding the downsampled image to the size of the second desensitized area.
[0018] According to one aspect of an embodiment of the present specification, the second slice sample set and the seal fusion sample image set are determined in the following manner: based on the seal text, the preset seal template, and the preset seal size, the sample seal synthesis parameters are determined and the sample seal image is synthesized on a blank base plate; based on the longest side of the sample seal image, the preset document image is cropped to obtain slices of the preset document image, and the slices of multiple preset document images constitute the second slice sample set; the sample seal image is synthesized into the slices of the preset document image to generate a seal fusion sample image, and the multiple seal fusion sample images constitute the seal fusion sample image set.
[0019] According to one aspect of the embodiments of the present specification, a seal erasure model is obtained by training in the following manner: obtaining a second sample slice set and seal slice features, inputting the second sample slice set into a conditional generation model, and obtaining an image output by the conditional generation model; calculating a loss value between the image output by the conditional generation model and the second slice sample set, and iteratively updating the conditional generation model based on the loss value to obtain the seal erasure model.
[0020] The embodiment of the present specification also provides an unstructured data desensitization processing device, the device comprising: a first desensitized area generation unit, used to use a text erasure model to erase sensitive text information in a text slice image, and generate a first desensitized area in the original text image, wherein the text erasure model is obtained by generating a model through a first slice sample set and a text slice sample set training condition, and the text slice image is obtained by identifying sensitive entities in the original text image; a second desensitized area generation unit, used to use a portrait detection model to identify key point coordinates in the original portrait image, and determine a second desensitized area in the original portrait image based on the key point coordinates, wherein the portrait detection model is based on The portrait detection basic model is trained according to the sample portrait image and the key point coordinate features in the sample portrait image; the third desensitized area generation unit is used to use the seal erasure model to erase the key data in the seal slice image to generate the third desensitized area in the original seal image, wherein the seal erasure model is obtained by training the conditional generation model through the second slice sample set and the seal fusion sample image set, and the seal slice image is obtained by identifying the seal in the original seal image; the write-back unit is used to write the first desensitized area back to the original text image, write the second desensitized area back to the original portrait image, and write the third desensitized area back to the original seal image to obtain the desensitized image.
[0021] An embodiment of the present specification also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the unstructured data desensitization processing method when executing the computer program.
[0022] The embodiments of the present specification also provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the unstructured data desensitization processing method is implemented.
[0023] The embodiments of this specification also provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the unstructured data desensitization processing method is implemented.
[0024] This manual achieves the desensitization of portraits, seals, and QR codes in the data, improving the protection of sensitive data. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0026] Figure 1 The figure is a flow chart of a method for desensitizing unstructured data according to an embodiment of the present specification;
[0027] Figure 2 The flowchart of a method for determining a first slice sample set and a text slice sample set according to an embodiment of the present specification is shown;
[0028] Figure 3 The figure is a flow chart of a method for training a text erasure model according to an embodiment of the present specification;
[0029] Figure 4 This is a flow chart of a method for determining a portrait detection model according to an embodiment of this specification;
[0030] Figure 5 The figure is a flow chart of a method for determining a desensitization area of a portrait according to an embodiment of the present specification;
[0031] Figure 6 The figure is a flow chart of a method for coding a second desensitized area according to an embodiment of the present specification;
[0032] Figure 7 It is a flow chart of a method for determining a second slice sample set and a seal fusion sample image set according to an embodiment of the present specification;
[0033] Figure 8 The figure is a flow chart of a method for training a seal erasure model according to an embodiment of the present specification;
[0034] Fig. 9The figure shows a schematic diagram of an unstructured data desensitization processing device according to an embodiment of the present specification;
[0035] Fig. 10A The figure shows a schematic diagram of a text slice sample set according to an embodiment of the present specification;
[0036] Fig. 10B Shown is a schematic diagram of a first slice sample set according to an embodiment of this specification;
[0037] Fig.11A It is a schematic diagram of a seal fusion sample image set according to an embodiment of this specification;
[0038] Fig. 11B Shown is a schematic diagram of a second sample slice set according to an embodiment of this specification;
[0039] Fig.12 This is a schematic diagram of a seal cross-shaped desensitization according to an embodiment of this specification;
[0040] Fig.13 This is a schematic diagram of identifying the coordinates of key points of a portrait according to an embodiment of this specification;
[0041] Fig.14 The figure shows a schematic diagram of desensitizing and writing back text in an embodiment of the present specification;
[0042] Fig.15 The figure shows a schematic diagram of the structure of a computer device according to an embodiment of the present specification.
[0043] Description of the accompanying symbols:
[0044] 901, a first desensitization area generating unit;
[0045] 902, a second desensitization area generating unit;
[0046] 903, a third desensitization area generating unit;
[0047] 904, write-back unit;
[0048] 1502. Computer equipment;
[0049] 1504. Processor;
[0050] 1506. Memory;
[0051] 1508, driving mechanism;
[0052] 1510, input / output module;
[0053] 1512. Input devices;
[0054] 1514. Output device;
[0055] 1516. Presentation equipment;
[0056] 1518. Graphical user interface;
[0057] 1520, network interface;
[0058] 1522. Communication link;
[0059] 1524. Communication bus. DETAILED DESCRIPTION
[0060] 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 the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0061] It should be noted that the terms "first", "second", etc. in the description and claims of this specification 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 specification described herein can be implemented in an order other than those illustrated or described herein. 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.
[0062] This specification provides method operation steps as described in the embodiments or flow charts, but more or fewer operation steps may be included based on routine or non-creative work. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the system or device product is executed in practice, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel.
[0063] It should be noted that the unstructured data desensitization processing method of this specification can be used in the field of image recognition, and can also be used in the field of semantic understanding, natural language processing, or image processing technology, and can also be used in the field of computer technology. This specification does not limit the application field of the unstructured data desensitization processing method.
[0064] Figure 1The flowchart of a method for desensitizing unstructured data according to an embodiment of the present specification is shown, which specifically includes the following steps:
[0065] Step 101, using a text erasure model, erases sensitive text information in a text slice image to generate a first desensitized area in the original text image, wherein the text erasure model is obtained by generating a model based on a first slice sample set and a text slice sample set training condition, and the text slice image is obtained by identifying sensitive entities in the original text image.
[0066] In this specification, the text image may contain content involving personal privacy, business secrets, confidential information or content that should be kept confidential according to the law, and the corresponding content in the text image needs to be protected as sensitive information. Therefore, it is necessary to erase, block or replace the sensitive information in the text image. Furthermore, while processing the sensitive information in the text image, it is expected that the non-sensitive information and image background (including but not limited to: image background color, image shading information, etc.) in the text image are retained, so as to improve the availability of the desensitized data on the basis of fully protecting the data security.
[0067] In this step, the conditional generative model is trained multiple times using paired images as training samples to obtain a text erasure model. The paired images are the original text image and the image with sensitive information erased and background information. Figure 2 , Fig. 10A and Fig. 10B Description. In addition, the conditional generation model can be a pix2pix model based on the GAN (Generative Adversarial Nets) network. Among them, the pix2pix model is a one-to-one mapping relationship between each pixel in a pair of images. It has a good desensitization effect on slices of different textures and sizes. Compared with other GAN network models such as EraseNet and CycleGAN, it is more suitable for the data scenarios involved in this solution.
[0068] In this step, the text erasure model generates an image slice close to the original image background color based on the input text image. Compared with the original text image, the image slice no longer contains sensitive text information, so the image slice can also be called the first desensitization area. In this way, sensitive information in the input text image can be removed while the characteristics of the original text image can be better preserved.
[0069] The text slice image is obtained by identifying the sensitive entities in the original text image. The text image to be processed is subjected to text recognition to identify the text, type and coordinate information related to the sensitive information in the text image. The specific steps are as follows:
[0070] (1) Preprocessing the text by encoding it according to its coordinates;
[0071] (2) The preprocessed text is input into the entity recognition model for prediction, and the prediction result is decoded to obtain the entity type of each word in BIO format. Among them, the entity types mainly include: name, place name, organization name, date, ID number, telephone number, email address, etc. For some sensitive text types that are difficult to judge through the entity recognition model, such as digital telephone numbers, mobile phone numbers, ID card numbers, bank card numbers, etc., the index of the sensitive text is obtained through regular matching and formula verification, and the image coordinates of the corresponding text are calculated.
[0072] (3) Filter out the text of the sensitive entity type that needs to be desensitized, and calculate the coordinates of the sensitive entity text based on its index information. In the embodiment of this specification, the desensitization rule is to retain at most the first 1 / 3 and the last 1 / 3 of the sensitive entity text (rounded down), and replace the middle with an asterisk. Some types of sensitive information have special desensitization requirements, such as the address needs to be desensitized for at least 6 digits.
[0073] (4) Slice the text image according to the preset desensitization rules and the coordinates of the sensitive entity text.
[0074] After obtaining the slices, the text erasure model is used to erase the text content on the slices to achieve desensitization replacement of sensitive entity text in the text image.
[0075] This manual can write back the desensitized text after processing the sensitive text in the image according to the desensitization rules, retain the necessary text to the maximum extent, and improve the availability of the desensitized data.
[0076] Step 102, using a portrait detection model to identify key point coordinates in the original portrait image, and determine a second desensitized area in the original portrait image based on the key point coordinates, wherein the portrait detection model is trained based on the sample portrait image and key point coordinate features in the sample portrait image.
[0077] In the embodiments of this specification, the original portrait image can come from: a portrait photo of a certificate, a scanned copy of a certificate, or a photocopy of a portrait photo. In this step, by using sample portrait images marked with key point coordinate features as training samples, the portrait detection basic model is trained multiple times to obtain a portrait detection model. Among them, the key point coordinate features include but are not limited to: eye coordinate features, nose coordinate features, mouth coordinate features, ear coordinate features, etc. in the face.
[0078] According to the trained portrait detection model, after predicting the key point coordinates of the portrait image, the area where the key point coordinates are located is used as the second desensitization area for desensitization. Specifically, the area where the coordinates of both eyes in the portrait are located can be covered or blurred, thereby achieving the effect of desensitization and protecting user privacy.
[0079] Furthermore, the size or position of the second desensitization area can be determined in combination with specific desensitization requirements. For example, the desensitization requirements for portrait images in this application may be higher precision requirements such as "only blocking the half of the face where the eyes are located". In this case, it is necessary to determine the second desensitization area based on the coordinates of the eyes in the portrait and the upper and lower boundaries or left and right boundaries of the portrait image. Specifically, it is necessary not only to detect the portrait area, but also to judge the position of the facial features of the portrait and the direction of the portrait image. Therefore, this application does not limit the specific setting of the second desensitization area.
[0080] Step 103, using the seal erasure model, erases the key data in the seal slice image, and generates a third desensitized area in the original seal image, wherein the seal erasure model is obtained by training the conditional generation model of the second slice sample set and the seal fusion sample image set, and the seal slice image is obtained by identifying the seal in the original seal image.
[0081] In this step, the seal information in the image containing the seal also involves sensitive information to a certain extent, so it is first necessary to determine the seal slice image containing sensitive seal information from the original seal image, and further erase the sensitive information or key information of the seal from the seal slice image. Therefore, this step uses the seal erasure model to desensitize the key data in the seal image, and obtains the third desensitized area in the seal image that retains non-sensitive information.
[0082] The conditional generative model in this step can be a pix2pix model based on a GAN (Generative Adversarial Nets) network. The seal erasure model can be obtained by training the conditional generative model through the second slice sample set and the seal fusion sample image set. Specifically, the conditional generative model is optimized for scenes such as scans and copies, and the seal erasure model is constructed after multiple iterations.
[0083] In this step, the seal slice image is obtained by identifying the seal in the original seal image. The specific steps are as follows:
[0084] (1) Locate the seal area in the original seal image to obtain the seal coordinates;
[0085] (2) According to the seal coordinates, the original seal image is sliced to obtain a seal slice image.
[0086] Specifically, a detection model based on CenterNet is used to locate the seal area in the original seal image through center point detection and edge regression, and the seal type in the seal image is classified and identified, thereby determining the seal coordinates in the original seal image, and slicing the original seal image according to the seal coordinates. Fig.12 As shown, the CenterNet-based detection model is first used to identify the position of the seal in the seal image. Further, according to the position of the seal, the middle 1 / 2 area in the horizontal and vertical directions of the original seal image is delineated as the area to be removed of sensitive information, and 4 seal slice images to be processed are obtained, which are specifically the shaded parts in the figure.
[0087] This step further requires using a stamp erasing model to desensitize the four stamp slice images to be processed, and generate a desensitized area in the original stamp image.
[0088] Step 104, respectively write the first desensitized area back to the original text image, write the second desensitized area back to the original portrait image, and write the third desensitized area back to the original seal image to obtain a desensitized image.
[0089] Based on the desensitized areas obtained by processing each model in step 101 to step 103, the processed desensitized areas are written back to the original text image, the original portrait image or the original seal image to obtain the desensitized text image, the portrait image or the seal image respectively.
[0090] In this step, according to the desensitization requirements for the original text image, the original text image is sliced according to the sensitive text entity coordinates, and the text image slices are desensitized using the second desensitization area generated in step 101 to achieve desensitization processing of the original text image.
[0091] In this step, according to the desensitization requirement of the original seal image, the original seal image is sliced according to the seal coordinates, and according to the coordinates of each slice, the seal image slices are partially or completely desensitized using the third desensitization area generated in step 103, thereby realizing the desensitization processing of the original seal image. While retaining the seal position information, sensitive information is removed.
[0092] This application can realize sensitive information detection of text, portraits, seals and QR codes in unstructured data of any format, and can generate end-to-end desensitized images. In particular, in the desensitization of text images, the text can be written back instead of directly blocked, which improves the availability of desensitized data while fully protecting data security.
[0093] Figure 2 The flowchart of a method for determining a first slice sample set and a text slice sample set according to an embodiment of the present specification is shown, which specifically includes the following steps:
[0094] Step 201 , randomly selecting a plurality of sample baseboard images and a plurality of sample texts, wherein the plurality of sample texts have different fonts, font sizes and word counts.
[0095] The sample base image in this step is at least one of a solid color base or a shading, and has image background information such as a solid color base or a shading. The multiple sample base images can be images of the same size with different background colors or shading, or images of different sizes with different background colors or shading. This step does not limit the size of the sample base image.
[0096] The sample text may be randomly generated, wherein the sample text may be text with actual semantics or random meaningless text. Text with actual semantics includes but is not limited to: real text excerpts, semantic entities, etc., and random meaningless text includes but is not limited to: numbers, letter strings, etc. Furthermore, the generated sample text may have a variety of different fonts, font sizes, word counts, colors, etc.
[0097] Step 202, generating a sample base plate slice image without text according to the font, font size, word count of the sample text and the sample base plate image, and a plurality of sample base plate slice images constitute a first slice sample set.
[0098] The size of the sample base plate slice image is determined according to the font, font size, and number of words of the sample text, and the sample base plate image selected in step 201 is cut to generate a sample base plate slice without text. In this specification, the sample base plate slice without text can be recorded as image B. Multiple or more sample base plate slice images constitute a first slice sample set.
[0099] The first slice sample set composed of multiple sample bottom plate slice images includes:
[0100] Writing all sample bottom plate slice images into the first initial blank image in a longitudinal arrangement;
[0101] Compare the length of the longest sample bottom plate slice in the first initial blank image with the sum of the heights of all sample bottom plate slices arranged longitudinally, and determine the larger value;
[0102] The larger value is used as the side length of the initial blank image to construct a first slice sample set.
[0103] Specifically, all sample bottom plate slices (Figure B) are written into the first initial blank image in a longitudinal arrangement; the longest sample bottom plate slice is determined according to the length of all sample bottom plate slices; the sum of the heights of all sample bottom plate slices after longitudinal arrangement is further determined and recorded as the total height. The length of the longest sample bottom plate slice is compared with the total height. The larger value of the two is used as the side length of the blank image to construct the first slice sample set.
[0104] The blank image is a square. For example, if the larger value of the longest sample bottom plate slice and the total height is determined to be 512, the longest side of the first initial blank image is resized to 512, and the short side is padded to 512 to obtain a large blank image, such as Fig. 10B As shown, Fig. 10B The first slice sample set in this step is shown.
[0105] Step 203, each type of sample text is written into the corresponding sample base plate slice map, generating multiple sample text slices, and the multiple sample text slices constitute a text slice sample set. Specifically, the sample texts with different fonts, font sizes and word counts are written into a sample base plate slice map with a length corresponding to the word count and a height corresponding to the font size, and a sample base plate slice map with the sample text is obtained, that is, a sample text slice. In this specification, the sample text slice with the sample text can be recorded as Figure A.
[0106] In this specification, a plurality of sample text slices constitutes a text slice sample set.
[0107] Specifically, all sample text slices (denoted as A) are written into the second initial blank image in a vertical arrangement, and the longest sample text slice is determined according to the length of all sample text slices; further, the sum of the heights of all sample text slices after vertical arrangement is determined and recorded as the total height. Compare the length of the longest sample text slice with the total height. The larger value of the two is used as the side length of the blank image, and the blank image is a square. For example, if the larger value of the longest sample text slice and the total height is determined to be 512, then the longest side of the second initial blank image is resized to 512, and the short side is padded to 512 to obtain a large blank image, such as Fig. 10A shown.
[0108] According to the above steps, 10 to 30 pairs of sample text slices A and sample base plate slices B are generated, and the sizes are unified to generate the following Fig. 10A and Fig. 10B The text slice sample set and the first slice sample set are used to train and build a text erasure model, which can reduce the time consumption of model training.
[0109] Figure 3 The above is a flow chart of a method for training a text erasure model according to an embodiment of this specification, which specifically includes the following steps:
[0110] Step 301 , obtaining a first slice sample set and a text slice sample set, inputting the text slice sample set into a conditional generation model, and obtaining an image output by the conditional generation model.
[0111] In this step, a sample data set for training the conditional generation model is obtained, wherein the sample data set includes a first slice sample set and a text slice sample set corresponding to the first slice sample set. Specifically, whenever a text slice sample set is input to the conditional generation model, the conditional generation model outputs a corresponding image, which clears the text in the text slice sample set.
[0112] Step 302, calculate the loss value between the image output by the conditional generation model and the first slice sample set, iteratively update the conditional generation model based on the loss value, and obtain the text erasure model.
[0113] In this step, based on the difference between the image output by the conditional generation model and the first slice sample set in step 301, the loss value between the two is calculated, and the conditional generation model is further iteratively updated based on the loss value until the loss value converges to a preset threshold, and the training of the conditional generation model is determined to be completed, and a text erasure model is constructed; or when the iteration of the conditional generation model reaches a preset value here, the training of the conditional generation model is determined to be completed, and a text erasure model is obtained.
[0114] The constructed text erasure model can be used to desensitize the text image to obtain an image without sensitive information and retaining background information.
[0115] Figure 4 The above is a flow chart of a method for determining a portrait detection model according to an embodiment of this specification, which specifically includes the following steps:
[0116] Step 401, obtaining a sample portrait image and key point coordinate features in the sample portrait image.
[0117] The portrait scenes involved in the embodiments of this specification include but are not limited to: portraits in ID photos, scans, and copies. Conventional portrait detection models can only be used for portrait detection in natural scenes, but cannot accurately detect and identify portraits in scenes such as ID photos and scans. Therefore, in order to improve the detection accuracy of the model in the portrait scenes involved in this specification, this application optimizes the image data used to train the model.
[0118] This step uses the following types of images as sample portrait images through data synthesis, including but not limited to: certificate sample portraits; sample portraits partially blocked by seals or other texts, sample portraits of different sizes, or multiple portraits in different directions in one image.
[0119] In some other embodiments of the present specification, the types of sample portrait images can also be enriched through dynamic data enhancement. For example, the sample portrait image is rotated at four angles (for example: 0°, 90°, 180°, 270°), the image is grayed or blurred, etc. While determining the sample portrait image, the key point coordinate features (i.e., the facial features coordinate features) in the sample portrait image are determined respectively as label data for subsequent training of the portrait detection model.
[0120] Step 402: input the sample portrait image into a portrait detection basic model to obtain the portrait key point coordinates output by the portrait detection basic model.
[0121] In this step, the basic portrait detection model can be a basic detection model based on RetinaFace, which outputs the locations of the key points of the facial features in the portrait based on the detection of the face area. The accuracy of the key point coordinates output by the basic detection model based on RetinaFace is not high enough in the initial situation. Therefore, it is necessary to combine the key point coordinate features in the sample portrait image with the key point coordinates output by the model for iteration, and further train to obtain a portrait detection model suitable for actual use scenarios. Improve the detection accuracy of the portrait detection model in the application scenario of this manual.
[0122] Step 403, calculating the loss value of the portrait key point coordinates and the key point coordinate features in the sample portrait image, iteratively updating the portrait detection basic model based on the loss value, and obtaining the portrait detection model.
[0123] In this step, the loss value between the key point coordinates output by the basic detection model based on RetinaFace and the key point coordinate features in step 401 is calculated, and the basic detection model based on RetinaFace is further iteratively updated according to the loss value until the loss value converges to a preset threshold, the model training is determined to be completed, and the image detection is constructed; or when the number of iterations of the basic detection model based on RetinaFace reaches a preset value, the model training is determined to be completed, and the portrait detection model is obtained.
[0124] Furthermore, the portrait detection model can be used to predict the portrait image to obtain the eye coordinates in the portrait image. The constructed portrait detection model is used to perform desensitization processing on the image containing the portrait to obtain a second desensitized area without portrait sensitive information in the portrait image.
[0125] Figure 5 The flowchart of a method for determining a desensitization area of a portrait according to an embodiment of the present specification is shown, which specifically includes the following steps:
[0126] Step 501, determining the angle of the original portrait image according to the slope between the key point coordinate points.
[0127] In this step, the eye images in the original portrait image are used as the key point coordinates for description. Specifically, the coordinates of the four corners of the original portrait image and the eye coordinates of the face in the original portrait image are inferred based on the portrait detection model. The coordinates of the four corners are expressed in clockwise order from the upper left corner as follows: (x 1 ,y 1 );(x 2 ,y 2 );(x 3 ,y 3 );(x 4 ,y 4 The coordinate points of both eyes are expressed as: (x 5 ,y 5 ) and (x 6 ,y 6 ).
[0128] According to the coordinates of both eyes, the slope between the coordinate points of both eyes is calculated to further determine the angle or direction of the original portrait image. Specifically, if the slope k>1, it can be determined that the angle of the portrait image is 90° or 270°, and the original portrait image is placed vertically; if the slope k<1, it can be determined that the angle of the portrait image is 0° or 180°, and the original portrait image is placed horizontally.
[0129] Step 502, according to the angle of the original portrait image, respectively calculate the distances between the key point coordinates and the upper and lower boundaries of the original portrait image, or the distances between the key point coordinates and the left and right boundaries of the original portrait image.
[0130] In this step, the eye coordinates in the original portrait image are taken as the key point coordinates. According to the different angles of the original portrait image, the distance between the eye coordinates of the face in the original portrait image and the upper and lower sides of the original portrait image is calculated respectively, and this distance is called the first distance; or the distance between the eye coordinates of the face and the left and right sides of the original portrait image is called the second distance. Specifically, when the angle of the original portrait image is 0° or 180°, that is, the original portrait image is located in the horizontal positive direction or the horizontal reverse direction, the following formula is used to calculate the distance between the eye coordinates and the upper and lower sides of the original portrait image:
[0131] dis1=abs(y 5 -min(y 1 ,y 2))+abs(y 6 -(min(y 1 ,y 2 ));
[0132] dis2=abs(y 5 -max(y 3 ,y 4 ))+abs(y 6 -max(y 3 ,y 4 )); where dis1 represents the distance between the vertical coordinates of both eyes and the upper side of the original portrait image, dis2 represents the distance between the vertical coordinates of both eyes and the lower side of the original portrait image, and y 5 and 6 Respectively represent the ordinates of the two key points, y 1 ,y 2 and 3 ,y 4 Respectively represent the vertical coordinates of the four corners of the original portrait image.
[0133] When the angle of the original portrait image is 90° or 270°, the following formula is used to calculate the relative distances between the coordinates of the two eyes and the left and right sides of the original portrait image.
[0134] dis3=abs(x 5 -min(x 1 ,x 2 ))+abs(y 6 -(min(x 1 ,y 2 ));
[0135] dis4=abs(x 5 -max(x 3 ,x 4 ))+abs(y 6 -max(x 3 ,x 4 ));
[0136] Among them, dis3 represents the distance between the binocular coordinates and the left side of the original portrait image, dis4 represents the distance between the binocular coordinates and the right side of the original portrait image, and x 5 and x 6 Respectively represent the horizontal coordinates of the two key points, x 1 ,x 2 and x 3 ,x 4 Represent the horizontal coordinates of the four corners of the original portrait image.
[0137] Step 503, determining the second desensitization area according to the distances between the key point coordinates and the upper and lower boundaries of the original portrait image, or the distances between the key point coordinates and the left and right boundaries of the original portrait image.
[0138] According to step 502, when it is determined that the portrait is 0° or 180°, the original portrait image is in the horizontal direction, and the distances between the eye coordinates and the upper and lower sides of the original portrait image are calculated respectively. For example, the distance between the eye coordinates and the upper side of the original portrait image is recorded as the first distance dis1, and the distance between the eye coordinates and the lower side of the original portrait image is recorded as the second distance dis2. If the first distance is less than the second distance, it means that the portrait is 0° and the original portrait image is in a horizontal position. In this case, the portrait desensitization area is the upper half of the original portrait image, specifically: the part from the eyes of the face to the upper boundary of the original portrait image.
[0139] If the first distance dis1 is greater than the second distance dis2, it means that the portrait is 180° and the original portrait image is in an inverted horizontal position. In this case, the portrait desensitization area is the lower half of the original portrait image, specifically: the part from the eyes of the face down to the lower boundary of the original portrait image.
[0140] According to step 502, when it is determined that the portrait is 90° or 270°, the original portrait image is in a vertical direction, and the distances between the horizontal coordinates of both eyes and the left and right sides of the original portrait image are calculated respectively. For example, the distance between the horizontal coordinates of both eyes and the left side of the original portrait image is recorded as the third distance dis3, and the distance between the horizontal coordinates of both eyes and the right side of the original portrait image is recorded as the fourth distance dis4. If the third distance is less than the fourth distance, it means that the portrait is 90° and the portrait figure is in a vertical positive position. In this case, the portrait desensitization area is the left half of the original portrait image, specifically: the part from the left side of the human face to the left edge of the original portrait image.
[0141] If the third distance dis3 is greater than the fourth distance dis4, it means that the original portrait image is 270° and the original portrait image is in a vertical reverse position. In this case, the portrait desensitization area is the right half of the portrait image, specifically: the part from the right side of the face and eyes to the right of the original portrait image.
[0142] Figure 6 The above is a flow chart of a method for coding the second desensitized area according to an embodiment of this specification. In this specification, in the process of desensitizing the original portrait image, desensitization is mainly achieved by coding the area where the human eyes are located. Among them, it is necessary to dynamically calculate the density of the portrait mosaic according to the size of the portrait area to prevent invalid coding caused by too dense mosaics when the image resolution is high. Specifically, the following steps are included:
[0143] Step 601, determining the size of the second desensitization area according to the coordinates of the diagonal points of the second desensitization area.
[0144] In the embodiment of this specification, according to the coordinates of two points of the second desensitized area (i.e., the portrait area to be coded) obtained in the aforementioned portrait detection, the coordinates of the two points are: the coordinates of the point at the upper left corner of the second desensitized area, and the coordinates of the point at the lower right corner of the second desensitized area. According to the coordinates of these two points, the width and height of the second desensitized area are calculated, and the width is recorded as w, and the height is recorded as h.
[0145] Step 602: Slice the second desensitized area and downsample the sliced image.
[0146] This step cuts the second desensitized image according to the coordinates of the upper left corner and the lower right corner of the second desensitized area to obtain image slices of the second desensitized area. The image slices are downsampled in the horizontal and vertical directions with the specifications of w / / 10 and h / / 10 to achieve coding.
[0147] Step 603: Expand the downsampled image to the size of the second desensitized area.
[0148] This step copies and expands the downsampled image at the same ratio as in step 602, and adjusts it to the size of the second desensitized area (width is w, height is h), thereby completing the coding of the second desensitized area of the portrait image.
[0149] In terms of portrait image desensitization, this manual does not require preset masking areas. It can partially or completely replace designated sensitive information according to specific desensitization requirements, realize end-to-end automatic generation of desensitized images, and improve the availability of desensitized data.
[0150] Figure 7 The flowchart of a method for determining a second slice sample set and a seal fusion sample image set according to an embodiment of the present specification is shown.
[0151] Step 701, according to the seal text, the preset seal template, and the preset seal size, determine the sample seal synthesis parameters and synthesize the sample seal image on the blank base plate. In this step, in order to generate the seal sample image for training the seal erasure model, it is necessary to prepare the seal template, seal text corpus and seal size required for generating the seal sample image, wherein the seal text corpus required for generating the seal sample image includes but is not limited to: name, company name, seal type (for example, financial seal, business seal, etc.), seal anti-counterfeiting code, etc.
[0152] The seal template required for generating the seal sample image includes but is not limited to: seal shape (e.g., circle, ellipse, rectangle, square), text position in the seal sample image, non-seal text content in the seal sample image, etc. The text position in the seal sample image may be: text surrounding the seal sample, text covering the seal sample and covering part of the seal sample, text below the seal sample and partially covered by the seal, etc., or other situations. The non-seal text content in the seal sample image may be random text, or real text excerpts, semantic entities, etc.
[0153] According to the seal template, the preset seal size and seal text, various seal synthesis parameters are further determined. The seal synthesis parameters include but are not limited to: seal color, text position, text size, text spacing, text curvature, etc. After determining the sample seal synthesis parameters, the above seal synthesis parameters are used on a blank base plate to synthesize a sample seal image.
[0154] Step 702 : According to the longest side of the sample seal image, the preset document image is cropped to obtain slices of the preset document image, and multiple slices of the preset document image constitute a second slice sample set.
[0155] In this step, the preset document image refers to an image with text or background information but without all seal features. Specifically, the preset text image can be: an image with text or background information and a partial seal image; or an image with text or background information and without any seal features.
[0156] In the embodiment of the present specification, before generating the seal fusion sample image, the sample seal image may be processed, including: image rotation, grayscale, binarization, edge blur, partial loss, gradient and other effects. The longest side of the sample seal image after image processing is determined, and the longest side is recorded as w. A square slice with a side length of w is cut out at an arbitrary position in the preset document image, and the cut square slice is recorded as a second slice sample. The slices of multiple preset document images constitute a second slice sample set.
[0157] Step 703 , synthesizing the sample seal image into a slice of a preset document image to generate a seal fusion sample image. A plurality of seal fusion sample images constitute a seal fusion sample image set.
[0158] In this step, the sample seal image is synthesized into the slice of the preset document image (the second slice sample) by pixel fusion. There may be a situation where the sample seal is partially blocked by the document, or the text is partially blocked by the sample seal. When randomly selecting the position of the synthesized seal, a certain proportion of the overlapping seal positions is added to generate the following Fig.11A Stamp fusion sample images shown.
[0159] In this step, the second slice samples of the preset document image after size processing are resized to 512, and multiple second slice samples are used as a second slice sample set. Multiple seal fusion sample images are proportionally resized to 512 to form a seal fusion sample image set.
[0160] Figure 8 The flowchart of a method for training a seal erasure model according to an embodiment of the present specification is shown, which specifically includes the following steps:
[0161] Step 801, obtaining a second sample slice set and seal slice features, inputting the second sample slice set into a conditional generation model, and obtaining an image output by the conditional generation model.
[0162] In this step, a sample data set for training the conditional generation model is obtained, wherein the sample data set includes a second slice sample set and a seal slice feature corresponding to each second slice sample in the second slice sample set. As mentioned above, the second slice sample set is a plurality of seal fusion sample images, and each second slice sample set has a corresponding seal slice feature.
[0163] Specifically, whenever the second slice sample is input to the conditional generation model, the conditional generation model outputs a corresponding image, in which the seal in the second slice sample set is cleared.
[0164] Step 802, calculating the loss value between the image output by the conditional generation model and the second slice sample set, iteratively updating the conditional generation model based on the loss value, and obtaining the seal erasure model.
[0165] In this step, the loss value between the image output by the conditional generation model and the second slice sample in step 702 is calculated, and the conditional generation model is further iteratively updated according to the loss value until the loss value converges to a preset threshold, and the model training is determined to be completed, and the seal erasure model is constructed; or when the number of iterations of the conditional generation model reaches a preset value, the model training is determined to be completed, and the seal erasure model is obtained.
[0166] like Fig. 9 The figure shows a schematic diagram of the structure of an unstructured data desensitization processing device according to an embodiment of the present specification. The figure describes the basic structure of the unstructured data desensitization processing device, wherein the functional units and modules can be implemented in software, or a general chip or a specific chip can be used to implement the unstructured data desensitization processing. The device specifically includes:
[0167] A first desensitized region generating unit 901 is used to use a text erasure model to erase sensitive text information in a text slice image and generate a first desensitized region in an original text image, wherein the text erasure model is obtained by generating a model based on a first slice sample set and a text slice sample set training condition, and the text slice image is obtained by identifying sensitive entities in the original text image;
[0168] A second desensitized area generating unit 902 is used to use a portrait detection model to identify key point coordinates in the original portrait image, and determine a second desensitized area in the original portrait image based on the key point coordinates, wherein the portrait detection model is obtained by training a portrait detection basic model according to a sample portrait image and key point coordinate features in the sample portrait image;
[0169] The third desensitized area generating unit 903 is used to use the seal erasing model to erase the key data in the seal slice image and generate the third desensitized area in the original seal image, wherein the seal erasing model is obtained by training the conditional generation model of the second slice sample set and the seal fusion sample image set, and the seal slice image is obtained by identifying the seal in the original seal image;
[0170] The writing-back unit 904 is used to write the first desensitized area back to the original text image, write the second desensitized area back to the original portrait image, and write the third desensitized area back to the original seal image to obtain a desensitized image.
[0171] Fig. 10A The figure shows a schematic diagram of a text slice sample set of an embodiment of the present specification. The text slice sample set is composed of multiple or more sample text slices. The text slice sample set can be understood as: multiple sample text slices are arranged in sequence in a vertical arrangement in a large blank image, and each sample text slice has text and a background color or shading. The font, font size, font color, and number of words in each sample text slice are different.
[0172] Fig. 10B The first slice sample set is a schematic diagram of an embodiment of the present specification. The first slice sample set is composed of multiple or multiple sample base plate slice images. The first slice sample set can be understood as: multiple sample base plate images are arranged in sequence in a vertical arrangement in a large blank image, and each sample base plate image has no text, only background color or shading.
[0173] Fig.11A Shown is a schematic diagram of a seal fusion sample image set according to an embodiment of the present specification, in which the sample seals are synthesized into a slice of a preset document image by pixel fusion, and when the position of the synthesized seal is randomly selected, a certain proportion of overlapping seal positions are added to generate the seal fusion sample image shown in the figure.
[0174] Fig. 11B The figure shows a schematic diagram of a second sample slice set of an embodiment of the present specification. According to the longest side w of the seal image, a square slice with a side length of w is cut out at an arbitrary position in the preset document image, and the cut square slice is recorded as the second slice sample. There is no seal feature in the second slice sample, only text.
[0175] Fig.12 The following is a schematic diagram of a seal cross desensitization method according to an embodiment of this specification. The seal position in the seal image is identified using a detection model based on CenterNet, and the middle 1 / 2 area in the horizontal and vertical directions of the original seal image is further delineated according to the seal position as the area to be removed of sensitive information, and 4 seal slice images to be processed are obtained, which are specifically the shaded parts in the figure.
[0176] Fig.13 This is a schematic diagram of identifying the coordinates of key points of a portrait according to an embodiment of this specification. The key point coordinates of the original portrait image are predicted using a portrait detection model to obtain the key point coordinates shown in the figure, including the coordinates of the left eye, right eye, nose tip, right corner of the mouth, and left corner of the mouth. In the process of desensitizing the original portrait image, desensitization is mainly achieved by coding the area where the eyes are located.
[0177] Fig.14 The figure shows a schematic diagram of desensitizing and writing back text in an embodiment of this specification. The text in the figure is the name of a person in an ID card. First, the text of the sensitive entity type that needs to be desensitized is screened out, and the coordinates of the sensitive entity text are calculated based on its index information. The desensitization rule is to retain at most the first 1 / 3 and the last 1 / 3 of the sensitive entity text (rounded down), and replace the middle with an asterisk, thereby obtaining the desensitized text shown in the figure.
[0178] like Fig.15Shown is a schematic diagram of a computer device provided by an embodiment of this specification. The unstructured data desensitization processing method described in this application can be applied to the computer device. The computer device 1502 may include one or more processors 1504, such as one or more central processing units (CPUs), and each processing unit may implement one or more hardware threads. The computer device 1502 may also include any memory 1506, which is used to store any kind of information such as code, settings, data, etc. Non-restrictive, for example, the memory 1506 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 can use any technology to store information. Further, any memory can provide volatile or non-volatile retention of information. Further, any memory can represent a fixed or removable component of the computer device 1502. In one case, when the processor 1504 executes an associated instruction stored in any memory or a combination of memories, the computer device 1502 can perform any operation of the associated instruction. The computer device 1502 also includes one or more drive mechanisms 1508 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.
[0179] The computer device 1502 may also include an input / output module 1510 (I / O) for receiving various inputs (via input devices 1512) and for providing various outputs (via output devices 1514). A specific output mechanism may include a presentation device 1516 and an associated graphical user interface (GUI) 1518. In other embodiments, the input / output module 1510 (I / O), input device 1512, and output device 1514 may not be included, and the computer device 1502 may be used as a computer device in a network. The computer device 1502 may also include one or more network interfaces 1520 for exchanging data with other devices via one or more communication links 1522. One or more communication buses 1524 couple the components described above together.
[0180] The communication link 1522 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 1522 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.
[0181] Corresponds to Figures 1 to 8 The method in the embodiment of the present specification also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are executed.
[0182] The embodiment of the present specification also provides a computer-readable instruction, wherein when the processor executes the instruction, the program therein causes the processor to execute the following Figures 1 to 8 The method shown.
[0183] The present specification also provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the following is achieved: Figures 1 to 8 The method shown.
[0184] It should be understood that in the various embodiments of this specification, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this specification.
[0185] 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 specification generally indicates that the associated objects before and after are in an "or" relationship.
[0186] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this specification.
[0187] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0188] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0189] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of this specification.
[0190] In addition, each functional unit in each embodiment of this specification may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0191] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this specification is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of this specification. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0192] Specific embodiments are used in this specification to illustrate the principles and implementation methods of this specification. The description of the above embodiments is only used to help understand the methods and core ideas of this specification. At the same time, for those skilled in the art, according to the ideas of this specification, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this specification.
Claims
1. A method for desensitizing unstructured data, characterized in that: The method comprises: Using a text erasure model, erasing sensitive text information in a text slice image, and generating a first desensitized area in the original text image, wherein the text erasure model is obtained by generating a model through a first slice sample set and a text slice sample set training condition, and the text slice image is obtained by identifying sensitive entities in the original text image; Using a portrait detection model, identifying key point coordinates in the original portrait image, and determining a second desensitized area in the original portrait image based on the key point coordinates, wherein the portrait detection model is obtained by training a portrait detection basic model according to the sample portrait image and key point coordinate features in the sample portrait image; Use a seal erasing model to erase key data in the seal slice image and generate a third desensitized area in the original seal image, wherein the seal erasing model is obtained by training a conditional generation model using a second slice sample set and a seal fusion sample image set, and the seal slice image is obtained by identifying a seal in the original seal image; The first desensitized area is written back to the original text image, the second desensitized area is written back to the original portrait image, and the third desensitized area is written back to the original seal image to obtain a desensitized image.
2. The method according to claim 1, characterized in that The first slice sample set and the text slice sample set are determined in the following manner: Randomly selecting a plurality of sample baseboard images and a plurality of sample texts, wherein the plurality of sample texts have different fonts, font sizes and word counts; Generate a sample bottom plate slice image without text according to the font, font size, word count of the sample text and the sample bottom plate image, wherein the plurality of sample bottom plate slice images constitute a first slice sample set; Each type of sample text is written into the corresponding sample base plate slice map to generate multiple sample text slices, and the multiple sample text slices constitute a text slice sample set.
3. The method according to claim 2, characterized in that The text erasure model is trained in the following way: Acquire a first slice sample set and a text slice sample set, input the text slice sample set into a conditional generation model, and obtain an image output by the conditional generation model; Calculate the loss value of the image output by the conditional generation model and the first slice sample set, iteratively update the conditional generation model based on the loss value, and obtain the text erasure model.
4. The method according to claim 2, characterized in that: The first slice sample set composed of a plurality of sample bottom plate slice images includes: Writing all sample bottom plate slice images into the first initial blank image in a longitudinal arrangement; Compare the length of the longest sample bottom plate slice image in the first initial blank image with the sum of the heights of all sample bottom plate slice images arranged vertically, and determine the larger value; Taking the larger value as the side length of the first initial blank image, constructing a first slice sample set; A text slice sample set composed of multiple sample text slices includes: Writing all sample text slices into the second initial blank image in a vertical arrangement; Compare the length of the longest sample text slice in the second initial blank image with the sum of the heights of all sample text slices arranged vertically, and determine the larger value; The larger value is used as the side length of the second initial blank image to construct a text slice sample set.
5. The method according to claim 1, characterized in that The portrait detection model is trained in the following ways: Obtaining sample portrait images and key point coordinate features in the sample portrait images; Inputting the sample portrait image into a portrait detection basic model to obtain the portrait key point coordinates output by the portrait detection basic model; The loss values of the portrait key point coordinates and the key point coordinate features in the sample portrait image are calculated, and the portrait detection basic model is iteratively updated based on the loss values to obtain the portrait detection model.
6. The method according to claim 5, characterized in that Determining the second desensitization area in the original portrait image based on the key point coordinates includes: According to the slope between the key point coordinates, determine the angle of the original portrait image; According to the angle of the original portrait image, the distances between the key point coordinates and the upper and lower boundaries of the original portrait image, or the distances between the key point coordinates and the left and right boundaries of the original portrait image are calculated respectively; The second desensitization area is determined according to the distance between the key point coordinates and the upper and lower boundaries of the original portrait image, or the distance between the key point coordinates and the left and right boundaries of the original portrait image.
7. The method according to claim 6, characterized in that The distance between the key point coordinates and the upper and lower boundaries of the original portrait image, or the distance between the key point coordinates and the left and right boundaries of the original portrait image is calculated using the following formula: dis1=abs(y5-min(y1,y2))+abs(y6-(min(y1,y2)); dis2 = abs(y5-max(y3,y4))+abs(y6-max(y3,y4)); where dis1 represents the distance between the vertical coordinates of both eyes and the upper edge of the original portrait image, dis2 represents the distance between the vertical coordinates of both eyes and the lower edge of the original portrait image, y5 and y6 represent the vertical coordinates of the two key points, y1, y2 and y3, y4 represent the vertical coordinates of the four corners of the original portrait image; dis3=abs(x5-min(x1,x2))+abs(y6-(min(x1,y2)); dis4=abs(x5-max(x3,x4))+abs(y6-max(x3,x4)); wherein dis3 represents the distance between the coordinates of both eyes and the left side of the original portrait image, dis4 represents the distance between the coordinates of both eyes and the right side of the original portrait image, x5 and x6 represent the horizontal coordinates of the coordinates of the two key points respectively, and x1, x2 and x3, x4 represent the horizontal coordinates of the four corners of the original portrait image respectively.
8. The method according to claim 7, characterized in that Before writing the second desensitized area back to the original portrait image, the method further includes: Determine the size of the second desensitization area according to the coordinates of the diagonal points of the second desensitization area; Slicing the second desensitized area, and downsampling the sliced image; The downsampled image is expanded to the size of the second desensitized area.
9. The method according to claim 1, characterized in that: The second slice sample set and the seal fusion sample image set are determined in the following manner: Determine sample seal synthesis parameters and synthesize the sample seal image on a blank base plate according to the seal text, the preset seal template, and the preset seal size; According to the longest side of the sample seal image, the preset document image is cropped to obtain slices of the preset document image, and the slices of the plurality of preset document images constitute a second slice sample set; The sample seal image is synthesized into a slice of a preset document image to generate a seal fusion sample image, and a plurality of seal fusion sample images constitute a seal fusion sample image set.
10. The method according to claim 9, characterized in that The stamp erasure model is trained in the following way: Acquire a second sample slice set and seal slice features, input the second sample slice set into a conditional generation model, and obtain an image output by the conditional generation model; The loss value between the image output by the conditional generation model and the second slice sample set is calculated, and the conditional generation model is iteratively updated based on the loss value to obtain the seal erasure model.
11. A device for desensitizing unstructured data, characterized in that: The device comprises: A first desensitized area generating unit is used to use a text erasure model to erase sensitive text information in a text slice image to generate a first desensitized area in an original text image, wherein the text erasure model is obtained by generating a model based on a first slice sample set and a text slice sample set training condition, and the text slice image is obtained by identifying sensitive entities in the original text image; A second desensitized area generating unit is used to use a portrait detection model to identify key point coordinates in the original portrait image, and determine a second desensitized area in the original portrait image based on the key point coordinates, wherein the portrait detection model is obtained by training a portrait detection basic model according to a sample portrait image and key point coordinate features in the sample portrait image; A third desensitized area generating unit is used to use a seal erasure model to erase key data in the seal slice image to generate a third desensitized area in the original seal image, wherein the seal erasure model is obtained by training a conditional generation model using a second slice sample set and a seal fusion sample image set, and the seal slice image is obtained by identifying a seal in the original seal image; The writing-back unit is used to write the first desensitized area back to the original text image, write the second desensitized area back to the original portrait image, and write the third desensitized area back to the original seal image to obtain the desensitized image.
12. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 10 is implemented.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
14. 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 method according to any one of claims 1 to 10 is implemented.