Commit 2d7471e5 authored by Gunasinghe M.D.'s avatar Gunasinghe M.D.

Upload New File

parent 748938ce
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Gunasinghe M.D.
"""
# Image Preprocessing for train, test and validation sets
import os
import random
import glob
def prepare_test_data(n):
base_path = "shapes"
f1 = random.sample(glob.glob(os.path.join(base_path, "test/circles") + "/*"), n)
f2 = random.sample(glob.glob(os.path.join(base_path, "test/squares") + "/*"), n)
f3 = random.sample(glob.glob(os.path.join(base_path, "test/triangles") + "/*"), n)
for c in f1:
os.remove(c)
for s in f2:
os.remove(s)
for t in f3:
os.remove(t)
def prepare_validation_data(n):
base_path = "shapes"
f1 = random.sample(glob.glob(os.path.join(base_path, "validation/circles") + "/*"), n)
f2 = random.sample(glob.glob(os.path.join(base_path, "validation/squares") + "/*"), n)
f3 = random.sample(glob.glob(os.path.join(base_path, "validation/triangles") + "/*"), n)
for c in f1:
os.remove(c)
for s in f2:
os.remove(s)
for t in f3:
os.remove(t)
# n = number of samples to remove from each categorical folder
prepare_test_data(70)
prepare_validation_data(40)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment