221 - Easy way to split data on your disk into train, test, and validation?

DigitalSreeni
DigitalSreeni
32.7 هزار بار بازدید - 3 سال پیش - Code generated in the video
Code generated in the video can be downloaded from here:
https://github.com/bnsreenu/python_fo...

pip install split-folders

import splitfolders  # or import split_folders

input_folder = 'cell_images/'

Split with a ratio.
To only split into training and validation set, set a tuple to `ratio`, i.e, `(.8, .2)`.
#Train, val, test
splitfolders.ratio(input_folder, output="cell_images2",
                  seed=42, ratio=(.7, .2, .1),
                  group_prefix=None) # default values


Split val/test with a fixed number of items e.g. 100 for each set.
To only split into training and validation set, use a single number to `fixed`, i.e., `10`.
enable oversampling of imbalanced datasets, works only with fixed
splitfolders.fixed(input_folder, output="cell_images2",
                  seed=42, fixed=(35, 20),
                  oversample=False, group_prefix=None)
3 سال پیش در تاریخ 1400/03/19 منتشر شده است.
32,734 بـار بازدید شده
... بیشتر