text_plain_output_1.png
from imutils import paths

from tqdm import tqdm

data_dir = '../input/super-hero/Q4-superheroes_image_data/'
train_dir = data_dir + 'CAX_Superhero_Train'
test_dir = data_dir + 'CAX_Superhero_Test'

def create_img_df(dir):
    img_list = list(paths.list_images(dir))
    data = pd.DataFrame(columns=['File_name', 'Target'])
    for i, ipaths in tqdm(enumerate(img_list), total=len(img_list)):
        data.loc[i, 'image_path'] = ipaths
        data.loc[i, 'File_name'] = os.path.basename(ipaths)
        data.loc[i, 'Target'] = os.path.split(os.path.dirname(ipaths))[-1]
    return data

train_csv = create_img_df(train_dir)

plt.figure(figsize=(10, 6))
g = sns.countplot(train_csv['Target'])
g.set_xticklabels(g.get_xticklabels(), rotation=40)