Vec2Face: Unveil Human Faces from their Blackbox Features in Face Recognition

Unveiling face images of a subject given his/her high-level representations extracted from a blackbox Face Recognition engine is extremely challenging. It is because the limitations of accessible information from that engine including its structure and uninterpretable extracted features. This paper presents a novel generative structure with Bijective Metric Learning, namely Bijective Generative Adversarial Networks in a Distillation framework (DiBiGAN), for synthesizing faces of an identity given that person's features. In order to effectively address this problem, this work firstly introduces a bijective metric so that the distance measurement and metric learning process can be directly adopted in image domain for an image reconstruction task. Secondly, a distillation process is introduced to maximize the information exploited from the blackbox face recognition engine. Then a Feature-Conditional Generator Structure with Exponential Weighting Strategy is presented for a more robust generator that can synthesize realistic faces with ID preservation. Results on several benchmarking datasets including CelebA, LFW, AgeDB, CFP-FP against matching engines have demonstrated the effectiveness of DiBiGAN on both image realism and ID preservation properties.


Introduction
Face recognition has recently matured and achieved high accuracy against millions of identities [47,48]. A face recognition system is often designed in two main stages, i.e. feature extraction and feature comparison. The role of feature extraction is more important since it directly determines the robustness of the engine. This operator defines an embedding process mapping input facial images into a higher-level latent space where embedded features extracted from photos of the same subject distribute within a small margin [32]. Moreover, since most face recognition engines are set into a blackbox mode to protect the Figure 1. Metric Learning for Image Reconstruction. By maintaining the one-to-one mapping via a bijection, the distance between images can be directly and intuitively measured and enhances the metric learning process for image reconstruction task.
technologies [25], there is no apparent technique to inverse that embedding process to reconstruct the faces of a subject given his/her extracted features from those engines.
Some Blackbox Adversarial Attack approaches [20,21,44] have partially addressed this task by analyzing the gradients of the classifier's outputs to generate adversarial examples that mislead the behaviour of that classifier. However, they only focus on a closed-set problem where the output classes are predefined. Moreover, their goal is to generate imperceptible pertubations added to the given input signal. Other methods [1,4,7,43,53] are also introduced in literature but still require the access to the classifier structure, i.e. whitebox setting. Meanwhile, our goal focuses on a more challenging reconstruction task with a blackbox face recognition. Firstly, this process reconstructs faces from scratch without any hint from input images. Secondly, in a blackbox setting, there is no information about the engine's structure, and, therefore, it is unable to directly exploit knowledge from the inverse mapping process (i.e. back-propagation). Thirdly, the embedded features from a face recognition engine are for open-set problem where no label information is available. More importantly, the subjects to be reconstructed may have never been seen during training process of the face recognition engine. In the scope of this work, we assume that the face recognition engines are primarily developed by Convolutional Neural Networks Table 1. Comparisons of our DibiGAN and other unrestricted synthesis methods. Image Reconstruction (Img Recon), Feature Representation (Feat), Guided Image (ImgG), Feature Conditional (Feat Cond), Neighborly Deconvolution (NB Deconv), Optimization (Opt).

Ours
NBNet [34] SynNormFace [4] IFaceRec [53]  (CNN) that dominate recent state-of-the-art results in face recognition [5,10,12,28,29,40,45,46,52]. We also assume that there is no further post-processing after the step of CNN feature extraction. We then develop a theory to guarantee the reconstruction robustness of the proposed method.
Contributions. This paper presents a novel generative structure, namely Bijective Generative Adversarial Networks in a Distillation framework (DiBiGAN), with Bijective Metric Learning for the image reconstruction task. The contributions of this work are four-fold. (1) Although many metric learning techniques have been introduced in the literature, they are mainly adopted for classification rather than reconstruction process. By addressing limitations of classifier-based metrics for image reconstruction, we propose a novel Bijective Metric Learning with bijection (one-to-one mapping) property so that the distances in latent features are equivalent to those between images (see Fig. 1). It, therefore, provides a more effective and natural metric learning approach to the image reconstruction task. (2) We exploit different aspects of the distillation process for the image reconstruction task in a blackbox mode. They include distilled knowledge from the blackbox face matcher and ID knowledge extracted from a real face structure. (3) We introduce a Feature-Conditional Generator Structure with Exponential Weighting Strategy for Generative Adversarial Network (GAN)-based framework to learn a more robust generator to synthesize realistic faces with ID preservation. (4) Evaluations on benchmarks against various face recognition engines have illustrated the improvements of DiBiGAN in both image realism and ID preservation. To the best of our knowledge, this is one of the first metric learning methods for image reconstruction (Table 1).

Related Work
Synthesizing images [4,7,8,9,34,53] has brought several interests from the community. We divided into two groups, i.e. unrestricted and adversarial synthesis. Unrestricted synthesis. The approaches focus on reconstructing an image from scratch given its high-level representation. Since the mapping is from a low-dimensional latent space to a highly nonlinear image space, several regularizations have to be applied, e.g. Gaussian Blur [51] for high-frequency samples or Total Variation [11,33] for maintaining piece-wise constant patches. These optimization-based techniques are limited with high com-putation or unrealistic reconstructions. Later, Dosovitskiy et al. [7] proposed to reconstruct the image from its shallow (i.e. HOG, SIFT) and deep features using a Neural Network (NN). Zhmoginov et al. [53] presented an iterative method to invert Facenet [40] feature with feed-forward NN. Cole et al. [4] proposed an autoencoder structure to map the features to frontal neutral face of the subject. Yang et al. [49] adopted autoencoder for model inversion task. Generally, to produce better synthesized quality, these approaches require full access to the deep structure to exploit the gradient information from the embedding process. Mai et al. [34] developed a neighborly deconvolutional network to support the blackbox mode. However, with only pixel and perceptual [23] losses, there are limitations of ID preservation when synthesizing different features of the same subject. In this work, we address this issue with Bijective Metric Learning and Distillation Knowledge for reconstruction task. Adversarial synthesis. Adversarial approaches aim at generating unnoticable perturbations from input images for adversarial examples to mislead the behaviour of a deep structure. Either directly accessing or indirectly approximating gradients, adversarial examples are created by maximizing corresponding loss which can fool a classifier [1,2,3,20,21,30,35,42,44]. Ilyas et. al. [21] proposed bandit optimization to exploit prior information about the gradient of deep learning models. Later, Ilyas et. al. [20] introduced Natural Evolutionary Strategies to enable query-efficient generation of black-box adversarial examples. Other knowledge from the blackbox classifier are also exploited for this task [44,1,43]. Generally, although the approaches in this direction tried to extract the gradient information from a blackbox classifier, their goal are mainly to mislead the behaviours of the classifier with respect to a pre-defined set of classes. Therefore, they are closed-set approaches. Meanwhile, in our work, the proposed framework can reconstruct faces of subjects that have not been seen in the training process of the classifier.

Our Proposed Method
Let F : I → F be a function that maps an input image I from image domain I ∈ R W ×H×C to its high-level embedding feature F (I) in latent domain F ∈ R M . In addition, a function C : F → Y takes F(I) as its input and gives the identity (ID) prediction of the subject in space Y ∈ R N where each dimension represents a predefined subject class.  The approaches solving this problem usually exploit the relationship between an input image and its class label for the reconstruction process. Moreover, since the output score s is fixed according to predefined N classes, the reconstruction is limited on images of training subject IDs. Definition 2 (Feature Reconstruction). Given a blackbox functions F ; and its embedding feature f = F (I) of an unknown image I, feature reconstruction is to recover I from f by optimizingĨ * = arg minĨ L(F (Ĩ), f ). Compared to the model inversion problem, Feature Reconstruction is more challenging since the constraints on predefined classes are removed. Therefore, the solution for this problem turns into an open-set mode where it can reconstruct faces other than the ones used for learning F , i.e. face recognition engine. Moreover, since the parameters of F are inaccessible due to its blackbox setting, directly recovering I based on its gradient is impossible. Therefore, the feature reconstruction task can be reformulated via a function (generator) G : F → I as the reverse mapping of F .
, θ g denotes the parameters of G, and p I (x) is the probability density function of x. In other words, p I (x) indicates the distribution that image I belonged to (i.e. the distribution of training data of F ). Intuitively, function G can be seen as a function that maps images from embedding space F back to image space such that all reconstructed images [G • F ](x; θ g ) are maintained to be close to its real x with respect to the distance metric L x G . To produce "good quality" synthesis (i.e. realistic images with ID preservation), different choices for L x G have been commonly exploited [22,23,34] such as pixel difference in image domain via L 1 /L 2 distance; Probability Distribution Divergence (i.e. Adversarial loss defined via an additional Discriminator) for realistic penalization; or Perceptual distance that penalizes the image structure in highlevel latent space. Among these metrics, except the pixel difference that is computed directly in image domain, the others are indirect metrics where another mapping function (i.e. classifier) from image space to latent space is required.

Limitations of Classifier-based Metrics
Although these indirect metrics have shown their advantages in several tasks, there are limitations when only the blackbox function F and its embedded features are given. Limitation 1. As shown in several adversarial attack works [15,39], since the function F is not a one-to-one mapping function from I to F, it is straightforward to find two images of similar latent representation that are drastically different in image content. Therefore, with no prior knowledge about the subject ID of image I, starting to reconstruct it from scratch may easily fall into the case where the reconstructed imageĨ is totally different to I but has similar embedding features. The current Probability Distribution Divergence with Adversarial Loss or Perceptual Distance is limited in maintaining the constrain "the reconstructions of features of the same subject ID should be similar". Limitation 2. Since the access to the structure and intermediate features of F is unavailable in the blackbox mode, the function G is unable to directly exploit valuable information from the gradient of F and the intermediate representation during embedding. As a result, the distance metrics defined via F , i.e. perceptual distance, is less effective as in whitebox setting. Next sections will introduce two loss functions to tackle these problems to learn a robust function G.

Bijective Metrics for Image Reconstruction
Many metric learning proposals for face recognition [5,28,29,45,46,52] have been used to improve both intraclass compactness and inter-class separability with a large margin. However, for feature reconstruction, directly adopting these metrics, e.g. angular distance for reconstructed images to cluster images of the same ID is infeasible.
Therefore, we propose a bijection metric for feature reconstruction task such that the mapping function from image to latent space is one-to-one. The distance between their latent features is equivalent to the distance between images. By this way, these metrics are more aligned to image domain and can be effectively adopted for reconstruction task. Moreover, since two different images cannot be mapped to the same latent features, the metric learning process is more reliable. The optimization of G in Eqn. (1) is rewritten as: and p x (x) denotes a density function estimated from an alternative large-scale face dataset.
Notice that although the access to p I (x) is not available, this approximation can be practically adopted due to a prior knowledge about p I (x) that images drawn from p I (x) are facial images. Let H : I → Z define a bijection mapping from x to a latent variable z = H(x). With the bijective property, the optimization in Eqn. (2) is equivalent to.
arg min where z = H(x); p x (x) = p z (z)| det(J x J x )| 1/2 by the change of variable formula; J x is the Jacobian of H with respect to x; and L z G is the distance metric in Z. Intuitively, Eqn. (3) indicates that instead of computing the distance L x G and estimating p x (x) directly in image domain, the optimization process can be equivalently accomplished via the distance L z G and density p z (z) in Z according to the bijective property of H. The prior distributions p z . In general, there are various choices for the prior distribution p z and the ideal one should have two properties: (1) simplicity in density estimation, and (2) easily sampling. Motivated from these properties, we choose Gaussian distribution for p z . Notice that other distribution types are still applicable in our framework. The distance metric L z G . With the choice of p z as a Gaussian, the distance between images in I is equivalent to the deviation between Gaussians in latent space. Therefore, we can effectively define L z G as the squared Wasserstein coupling distance between two Gaussian distributions. where {μ,Σ} and {µ, Σ} are the means and covariances of z and z, respectively. The metric L z G then can be extended with image labels to reduce the distance between images of the same ID and enhance the margin between different IDs.
where m defines parameter controlling the margin between classes; and {lz 1 , lz 2 } denote the subject ID of {z 1 ,z 2 }.
Learning the Bijection H. In order to effectively learn the bijection H, we adopt the structure of mapping function from [6,13,14] as the backbone for the tractable log-det computation with the log-likelihood loss for training process. Moreover, to further improve the discriminative property of H in latent space Z, we propose to exploit the ID label in training process of H. Particularly, given K classes (i.e. ID) of the training set, we choose K Gaussian distributions with different means {µ 1 , µ 2 , .., µ K } and covariances {Σ 1 , Σ 2 , ..., Σ K } and enforce samples of each class distributed on its own prior distribution, i.e. z k ∼ N (µ k , Σ k ). Formally, the log-likelihood loss function to learn H is formulated as θ * H = arg max θ H log p x (x, k; θ H ) = arg max θ H log p z (z, k; θ H ) + 1 2 log | det(J x J x )|.

Reconstruction from Distillation Knowledge
In the simplest approach, the generator G can still learn to reconstruct image by adopting the Perceptual Distance as in previous works to compare F (Ĩ) and F (I). However, as mentioned in Sec. 3.1, due to limited information that can be accessed from F , "key" information (i.e. the gradients of F as well as its intermediate representations) making the perceptual loss effective is lacking. Therefore, we propose to first distill the knowledge from the blackbox F to a "student" function F S and then take advantages of these knowledge via F S for training the generator. On one hand, via the distillation process, F S can mimic F by aligning its feature space to that of F and keeping the semantics of the extracted features for reconstruction. On the other hand, with F S , the knowledge about the embedding process of F (i.e. gradient, and intermediate representation) becomes more transparent; and, therefore, maximize the information which can be exploited from F . Particularly, let F S : I → F and F S = F S 1 • F S 2 · · · • F S n be the composition of n-sub components. The knowledge from F can be distilled to F S by aligning their extracted features as.
Then G is enhanced via the distilled knowledge of both final embedding features and intermediate representation by.
where {λ j } n 1 and λ a denote the hyper-parameters controlling the balance between terms. The first component of  Network Architecture. Given an input image x, the generator G takes F (x) as its input and aims to synthesize an imagex that is as similar to x as possible in terms of identity and appearance. We adopt the GAN-based generator structure for G and optimize using different criteria.

Learning the Generator
where {L biject , L distill , L adv , L recon } denote the bijective, distillation, adversarial, and reconstruction losses, respectively. {λ b , λ d , λ adv , λ r } are their parameters controlling their relative importance. D is a discriminator distinguishing the real images from a synthesized one. There are three main critical components in our framework including the Bijective H, the student matcher F S for ID preservation; and the discriminator D for realistic penalization. The Discriminator D is updated with the objective function as.
where px is the random interpolation distribution between real and generated images [16]. Then, the whole framework is trained following GAN-based minimax strategy. Learning Strategies. Besides the losses, we introduce a Feature-Conditional Structure for G and a exponential Weighting Strategy to adaptively scheduling the importance factors between loss terms during training process. Feature-conditional Structure. A natural design for the structure of G is to directly use F (x) as the input for G. However, this structure limits the learning capability of G. Particularly, besides ID information, F (x) may include other "background" conditions such as poses, illuminations, expressions. Therefore, setting F (x) as the only input implicitly enforces G to "strictly" model these factors as well. This makes the training process of G less effective. To relax this constraint, we introduce a Feature-Conditional structure (i.e. the generator structure in Fig. 2) where a random variable v is adopted as an additional input so that these background factors can be modeled through v. Moreover, we propose to use v as the direct input to G and inject the information from F (x) through out the structure. By this way, F (x) can act as the conditional ID-related information for all reconstruction scales and gives the better synthesis. Exponential Weighting Strategy. As the progressive growing training strategy [24] initializes its learning process on synthesizing low-resolution images and then gradually increasing their levels of details, it is quite effective for enhancing the details of generated images in general. However, this strategy has limited capability in preserving the subject ID. In particular, in the early stages at low scales with blurry synthesis, it is difficult to control the subject ID of faces to be synthesized while in the later stages at higher scales when the generator becomes more mature and learns to add more details, the IDs of those faces have already been constructed and become hard to be changed. Therefore, we propose to adopt a exponential weighting scheme for (1) emphasizing on ID preservation in early stages; and (2) enhancing the realism in later stages. Particularly, the param- where R(i) denotes the current scales of stage i and R M is the maximum scales to be learned by G.

Experimental Results
We qualitatively and quantitatively validate our proposed method in both reconstructed quality and ID preservation in several in-the-wild modes such as poses, expressions, and occlusions. Both image-quality and face-matching datasets are used for evaluations. Different face recognition engines are adopted to demonstrate the robustness of our model. Data Setting. Our training data includes the publicly available Casia-WebFace [50] with 490K labeled facial images of over 10K subjects. The duplicated subjects between training and testing sets are removed to ensure no overlapping between them. For validation, as commonly used for attribute learning and image quality evaluation, we adopt the testing split of 10K images from CelebA [31] to validate the reconstruction quality. For ID preservation, we explore  [34] and MPIE-NBNet [34] (2nd and 3rd rows) reconstruct faces with limited quality, DibiGAN in whitebox (4th row) and blackbox (5th row) modes are able to produce realistic faces with better ID preservation comparable to real faces (6th row).
LFW [18], AgeDB [36], and CFP-FP [41] which provide face verification protocols against different in-the-wild face variations. Since each face matcher engine requires different preprocessing process, the training and testing data are aligned to the required template accordingly.
Network Architectures. We exploited the Generator structure of PO-GAN [24] with 5 convolutional blocks for G while the Feature Conditional branch consists of 8 fully connected layers. The discriminator D includes five consecutive blocks of two convolution and one downsampling operators. In the last block of D, the minibatch-stddev operator followed by convolution and fully connected are also adopted. AdaIN operator [19] is applied for feature injection node. For the bijection H, we set a configuration of 5 sub-mapping functions where each of them is presented with two 32-feature-map residual blocks. This structure is trained using the log-likelihood objective function on Casia-WebFace. Resnet-50 [17] is adopted for F S .

Model Configurations. Our framework is implemented in
TensorFlow and all the models are trained on a machine with four NVIDIA P6000 GPUs. The batch size is set based on the resolution of output images, for the very first resolution of output images (4 × 4), the batch size is set to 128, the batch size will be divided by two when the resolution of images is doubled. We use Adam Optimizer with the started learning rate of 0.0015. We experimentally set {α = 0.001, β = 1.0, λ j = 1, λ a = 10.0} to maintain the balanced values between loss terms.
Ablation Study. To study the effectiveness of the proposed bijective metric for image reconstruction task, we employ an ablation study on MNIST [26] with LeNet [27] as the function F . We also set to whitebox mode where F is directly used in L distill to remove the effects of other factors. Then 50K training images from MNIST and their 1 × 1024 feature vectors are used to train G. Notice that since the image size is 32 × 32, G and D structures are configured with three convolutional blocks. The resulting distributions of synthesized testing images of all classes without and with L biject are plotted in Fig. 3. Compared to G learned with only classifier-based metrics (Fig. 3(a)), the one with bijective metric learning (Fig. 3(b)) is supervised with more direct metric learning mechanism in image domain, and, therefore, shows the advantages with enhanced intra-and inter-class distributions.

Face Reconstruction Results
This section demonstrates the capability of our proposed methods in terms of effectively synthesizing faces from subject's features. To train DibiGAN, we adopt the ArcFace-Resnet100 [5] trained on 5.8M images of 85K subjects for function F and extract the 1 × 512 feature vectors for all training images. These features together with the training images are then used to train the whole framework. We divided the experiments in two settings, i.e. whitebox and blackbox, where the main difference is the visibility of the matcher structure during training process. In the whitebox mode F is directly used in Eqn. (7) to evaluate L distill G while in the blackbox mode, F S is learned from F through a distillation process as in Eqn. (6) and used for L distill G . The first row of Table 2 shows the matching accuracy of F and F S using real faces on benchmarking datasets. Face Reconstruction from features of frontal faces. After training, given only the deep features extracted from F on testing images, the generator G is applied to synthesize the subjects' faces. Qualitative examples of our synthesized faces in comparison with other methods are illustrated in Fig. 4. As can be seen, our generator G is able to reconstruct realistic faces even when their embedding features are extracted from faces with a wide range of in-the-wild  variations. More importantly, in both whitebox and blackbox settings, our proposed method successfully preserves the ID features of these subjects. In whitebox setting, since the structure of F is accessible, the learning process can effectively exploit different aspects of embedding process from F and produce a generator G that depicts better facial features of the real faces. For example, together with ID information, poses, glasses, or hair style from the real faces can also be recovered. On the other hand, although the accessible information is very limited in blackbox setting, the learned G can still be enjoyed from the distilled knowledge of F S and effectively fill the knowledge gap with whitebox setting. In comparison to different configurations of NBNet [34], better faces in terms of image quality and ID preservation can be obtained by our proposed model. Effect of expressions and occluded regions. Fig. 5 illustrates our synthesis from features of faces that contain both expressions and occlusions. Similar to previous experiment, our model robustly depicts realistic faces with similar ID features as in the real faces. Those reconstructed faces' quality again outperforms NBNet in both realistic and ID terms. Notice that the success of robustly handling with those challenging factors comes from two properties: (1) The matcher F was trained to ignore those facial variations in its embedding features; and (2) both bijective metric learning and distillation process can effectively exploit necessary knowledge from F as well as real face distributions in image domain for synthesis process. Effect of different features from the same subject. Fig.  6 illustrates the advantages of our method in synthesizing faces given different feature representations of the same subject. These results further show the advantages of the proposed bijective metric in enhancing the boundary between classes and constrain the similarity between reconstructed faces of the same subject in image domain. As a result, reconstructed faces from features of the same subject ID not only keep the features of that subject (i.e. similar to Table 2. Realism Quality and Matching Accuracy. Comparison results in Multi-Scale Structural Similarity (MS-SSIM) (the smaller value is better); Inception score and Matching Accuracy (the higher value is better). For each configuration in (A)-(C) and (D)-(F), each loss function is cumulative enable on the top of the previous configuration. − denotes "not applicable".  Fig. 7. These results further illustrate the advantages of our model structure in its capability of capturing various factors for the reconstruction process.

Face Quality and Verification Accuracy
In order to quantitatively validate the realism of our reconstructed images and how well they can preserve the ID of the subjects, three metrics are adopted: (1) Multi-scale Structural similarity (MS-SSIM) [37]; (2) Inception Score (IS) [38]; and (3) face verification accuracy. Image quality. To quantify the realism of the reconstructed faces, we synthesize testing images of CelebA in several training configurations as shown in Table 2, where each loss function in cumulatively enables on the top of the previous configuration. Then MS-SSIM and IS metrics are applied to measure their image quality. We also compare our model in both whitebox and blackbox settings with other baselines including PO GAN structure [24] and NBNet [34]. Notice that we only adopt the adversarial and reconstruction losses for configs (A) and (D). For all configs (A), (B), and (C), PO GAN baseline takes only the embedding features as its input. These results show that in all configurations, our method maintains comparative reconstruction quality as PO GAN and very close to that of real faces. Moreover, our synthesis consistently outperforms NBNet in both metrics. ID Preservation. Our model is experimented against LFW, AgeDB, and CFP-FP where an image in each positive pair is substituted by the reconstructed one while the remaining image of that pair is kept as the reference real face. The matching accuracy is reported in Table 2. These results further demonstrate the advantages and contributions of each 1 We report the accuracy of original matcher F for whitebox setting and F S for blackbox setting. component in our framework. Compared to PO GAN structure, our Feature-Conditional Structure gives more flexibility in modeling ID features, and achieves better matching accuracy. In combination with distilled knowledge from F S , the Generator produces a big jump in accuracy and close the gap to real faces to only 2.02% and 2.72% on LFW in whitebox and blackbox settings, respectively. By further incorporating the bijective metric, these gaps are further reduced to only 0.6% and 0.65% for the two settings.
Reconstructions against different Face Recognition Engines. To illustrate the accuracy of our propose structure, we validate the its performance against different face recognition engines as shown in Table 3. All Generators are set to blackbox mode and only the final extracted features are accessible. Our reconstructed faces are able to maintain the ID information and achieve competitive accuracy as real faces. These performance again emphasizes the accuracy of our model in capturing behaviours of the feature extraction functions F and provides high quality reconstructions.

Conclusions.
This work has presented a novel generative structure with Bijective Metric Learning for feature reconstruction problem to unveil the subjects' faces given their deep blackboxed features. Thanks to the introduced Bijective Metric and Distillation Knowledge, our DibiGAN effectively maximizes the information to be exploited from a given blackbox face matcher. Experiments on a wide range of in-thewild face variations against different face matching engines demonstrated the advantages of our method on synthesizing realistic faces with subject's visual identity.