Face region anonymization method based on reversible neural network and diffusion model
By employing a face region anonymization method based on reversible neural networks and diffusion models, the problem of incompatibility between privacy protection and editing needs in existing technologies is solved. This method achieves privacy protection and reversible restoration during image transmission and model processing, and supports diverse editing operations.
Patent Information
- Application Number
- CN202611085620.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-21
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies struggle to ensure visual naturalness while simultaneously maintaining the reversibility, controllability, and semantic consistency of facial images, making it difficult to reconcile privacy protection with editing needs.
A face region anonymization method based on reversible neural networks and diffusion models is adopted. Through face detection, reversible encryption, generative model editing and boundary fusion processing, the face region is anonymized and reversibly restored.
It achieves privacy protection during image transmission and model processing, maintains the semantic structure and texture continuity of images, supports diverse editing operations, and can reversibly restore the original facial features.
Smart Images

Figure CN123181601A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and privacy protection technology, and in particular to a method for anonymizing facial regions based on reversible neural networks and diffusion models. Background Technology
[0002] With the rapid development of generative artificial intelligence in fields such as image editing, virtual human creation, and medical image processing, large-scale diffusion models are widely used for semantically driven local image modification. However, these models typically require access to the complete content of the original image. In public model inference or cloud inference scenarios, facial features, as highly sensitive biometric information, are extremely prone to privacy leaks and identity abuse.
[0003] Existing facial privacy protection technologies have significant limitations: blurring and pixel substitution methods severely degrade image quality, rendering the images unusable for subsequent tasks; feature perturbation and encryption methods are mostly irreversible and affect the interpretability of downstream tasks; GAN-based anonymization methods suffer from training instability, artifact generation, insufficient local control finesse, and the generated results are difficult to reversibly recover; image inpainting and reconstruction methods based on diffusion models lack integration with reversible encryption mechanisms, making controlled recovery of anonymized regions impossible. Overall, existing technologies struggle to simultaneously ensure visual naturalness while maintaining reversibility, controllability, and semantic consistency, representing a key challenge currently facing the field. Summary of the Invention
[0004] This invention provides a face region anonymization method based on reversible neural networks and diffusion models, which achieves an organic unity of privacy protection, editability, and reversible restoration, and solves the problems of image distortion, irreversibility, and incompatibility between privacy protection and editing requirements in existing technologies.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: Face region anonymization methods based on reversible neural networks and diffusion models include: (1) Face detection and region extraction: The FaceNet face recognition algorithm is used to detect the face position in the input image, obtain the coordinate information of the face bounding box, and crop the face sub-image containing complete facial features from the original image according to the coordinate information; (2) Noise addition and reversible encryption of face: A noise matrix with the same shape as the face sub-image is generated based on Gaussian distribution. The noise matrix and the face sub-image are superimposed at the pixel level through a reversible neural network INN to obtain a noisy encrypted face image. The face encrypted image is used to replace the corresponding face region in the original image to obtain the overall encrypted image. (3) Generative model editing: The overall encrypted image is input into the Stable Diffusion model, and combined with the natural language text instructions provided by the user, the overall encrypted image is subjected to semantic-level local reconstruction and generative editing to obtain the edited image; (4) Face Denoising and Restoration: The noise matrix used in the encryption stage is called to perform inverse noise reduction operation on the face region in the edited image to obtain a preliminary decrypted face image; (5) Boundary fusion and result output: The non-face regions of the preliminary decrypted face image and the original image are subjected to boundary fusion processing to obtain the final anonymized image. The final anonymized image maintains the editing effect corresponding to the text instructions and does not disclose the original face identity information.
[0006] In this specification, the reversible neural network INN adopts the RealNVP structure, which contains 4 Affine Coupling Layers. The mapping of each Affine Coupling Layer is implemented through a three-layer convolutional network. The number of channels of the three-layer convolutional network is 32-32-3, the kernel size is 3×3, and the reverse mapping is explicitly solvable.
[0007] In this specification, when generating the noise matrix in step (2), noise data is generated independently for the three RGB channels of the image. The noise data of each channel satisfies the Gaussian distribution characteristics, ensuring that the noise disturbance to the face sub-image achieves visual identity hiding without destroying the semantic structure of the image.
[0008] In this specification, before editing the generative model in step (3), the overall encrypted image is mapped to a low-dimensional latent space by a variational autoencoder (VAE), so that the noise pattern corresponding to the face encrypted image is compressed into a low-frequency perturbation in the latent space, while preserving the contour, position and local semantic information related to illumination of the face.
[0009] In this specification, the generative model editing in step (3) adopts a dual-condition fusion mechanism, which weights and fuses the latent space encoding of the overall encrypted image with the text embedding obtained by the CLIP text encoder. The weight of the text embedding is higher than that of the latent space encoding, ensuring that the editing semantics take precedence over the encryption noise.
[0010] In this specification, when editing the generative model in step (3), an attention region reweighting mechanism is introduced. A soft-mask attention map is constructed based on the face bounding box. The attention map assigns attention weights according to the distance from the pixel to the center of the face box, so that the diffusion model maintains high attention in non-face areas to preserve background details, and weakens high-frequency attention and retains low-frequency structural attention in face encryption areas.
[0011] In this specification, after obtaining the preliminary decrypted face image in step (4), a local smoothing compensation mechanism is introduced to perform weighted fusion of the face region in the preliminary decrypted face image and the edited image, so as to balance the authenticity of the decrypted face and the consistency of the editing effect, and avoid excessive restoration that introduces image artifacts.
[0012] In this specification, the boundary fusion process in step (5) includes two steps: Poisson fusion and Gaussian feathering Alpha blending. First, the gradient information in the face region is maintained by Poisson fusion so that the boundary of the face region is strictly consistent with the target image. Then, a soft mask after Gaussian smoothing is generated based on the binary face mask. The soft transition between the face region and the background is achieved by pixel-by-pixel Alpha blending to eliminate stitching marks.
[0013] In this specification, when generating the noise matrix in step (2), the strength of the noise disturbance is adjusted by the noise intensity control parameter so that the face encryption image cannot be visually identified as a specific person, while ensuring that the semantic structure of the overall encryption image can be recognized by the diffusion model.
[0014] In this specification, the weighting coefficient of the initially decrypted face image is higher than the weighting coefficient of the face region in the edited image. This coefficient allocation ensures that the restored face features are highly consistent with the original face pixel distribution, while also being compatible with reasonable semantic modifications brought about by generative editing.
[0015] In summary, the present invention has at least the following beneficial effects: By adding noise and encrypting the facial area on the user's end, the image is in a "disguised" state during network transmission and model processing. No third party can recover the original facial features from the encrypted image, thus effectively preventing the leakage or misuse of user identity information.
[0016] Unlike traditional encryption or obfuscation methods, the noisy images of this invention still maintain complete semantic structure and texture continuity, thus allowing them to be normally recognized and edited by generative models based on the diffusion process. The model can perform diverse operations on the noisy images, such as background replacement, facial expression modification, and eye magnification, without affecting the model's input understanding and generation results, achieving "privacy encryption without affecting editability."
[0017] The noise-adding encryption mechanism employed in this invention is a linear reversible mapping. After the editing result is returned, the system can use the recorded noise matrix to perform a precise inverse transformation, restoring the true appearance of the edited face region. Unlike traditional image encryption or anonymization methods, this invention does not destroy the original pixel distribution and does not introduce information loss, achieving "lossless conversion between encryption and restoration". Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a schematic diagram of the face region anonymization method based on reversible neural networks and diffusion models involved in this invention. Detailed Implementation
[0020] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of the embodiments of the invention. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.
[0021] The following disclosure provides many different implementations or examples for carrying out different structures of the embodiments of the present invention. To simplify the disclosure of the embodiments of the present invention, specific examples of components and arrangements are described below. Of course, these are merely examples and are not intended to limit the embodiments of the present invention. Furthermore, reference numerals and / or reference letters may be repeated in different examples of the embodiments of the present invention; such repetition is for simplification and clarity and does not in itself indicate a relationship between the various implementations and / or arrangements discussed.
[0022] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0023] like Figure 1 As shown, this embodiment provides a face region anonymization method based on a reversible neural network and a diffusion model, including: (1) Face detection and region extraction: The FaceNet face recognition algorithm is used to detect the face position in the input image, obtain the coordinate information of the face bounding box, and crop the face sub-image containing complete facial features from the original image according to the coordinate information; (2) Noise addition and reversible encryption of face: A noise matrix with the same shape as the face sub-image is generated based on Gaussian distribution. The noise matrix and the face sub-image are superimposed at the pixel level through a reversible neural network INN to obtain a noisy encrypted face image. The face encrypted image is used to replace the corresponding face region in the original image to obtain the overall encrypted image. (3) Generative model editing: The overall encrypted image is input into the Stable Diffusion model, and combined with the natural language text instructions provided by the user, the overall encrypted image is subjected to semantic-level local reconstruction and generative editing to obtain the edited image; (4) Face Denoising and Restoration: The noise matrix used in the encryption stage is called to perform inverse noise reduction operation on the face region in the edited image to obtain a preliminary decrypted face image; (5) Boundary fusion and result output: The non-face regions of the preliminary decrypted face image and the original image are subjected to boundary fusion processing to obtain the final anonymized image. The final anonymized image maintains the editing effect corresponding to the text instructions and does not disclose the original face identity information.
[0024] In some embodiments, the reversible neural network INN adopts a RealNVP structure, which includes four Affine Coupling Layers. The mapping of each Affine Coupling Layer is achieved through a three-layer convolutional network with 32-32-3 channels and a kernel size of 3×3. The reverse mapping is explicitly solvable.
[0025] In some embodiments, when generating the noise matrix in step (2), noise data is generated independently for the three RGB channels of the image. The noise data of each channel satisfies the Gaussian distribution characteristics, ensuring that the noise perturbation of the face sub-image achieves visual identity hiding without destroying the semantic structure of the image.
[0026] In some embodiments, before generative model editing in step (3), the overall encrypted image is mapped to a low-dimensional latent space by a variational autoencoder (VAE), so that the noise pattern corresponding to the face encrypted image is compressed into a low-frequency perturbation in the latent space, preserving the contour, position and local semantic information related to illumination of the face.
[0027] In some embodiments, the generative model editing in step (3) adopts a dual-condition fusion mechanism, which weights and fuses the latent space encoding of the overall encrypted image with the text embedding obtained by the CLIP text encoder, wherein the weight of the text embedding is higher than the weight of the latent space encoding, ensuring that the editing semantics take precedence over the encryption noise.
[0028] In some embodiments, during generative model editing in step (3), an attention region reweighting mechanism is introduced to construct a soft-mask attention map based on the face bounding box. The attention map assigns attention weights according to the distance from the pixel to the center of the face box, so that the diffusion model maintains high attention in non-face areas to preserve background details, while weakening high-frequency attention and preserving low-frequency structural attention in face encryption areas.
[0029] In some embodiments, after obtaining the initially decrypted face image in step (4), a local smoothing compensation mechanism is introduced to perform weighted fusion of the face region in the initially decrypted face image and the edited image, so as to balance the authenticity of the decrypted face and the consistency of the editing effect, and avoid excessive restoration that introduces image artifacts.
[0030] In some embodiments, the boundary fusion process in step (5) includes two steps: Poisson fusion and Gaussian feathering Alpha blending. First, the gradient information in the face region is maintained by Poisson fusion so that the boundary of the face region is strictly consistent with the target image. Then, a soft mask after Gaussian smoothing is generated based on the binary face mask. The soft transition between the face region and the background is achieved by pixel-by-pixel Alpha blending to eliminate stitching marks.
[0031] In some embodiments, when generating the noise matrix in step (2), the strength of the noise disturbance is adjusted by the noise intensity control parameter so that the face encryption image cannot be visually identified as a specific person, while ensuring that the overall encryption image can be recognized by the diffusion model in terms of semantic structure.
[0032] In some embodiments, the local smoothing compensation mechanism uses a weighting coefficient that is higher for the face region of the initially decrypted image than for the edited image. This coefficient allocation ensures that the restored face features are highly consistent with the original face pixel distribution, while also being compatible with reasonable semantic modifications brought about by generative editing.
[0033] The technical concept of this invention is as follows: This invention proposes a face anonymization scheme that integrates reversible encryption and a generative diffusion model. The core process is as follows: First, the face region in the image is automatically detected and extracted using a face recognition algorithm; then, the face region is reversibly annoyed and encrypted using a reversible neural network (INN), causing visual distortion of the face while preserving its semantic structure; next, the encrypted image is input into a Stable Diffusion model, and semantically consistent generative editing is completed in conjunction with user text commands; finally, the face region is restored by denoising through the inverse transform corresponding to the encryption stage, and seamless integration of the face and background is achieved through boundary fusion processing.
[0034] Technical effects: Privacy and security protection: By adding noise and encrypting the face region on the user's end, the image is anonymized during network transmission and model processing, effectively avoiding the leakage of original facial features and preventing the misuse of identity information.
[0035] Improved editing compatibility: The encrypted image retains its complete semantic structure and texture continuity, and can be normally recognized by generative models. It supports diverse semantic editing operations such as background replacement, expression modification, and local feature adjustment, without affecting the model's understanding of image content and generation effect.
[0036] Reversible lossless restoration: It adopts a linear reversible mapping noise encryption mechanism. After editing, the core features of the original face can be accurately restored through the corresponding inverse transformation without destroying the original pixel distribution or introducing information loss. At the same time, the visual naturalness of the restored image is ensured through boundary fusion processing.
[0037] The technical process of this invention mainly includes the following steps: 1. Face detection and region extraction: The FaceNet face recognition algorithm is used to automatically detect the face position in the input image and extract the boundary coordinates of the facial region.
[0038] 2. Face noise addition and reversible encryption: For the extracted face region, a noise matrix is randomly generated based on Gaussian distribution and superimposed on the original pixels to achieve reversible noise addition of INN, so that the face is visually distorted but can be recovered in subsequent stages.
[0039] 3. Generative Model Editing: The noisy image is input into the Stable Diffusion model, and semantic layer reconstruction and generative editing of the image are performed in combination with user-provided text instructions.
[0040] 4. Face Denoising and Reconstruction: After the editing result is generated, the face region is subjected to the reverse denoising operation corresponding to the encryption stage to restore the original identity-related pixel features, while keeping the editing effect effective in non-face regions.
[0041] 5. Output and Result Saving: The system finally outputs a three-stage result image, including an encrypted image, an edited image, and a restored image. The final result achieves an image that maintains the semantic modification effect without leaking identity privacy.
[0042] Face recognition: In this invention's system, FaceNet is used for automatic face detection and region localization in the input image. The system detects the bounding box coordinates (top, right, bottom, left) of the face by calling the model, and then crops out the region containing complete facial features from the original image. This process is the first step in the entire system, ensuring that subsequent noise addition, diffusion model editing, and denoising restoration only affect the face-related regions and do not affect the global semantic content of the image.
[0043] FaceNet is a high-precision face recognition algorithm based on deep convolutional neural networks. The core idea of this algorithm is to map face images into a low-dimensional Euclidean space, such that the distance between face images of the same person is small, while the distance between face images of different people is large. FaceNet achieves this feature space separability by training a triplet loss function. Specifically, FaceNet uses an input triplet (Anchor, Positive, Negative), that is, two face images of the same person (Anchor and Positive) and a face image of a different person (Negative), and optimizes the network parameters by minimizing the following loss function: ; Where f(x) represents the feature vector extracted by the network. This is a boundary constant. After being trained on large-scale data, FaceNet achieves extremely high robustness and accuracy in face detection and feature embedding.
[0044] Face noise reduction: This invention employs a RealNVP structure with reversible coupling layers, comprising four Affine CouplingLayers. The mapping for each layer is as follows: ; ; Where s and t are three-layer convolutional networks (32-32-3 channels, 3x3 kernels), and the inverse mapping is explicitly solvable. To achieve reversible noise addition, the INN of this invention adopts the following method: 1. Gaussian noise N is used as the conditional input for INN: ; 2. Use the same N to fully recover the data during decryption: ; This invention uses an INN module to ensure the reversibility of bijective mapping, and N, as a local perturbation, makes it more difficult to reverse-engineer the encrypted face portion.
[0045] This invention designs a lightweight "reversible noise-adding encryption mechanism" in image space for privacy protection and reversible editing of facial regions. This module includes the following key steps: First, a facial image is obtained through facial recognition. The system generates a Gaussian noise matrix with a shape that is exactly the same as the size of the face image. ,in Here are the noise intensity control parameters, where .
[0046] ; Each channel of the noise matrix is generated independently to perturb pixels in the RGB space. The second step is to convert the original face image matrix... The encryption result is obtained by adding the elements of the noise matrix N together. ; The clip operation is used to ensure that pixel values are within a certain range. The process is equivalent to a linear invertible transformation. RealNVP uses an additive mapping in the latent space, but in this scenario, it is implemented through an explicit noise matrix. In the third step, the system replaces the encrypted face regions back to their corresponding positions in the original image, resulting in the overall encrypted image. ,Right now: ; The image is visually unidentifiable, retaining only the background and non-face areas to ensure privacy. After Stable Diffusion completes image editing, the system reads the noise matrix N from the cache and performs reverse denoising on the edited face area: ; At this point, since N is exactly the same as the noise in the encryption stage, the subtraction operation can recover an image with a pixel height identical to the original face. In practical implementation, considering that the diffusion model may slightly modify local edge regions, this invention also introduces a local smoothing compensation mechanism: ; in This is used to balance the realism and consistency after denoising and to prevent artifacts from being introduced by over-restoration.
[0047] Generative Image Editing Model: In this invention, the generative image editing module is based on the StableDiffusion model and combines it with reversibly noisy face regions for locally controllable reconstruction, achieving semantically consistent editing under encrypted conditions. Unlike traditional image editing models, this invention does not receive real face images at the input stage, but rather anonymized images perturbed by a reversible noise mechanism. To ensure that the diffusion model can still correctly identify the image structure and perform local redrawing, this invention has specifically adapted and enhanced the input structure, conditional control method, and latent space coding method of the diffusion model, including the following aspects: 1. Late space-based encrypted image coding and reconstruction adaptation Stable Diffusion uses a VAE to map the input image to a low-dimensional latent space, and the encoder output is... This invention utilizes this characteristic to treat the "noisy face region" as structural noise in the latent space, while still preserving local semantics such as contour, position, and lighting that can be recognized by the model. Therefore, this invention has the following technical advantages: (1) The noise pattern of the encrypted face is compressed into a low-frequency perturbation in the latent space, which does not affect the model’s understanding of the overall scene layout; (2) The model is not sensitive to high-frequency textures, so it will not attempt to "fix privacy details" but only focus on the semantic modification corresponding to the text prompts; (3) The diffusion reverse process can naturally filter noise, so that the encrypted face area will not be inferred as a "real face", thereby reducing the risk of privacy leakage.
[0048] This feature provides the theoretical basis for the "editable under encrypted state" feature of this invention.
[0049] 2. Diffusion control mechanism that integrates image and text prompts This invention employs a Stable Diffusion Inpainting mechanism for local editing, meaning the model input consists of two parts: a noisy and encrypted image and user-provided natural language text prompts. (1) Encrypted image: ; (2) Text embedding conditions: ; (3) Dual-condition fusion: ; Where w=0.7 (text priority) ensures that the editing semantics are stronger than the encryption noise. At each step of the diffusion reverse process, the model will refer to the above two conditions to enable the editor to have the following capabilities: (1) The encrypted face region will not be restored to the real identity by the model, but will only be used as the "region to be edited" in the generation; (2) Various local / overall editing semantics such as "change hair color", "smiling expression", and "replace background" can be achieved through text commands.
[0050] 3. Diffusion Attention Redistribution Strategy for Encrypted Images To address the issue of encryption noise causing erroneous facial structures generated by diffusion models in the face region, this invention introduces an attention region reweighting mechanism in the latent space denoising stage. This mechanism encourages the model to maintain high attention in non-face regions to preserve high-quality background details, while focusing on low-frequency structures (such as contours, poses, and expression regions) in encrypted face regions, thus mitigating the impact of high-frequency noise. The attention allocation mechanism of this invention is as follows: (1) Calculate the attention area Based on the face detection bounding box B, construct a soft mask: ; in is the distance from the pixel to the center of the face bounding box, r is the radius of the face bounding box, and M will generate a blurred face region attention map.
[0051] (2) Reweighting Cross-Attention Cross-Attention of Stable Diffusion: ; This invention adjusts the softmax result A according to M: ; in, This indicates that non-face areas retain their original attention. Set to 0.2, The smaller the parameter, the lower the attention in the face region is and the more it is replaced by low-frequency attention. In other words, the model weakens high-frequency attention in the face region, but retains structural attention.
[0052] Boundary Blending Processing for Face Region Replacement: After the editing stage, the edited face region needs to be replaced back into the overall image. Since the brightness distribution, color characteristics, and texture structure of the face region may differ from the target image, directly pasting it back will result in obvious stitching artifacts. This invention proposes a pixel-domain-based boundary fusion processing method to achieve a seamless transition and ensure visual consistency of the fused region.
[0053] The pixel-domain fusion method used in this invention includes two steps: Poisson fusion and Gaussian feathering alpha fusion. These steps are used to process the gradient continuity and color texture transition of the image, respectively, thereby achieving a stable and natural fusion effect in practical applications.
[0054] 1. Poisson Fusion Poisson fusion addresses the issues of abrupt brightness changes and gradient discontinuities in the texture region by minimizing energy in the gradient domain. Its basic idea is to preserve the gradient information of the source image within the face region while ensuring strict consistency between the boundary and the target image, thus achieving a natural transition.
[0055] (1) Mathematical model Let the face region be The merged image is The Poisson fusion optimization objective is: ; And satisfy the boundary conditions: ; in, Represents the image gradient. It is the edited face area. For the overall image to be merged, This refers to the boundary of the face region.
[0056] (2) Gaussian feathering Alpha mixing Based on the principle that Poisson blending ensures gradient continuity, this invention further employs Gaussian feathering Alpha blending to achieve a soft transition at the boundary, thereby resolving potential issues such as boundary blurring, color temperature deviation, or slight texture differences that may remain with Poisson blending.
[0057] From binary face mask Generate a Gaussian smoothed soft mask : ; in, The feathering radius is... Used to control the fusion weights.
[0058] Achieving a natural transition between the face and the background through pixel-by-pixel alpha blending: ; This method can effectively solve color differences and texture breaks at the boundaries.
[0059] FaceNet: A facial recognition algorithm; INN: Invertible Neural Networks; VAE: Variational Autoencoder; Stable Diffusion: A stable diffusion model; Stable Diffusion Inpainting: A local image reconstruction technique based on the diffusion process; CLIP: Cross-modal language-image pre-trained model; RealNVP: The specific implementation structure of a reversible neural network; Affine Coupling Layer: Affine coupling layer; Cross-Attention: a mechanism for cross-attention; Triplet Loss: The loss function for triplet pairs; Gaussian Distribution; prompt: a text prompt command; randn: Gaussian random number generation function; clip: Pixel value clipping function; Enc: Encoder function; Softmax: The activation function in the cross-attention mechanism; GaussianBlur: Gaussian blur function; : The face sub-image region cropped from the original image; (top, right, bottom, left): The coordinates of the face bounding box; L: FaceNet's triplet loss function; f(x): Feature vector extracted by the FaceNet model; : Triple samples, representing anchor face, positive face, and negative face respectively. Boundary constants in triplet loss; Parameters for adjusting facial region attention; Gaussian noise matrix; Noise intensity control parameters; : The noise value of the (i,j,k)th pixel in the noise matrix; Noise-added encrypted facial images; The overall encrypted image obtained after replacing the face area; Image results after Stable Diffusion editing; Face region image recovered through inverse noise reduction; Decrypted face image after local smoothing compensation; The final anonymized image; Image after Poisson fusion; λ: Decryption fusion weighting coefficient; : Dual-condition fusion weighting coefficient; : Distance from the pixel to the center of the face frame; r: Radius of the face bounding box; Image gradient; : The edited face area; Overall image to be merged; : Set of facial regions; : Boundary of the face region; Feathering radius; z: Latent space encoding; Encrypted image latent space coding; Text embedding vector; : Dual-condition fusion vector; M: Soft mask attention graph; M binary Binary face mask; M soft Gaussian soft mask; A: Original attention weight matrix; A ’ : Reweighted attention weight matrix.
[0060] The embodiments described above are for illustrative purposes only and are not intended to limit the invention. Therefore, any changes in numerical values or substitutions of equivalent elements should still fall within the scope of this invention.
[0061] The above detailed description will enable those skilled in the art to understand that the present invention can indeed achieve the aforementioned objectives and has complied with the provisions of the Patent Law.
[0062] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the invention. The above descriptions are merely preferred embodiments of the invention and are not intended to limit the invention. It should be noted that any modifications, equivalent substitutions, and improvements made within the spirit and principles of the invention should be included within the scope of protection of the invention.
[0063] It should be noted that the above description of the process is for illustrative purposes only and does not limit the scope of this specification. Those skilled in the art can make various modifications and changes to the process under the guidance of this specification. However, these modifications and changes remain within the scope of this specification.
[0064] The basic concepts have been described above. Obviously, for those skilled in the art who have read this application, the above disclosure is merely illustrative and does not constitute a limitation of this application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and corrections to this application. Such modifications, improvements, and corrections are suggested in this application, and therefore, such modifications, improvements, and corrections still fall within the spirit and scope of the exemplary embodiments of this application.
[0065] Furthermore, this application uses specific terms to describe its embodiments. For example, "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic related to at least one embodiment of this application. Therefore, it should be emphasized and noted that "an embodiment," "one embodiment," or "an alternative embodiment" mentioned twice or more in different positions in this specification do not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of this application can be appropriately combined.
[0066] Furthermore, those skilled in the art will understand that aspects of this application can be described and illustrated through several patentable types or situations, including any new and useful combination of processes, machines, products, or substances, or any new and useful improvements thereof. Therefore, aspects of this application can be implemented entirely in hardware, entirely in software (including firmware, resident software, microcode, etc.), or a combination of hardware and software. All of the above hardware or software can be referred to as a “unit,” “module,” or “system.” Furthermore, aspects of this application can take the form of a computer program product embodied in one or more computer-readable media, wherein computer-readable program code is contained therein.
[0067] The computer program code required for the operation of each part of this application can be written in any one or more programming languages, including object-oriented programming languages such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB.NET, and Python; general programming languages such as C; Visual Basic, Fortran2103, Perl, COBOL2102, PHP, and ABAP; dynamic programming languages such as Python, Ruby, and Groovy; or other programming languages. This program code can run entirely on the user's computer, or as a standalone software package on the user's computer, or partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer via any network, such as a local area network (LAN) or wide area network (WAN), or connected to an external computer (e.g., via the Internet), or in a cloud computing environment, or used as a service such as Software as a Service (SaaS).
[0068] Furthermore, unless expressly stated in the claims, the order of processing elements and sequences, the use of numbers and letters, or other names described in this application are not intended to limit the order of the processes and methods of this application. Although some currently considered useful embodiments of the invention have been discussed in the foregoing disclosure by way of various examples, it should be understood that such details are for illustrative purposes only, and the appended claims are not limited to the disclosed embodiments; rather, the claims are intended to cover all modifications and equivalent combinations that conform to the substance and scope of the embodiments of this application. For example, although the implementation of the various components described above can be embodied in a hardware device, it can also be implemented as a purely software solution, such as an installation on an existing server or mobile device.
[0069] Similarly, it should be noted that, in order to simplify the description of the present application and thus aid in the understanding of one or more embodiments of the invention, the foregoing description of the embodiments of the present application sometimes combines multiple features into a single embodiment, drawing, or description thereof. However, this approach of the present application should not be construed as reflecting an intention that the claimed subject matter requires more features than expressly recited in each claim. Rather, the subject of the invention should possess fewer features than in any single embodiment described above.
Claims
1. A face region anonymization method based on reversible neural networks and a diffusion model, characterized in that, include: (1) Face detection and region extraction: The FaceNet face recognition algorithm is used to detect the face position in the input image, obtain the coordinate information of the face bounding box, and crop the face sub-image containing complete facial features from the original image according to the coordinate information; (2) Noise addition and reversible encryption of face: A noise matrix with the same shape as the face sub-image is generated based on Gaussian distribution. The noise matrix and the face sub-image are superimposed at the pixel level through a reversible neural network INN to obtain a noisy encrypted face image. The face encrypted image is used to replace the corresponding face region in the original image to obtain the overall encrypted image. (3) Generative model editing: The overall encrypted image is input into the Stable Diffusion model, and combined with the natural language text instructions provided by the user, the overall encrypted image is subjected to semantic-level local reconstruction and generative editing to obtain the edited image; (4) Face Denoising and Restoration: The noise matrix used in the encryption stage is called to perform inverse noise reduction operation on the face region in the edited image to obtain a preliminary decrypted face image; (5) Boundary fusion and result output: The non-face regions of the preliminary decrypted face image and the original image are subjected to boundary fusion processing to obtain the final anonymized image. The final anonymized image maintains the editing effect corresponding to the text instructions and does not disclose the original face identity information.
2. The face region anonymization method based on reversible neural networks and diffusion models according to claim 1, characterized in that, The reversible neural network INN adopts the RealNVP structure, which contains 4 AffineCoupling Layers. The mapping of each AffineCoupling Layer is achieved through a three-layer convolutional network. The number of channels in the three-layer convolutional network is 32-32-3, the kernel size is 3×3, and the reverse mapping is explicitly solvable.
3. The face region anonymization method based on reversible neural networks and diffusion models according to claim 1, characterized in that, In step (2), when generating the noise matrix, noise data is generated independently for the three RGB channels of the image. The noise data of each channel satisfies the Gaussian distribution characteristics, ensuring that the noise perturbation of the face sub-image achieves visual identity hiding without destroying the semantic structure of the image.
4. The face region anonymization method based on reversible neural networks and diffusion models according to claim 1, characterized in that, Before editing the generative model in step (3), the overall encrypted image is mapped to a low-dimensional latent space by a variational autoencoder (VAE), so that the noise pattern corresponding to the face encrypted image is compressed into a low-frequency perturbation in the latent space, while preserving the contour, position and local semantic information related to illumination of the face.
5. The face region anonymization method based on reversible neural networks and diffusion models according to claim 1, characterized in that, In step (3), the generative model editing adopts a dual-condition fusion mechanism, which weights and fuses the latent space encoding of the overall encrypted image with the text embedding obtained by the CLIP text encoder. The weight of the text embedding is higher than that of the latent space encoding, ensuring that the editing semantics take precedence over the encryption noise.
6. The face region anonymization method based on reversible neural networks and diffusion models according to claim 1, characterized in that, In step (3), an attention region reweighting mechanism is introduced during generative model editing. A soft-mask attention map is constructed based on the face bounding box. The attention map assigns attention weights according to the distance from the pixel to the center of the face box, so that the diffusion model maintains high attention in non-face areas to preserve background details, while weakening high-frequency attention and retaining low-frequency structural attention in face encryption areas.
7. The face region anonymization method based on reversible neural networks and diffusion models according to claim 1, characterized in that, After obtaining the preliminary decrypted face image in step (4), a local smoothing compensation mechanism is introduced to perform weighted fusion of the face region in the preliminary decrypted face image and the edited image, so as to balance the authenticity of the decrypted face and the consistency of the editing effect, and avoid excessive restoration that introduces image artifacts.
8. The face region anonymization method based on reversible neural networks and diffusion models according to claim 1, characterized in that, The boundary fusion process in step (5) includes two steps: Poisson fusion and Gaussian feathering Alpha blending. First, the gradient information in the face region is maintained by Poisson fusion so that the boundary of the face region is strictly consistent with the target image. Then, a soft mask after Gaussian smoothing is generated based on the binary face mask. The soft transition between the face region and the background is achieved by pixel-by-pixel Alpha blending to eliminate stitching marks.
9. The face region anonymization method based on reversible neural networks and diffusion models according to claim 1, characterized in that, In step (2), when generating the noise matrix, the strength of the noise disturbance is adjusted by the noise intensity control parameter so that the face encryption image cannot be visually identified as a specific person, while ensuring that the overall encryption image can be recognized by the diffusion model in terms of semantic structure.
10. The face region anonymization method based on reversible neural networks and diffusion models according to claim 7, characterized in that, In the local smoothing compensation mechanism, the weighting coefficient of the initially decrypted face image is higher than the weighting coefficient of the face region in the edited image. This coefficient allocation ensures that the restored face features are highly consistent with the original face pixel distribution, while also being compatible with reasonable semantic modifications brought about by generative editing.
