Column Name | Data Type | Significance | Valid Values |
---|---|---|---|
name_face_align | String | The name and path of the file upon which FairFace made predictions | [filepath] |
race_preds_fair7 | String | The predicted race of the image subject | [White|Black|Latino_Hispanic|East Asian|Southeast Asian|Middle Eastern|Indian] |
gender_preds_fair | String | The predicted gender of the image subject | [Male|Female] |
age_preds_fair | String | The predicted age range of the image subject | ['0-2'|'3-9'|'10-19'|'20-29'|'30-39'|'40-49'|'50-59'|'60-69'|'70+'] |
2 Data
Pursuant to the study, the team sought out multiple datasets on which we could evaluate the performance of two selected recognition models (Karkkainen and Joo 2021; Serengil and Ozpinar 2021) to generate performance data and perform statistical analysis on their ability to accurately identify race, age, and gender of a subject in a photograph.
Collectively, we landed on the UTK dataset to perform our evaluation (“UTKFace” 2021). The dataset has three main sets available for download from the main page: A set of “in-the-wild” faces, which are the raw unprocessed images. The second set is the Aligned & Cropped Faces, which have been cut down to allow facial algorithms to read them more easily. The final file is the Landmarks (68 points) dataset, which contains the major facial landmark points that algorithms use and process to examine the images.
2.1 Data Selection
2.1.1 Motivation
Joy Buolamwini, a PhD candidate at MIT Media Lab, published a paper on gender and racial biases in facial recognition in algorithms (Buolamwini 2023). In her paper, she tested facial recongition softwares from multiple large technology companies such as Microsoft, IBM, and Amazon on its effectiveness for different demographic groups. Her research led to a surprising conclusion that most AI algorithms offer a substantially less accurate prediction for feminine/female faces, particularly those with dark skin color.
To determine the degree in which bias is still present in modern facial recognition models, a dataset which comprise of face images with high diversity in regards to ethnicity is required. Upon searching, UTKFace came out as one of the largest datasets which fit our preferred qualifications.
2.1.2 Data Collection Method
The dataset utilized for this research is UTKFace dataset. It is a publicly available large scale face dataset non-commercial on Github. The dataset was created by Yang Song and Zhifei Zhang, researchers at Adobe and PhD candidates at The University of Tennessee, Knoxville. On its Github page, it is specified that the images were collected from the internet. They appear to be obtained through the application of technique such as web scraping. The dataset contains more than 24,000 face images, representing a highly diversified demographics. However, face images vary in pose, facial expression, lighting, and resolution.
2.1.3 Dataset Features
The input dataset provided feature information natively in each filename without additional external data. The features contained therein include the following items for each image’s subject. They are defined as follows:
- “[race] is an integer from 0 to 4, denoting White, Black, Asian, Indian, and Others (like Hispanic, Latino, Middle Eastern).”
- “[gender] is either 0 (male) or 1 (female)”
- “[age] is an integer from 0 to 116, indicating the age”
As our work is focused in potential biases in protected classes such as race, gender, and age, the features of UTKFace are sufficient to meet the needs for an input dataset for category prediction in our selected models. Examples of the source dataset images are in Figure 2.1.
2.1.4 Sources and Influences of Bias in the Dataset
Facial datasets can be extremely hard to categorize correctly, never mind reducing bias overall. Facial features that are androgynous or defer from the average features of the set can often be misrepresented or reported incorrectly. Those with features that make them look younger or older than their actual age may also be difficult for a computer to accurately guess.
The datasets used for analysis contain solely male/masculine and female/feminine faces. As stated above, the faces are labelled either 0, for male, or 1, for female. There are no gender non-conforming/non-binary/trans faces or people reported in the datasets, which could introduce potential bias. This absence of an entire category of facial features could also result in inaccurate guesses should these faces be added to the data later.
The datasets do not report nationality or ethnicity. This can introduce inaccuracy in the part of the identification, and it also may identify the face in a racial group that the person identified would consider inaccurate. This is as much a matter of potentially inaccurate data as it is social labels. There is also a level of erasure associated with simply creating a “multi-racial” category, given that it would bin all multiracial faces together with no further consideration. That is to say, there is no ideal solution to the issue at this time. However, it is always worth pointing out potential biases in data, research, and analysis.
The data given in the UTK dataset is composed purely of people who have their faces on the internet. This introduces a potential sampling bias. Given the topic, it is also likely to come from populations well-versed in technology. This can often exclude rural populations. Thus, the facial data present can be skewed towards urban residents or other characteristics, which can potentially create “lurking variables” that we aren’t aware of within the data. This is a common problem that many Anthropological and Sociological studies face when collecting and analyzing data. Being aware of the possibility is often the first, and most crucial, step towards reducing it.
Our source dataset, and thus our results and conclusions, are dependent on the correctness of labeling of images within the UTK dataset. Given that the dataset was web-scraped, we do not know the degree of care placed on dataset labeling during web-scraping. Any incorrect labels present in the data can skew our results.
Overall, all the given potential biases listed above are simply the largest and most easily identified. It is possible that other sources of bias are present in the data that we haven’t noticed. And identifying these biases does not mean that the data is not sound, or that any conclusions drawn from it are invalid. It simply indicates that further research should be done and that this data is far from the most complete picture of human facial features and identification. Examples of what is in the data, as well as a visualization of the bias present in the data, can be seen in Figure 2.2.
2.1.5 Exploration of Source Data
For initial exploration of the UTKFace dataset, we sought to determine the distribution of age, given other categorical variables. To support hypothesis testing, such as z-tests, t-tests, or proportionality tests, it is important for us to inspect our data for a normal distribution. In our case, we are only able to initially inspect age, as it is the only numerical variable from our data available.
Examining the data in Figure 2.2, we have a somewhat normal distribution of age with heavy tails, centered between the ages of 30 and 35. To examine distributions of categorical variables, we will perform a bootstrapped sampling of proportions of such variables, and include them in our results section. Having such distributions will provide normal distributions and support us in evaluating our results.
An interactive figure showcasing the distributions of various data factors in the image dataset, and showcasing the underlying data.
2.1.6 Assumption of Sample Independence
For each of the selected facial recognition models, we assume that each model’s training dataset is independent of the content of the UTKFace dataset. Independence between each model’s output and the source data is a requirement for performing our testing. We have no means or methods to verify whether or not any UTKFace images were used in the training of either model, and must make this assumption before moving forward in our methods and results.
2.2 Selected Models
2.2.1 FairFace
Developed by researchers at University of California, Los Angeles, FairFace was specifically designed to mitigate gender and racial biases. The model (Karkkainen and Joo 2021) was trained on 100K+ face images of people of various ethnicities with approximately equal stratification across all groups. Beside facial recognition model, FairFace also provided the dataset (Karkkainen and Joo 2021) which it was trained on. The dataset is immensely popular among facial recognition algorithm developers. Owing to its reputation in bias mitigation, FairFace appears to be a valuable piece for the objective of this research.
2.2.2 DeepFace
DeepFace is a lightweight open-source model developed and used by Meta (Facebook). Being developed by one of the largest social media companies, it is widely known among developers. Therefore, its popularity prompts us to evaluate its performance. It should be noted that the DeepFace model we leverage in our evaluation is a free open source version (Serengil and Ozpinar 2021). It is highly unlikely that this version is as advanced as any model Meta uses internally for proprietary purposes. We should not view the resulting output of this model as being representative of algorithms internal to Meta.
2.2.3 FairFace Outputs
FairFace outputs provided predictions age and race, and two different predictions for race - one based upon their “Fair4” model, and the other based upon their “Fair7” model. In addition to these predictions, the output included scores for each category. With the nature of our planned analyses, the scores are of less importance to us in our evaluation.
To examine more in detail on “Fair” and “Fair4” models, the latter provided predictions of race in the following categories: [White, Black, Asian, Indian]. Of note, the “Fair4” model omitted “Other” categories as listed in the race category for the UTK dataset. However, the “Fair7” model provides predictions across [White, Black, Latino_Hispanic, East Asian, Southeast Asian, Indian, Middle Eastern]. We elected to use the Fair7 model, and to refactor the output categories to match those of the UTK dataset. Namely, we refactored instances of Middle Eastern and Latino_Hispanic as “Other” and instances of “East Asian” and “Southeast Asian” as “Asian” to match the categories explicitly listed in UTKFace.
Additionally, FairFace only provides a predicted age range as opposed to a specific, single, predicted age as a string. To enable comparison of actual values to the predicted values, we maintained this column as a categorical variable, and split it into a lower and upper bound of predicted age as an integer in the event we require it for our analyses.
With the above considerations in mind, the following output features are of import to the team:
2.2.4 DeepFace Outputs
Default outputs provide a wide range of information for the user. In addition to providing its predictions, DeepFace also provides scores associated with each evaluation on a per-class basis (i.e. 92% for Race #1, 3% Race #2, 1% Race #3, and 4% Race #4). For our planned analyses, the score features are of less concern to us.
We focus on the following select features from DeepFace outputs to have the ability to cross-compare between UTKFace, FairFace, and DeepFace:
Column Name | Data Type | Significance | Valid Values |
---|---|---|---|
Age | Integer | The predicted age of the image subject | Any Integer |
Dominant Gender | String | The predicted gender of the iamge subject | [Man|Woman] |
Dominant Race | String | The predicted race of the image subject | [middle eastern|asian|white|latino hispanic|black|indian] |
2.3 Evaluating Permutations of Inputs and Models for Equitable Evaluation
Aside from the differences in the outputs of each model in terms of age, race, and gender, there are also substantial differences between FairFace and DeepFace in terms of their available settings when attempting to categorize and predict the features associated with an image.
The need for this permutation evaluation rose from some initial scripting and testing of these models on a small sample of images from another facial dataset. We immediately grew concerned with DeepFace’s performance using default settings (namely, enforcing requirement to detect a face prior to categorization/prediction, and using OpenCV as the default detection backend). Running these initial scripting tests, we encountered a face detection failure rate, and thus a prediction failure rate, in DeepFace of approximately 70%.
We performed further exploratory analysis on both models in light of these facts, and sought some specific permutations of settings to determine which may provide the most fair and equitable comparison of the models prior to proceeding to analysis.
The goal for us in performing this exploration was to identify the settings for each model that might best increase the likelihood that the model’s output would result in a failure to reject our null hypotheses; our tests sought out the combination of settings that give each model the benefit of the doubt, and for each to deliver the greatest accuracy in their predictions. For simplicity’s sake, we leaned solely on the proportion of true positives across each category when compared with the source information to decide which settings to use.
2.3.1 DeepFace Analysis Options
DeepFace has a robust degree of available settings when performing facial categorization and recognition. These include enforcing facial detection prior to classification of an image, as well as 8 different facial detection models to detect a face prior to categorization. The default of these settings is OpenCV detection with detection enabled. Other detection backends include ssd, dlib, mtcnn, retinaface, mediapipe, yolov8, yunet, and fastmtcnn.
In a Python 3.8 environment, attempting to run detections using dlib, fastmtcnn, retinaface, mediapipe, yolov8, and yunet failed to run, or failed to install the appropriate models directly from source during execution. Repairing any challenges or issues with the core functionality of DeepFace and FairFace’s code is outside the scope of our work, and as such, we have excluded any of these non-functioning models from our settings permutation evaluation.
2.3.2 FairFace Analysis Options
The default script from FairFace provided no options via its command line script to change runtime settings. It uses dlib/resnet34 models for facial detection and image preprocessing, and uses its own Fair4 and Fair7 models for categorization. There are no other options or flags that can be set by a user when processing a batch of images.
We converted the simple script to a class in Python without addressing any feature bugs or errors in the underlying code. This change provided us some additional options when performing the analysis of an input image using FairFace - namely, the ability to analyze and categorize an image with or without facial detection, like the functionality of DeepFace. FairFace remains limited in the fact that is only detection model backend is built in dlib, but this change from a script to a class object gave us more options when considering what type of images to use and what settings to use on both models before generating our final dataset for analysis.
2.3.3 Specific Permutations
With the above options in mind, we designed the following permutations for evaluation on a subset of the UTK dataset:
Detection | Detection Model | Image Source |
---|---|---|
Enabled | FairFace=Dlib; DeepFace=OpenCV | Pre-cropped |
Enabled | FairFace=Dlib; DeepFace=OpenCV | In-The-Wild |
Enabled | FairFace=Dlib; DeepFace=mtcnn | Pre-cropped |
Enabled | FairFace=Dlib; DeepFace=mtcnn | In-The-Wild |
Disabled | FairFace,DeepFace=None | Pre-cropped |
Disabled | FairFace,DeepFace=None | In-The-Wild |
We processed each of the above setting permutations against approximately 9800 images, consisting of images from part 1 of 3 from the UTK dataset. Each of the cropped images (cropped_UTK_dataset.csv) and uncropped images (uncropped_UTK_dataset.csv) came from the same underlying subject in each image; the only difference between each image was whether or not it was pre-processed before evaluation by each model. Having the same underlying source subject enables us to perform a direct comparison of results between cropped vs. in-the-wild images, and better support a conclusion of which settings to use.
pred_model | detection_model | image_type | all_rate | age_grp_rate | gender_rate | race_rate |
---|---|---|---|---|---|---|
DeepFace | None | cropped | 0.07 | 0.16 | 0.67 | 0.70 |
DeepFace | None | uncropped | 0.08 | 0.15 | 0.73 | 0.65 |
DeepFace | mtcnn | cropped | 0.09 | 0.15 | 0.72 | 0.68 |
DeepFace | mtcnn | uncropped | 0.10 | 0.16 | 0.78 | 0.67 |
DeepFace | opencv | cropped | 0.03 | 0.08 | 0.19 | 0.20 |
DeepFace | opencv | uncropped | 0.08 | 0.15 | 0.66 | 0.59 |
FairFace | None | cropped | 0.40 | 0.61 | 0.89 | 0.77 |
FairFace | None | uncropped | 0.10 | 0.27 | 0.76 | 0.45 |
FairFace | dlib | cropped | 0.40 | 0.61 | 0.89 | 0.77 |
FairFace | dlib | uncropped | 0.44 | 0.62 | 0.92 | 0.79 |
Examining the true positive ratios for each case, our team concluded that the settings that gave both models the best chance for success in correctly predicting the age, gender, and race of subject images are as follows:
FairFace: enforce facial detection with dlib, and use uncropped images for evaluation
DeepFace: enforce facial detection with MTCNN detection backend and use uncropped images for evaluation.
These settings are equitable and make a degree of sense. Using facial detection, specifically coded for each model, should give each model the ability to isolate the portions of a face necessary for them to make a prediction, as opposed to using a pre-cropped image that could include unneeded information, or exclude needed information.
Having decided on these settings, our team proceeded to run the entirety of the UTK dataset through both DeepFace and FairFace models using a custom coded script that allowed us to apply multiprocessing across the list of images and evaluate all items in a reasonable amount of time.
Due to the resource-intensive design of FairFace, our script enables multiprocessing of FairFace to allow for multiple simultaneous instances of the FairFace class as a pool of worker threads to iterate over the source data.
We attempted the same multiprocessing methodology for DeepFace, but encountered issues with silent errors and halting program execution when iterating over all images using DeepFace. To alleviate this challenge, we processed DeepFace in a single-threaded manner, and with smaller portions of the dataset vs. pursuing an all-in-one go execution. We proceeded to store the data for each of these smaller runs in multiple output files to combine once we completed all processing requirements.
2.4 Model Evaluation Data Format
The final listing of all inputs and outputs from each model, with standardization methods discussed in this section applied, are summarized in Table 2.5.
Column Name | Definition | Data Type |
---|---|---|
img_path | Relative path location of the file within the UTK dataset | character vector |
file | The filename of each file within the UTK dataset | character vector |
src_age | The age of the subject in each image from the UTK dataset | integer |
src_gender | The gender of the subject in each image from the UTK dataset | character vector |
src_race | The race of the subject in each image from the UTK datset | character vector |
src_timestamp | The time at which the image was submitted to the UTK dataset | character vector |
src_age_grp | The age group (matching the predicted age ranges from the FairFace outputs) for each image in the UTK dataset | character vector |
pred_model | The model used to produce the predicted output (FairFace or DeepFace) | character vector |
pred_race | The race of the subject in the image, predicted by the given prediction model under the pred_model column | character vector |
pred_gender | The gender of the subject in the image, predicted by the given prediction model under the pred_model column | character vector |
pred_age_DF_only | The integer-predicted age by DeepFace of the subject in the image | integer |
pred_age_grp | The age group of the subject in the image, predicted by the given prediction model under the pred_model column | character vector |
pred_age_lower | The integer lower bound of the predicted age group | integer |
pred_age_upper | The integer upper bound of the predicted age group | integer |