text_plain_output_1.png image_output_1.png
from tensorflow.keras.preprocessing.image import load_img, img_to_array

import numpy as np

import pandas as pd

data = pd.read_csv('../input/hardfakevsrealfaces/data.csv')

height, width = (128, 128)
X = np.empty((data.shape[0], height, width, 3))
for i in range(data.shape[0]):
    img = load_img('../input/hardfakevsrealfaces/{}/{}.jpg'.format(data.loc[i, 'label'], data.loc[i, 'images_id']), target_size=(height, width))
    X[i] = img_to_array(img)
X.shape

def changeLabels(x):
    return labels[x]
labels = data.label.unique()
labels = {labels[i]: i for i in range(labels.size)}
y = data.label.apply(changeLabels)
y[:5]