February 2018
Intermediate to advanced
262 pages
6h 59m
English
We create a transformation object containing all the basic transformations required and use the ImageFolder to load the images from the data directory that we created in Chapter 5, Deep Learning for Computer Vision. In the following code, we create the datasets:
data_transform = transforms.Compose([ transforms.Resize((299,299)), transforms.ToTensor(), transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) ])# For Dogs & Cats datasettrain_dset = ImageFolder('../../chapter5/dogsandcats/train/',transform=data_transform)val_dset = ImageFolder('../../chapter5/dogsandcats/valid/',transform=data_transform)classes=2
By now, most of the preceding code will be self-explanatory.