Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A utility to create a PyTorch DatasetFolder from any .csv or .tsv file with file path and class data.

Project description


A utility to create a PyTorch DatasetFolder from any .csv or .tsv file with file path and class data.

Use Case

In PyTorch, the DataFolder and ImageFolder classes provide a convenient interface for computer vision datasets structured as such:



This utility transforms any dataset with a table containing file paths and class labels into this format.


Suppse you have dataset.csv of the form:


Running make-dataset-folder -p sample -l class dataset.csv output will create a folder output with the following structure:


Using the -m flag will move images rather than copy them. This could be useful for large datasets that shouldn't be duplicated on disk.


usage: make-datasetfolder [-h] [-p PATH_COLUMN] [-l LABEL_COLUMN] [-m] [-f]
                          [-t THREADS]
                          input output

positional arguments:
  input                 Path to input .csv or .tsv
  output                Path to output directory.

optional arguments:
  -h, --help            show this help message and exit
  -p PATH_COLUMN, --path-column PATH_COLUMN
                        Column name or index with file paths (default: 0).
  -l LABEL_COLUMN, --label-column LABEL_COLUMN
                        Column name or index with labels (default: 1).
  -m, --move            Move files instead of copying.
  -f, --force           Overwrite output directory if it already exists.
  -t THREADS, --threads THREADS
                        Number of threads to use (default: number of CPU

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for make-datasetfolder, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size make_datasetfolder-0.0.1-py3-none-any.whl (7.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size make_datasetfolder-0.0.1.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page