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

AttributeError: 'PosixPath' object has no attribute 'rstrip' #32

Closed surbhiagrawal22 closed 2 years ago

surbhiagrawal22 commented 2 years ago
import splitfolders
input_folder=pathlib.Path("/content/drive/MyDrive/StanfordCarsDataset/train")
print(input_folder)
output=pathlib.Path("/content/drive/MyDrive/StanfordCarsDataset/Train_val_split")
print(output)
# Split with a ratio.
# To only split into training and validation set, set a tuple to `ratio`, i.e, `(.8, .2)`.
splitfolders.ratio(input_folder, output=output,
    seed=1337, ratio=(.8, .2, ), group_prefix=None, move=True) # default values

I am using the above code for splitting images and getting below error

Copying files: 0 files [00:00, ? files/s]

AttributeError Traceback (most recent call last) in () 8 # To only split into training and validation set, set a tuple to ratio, i.e, (.8, .2). 9 splitfolders.ratio(input_folder, output=output, ---> 10 seed=1337, ratio=(.8, .2, ), group_prefix=None, move=True) # default values

4 frames /usr/lib/python3.7/shutil.py in _basename(path) 524 # Thus we always get the last component of the path, even for directories. 525 sep = os.path.sep + (os.path.altsep or '') --> 526 return os.path.basename(path.rstrip(sep)) 527 528 def move(src, dst, copy_function=copy2):

AttributeError: 'PosixPath' object has no attribute 'rstrip'

jfilter commented 2 years ago

Thanks, fixed in the new version 0.5.1.