Skip to Content
  • Proceeding Paper
  • Open Access

16 April 2026

7 Pages

Facial Attribute Prediction Using Knowledge Distillation †

,
,
,
,
,
and
1
Department of CSE, University of Asia Pacific, Dhaka 1205, Bangladesh
2
Department of CS, University of Calgary, Calgary, AB T2N 1N4, Canada
3
Department of CSE, University of Central Florida, Orlando, FL 32816, USA
*
Author to whom correspondence should be addressed.

Abstract

The rising need for intelligent applications on resource-limited devices presents a significant challenge. The deployment of big, high-accuracy deep learning models is impractical due to their processing costs. This thesis examines this issue in the realm of face attribute analysis. We present an approach for multi-attribute prediction (age, gender, ethnicity) using knowledge distillation to develop a model that is both highly accurate and computationally economical. The methodology comprises a two-phase technique utilizing the UTKFace dataset. A substantial, high-capacity “teacher” model, with a ResNet50 architecture, is trained to attain state-of-the-art precision in predicting age, gender, and ethnicity. Consequently, the extensive, intricate understanding from this educator is conveyed to a considerably smaller and more efficient “student” model utilizing a MobileNetV2 architecture. The transfer is accomplished by instructing the learner using both the accurate labels and the softened probability distributions produced by the teacher. The findings indicate that the distilled student model attains prediction accuracy nearly equivalent to that of its larger instructor model across all variables, while markedly decreasing model size and inference duration. The findings also confirm that knowledge distillation is a viable and efficient method for creating high-performance facial analysis systems appropriate for real-world implementation on mobile, edge, and other resource-constrained platforms.

1. Introduction

In the 21st century, digital photos have changed how we use technology and talk to each other. More and more, visual data is becoming an important and common source of information. Every day, billions of pictures are shared on social media. There are huge networks of surveillance cameras watching public places, and personal devices employ cameras built into them. The proliferation of digital information has enabled computers to process visual data in fundamentally new ways. This advancement has led to the development of complex algorithms capable of extracting meaningful information from images and videos on a scale previously considered unattainable. A notable application of this technology is the estimation of facial attributes such as age, gender, and ethnicity. Accurate and efficient prediction of these attributes has significant implications across domains, including business and science. For instance, in business, facial trait estimation plays a central role in next-generation personalized marketing and targeted advertising. Real-time systems that identify demographic groups can dynamically adjust content, product recommendations, and user experiences to enhance relevance and appeal. Such technologies also contribute to the design of adaptive and intuitive interfaces in human–computer interaction.
The rapid progress in this area is largely attributable to deep learning. The transition from traditional machine learning approaches, which relied on handcrafted features, to deep learning models capable of autonomously learning feature representations has been transformative. Convolutional neural networks (CNNs) have become the standard in computer vision applications. Architectures such as ResNet50, a 50-layer deep residual network, have demonstrated exceptional performance in learning complex hierarchical features from large-scale datasets such as ImageNet. Their deep structure enables the capture of both low-level edges and textures as well as high-level semantic concepts, making them highly effective for facial attribute estimation. When trained on diverse facial datasets such as UTKFace, these models can discern subtle visual cues that reveal age, gender, and ethnicity.

3. Methodology

3.1. Data Processing and Model Training

3.1.1. Data Processing

The data were preprocessed before training and testing. PyTorch’s (Version 2.5.1) Dataset class was employed to index image files and define the procedure for loading individual data points. Image transformations were subsequently applied to prepare the data for the model and enhance it through augmentation techniques. The dataset was then partitioned using random_split into a training set (80%) and a testing set (20%). Each subset was wrapped in a DataLoader to enable efficient processing, with batches consisting of 32 samples. Images were converted into PyTorch tensors, and pixel values were rescaled to the floating-point range [0.0,1.0]. To align classification targets with this scale and stabilize multi-task training, age values extracted from file names were normalized to [0.0,1.0].

3.1.2. Training Model

We developed a multi-task knowledge distillation framework that transfers deep knowledge from a ResNet50 teacher to a lightweight MobileNetV2 student for accurate and efficient facial attribute prediction (age, gender, and race). We trained a MultiAttributeModel based on Res-Net50 to set a high-performance baseline. Then, we trained a MultiAttributeModel based on MobileNetV2 from the ground up using only the correct labels. Next, we trained a MultiAttributeModel based on MobileNetV2 using our own MultiTaskDistillationLoss.
The results show how useful our suggested method is. The standard ResNet50 and MobileNetV2 models have a fully connected layer at the end that classifies images into 1000 classes in ImageNet. We changed the last layer of these models to an nn.Identity() layer so that they work for our needs. This cuts off the network’s head, turning the whole pre-trained architecture into a strong, fixed-size feature extractor. The modified backbone produces a high-dimensional feature vector that gives a detailed semantic summary of the input facial image. The overall loss function for the distilled student was a weighted combination, controlled by an alpha hyperparameter (e.g., 0.7), balancing the contribution of the hard losses (from ground-truth labels) and the soft, distilled losses (from the teacher’s guidance). The learning rate is 1 × 10−4.
After training, the teacher model was tested on a set of data that it had never seen before to see how well it could generalize. We monitored the training process of the teacher model to ensure its stability. The training logs from the Jupyter notebook show that the model learned well on all three tasks.

3.2. Result and Analysis

We used a custom MultiTaskDistillationLoss to train the student. This loss is a mix of a hard loss and a soft loss. For age, we used mean squared error (MSE) to see how close the teachers guess the student’s age. For gender and ethnicity, we used KL divergence loss on probabilities that have been softened by temperature to copy how the teacher classifies things.

3.2.1. Dataset

We obtained a dataset from Kaggle (UTKFace). It is a large-scale, challenging “In-the-Wild” Dataset with over 23,000 images. We split this data into 80% for training and 20% for testing.

3.2.2. Results

We trained and tested all of the models on the UTKFace dataset. For the age regression task, the evaluation metrics are mean absolute error (MAE). For the gender and race classification tasks, the metrics are classification accuracy, precision, recall, F1-score, and confusion matrices (Table 1, Figure 1).
Table 1. Accuracy of the model.
Figure 1. Teacher model training metrics, per epoch iteration.
The training metrics of the teacher model across 10 epochs are presented in Figure 2, Figure 3 and Figure 4. The total multi-task loss decreased consistently, beginning at approximately 1.57 and reaching 0.24 by the final epoch. The MAE for the age prediction task (non-normalized) also declined steadily, indicating effective learning of the age regression task. Classification accuracy for both gender and race improved rapidly during training. By epoch 10, gender accuracy increased from 73% to 97.29%, while race accuracy rose from 65% to 96.50%. The plot_training_metrics function illustrates these learning curves, confirming the observed trends: the loss decreased smoothly, and the accuracy improved steadily. These results suggest that the model avoided overfitting and successfully learned transferable features applicable to broader contexts.
Figure 2. Comparison of student models age prediction accuracy (distilled vs. non-distilled).
Figure 3. Comparison of student models gender prediction accuracy (distilled vs. non-distilled).
Figure 4. Comparison of student models race prediction accuracy (distilled vs. non-distilled).

4. Conclusions

This thesis investigates the trade-off between prediction accuracy and inference speed in modern deep learning. It focuses on multi-attribute facial prediction, aiming to design a lightweight yet accurate model for age, gender, and race estimation. The proposed approach enables efficient deployment on resource-constrained devices such as mobile and edge systems.

Author Contributions

Conceptualization, M.S. and T.A.; methodology, M.Z.; software, M.A.M.; validation, M.S. and S.M.A.; formal analysis, M.Z.; investigation, M.A.; resources, S.H.A.; data curation, S.M.A.; writing—original draft preparation, S.H.A.; writing—review and editing, T.A.; visualization, M.S.; supervision, T.A.; project administration, M.S. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

We obtained a dataset from Kaggle (UTKFace).

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Kalayeh, M.; Gong, B.; Shah, M. Improving facial attribute prediction using semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Honolulu, HI, USA, 21–26 July 2017; pp. 4227–4235. [Google Scholar]
  2. Abdulnabi, A.H.; Wang, G.; Lu, J.; Jia, K. Multi-task CNN model for attribute prediction. IEEE Trans. Multimed. 2015, 17, 1949–1959. [Google Scholar] [CrossRef] [Scilit]
  3. Huang, C.; Li, Y.; Loy, C.C.; Tang, X. Deep imbalanced learning for face recognition and attribute prediction. IEEE Trans. Pattern Anal. Mach. Intell. 2019, 42, 2781–2794. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  4. Huang, Y.; Chen, J.; Ouyang, W.; Wan, W.; Xue, Y. Image captioning with end-to-end attribute detection and subsequent attributes prediction. IEEE Trans. Image Process. 2020, 29, 4013–4026. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  5. Park, W.; Kim, D.; Lu, Y.; Cho, M. Relational knowledge distillation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Long Beach, CA, USA, 15–20 June 2019; pp. 3962–3971. [Google Scholar]
  6. He, K.; Zhang, X.; Ren, S.; Sun, J. Deep residual learning for image recognition. arXiv 2015, arXiv:1512.03385. [Google Scholar] [CrossRef] [Scilit]
  7. Cho, J.H.; Hariharan, B. On the efficacy of knowledge distillation. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), Seoul, Republic of Korea, 27 October–2 November 2019; pp. 4794–4802. [Google Scholar]
  8. Kim, S.; Park, Y.; Lee, E.C. Knowledge distillation for enhanced age and gender prediction accuracy. Mathematics 2024, 12, 2647. [Google Scholar] [CrossRef] [Scilit]
  9. Phuong, M.; Lampert, C.H. Towards understanding knowledge distillation. In Proceedings of the International Conference on Machine Learning (ICML), Long Beach, CA, USA, 9–15 June 2019; pp. 5142–5151. [Google Scholar]
  10. Zhang, Z.; Song, Y.; Qi, H. Age progression/regression by conditional adversarial autoencoder. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Honolulu, HI, USA, 21–26 July 2017; pp. 4352–4360. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.