Skip to content

πŸ“ Repo for python_splitter Python package. This package can split Images into Train, Test, Validation folders automatically by shuffling media/images for machine learning.

License

Notifications You must be signed in to change notification settings

bharatadk/python_splitter

Repository files navigation

Python Splitter Downloads


Open Sauced

πŸ• Open Sauced πŸ•

The path to your next Open Source contribution

Currently experimenting and planning! More Features will be added soon...

Developed by Bharat Adhikari (c) 2022

#Installation:
pip install python_splitter

Examples of How To Use

Grouping Images into Classes

import python_splitter
python_splitter.image_to_class('SOURCE_FOLDER')

image

Creating Train-Test folders (With Random-Shuffling Enabled)

import python_splitter
$ python_splitter.split_from_folder("SOURCE_FOLDER", train = 0.5, test = 0.3, val = 0.2)
$ python_splitter.split_from_folder("SOURCE_FOLDER", train = 0.5, test = 0.3)
# Note: Both above code gives same result because 0.5+0.3=0.8 . 
	   So, val = 0.2 is calculated automatically.
$ python_splitter.split_from_folder("SOURCE_FOLDER", train = 0.5, test = 0.5)
But, this will not create "val" folder because train+test=0.5+0.5 =1.0
# SOURCE_FOLDER = PATH_TO_THE_FOLDER_CONTAINING_IMAGE_CLASSES_FOLDERS

image

The splitted folder (train, test, and val) will be inside "Train_Test_Folder/"

import os

$ python_splitter.split_from_folder("SOURCE_FOLDER", train = 0.5, test = 0.3, val = 0.2)

$ print(os.listdir('Train_Test_Folder/')) # ['train', 'test', 'val']

To Access splitted folder (train, test, and val)

import os

$ print(os.listdir('Train_Test_Folder/train/')) # ['cat', 'dog', 'pig']
$ print(os.listdir('Train_Test_Folder/test/')) # ['cat', 'dog', 'pig']
$ print(os.listdir('Train_Test_Folder/val/')) # ['cat', 'dog', 'pig']

Starred By

About

πŸ“ Repo for python_splitter Python package. This package can split Images into Train, Test, Validation folders automatically by shuffling media/images for machine learning.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages