Skip to content

Instantly share code, notes, and snippets.

@esc
Created September 8, 2017 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esc/9ee129e6e0a5958a69cabf0a41974624 to your computer and use it in GitHub Desktop.
Save esc/9ee129e6e0a5958a69cabf0a41974624 to your computer and use it in GitHub Desktop.
GulpIO Blogpost Dataloader Example
from gulpio.dataset import GulpImageDataset
from gulpio.loader import DataLoader
from gulpio.transforms import Scale, CenterCrop, Compose, UnitNorm
# define data augmentations. Notice that there are different functions for videos and images
transforms = Compose([
Scale(28), # resize image by the shortest edge
CenterCrop(28),
UnitNorm(), # instance wise mean and std norm
])
# define dataset wrapper and pick this up by the data loader interface.
dataset = GulpImageDataset('/path/to/train_data', transform=transforms)
loader = DataLoader(dataset, batch_size=256, shuffle=True, num_workers=0, drop_last=True)
dataset_val = GulpImageDataset('/path/to/validation_data/', transform=transforms)
loader_val = DataLoader(dataset_val, batch_size=256, shuffle=True, num_workers=0, drop_last=True)
for data, label in loader:
# train your model here
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment