How to split folder with images into train, val and test?

Viewed 1741

I am using colab and I have a folder with images. How to split them into three folders with images with random splitting? I want there to be 0.8 in train, 0.1 in val and 0.1 in test. I tried splitfolders library:

splitfolders.ratio("content/data", output="output", seed=1337, ratio=(.8, .1, .1), group_prefix=None) 

but new folder didn't appear. and its not clear what would their names be. How to do that? Are there any other solutions?

Pytorch solutions are very welcomed

1 Answers

Try this in your computer.

I'm using this code in my project

import splitfolders 

#### input dataset that want to split
input_folder = 'D:/Raw_DS'  

output_folder= 'D:/Splitted_DS'

splitfolders.ratio(input_folder, output= output_folder, seed=1337, ratio = (0.8, 0.1, 0.1))
Related