{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "9435ed50-a826-497d-8aaf-4e2816f72e2c",
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import Image, display, HTML\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import ast\n",
    "\n",
    "df = pd.read_csv('labels_consensus.csv')\n",
    "df = df.reset_index(drop=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "f40d45a3-bdec-4241-830d-9f5a669fa503",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Function to convert the string to a list (if it's a string representation of a list)\n",
    "def safe_eval(value):\n",
    "    try:\n",
    "        return ast.literal_eval(value)\n",
    "    except (ValueError, SyntaxError):\n",
    "        return value  # If it's not a list-like string, just return the value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "c55576cf-40b0-4171-b854-d3d4301ea041",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Function to extract the item based on row index and the row_selection list\n",
    "def get_item_from_list(value, selection_index):\n",
    "    if isinstance(value, list):\n",
    "        return value[selection_index] if len(value) > selection_index else value[0]  # If list is smaller, return the first item\n",
    "    return value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "0482f18a-a8e8-4e6a-9648-53724ad891e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['male', 'female', \"['male', 'female']\", 'unknown',\n",
       "       \"['female', 'male']\"], dtype=object)"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Gender\"].unique()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62581b67-feb6-43c9-8926-e9ee9f61a0b3",
   "metadata": {},
   "source": [
    "### \"['male', 'female']\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "6215be41-f7b1-42e0-b079-b5a531132aa5",
   "metadata": {
    "scrolled": true,
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>File Name</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Age</th>\n",
       "      <th>Skin Color</th>\n",
       "      <th>Ancestry</th>\n",
       "      <th>Hair Color</th>\n",
       "      <th>Bangs</th>\n",
       "      <th>Bald</th>\n",
       "      <th>Beard</th>\n",
       "      <th>Glasses</th>\n",
       "      <th>Headwear</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2102</th>\n",
       "      <td>African/m.011y5k/m.011y5k_0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>dark</td>\n",
       "      <td>black</td>\n",
       "      <td>black</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>sun</td>\n",
       "      <td>unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6211</th>\n",
       "      <td>African/m.02qw2p3/m.02qw2p3_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>dark</td>\n",
       "      <td>black</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9176</th>\n",
       "      <td>African/m.03y6h1x/m.03y6h1x_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>dark</td>\n",
       "      <td>black</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9526</th>\n",
       "      <td>African/m.02z07fq/m.02z07fq_0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>dark</td>\n",
       "      <td>black</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13006</th>\n",
       "      <td>Asian/m.0g5rq7d/m.0g5rq7d_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>regular</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14264</th>\n",
       "      <td>Asian/m.0fsc4gr/m.0fsc4gr_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>brown</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14265</th>\n",
       "      <td>Asian/m.0fsc4gr/m.0fsc4gr_0004.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>brown</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14308</th>\n",
       "      <td>Asian/m.03qdlyn/m.03qdlyn_0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16405</th>\n",
       "      <td>Asian/m.0sgqn1b/m.0sgqn1b_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16537</th>\n",
       "      <td>Asian/m.07jrtd/m.07jrtd_0004.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16661</th>\n",
       "      <td>Asian/m.04ydpy4/m.04ydpy4_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>medium</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17211</th>\n",
       "      <td>Asian/m.01lsq_/m.01lsq__0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>medium</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>headband</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17214</th>\n",
       "      <td>Asian/m.043pzvx/m.043pzvx_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>['black', 'brown']</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21321</th>\n",
       "      <td>Caucasian/m.0zwh1k1/m.0zwh1k1_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>senior</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>gray</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21898</th>\n",
       "      <td>Caucasian/m.0gcr4zx/m.0gcr4zx_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>blonde</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22914</th>\n",
       "      <td>Caucasian/m.0705mg/m.0705mg_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22915</th>\n",
       "      <td>Caucasian/m.0705mg/m.0705mg_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23280</th>\n",
       "      <td>Caucasian/m.01387g/m.01387g_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24056</th>\n",
       "      <td>Caucasian/m.0gff83x/m.0gff83x_0005.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29654</th>\n",
       "      <td>Caucasian/m.028cfp/m.028cfp_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29883</th>\n",
       "      <td>Caucasian/m.01vt556/m.01vt556_0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>cap</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32155</th>\n",
       "      <td>Indian/m.02prw88/m.02prw88_0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>mustache</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32605</th>\n",
       "      <td>Indian/m.0279kcr/m.0279kcr_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33688</th>\n",
       "      <td>Indian/m.02ppgk7/m.02ppgk7_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33689</th>\n",
       "      <td>Indian/m.02ppgk7/m.02ppgk7_0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>['young', 'middle-aged']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>sun</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35532</th>\n",
       "      <td>Indian/m.05zm76x/m.05zm76x_0001.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>unknown</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37983</th>\n",
       "      <td>Indian/m.0gbztt_/m.0gbztt__0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38550</th>\n",
       "      <td>Indian/m.0n52w7s/m.0n52w7s_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38792</th>\n",
       "      <td>Indian/m.0k0p44f/m.0k0p44f_0002.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>young</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>mustache</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39737</th>\n",
       "      <td>Indian/m.0ghmnt/m.0ghmnt_0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39941</th>\n",
       "      <td>Indian/m.02sk83/m.02sk83_0003.jpg</td>\n",
       "      <td>['male', 'female']</td>\n",
       "      <td>senior</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>gray</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>regular</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    File Name              Gender  \\\n",
       "2102       African/m.011y5k/m.011y5k_0003.jpg  ['male', 'female']   \n",
       "6211     African/m.02qw2p3/m.02qw2p3_0002.jpg  ['male', 'female']   \n",
       "9176     African/m.03y6h1x/m.03y6h1x_0002.jpg  ['male', 'female']   \n",
       "9526     African/m.02z07fq/m.02z07fq_0003.jpg  ['male', 'female']   \n",
       "13006      Asian/m.0g5rq7d/m.0g5rq7d_0001.jpg  ['male', 'female']   \n",
       "14264      Asian/m.0fsc4gr/m.0fsc4gr_0001.jpg  ['male', 'female']   \n",
       "14265      Asian/m.0fsc4gr/m.0fsc4gr_0004.jpg  ['male', 'female']   \n",
       "14308      Asian/m.03qdlyn/m.03qdlyn_0003.jpg  ['male', 'female']   \n",
       "16405      Asian/m.0sgqn1b/m.0sgqn1b_0001.jpg  ['male', 'female']   \n",
       "16537        Asian/m.07jrtd/m.07jrtd_0004.jpg  ['male', 'female']   \n",
       "16661      Asian/m.04ydpy4/m.04ydpy4_0001.jpg  ['male', 'female']   \n",
       "17211        Asian/m.01lsq_/m.01lsq__0003.jpg  ['male', 'female']   \n",
       "17214      Asian/m.043pzvx/m.043pzvx_0002.jpg  ['male', 'female']   \n",
       "21321  Caucasian/m.0zwh1k1/m.0zwh1k1_0002.jpg  ['male', 'female']   \n",
       "21898  Caucasian/m.0gcr4zx/m.0gcr4zx_0002.jpg  ['male', 'female']   \n",
       "22914    Caucasian/m.0705mg/m.0705mg_0001.jpg  ['male', 'female']   \n",
       "22915    Caucasian/m.0705mg/m.0705mg_0002.jpg  ['male', 'female']   \n",
       "23280    Caucasian/m.01387g/m.01387g_0001.jpg  ['male', 'female']   \n",
       "24056  Caucasian/m.0gff83x/m.0gff83x_0005.jpg  ['male', 'female']   \n",
       "29654    Caucasian/m.028cfp/m.028cfp_0001.jpg  ['male', 'female']   \n",
       "29883  Caucasian/m.01vt556/m.01vt556_0003.jpg  ['male', 'female']   \n",
       "32155     Indian/m.02prw88/m.02prw88_0003.jpg  ['male', 'female']   \n",
       "32605     Indian/m.0279kcr/m.0279kcr_0001.jpg  ['male', 'female']   \n",
       "33688     Indian/m.02ppgk7/m.02ppgk7_0002.jpg  ['male', 'female']   \n",
       "33689     Indian/m.02ppgk7/m.02ppgk7_0003.jpg  ['male', 'female']   \n",
       "35532     Indian/m.05zm76x/m.05zm76x_0001.jpg  ['male', 'female']   \n",
       "37983     Indian/m.0gbztt_/m.0gbztt__0003.jpg  ['male', 'female']   \n",
       "38550     Indian/m.0n52w7s/m.0n52w7s_0002.jpg  ['male', 'female']   \n",
       "38792     Indian/m.0k0p44f/m.0k0p44f_0002.jpg  ['male', 'female']   \n",
       "39737       Indian/m.0ghmnt/m.0ghmnt_0003.jpg  ['male', 'female']   \n",
       "39941       Indian/m.02sk83/m.02sk83_0003.jpg  ['male', 'female']   \n",
       "\n",
       "                            Age Skin Color     Ancestry          Hair Color  \\\n",
       "2102                middle-aged       dark        black               black   \n",
       "6211                middle-aged       dark        black               black   \n",
       "9176                    unknown       dark        black               black   \n",
       "9526                      young       dark        black               black   \n",
       "13006                     young      light        asian               black   \n",
       "14264                     young      light        asian               brown   \n",
       "14265                     young      light        asian               brown   \n",
       "14308                     young      light        asian               black   \n",
       "16405                   unknown      light        asian               black   \n",
       "16537                     young      light        asian             unknown   \n",
       "16661                   unknown     medium        asian               black   \n",
       "17211                   unknown     medium        asian               black   \n",
       "17214                     young      light        asian  ['black', 'brown']   \n",
       "21321                    senior      light        white                gray   \n",
       "21898               middle-aged      light        white              blonde   \n",
       "22914                   unknown      light        white             unknown   \n",
       "22915                     young      light        white             unknown   \n",
       "23280                   unknown    unknown      unknown             unknown   \n",
       "24056               middle-aged    unknown      unknown             unknown   \n",
       "29654                     young      light        white               black   \n",
       "29883                     young      light        white               black   \n",
       "32155               middle-aged     medium  south_asian               black   \n",
       "32605                     young     medium  south_asian               black   \n",
       "33688                     young     medium  south_asian               black   \n",
       "33689  ['young', 'middle-aged']    unknown  south_asian               black   \n",
       "35532               middle-aged    unknown  south_asian               black   \n",
       "37983               middle-aged     medium  south_asian               black   \n",
       "38550                   unknown     medium  south_asian               black   \n",
       "38792                     young     medium  south_asian               black   \n",
       "39737                   unknown    unknown  south_asian               black   \n",
       "39941                    senior     medium  south_asian                gray   \n",
       "\n",
       "         Bangs Bald     Beard  Glasses  Headwear  \n",
       "2102   unknown   no   unknown      sun   unknown  \n",
       "6211        no   no   unknown       no        no  \n",
       "9176        no   no        no       no        no  \n",
       "9526        no   no        no       no        no  \n",
       "13006      yes   no        no  regular        no  \n",
       "14264      yes   no        no       no        no  \n",
       "14265      yes   no        no       no        no  \n",
       "14308       no   no        no       no        no  \n",
       "16405  unknown   no        no       no        no  \n",
       "16537       no   no        no       no        no  \n",
       "16661       no   no        no       no        no  \n",
       "17211      yes   no        no       no  headband  \n",
       "17214      yes   no        no       no        no  \n",
       "21321       no   no        no       no        no  \n",
       "21898      yes   no   stubble       no        no  \n",
       "22914       no   no        no       no        no  \n",
       "22915       no   no   stubble       no        no  \n",
       "23280       no   no   unknown       no        no  \n",
       "24056       no   no   unknown       no        no  \n",
       "29654       no   no   unknown       no        no  \n",
       "29883      yes   no        no       no       cap  \n",
       "32155       no   no  mustache       no        no  \n",
       "32605       no   no   stubble       no        no  \n",
       "33688      yes   no   unknown       no        no  \n",
       "33689       no   no   stubble      sun        no  \n",
       "35532  unknown   no        no       no        no  \n",
       "37983       no   no   unknown       no        no  \n",
       "38550       no   no        no       no        no  \n",
       "38792       no   no  mustache       no        no  \n",
       "39737      yes   no        no       no        no  \n",
       "39941       no  yes        no  regular        no  "
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df[\"Gender\"] == \"['male', 'female']\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "9387dbf1-7e88-462a-92d8-ef674d90d308",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/African/m.011y5k/m.011y5k_0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/African/m.02qw2p3/m.02qw2p3_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/African/m.03y6h1x/m.03y6h1x_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/African/m.02z07fq/m.02z07fq_0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.0g5rq7d/m.0g5rq7d_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.0fsc4gr/m.0fsc4gr_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.0fsc4gr/m.0fsc4gr_0004.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.03qdlyn/m.03qdlyn_0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.0sgqn1b/m.0sgqn1b_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.07jrtd/m.07jrtd_0004.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.04ydpy4/m.04ydpy4_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.01lsq_/m.01lsq__0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.043pzvx/m.043pzvx_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.0zwh1k1/m.0zwh1k1_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.0gcr4zx/m.0gcr4zx_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.0705mg/m.0705mg_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.0705mg/m.0705mg_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.01387g/m.01387g_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.0gff83x/m.0gff83x_0005.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.028cfp/m.028cfp_0001.jpg\" style=\"height: 100px;\"></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.01vt556/m.01vt556_0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.02prw88/m.02prw88_0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.0279kcr/m.0279kcr_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.02ppgk7/m.02ppgk7_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.02ppgk7/m.02ppgk7_0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.05zm76x/m.05zm76x_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.0gbztt_/m.0gbztt__0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.0n52w7s/m.0n52w7s_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.0k0p44f/m.0k0p44f_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.0ghmnt/m.0ghmnt_0003.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.02sk83/m.02sk83_0003.jpg\" style=\"height: 100px;\"></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for i in range(4):\n",
    "    image_filenames = df[df[\"Gender\"] == \"['male', 'female']\"][\"File Name\"].tolist()[i * 20: (i+1) * 20]\n",
    "    image_filenames = np.char.add('../RFW/data/', image_filenames)\n",
    "    images_html = \"\".join(\n",
    "        f'<div style=\"margin: 2px; text-align: center;\"><img src=\"{image_path}\" style=\"height: 100px;\"></div>'\n",
    "        for image_path in image_filenames\n",
    "    )\n",
    "    html = f'<div style=\"display:flex;align-items:center;justify-content:center;\">{images_html}</div>'\n",
    "    display(HTML(html))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "5a7ae69b-f9c6-4ccc-a0e1-eccd820caa18",
   "metadata": {},
   "outputs": [],
   "source": [
    "row_selection = [0,0,0,1,1,1,1,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "a994ff34-31b6-4f86-8a62-2e762e289a20",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2102,  6211,  9176,  9526, 13006, 14264, 14265, 14308, 16405,\n",
       "       16537, 16661, 17211, 17214, 21321, 21898, 22914, 22915, 23280,\n",
       "       24056, 29654, 29883, 32155, 32605, 33688, 33689, 35532, 37983,\n",
       "       38550, 38792, 39737, 39941])"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array(df[df[\"Gender\"] == \"['male', 'female']\"].index.tolist())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "a01aa148-d832-4330-bea7-b552bb542c41",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i, (j, row) in enumerate(df[df[\"Gender\"] == \"['male', 'female']\"].applymap(safe_eval).iterrows()):\n",
    "    for column in df.columns:\n",
    "        df.at[j, column] = get_item_from_list(row[column], row_selection[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "5f0da84c-a59c-4188-b6ec-e91a4e53433b",
   "metadata": {
    "scrolled": true,
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>File Name</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Age</th>\n",
       "      <th>Skin Color</th>\n",
       "      <th>Ancestry</th>\n",
       "      <th>Hair Color</th>\n",
       "      <th>Bangs</th>\n",
       "      <th>Bald</th>\n",
       "      <th>Beard</th>\n",
       "      <th>Glasses</th>\n",
       "      <th>Headwear</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2102</th>\n",
       "      <td>African/m.011y5k/m.011y5k_0003.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>dark</td>\n",
       "      <td>black</td>\n",
       "      <td>black</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>sun</td>\n",
       "      <td>unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6211</th>\n",
       "      <td>African/m.02qw2p3/m.02qw2p3_0002.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>dark</td>\n",
       "      <td>black</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9176</th>\n",
       "      <td>African/m.03y6h1x/m.03y6h1x_0002.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>unknown</td>\n",
       "      <td>dark</td>\n",
       "      <td>black</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9526</th>\n",
       "      <td>African/m.02z07fq/m.02z07fq_0003.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>dark</td>\n",
       "      <td>black</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13006</th>\n",
       "      <td>Asian/m.0g5rq7d/m.0g5rq7d_0001.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>regular</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14264</th>\n",
       "      <td>Asian/m.0fsc4gr/m.0fsc4gr_0001.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>brown</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14265</th>\n",
       "      <td>Asian/m.0fsc4gr/m.0fsc4gr_0004.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>brown</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14308</th>\n",
       "      <td>Asian/m.03qdlyn/m.03qdlyn_0003.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16405</th>\n",
       "      <td>Asian/m.0sgqn1b/m.0sgqn1b_0001.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>unknown</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16537</th>\n",
       "      <td>Asian/m.07jrtd/m.07jrtd_0004.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16661</th>\n",
       "      <td>Asian/m.04ydpy4/m.04ydpy4_0001.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>unknown</td>\n",
       "      <td>medium</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17211</th>\n",
       "      <td>Asian/m.01lsq_/m.01lsq__0003.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>unknown</td>\n",
       "      <td>medium</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>headband</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17214</th>\n",
       "      <td>Asian/m.043pzvx/m.043pzvx_0002.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21321</th>\n",
       "      <td>Caucasian/m.0zwh1k1/m.0zwh1k1_0002.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>senior</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>gray</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21898</th>\n",
       "      <td>Caucasian/m.0gcr4zx/m.0gcr4zx_0002.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>blonde</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22914</th>\n",
       "      <td>Caucasian/m.0705mg/m.0705mg_0001.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>unknown</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22915</th>\n",
       "      <td>Caucasian/m.0705mg/m.0705mg_0002.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23280</th>\n",
       "      <td>Caucasian/m.01387g/m.01387g_0001.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24056</th>\n",
       "      <td>Caucasian/m.0gff83x/m.0gff83x_0005.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29654</th>\n",
       "      <td>Caucasian/m.028cfp/m.028cfp_0001.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29883</th>\n",
       "      <td>Caucasian/m.01vt556/m.01vt556_0003.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>cap</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32155</th>\n",
       "      <td>Indian/m.02prw88/m.02prw88_0003.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>mustache</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32605</th>\n",
       "      <td>Indian/m.0279kcr/m.0279kcr_0001.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>young</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33688</th>\n",
       "      <td>Indian/m.02ppgk7/m.02ppgk7_0002.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>young</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33689</th>\n",
       "      <td>Indian/m.02ppgk7/m.02ppgk7_0003.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>young</td>\n",
       "      <td>unknown</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>sun</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35532</th>\n",
       "      <td>Indian/m.05zm76x/m.05zm76x_0001.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>unknown</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37983</th>\n",
       "      <td>Indian/m.0gbztt_/m.0gbztt__0003.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38550</th>\n",
       "      <td>Indian/m.0n52w7s/m.0n52w7s_0002.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>unknown</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38792</th>\n",
       "      <td>Indian/m.0k0p44f/m.0k0p44f_0002.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>young</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>mustache</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39737</th>\n",
       "      <td>Indian/m.0ghmnt/m.0ghmnt_0003.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>unknown</td>\n",
       "      <td>unknown</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39941</th>\n",
       "      <td>Indian/m.02sk83/m.02sk83_0003.jpg</td>\n",
       "      <td>male</td>\n",
       "      <td>senior</td>\n",
       "      <td>medium</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>gray</td>\n",
       "      <td>no</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>regular</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    File Name  Gender          Age Skin Color  \\\n",
       "2102       African/m.011y5k/m.011y5k_0003.jpg    male  middle-aged       dark   \n",
       "6211     African/m.02qw2p3/m.02qw2p3_0002.jpg    male  middle-aged       dark   \n",
       "9176     African/m.03y6h1x/m.03y6h1x_0002.jpg    male      unknown       dark   \n",
       "9526     African/m.02z07fq/m.02z07fq_0003.jpg  female        young       dark   \n",
       "13006      Asian/m.0g5rq7d/m.0g5rq7d_0001.jpg  female        young      light   \n",
       "14264      Asian/m.0fsc4gr/m.0fsc4gr_0001.jpg  female        young      light   \n",
       "14265      Asian/m.0fsc4gr/m.0fsc4gr_0004.jpg  female        young      light   \n",
       "14308      Asian/m.03qdlyn/m.03qdlyn_0003.jpg  female        young      light   \n",
       "16405      Asian/m.0sgqn1b/m.0sgqn1b_0001.jpg    male      unknown      light   \n",
       "16537        Asian/m.07jrtd/m.07jrtd_0004.jpg  female        young      light   \n",
       "16661      Asian/m.04ydpy4/m.04ydpy4_0001.jpg  female      unknown     medium   \n",
       "17211        Asian/m.01lsq_/m.01lsq__0003.jpg  female      unknown     medium   \n",
       "17214      Asian/m.043pzvx/m.043pzvx_0002.jpg    male        young      light   \n",
       "21321  Caucasian/m.0zwh1k1/m.0zwh1k1_0002.jpg    male       senior      light   \n",
       "21898  Caucasian/m.0gcr4zx/m.0gcr4zx_0002.jpg  female  middle-aged      light   \n",
       "22914    Caucasian/m.0705mg/m.0705mg_0001.jpg    male      unknown      light   \n",
       "22915    Caucasian/m.0705mg/m.0705mg_0002.jpg    male        young      light   \n",
       "23280    Caucasian/m.01387g/m.01387g_0001.jpg    male      unknown    unknown   \n",
       "24056  Caucasian/m.0gff83x/m.0gff83x_0005.jpg    male  middle-aged    unknown   \n",
       "29654    Caucasian/m.028cfp/m.028cfp_0001.jpg    male        young      light   \n",
       "29883  Caucasian/m.01vt556/m.01vt556_0003.jpg    male        young      light   \n",
       "32155     Indian/m.02prw88/m.02prw88_0003.jpg    male  middle-aged     medium   \n",
       "32605     Indian/m.0279kcr/m.0279kcr_0001.jpg    male        young     medium   \n",
       "33688     Indian/m.02ppgk7/m.02ppgk7_0002.jpg    male        young     medium   \n",
       "33689     Indian/m.02ppgk7/m.02ppgk7_0003.jpg    male        young    unknown   \n",
       "35532     Indian/m.05zm76x/m.05zm76x_0001.jpg    male  middle-aged    unknown   \n",
       "37983     Indian/m.0gbztt_/m.0gbztt__0003.jpg    male  middle-aged     medium   \n",
       "38550     Indian/m.0n52w7s/m.0n52w7s_0002.jpg    male      unknown     medium   \n",
       "38792     Indian/m.0k0p44f/m.0k0p44f_0002.jpg    male        young     medium   \n",
       "39737       Indian/m.0ghmnt/m.0ghmnt_0003.jpg    male      unknown    unknown   \n",
       "39941       Indian/m.02sk83/m.02sk83_0003.jpg    male       senior     medium   \n",
       "\n",
       "          Ancestry Hair Color    Bangs Bald     Beard  Glasses  Headwear  \n",
       "2102         black      black  unknown   no   unknown      sun   unknown  \n",
       "6211         black      black       no   no   unknown       no        no  \n",
       "9176         black      black       no   no        no       no        no  \n",
       "9526         black      black       no   no        no       no        no  \n",
       "13006        asian      black      yes   no        no  regular        no  \n",
       "14264        asian      brown      yes   no        no       no        no  \n",
       "14265        asian      brown      yes   no        no       no        no  \n",
       "14308        asian      black       no   no        no       no        no  \n",
       "16405        asian      black  unknown   no        no       no        no  \n",
       "16537        asian    unknown       no   no        no       no        no  \n",
       "16661        asian      black       no   no        no       no        no  \n",
       "17211        asian      black      yes   no        no       no  headband  \n",
       "17214        asian      black      yes   no        no       no        no  \n",
       "21321        white       gray       no   no        no       no        no  \n",
       "21898        white     blonde      yes   no   stubble       no        no  \n",
       "22914        white    unknown       no   no        no       no        no  \n",
       "22915        white    unknown       no   no   stubble       no        no  \n",
       "23280      unknown    unknown       no   no   unknown       no        no  \n",
       "24056      unknown    unknown       no   no   unknown       no        no  \n",
       "29654        white      black       no   no   unknown       no        no  \n",
       "29883        white      black      yes   no        no       no       cap  \n",
       "32155  south_asian      black       no   no  mustache       no        no  \n",
       "32605  south_asian      black       no   no   stubble       no        no  \n",
       "33688  south_asian      black      yes   no   unknown       no        no  \n",
       "33689  south_asian      black       no   no   stubble      sun        no  \n",
       "35532  south_asian      black  unknown   no        no       no        no  \n",
       "37983  south_asian      black       no   no   unknown       no        no  \n",
       "38550  south_asian      black       no   no        no       no        no  \n",
       "38792  south_asian      black       no   no  mustache       no        no  \n",
       "39737  south_asian      black      yes   no        no       no        no  \n",
       "39941  south_asian       gray       no  yes        no  regular        no  "
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[[ 2102,  6211,  9176,  9526, 13006, 14264, 14265, 14308, 16405,\n",
    "       16537, 16661, 17211, 17214, 21321, 21898, 22914, 22915, 23280,\n",
    "       24056, 29654, 29883, 32155, 32605, 33688, 33689, 35532, 37983,\n",
    "       38550, 38792, 39737, 39941]]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "189ab14c-18ff-4bd2-bef1-fdc4a9829ae5",
   "metadata": {},
   "source": [
    "### \"['female', 'male']\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "aa8af17a-3718-4fe1-b86b-ff40a9f17a95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>File Name</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Age</th>\n",
       "      <th>Skin Color</th>\n",
       "      <th>Ancestry</th>\n",
       "      <th>Hair Color</th>\n",
       "      <th>Bangs</th>\n",
       "      <th>Bald</th>\n",
       "      <th>Beard</th>\n",
       "      <th>Glasses</th>\n",
       "      <th>Headwear</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10824</th>\n",
       "      <td>Asian/m.026xcqk/m.026xcqk_0001.jpg</td>\n",
       "      <td>['female', 'male']</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>regular</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15733</th>\n",
       "      <td>Asian/m.0668qy/m.0668qy_0002.jpg</td>\n",
       "      <td>['female', 'male']</td>\n",
       "      <td>young</td>\n",
       "      <td>medium</td>\n",
       "      <td>unknown</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20281</th>\n",
       "      <td>Caucasian/m.04gl6yr/m.04gl6yr_0002.jpg</td>\n",
       "      <td>['female', 'male']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>unknown</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27709</th>\n",
       "      <td>Caucasian/m.09chpl/m.09chpl_0005.jpg</td>\n",
       "      <td>['female', 'male']</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>['blonde', 'gray']</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37368</th>\n",
       "      <td>Indian/m.0gbzpk3/m.0gbzpk3_0001.jpg</td>\n",
       "      <td>['female', 'male']</td>\n",
       "      <td>young</td>\n",
       "      <td>unknown</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>hijab</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    File Name              Gender  \\\n",
       "10824      Asian/m.026xcqk/m.026xcqk_0001.jpg  ['female', 'male']   \n",
       "15733        Asian/m.0668qy/m.0668qy_0002.jpg  ['female', 'male']   \n",
       "20281  Caucasian/m.04gl6yr/m.04gl6yr_0002.jpg  ['female', 'male']   \n",
       "27709    Caucasian/m.09chpl/m.09chpl_0005.jpg  ['female', 'male']   \n",
       "37368     Indian/m.0gbzpk3/m.0gbzpk3_0001.jpg  ['female', 'male']   \n",
       "\n",
       "               Age Skin Color     Ancestry          Hair Color Bangs Bald  \\\n",
       "10824        young      light        asian               black   yes   no   \n",
       "15733        young     medium      unknown               black   yes   no   \n",
       "20281  middle-aged      light        white             unknown   yes   no   \n",
       "27709  middle-aged      light        white  ['blonde', 'gray']    no   no   \n",
       "37368        young    unknown  south_asian               black    no   no   \n",
       "\n",
       "         Beard  Glasses Headwear  \n",
       "10824       no  regular       no  \n",
       "15733       no       no       no  \n",
       "20281  stubble       no       no  \n",
       "27709       no       no       no  \n",
       "37368       no  unknown    hijab  "
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df[\"Gender\"] == \"['female', 'male']\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "d1e27e5f-65da-4aae-a1ea-bf45a3755bcc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.026xcqk/m.026xcqk_0001.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Asian/m.0668qy/m.0668qy_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.04gl6yr/m.04gl6yr_0002.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.09chpl/m.09chpl_0005.jpg\" style=\"height: 100px;\"></div><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Indian/m.0gbzpk3/m.0gbzpk3_0001.jpg\" style=\"height: 100px;\"></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for i in range(4):\n",
    "    image_filenames = df[df[\"Gender\"] == \"['female', 'male']\"][\"File Name\"].tolist()[i * 20: (i+1) * 20]\n",
    "    image_filenames = np.char.add('../RFW/data/', image_filenames)\n",
    "    images_html = \"\".join(\n",
    "        f'<div style=\"margin: 2px; text-align: center;\"><img src=\"{image_path}\" style=\"height: 100px;\"></div>'\n",
    "        for image_path in image_filenames\n",
    "    )\n",
    "    html = f'<div style=\"display:flex;align-items:center;justify-content:center;\">{images_html}</div>'\n",
    "    display(HTML(html))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "c58eec40-11e6-41ef-9ee7-d8e6018e56bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "row_selection = [0,0,0,0,0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "8c0d5201-d350-47c0-95d4-613ce4c11787",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([10824, 15733, 20281, 27709, 37368])"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array(df[df[\"Gender\"] == \"['female', 'male']\"].index.tolist())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "ed844dbc-fabe-4d18-9d07-152d8ec0352a",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i, (j, row) in enumerate(df[df[\"Gender\"] == \"['female', 'male']\"].applymap(safe_eval).iterrows()):\n",
    "    for column in df.columns:\n",
    "        df.at[j, column] = get_item_from_list(row[column], row_selection[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "656f9df4-3015-4977-8bc3-4f39a494202f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>File Name</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Age</th>\n",
       "      <th>Skin Color</th>\n",
       "      <th>Ancestry</th>\n",
       "      <th>Hair Color</th>\n",
       "      <th>Bangs</th>\n",
       "      <th>Bald</th>\n",
       "      <th>Beard</th>\n",
       "      <th>Glasses</th>\n",
       "      <th>Headwear</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10824</th>\n",
       "      <td>Asian/m.026xcqk/m.026xcqk_0001.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>light</td>\n",
       "      <td>asian</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>regular</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15733</th>\n",
       "      <td>Asian/m.0668qy/m.0668qy_0002.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>medium</td>\n",
       "      <td>unknown</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20281</th>\n",
       "      <td>Caucasian/m.04gl6yr/m.04gl6yr_0002.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>unknown</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>stubble</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27709</th>\n",
       "      <td>Caucasian/m.09chpl/m.09chpl_0005.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>middle-aged</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>blonde</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37368</th>\n",
       "      <td>Indian/m.0gbzpk3/m.0gbzpk3_0001.jpg</td>\n",
       "      <td>female</td>\n",
       "      <td>young</td>\n",
       "      <td>unknown</td>\n",
       "      <td>south_asian</td>\n",
       "      <td>black</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>unknown</td>\n",
       "      <td>hijab</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    File Name  Gender          Age Skin Color  \\\n",
       "10824      Asian/m.026xcqk/m.026xcqk_0001.jpg  female        young      light   \n",
       "15733        Asian/m.0668qy/m.0668qy_0002.jpg  female        young     medium   \n",
       "20281  Caucasian/m.04gl6yr/m.04gl6yr_0002.jpg  female  middle-aged      light   \n",
       "27709    Caucasian/m.09chpl/m.09chpl_0005.jpg  female  middle-aged      light   \n",
       "37368     Indian/m.0gbzpk3/m.0gbzpk3_0001.jpg  female        young    unknown   \n",
       "\n",
       "          Ancestry Hair Color Bangs Bald    Beard  Glasses Headwear  \n",
       "10824        asian      black   yes   no       no  regular       no  \n",
       "15733      unknown      black   yes   no       no       no       no  \n",
       "20281        white    unknown   yes   no  stubble       no       no  \n",
       "27709        white     blonde    no   no       no       no       no  \n",
       "37368  south_asian      black    no   no       no  unknown    hijab  "
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[[10824, 15733, 20281, 27709, 37368]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d3b76f5-dd53-4719-ae21-55a275e17eed",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cc9a4b12-007c-4ecf-b3d0-1d3c3df15464",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "b9a6ff93-d33e-44d1-8c3b-9357de456ee2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['young', 'senior', 'middle-aged', 'unknown',\n",
       "       \"['young', 'middle-aged']\"], dtype=object)"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Age\"].unique()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "25d3b38b-fe56-4a05-bab7-8ae19daf4771",
   "metadata": {},
   "source": [
    "### \"['young', 'middle-aged']\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "6b33274c-0a9e-4415-9165-b424589c7b4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>File Name</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Age</th>\n",
       "      <th>Skin Color</th>\n",
       "      <th>Ancestry</th>\n",
       "      <th>Hair Color</th>\n",
       "      <th>Bangs</th>\n",
       "      <th>Bald</th>\n",
       "      <th>Beard</th>\n",
       "      <th>Glasses</th>\n",
       "      <th>Headwear</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>30093</th>\n",
       "      <td>Caucasian/m.04cvpmr/m.04cvpmr_0005.jpg</td>\n",
       "      <td>unknown</td>\n",
       "      <td>['young', 'middle-aged']</td>\n",
       "      <td>light</td>\n",
       "      <td>white</td>\n",
       "      <td>black</td>\n",
       "      <td>yes</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    File Name   Gender  \\\n",
       "30093  Caucasian/m.04cvpmr/m.04cvpmr_0005.jpg  unknown   \n",
       "\n",
       "                            Age Skin Color Ancestry Hair Color Bangs Bald  \\\n",
       "30093  ['young', 'middle-aged']      light    white      black   yes   no   \n",
       "\n",
       "      Beard Glasses Headwear  \n",
       "30093    no      no       no  "
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df[\"Age\"] == \"['young', 'middle-aged']\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "dc324877-749b-49b6-a510-876e580d8a9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"><div style=\"margin: 2px; text-align: center;\"><img src=\"../ICCV 2025/RFW/data/Caucasian/m.04cvpmr/m.04cvpmr_0005.jpg\" style=\"height: 100px;\"></div></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style=\"display:flex;align-items:center;justify-content:center;\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for i in range(4):\n",
    "    image_filenames = df[df[\"Age\"] == \"['young', 'middle-aged']\"][\"File Name\"].tolist()[i * 20: (i+1) * 20]\n",
    "    image_filenames = np.char.add('../RFW/data/', image_filenames)\n",
    "    images_html = \"\".join(\n",
    "        f'<div style=\"margin: 2px; text-align: center;\"><img src=\"{image_path}\" style=\"height: 100px;\"></div>'\n",
    "        for image_path in image_filenames\n",
    "    )\n",
    "    html = f'<div style=\"display:flex;align-items:center;justify-content:center;\">{images_html}</div>'\n",
    "    display(HTML(html))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "27779a23-9acb-42df-af4b-a45e93ab2f85",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.iloc[30093]['Age'] = \"young\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4ba79498-5288-4901-9f6f-b9f2545cc165",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "eb454b4d-f201-4c1e-98b2-8f366686410c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['dark', 'unknown', 'medium', 'light'], dtype=object)"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Skin Color\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "d7150c13-d852-47d1-a8b5-ae09256bbbbb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['black', 'latino/hispanic', 'unknown', 'south_asian', 'asian',\n",
       "       'white', 'indigenous', 'middle_eastern'], dtype=object)"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Ancestry\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "0eed425b-f0bb-46b0-a251-142b373cdfac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['blonde', 'black', 'gray', 'unknown', 'brown', 'other', 'red', nan],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Hair Color\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "0ef09d5d-7aac-4245-9bdc-411bda76ce7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['no', 'yes', 'unknown'], dtype=object)"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Bangs\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "2de1d23a-dc23-4af4-bbaf-b8119906db58",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['no', 'yes', 'unknown'], dtype=object)"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Bald\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "0d667a8b-7690-4d2b-a5c4-5384febe328c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['unknown', 'stubble', 'no', 'mustache', 'full'], dtype=object)"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Beard\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "5198fda6-7808-44e6-8eb2-165f6916d771",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['no', 'sun', 'regular', 'unknown'], dtype=object)"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Glasses\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "a28a9d3e-c09d-4b10-bf76-ffa8eaae6a55",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['no', 'hat', 'cap', 'unknown', 'headband', 'helmet', 'turban',\n",
       "       'beanie', 'hijab'], dtype=object)"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Headwear\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5d5695eb-514b-4e8a-a564-d53f1fecb53e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "3168a858-6b8c-446e-8bd7-05148f02a9ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv('labels_RFW.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "02b28c77-1105-4a25-979e-536d72329967",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb04c204-800c-4065-918b-71fdb2e74cb5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "009dbd79-48d4-4db3-b957-f0a1e5e9b0c3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32c86e01-a849-4edf-b4b9-2cb999bc30ee",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
