text_plain_output_1.png
import numpy as np

import os

import os

train_images_dir = 'train_images'
train_maps_dir = 'train_labels'
val_images_dir = 'valid_images'
val_maps_dir = 'valid_labels'
test_images_dir = 'test_images'
test_maps_dir = 'test_labels'
train_images = np.array(os.listdir(train_images_dir), dtype=object)
train_maps = np.array(os.listdir(train_maps_dir), dtype=object)
val_images = np.array(os.listdir(val_images_dir), dtype=object)
val_maps = np.array(os.listdir(val_maps_dir), dtype=object)

def remove_folder_contents(folder):
    for the_file in os.listdir(folder):
        file_path = os.path.join(folder, the_file)
        try:
            if os.path.isfile(file_path):
                os.unlink(file_path)
            elif os.path.isdir(file_path):
                remove_folder_contents(file_path)
                os.rmdir(file_path)
        except Exception as e:
remove_folder_contents('./test_images')
remove_folder_contents('./test_labels')

split_data(test_images_dir, test_maps_dir, 0.2)
test_images = np.array(os.listdir(test_images_dir), dtype=object)
test_maps = np.array(os.listdir(test_maps_dir), dtype=object)
print('****TRAIN****')
print(f'There are {len(train_images)} images')
print(f'There are {len(train_maps)} masks')
print('****TEST****')
print(f'There are {len(test_images)} images')
print(f'There are {len(test_maps)} masks')