image_output_1.png
import matplotlib.pyplot as plt

import os

import os

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import numpy as np
import pandas as pd
import os

import os
directories = ['../input/csc4851-homework4/birds_400/test', '../input/csc4851-homework4/birds_400/train', '../input//csc4851-homework4/birds_400/valid']
for dir in directories:
    label = []
    path = []
    for dirname, _, filenames in os.walk(dir):
        for filename in filenames:
            label.append(os.path.split(dirname)[1])
            path.append(os.path.join(dirname, filename))
    if dir == directories[0]:
        df_test = pd.DataFrame(columns=['path', 'label'])
        df_test['path'] = path
        df_test['label'] = label
    elif dir == directories[1]:
        df_train = pd.DataFrame(columns=['path', 'label'])
        df_train['path'] = path
        df_train['label'] = label
    elif dir == directories[2]:
        df_valid = pd.DataFrame(columns=['path', 'label'])
        df_valid['path'] = path
        df_valid['label'] = label

fig, axes = plt.subplots(nrows=3, ncols=5, figsize=(15, 7), subplot_kw={'xticks': [], 'yticks': []})
df_sample = df_train.sample(15)
df_sample.reset_index(drop=True, inplace=True)
for i, ax in enumerate(axes.flat):
    ax.imshow(plt.imread(df_sample.path[i]))
    ax.set_title(df_sample.label[i])
plt.tight_layout()
plt.show()