text_plain_output_1.png image_output_1.png
import cv2

import numpy as np

import os

import numpy as np
import pandas as pd
import cv2
from IPython.display import Image
import matplotlib.pyplot as plt
import os
import tensorflow as tf
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split

onlyfiles = os.listdir('../input/utkface_aligned_cropped/UTKFace')
y = np.array([[[i.split('_')[0]], [i.split('_')[1]]] for i in onlyfiles])

X_data = []
for file in onlyfiles:
    face = cv2.imread('../input/utkface_aligned_cropped/UTKFace/' + file, cv2.IMREAD_COLOR)
    face = cv2.cvtColor(face, cv2.COLOR_BGR2RGB)
    face = cv2.resize(face, (32, 32))
    X_data.append(face)
X_data = np.array(X_data)
X_data.shape