text_plain_output_1.png
import os

import pandas as pd

root = '../input/104-flowers-garden-of-eden'
train_df = pd.DataFrame()
folder = os.listdir(root)
for f in folder:
    classes = os.listdir(os.path.join(root, f, 'train'))
    for c in classes:
        images = os.listdir(os.path.join(root, f, 'train', c))
        tmp_df = pd.DataFrame(images, columns=['image_name'])
        tmp_df['class'] = c
        tmp_df['folder'] = f
        tmp_df['type'] = 'train'
        train_df = train_df.append(tmp_df, ignore_index=True)
val_df = pd.DataFrame()
folder = os.listdir(root)
for f in folder:
    classes = os.listdir(os.path.join(root, f, 'val'))
    for c in classes:
        images = os.listdir(os.path.join(root, f, 'val', c))
        tmp_df = pd.DataFrame(images, columns=['image_name'])
        tmp_df['class'] = c
        tmp_df['folder'] = f
        tmp_df['type'] = 'val'
        val_df = val_df.append(tmp_df, ignore_index=True)

CLASSES = ['pink primrose', 'hard-leaved pocket orchid', 'canterbury bells', 'sweet pea', 'wild geranium', 'tiger lily', 'moon orchid', 'bird of paradise', 'monkshood', 'globe thistle', 'snapdragon', "colt's foot", 'king protea', 'spear thistle', 'yellow iris', 'globe-flower', 'purple coneflower', 'peruvian lily', 'balloon flower', 'giant white arum lily', 'fire lily', 'pincushion flower', 'fritillary', 'red ginger', 'grape hyacinth', 'corn poppy', 'prince of wales feathers', 'stemless gentian', 'artichoke', 'sweet william', 'carnation', 'garden phlox', 'love in the mist', 'cosmos', 'alpine sea holly', 'ruby-lipped cattleya', 'cape flower', 'great masterwort', 'siam tulip', 'lenten rose', 'barberton daisy', 'daffodil', 'sword lily', 'poinsettia', 'bolero deep blue', 'wallflower', 'marigold', 'buttercup', 'daisy', 'common dandelion', 'petunia', 'wild pansy', 'primula', 'sunflower', 'lilac hibiscus', 'bishop of llandaff', 'gaura', 'geranium', 'orange dahlia', 'pink-yellow dahlia', 'cautleya spicata', 'japanese anemone', 'black-eyed susan', 'silverbush', 'californian poppy', 'osteospermum', 'spring crocus', 'iris', 'windflower', 'tree poppy', 'gazania', 'azalea', 'water lily', 'rose', 'thorn apple', 'morning glory', 'passion flower', 'lotus', 'toad lily', 'anthurium', 'frangipani', 'clematis', 'hibiscus', 'columbine', 'desert-rose', 'tree mallow', 'magnolia', 'cyclamen ', 'watercress', 'canna lily', 'hippeastrum ', 'bee balm', 'pink quill', 'foxglove', 'bougainvillea', 'camellia', 'mallow', 'mexican petunia', 'bromelia', 'blanket flower', 'trumpet creeper', 'blackberry lily', 'common tulip', 'wild rose']

print('num class:', len(CLASSES))
train_df['label'] = train_df['class'].apply(lambda x: CLASSES.index(x))
val_df['label'] = val_df['class'].apply(lambda x: CLASSES.index(x))