Here I have written a code to load images then after that what should I do to split those images into three folders ; train, test and validation using ratios 70%, 15% and 15% respectively.
from os import listdir
from PIL import Image as PImage
import split_folders
import os, os.path
import numpy as np
#imgs.append(Image.open(os.path.join(path,image))
def loadImages(path):
imagesList = listdir(path)
loadedImages = []
for image in imagesList:
with open(os.path.join(path, image), 'rb') as i:
img = PImage.open(i)
loadedImages.append(img)
return loadedImages
path = "./Inputs/"
imgs = loadImages(path)
for img in imgs:
print(img)
train, validate, test = np.split(imgs.sample(frac=1), [int(.7*len(imgs)), int(.85*len(imgs))])
this is wrong since this not supports list object
So any solution?