[Python] How to easily create Training, Validation, Test folders for multiple classification problems

Introduction

In the Multi Classes Classification problem, we will introduce how to divide your own image data into Training, Validation, and Test.

Thing you want to do

Suppose that the image data you have is in the input folder as shown in the figure below.

<img width="300", alt="image.png " src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/208980/bf6cf0ab-9452-272d-bfe8-8f0981b9182e.png "> I would like to divide the image data into training, validation, and test folders as shown in the figure below. <img width="300", alt="image.png ", src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/208980/7c1eae06-3cfd-8b31-7f0c-1ba898b1315b.png ">

Installation method

pip install split-folders

How to use

Create a Python program. Import the split-folders module and execute the code below.

import split_folders

# Split with a ratio.
# To only split into training and validation set, set a tuple to `ratio`, i.e, `(.8, .2)`.
split_folders.ratio('input_folder', output="output", seed=1337, ratio=(.8, .1, .1)) # default values


Related Documents

  1. [Split Folders]https://github.com/jfilter/split-folders

Recommended Posts

[Python] How to easily create Training, Validation, Test folders for multiple classification problems
How to define multiple variables in a python for statement
Create folders from '01' to '12' with python
How to create * .spec files for pyinstaller.
How to do portmanteau test with python
[Python] Organizing how to use for statements
How to use "deque" for Python data
How to build an environment for using multiple versions of Python on Mac
[Python] How to test command line parser click
How to create a Python virtual environment (venv)
How to create a JSON file in Python
[Python] How to draw multiple graphs with Matplotlib
How to install Python for pharmaceutical company researchers
How to create a shortcut command for LINUX
How to make Python faster for beginners [numpy]
Script to easily create a client device environment for AWS IoT (Python v2 version)
How to use NUITKA-Utilities hinted-compilation to easily create an executable file from a Python script
20th Offline Real-time How to Write Problems in Python
[BigQuery] How to use BigQuery API for Python -Table creation-
[For beginners] How to use say command in python!
Create your own Big Data in Python for validation
How to convert Python # type for Python super beginners: str
How to write string concatenation in multiple lines in Python
[For beginners] How to study Python3 data analysis exam
[Blender x Python] How to create an original object
How to run python in virtual space (for MacOS)
Prometheus client_python tips-How to create metrics for multiple targets
[Go] How to create a custom error for Sentry
How to create a local repository for Linux OS
How to create an image uploader in Bottle (Python)
[Python] How to create Correlation Matrix and Heat Map
How to retrieve multiple arrays using slice in python.
[Python] How to create a 2D histogram with Matplotlib
Python # How to check type and type for super beginners
[Introduction to Python] How to write repetitive statements using for statements
How to create a kubernetes pod from python code
[Python] Create multiple directories
How to install python
How to test that Exception is raised in python unittest
How to slice a block multiple array from a multiple array in Python
[python] How to use the library Matplotlib for drawing graphs
A simple way to avoid multiple for loops in Python
How to learn TensorFlow for liberal arts and Python beginners
How to make a Python package (written for an intern)
[Python Kivy] How to create a simple pop up window
How to use machine learning for work? 03_Python coding procedure
How to specify Cache-Control for blob storage in Azure Storage in Python
How to write a test for processing that uses BigQuery
How to implement Python EXE for Windows in Docker container
How to convert Python # type for Python super beginners: int, float
I didn't know how to use the [python] for statement
How to create a SAS token for Azure IoT Hub
13th Offline Real-time How to Solve Writing Problems in Python
[Python Kivy] How to create an exe file with pyinstaller
Overview of Python virtual environment and how to create it
How to write offline real-time Solving E05 problems with Python
How to easily create an environment where python code runs on Jupyter without polluting the local environment