application_vnd.jupyter.stderr_output_1.png
from tensorflow.keras.preprocessing.image import ImageDataGenerator, load_img

import matplotlib.pyplot as plt

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')

plt.figure(figsize=(14, 22))
i = 1
for expression in os.listdir(train_dir):
    img = load_img(train_dir + expression + '/' + os.listdir(train_dir + expression)[1])
    plt.subplot(1, 7, i)
    plt.imshow(img)
    plt.title(expression)
    plt.axis('off')
    i += 1
plt.show()