February 2018
Intermediate to advanced
262 pages
6h 59m
English
Loading data is similar to what we have seen for solving image classification problems in Chapter 5, Deep Learning for Computer Vision. We will be using the pretrained VGG model, so we have to normalize the images using the same values on which the pretrained model is trained.
The following code shows how we can do this. The code is mostly self-explanatory as we have already discussed it in detail in the previous chapters:
#Fixing the size of the image, reduce it further if you are not using a GPU.imsize = 512 is_cuda = torch.cuda.is_available()#Converting image ,making it suitable for training using the VGG model.prep = transforms.Compose([transforms.Resize(imsize), transforms.ToTensor(), transforms.Lambda(lambda x: x[torch.LongTensor([2,1,0])]), ...