text_plain_output_1.png
from tensorflow.keras.preprocessing.image import ImageDataGenerator, load_img

import os

import pandas as pd

train_dir = '/kaggle/input/happy-sad-7125/train/'
test_dir = '/kaggle/input/happy-sad-7125/test/'
row, col = (48, 48)
classes = 2
def count_exp(path, set_):
    dict_ = {}
    for expression in os.listdir(path):
        dir_ = path + expression
        dict_[expression] = len(os.listdir(dir_))
    df = pd.DataFrame(dict_, index=[set_])
    return df
train_count = count_exp(train_dir, 'train')
test_count = count_exp(test_dir, 'test')

train_datagen = ImageDataGenerator(rescale=1.0 / 255, zoom_range=0.4, horizontal_flip=True)
training_set = train_datagen.flow_from_directory(train_dir, batch_size=16, target_size=(48, 48), shuffle=True, color_mode='grayscale', class_mode='categorical')
test_datagen = ImageDataGenerator(rescale=1.0 / 255)
test_set = test_datagen.flow_from_directory(test_dir, batch_size=15, target_size=(48, 48), shuffle=True, color_mode='grayscale', class_mode='categorical')