Skip to content

New datasets, transforms and fixes

Compare
Choose a tag to compare
@soumith soumith released this 24 Apr 18:16

This version introduces several fixes and improvements to the previous version.

Better printing of Datasets and Transforms

  • Add descriptions to Transform objects.
# Now T.Compose([T.RandomHorizontalFlip(), T.RandomCrop(224), T.ToTensor()]) prints
Compose(
    RandomHorizontalFlip(p=0.5)
    RandomCrop(size=(224, 224), padding=0)
    ToTensor()
)
  • Add descriptions to Datasets
# now torchvision.datasets.MNIST('~') prints
Dataset MNIST
    Number of datapoints: 60000
    Split: train
    Root Location: /private/home/fmassa
    Transforms (if any): None
    Target Transforms (if any): None

New transforms

  • Add RandomApply, RandomChoice, RandomOrder transformations #402

    • RandomApply: applies a list of transformation with a probability
    • RandomChoice: choose randomly a single transformation from a list
    • RandomOrder: apply transformations in a random order
  • Add random affine transformation #411

  • Add reflect, symmetric and edge padding to transforms.pad #460

Performance improvements

  • Speedup MNIST preprocessing by a factor of 1000x
  • make weight initialization optional to speed VGG construction. This makes loading pre-trained VGG models much faster
  • Accelerate transforms.adjust_gamma by using PIL's point function instead of custom numpy-based implementation

New Datasets

  • EMNIST - an extension of MNIST for hand-written letters
  • OMNIGLOT - a dataset for one-shot learning, with 1623 different handwritten characters from 50 different alphabets
  • Add a DatasetFolder class - generalization of ImageFolder

Miscellaneous improvements

  • FakeData accepts a seed argument, so having multiple different FakeData instances is now possible
  • Use consistent datatypes in Dataset targets. Now all datasets that returns labels will have them as int
  • Add probability parameter in RandomHorizontalFlip and RandomHorizontalFlip
  • Replace np.random by random in transforms - improves reproducibility in multi-threaded environments with default arguments
  • Detect tif images in ImageFolder
  • Add pad_if_needed to RandomCrop, so that if the crop size is larger than the image, the image is automatically padded
  • Add support in transforms.ToTensor for PIL Images with mode '1'

Bugfixes

  • Fix passing list of tensors to utils.save_image
  • single images passed to make_grid now are now also normalized
  • Fix PIL img close warnings
  • Added missing weight initializations to densenet
  • Avoid division by zero in make_grid when the image is constant
  • Fix ToTensor when PIL Image has mode F
  • Fix bug with to_tensor when the input is numpy array of type np.float32.