Abstract
We use CNNs to build a system that both classifies images of faces based on a variety of different facial attributes and generates new faces given a set of desired facial characteristics. After introducing the problem and providing context in the first section, we discuss recent work related to image generation in Section 2. In Section 3, we describe the methods used to fine-tune our CNN and generate new images using a novel approach inspired by a Gaussian mixture model. In Section 4, we discuss our working dataset and describe our preprocessing steps and handling of facial attributes. Finally, in Sections 5, 6 and 7, we explain our experiments and results and conclude in the following section. Our classification system has 82% test accuracy. Furthermore, our generation pipeline successfully creates well-formed faces.
1. Introduction
Generating realistic images based on specific descriptive traits—such as "a middle-aged man with brown hair and glasses"—is a significant challenge in computer vision. Traditionally, this task has been the domain of specialized generative architectures like Generative Adversarial Networks (GANs) or Variational Autoencoders (VAEs). This research explores an alternative: can a standard, pre-trained classification Convolutional Neural Network (CNN) be repurposed to generate well-formed faces? By reverse-engineering the hidden layers of a discriminative model, we aim to bypass the need for training complex generative models from scratch.
2. Related Work
At the time of this study, state-of-the-art image generation primarily relied on computationally intensive models. Restricted Boltzmann Machines (RBMs), Autoencoders, and GANs were the standard. While effective, these models often require massive datasets and significant training time. Our approach investigates whether the rich feature representations learned by a classifier like VGG-Face can be inverted to synthesize new visual data.
3. Methods
Our system operates in two distinct phases: attribute classification and image generation.
3.1 Classification and Fine-Tuning
We utilize the pre-trained 16-layer VGG-Face network as our backbone. To adapt it for attribute recognition, we modify the architecture by attaching 42 multi-label softmax heads to the fc-7 layer. These heads are designed to classify 73 different facial attributes. To provide the network with implicit context, we group highly correlated attributes (e.g., various hair colors) into single multi-label classifiers.
3.2 Generation via Feature Inversion
Our initial attempt at generation used standard class visualization. This baseline method starts with a mean image plus noise and uses gradient descent to update pixels to maximize a target attribute score. However, this failed to produce coherent faces, often resulting in "monstrous" images with overlapping or duplicate features (e.g., multiple noses).
To overcome this, we introduced a custom Gaussian Mixture Model (cGMM) for feature inversion. Instead of maximizing a final score, we target specific activations in a hidden layer. We model the distribution of activations for each attribute as an independent multivariate Gaussian. To generate a novel face, we calculate a weighted sum of samples from the relevant Gaussians to construct a target feature map. We then optimize the input pixels to match this "hallucinated" activation pattern.
4. Datasets
We employed a subset of the PubFig Dataset, comprising approximately 28,000 images (20,000 for training and 8,000 for testing). Each image is annotated with 73 attributes, ranging from gender and ethnicity to specific accessories like eyewear.
A critical observation during data preparation was the presence of severe class imbalances. For instance, 76% of the subjects are labeled as white, while only 3% are black. Similarly, 90% of the subjects do not wear glasses. These skews significantly impact the model's ability to generate diverse features.
5. Key Insights
A primary takeaway is that standard class visualization lacks spatial awareness; the network knows what a feature looks like but not where or how many should exist. Feature inversion solves this by providing a structural blueprint. By modeling the latent space distributions, we can mathematically "mix" traits to estimate the neural activations of a face that does not yet exist.
6. Results
The fine-tuned VGG-Face model achieved an average test accuracy of 81.5% across all 73 attributes. In the generation phase, the cGMM feature inversion successfully produced coherent, structurally sound faces from random noise, effectively solving the "multiple feature" problem of the baseline. While the generated faces were well-formed, they tended to resemble the training set's mean image, with requested attributes appearing subtle rather than highly distinct.
7. Conclusion and Future Work
This research demonstrates that a classification CNN can indeed serve as a generative engine. However, the current cGMM approach is limited by its assumption of attribute independence—ignoring real-world correlations like "gray hair" and "senior." Future work will focus on training with more diverse datasets to mitigate bias and exploring direct sampling from Gaussians to introduce greater variety in the generated outputs. Comparing this CNN-only approach against VAEs will also provide deeper insights into the trade-offs between model complexity and generation quality.
Summary updated