text_plain_output_1.png
import os

import shutil

import numpy as np
import pandas as pd
import os

basedir = '/kaggle/input/5-flower-types-classification-dataset/flower_images'

source_path_orchid = os.path.join(basedir, 'Orchid')
source_path_sunflower = os.path.join(basedir, 'Sunflower')
source_path_tulip = os.path.join(basedir, 'Tulip')
source_path_lotus = os.path.join(basedir, 'Lotus')
source_path_lilly = os.path.join(basedir, 'Lilly')

import shutil
root_dir = '/kaggle/working/fiveflowers'
if os.path.exists(root_dir):
    shutil.rmtree(root_dir)
def create_train_val_dirs(root_path):
    os.makedirs(os.path.join(root_path, 'training'))
    os.makedirs(os.path.join(f'{root_path}/training', 'Lilly'))
    os.makedirs(os.path.join(f'{root_path}/training', 'Lotus'))
    os.makedirs(os.path.join(f'{root_path}/training', 'Orchid'))
    os.makedirs(os.path.join(f'{root_path}/training', 'Sunflower'))
    os.makedirs(os.path.join(f'{root_path}/training', 'Tulip'))
    os.makedirs(os.path.join(root_path, 'validation'))
    os.makedirs(os.path.join(f'{root_path}/validation', 'Lilly'))
    os.makedirs(os.path.join(f'{root_path}/validation', 'Lotus'))
    os.makedirs(os.path.join(f'{root_path}/validation', 'Orchid'))
    os.makedirs(os.path.join(f'{root_path}/validation', 'Sunflower'))
    os.makedirs(os.path.join(f'{root_path}/validation', 'Tulip'))
try:
    create_train_val_dirs(root_path=root_dir)
except FileExistsError:
    print('You should not be seeing this since the upper directory is removed beforehand')
for rootdir, dirs, files in os.walk(root_dir):
    for subdir in dirs:
        print(os.path.join(rootdir, subdir))