Skip to content

A better PyTorch data loader capable of custom image operations and image subsets

License

Notifications You must be signed in to change notification settings

BinItAI/BetterLoader

Repository files navigation

Making it harder to do easy things, but easier to do harder things with the Pytorch Dataloader


AboutInstallationUsageDevelopmentLicense

PyPi Badge PyPi Version Github Actions Build Status Issues license


About BetterLoader

BetterLoader is a hyper-customizable extension of the default PyTorch dataloader class, that allows for custom transformations pre-load and image subset definitions. Use the power of custom index files to maintain only a single copy of a dataset with a fixed, flat file structure, and allow BetterLoader to do all the heavy lifting.

Installation

pip install betterloader

Usage

BetterLoader allows you to dynamically assign images to labels, load subsets of images conditionally, perform custom pretransforms before loading an image, and much more.

Basic Usage

A few points worth noting are that:

  • BetterLoader does not expect a nested folder structure. In its current iteration, files are expected to all be present in the root directory.
  • Every instance of BetterLoader requires an index file to function. Sample index files may be found here.
from betterloader import BetterLoader

index_json = './examples/sample_index.json'
basepath = "./examples/sample_dataset/"
batch_size = 2

loader = BetterLoader(basepath=basepath, index_json_path=index_json)
dataloaders, sizes = loader.fetch_segmented_dataloaders(batch_size=batch_size, transform=None)

print("Dataloader sizes: {}".format(str(sizes)))

For more information and more detailed examples, please check out the BetterLoader docs!

Development

We use Makefile to make our lives a little easier :)

Install Dependancies

make install

Run Sample

make sample

Run Unit Tests

make test

Meta

Distributed under the MIT license. See LICENSE for more information.

Documentation & Usage