jfilter / split-folders

🗂 Split folders with files (i.e. images) into training, validation and test (dataset) folders
MIT License
414 stars 72 forks source link

What if I want to take exactly 200 files from each folder for training and rest for validation/test #20

Closed iam8github closed 4 years ago

iam8github commented 4 years ago

Hey @jfilter ,

First of all, let me admire your efforts for making our lives so easy by developing this very handy tool. However, there is problem for imbalanced number of files in folders. In my case I want to keep exactly 200 files for training and rest for the test/validation regardless of how many files left for test/validation. If I do so following your code guidelines;

To only split into training and validation set, use a single number to fixed, i.e., 10.

I got the following assertion error. Could you please help me to resolve this issue.

TypeError Traceback (most recent call last)

in () 7 8 #no_files ----> 9 sp.fixed(data_dir, output=output_dir, seed=13, fixed=200, oversample=False, group_prefix=None) # default values /usr/local/lib/python3.6/dist-packages/splitfolders/split.py in fixed(input, output, seed, fixed, oversample, group_prefix) 96 fixed = fixed 97 ---> 98 assert len(fixed) in (1, 2) 99 100 if tqdm_is_installed: TypeError: object of type 'int' has no len()
jfilter commented 4 years ago

Thanks for reporting, fixed in new version 0.4.3. In 0.4.2 please use it like this: (200,).

iam8github commented 4 years ago

Thanks for reporting, fixed in new version 0.4.3. In 0.4.2 please use it like this: (200,).

Thank you for update, How to use the updated version?

jfilter commented 4 years ago

Thank you for update, How to use the updated version?

Like this:

sp.fixed(data_dir, output=output_dir, seed=13, fixed=200, oversample=False, group_prefix=None)