text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
from PIL import Image

from torchvision import datasets, models, transforms

import matplotlib.pyplot as plt

data_dir = '../input'
train_dir = data_dir + '/train'
test_dir = data_dir + '/test'

pil2tensor = transforms.ToTensor()
tensor2pil = transforms.ToPILImage()
pil_image = Image.open(train_dir + '/0a750c2e8.jpg')
rgb_image = pil2tensor(pil_image)
def plot_image(tensor):
    plt.figure()
    plt.imshow(tensor.numpy().transpose(1, 2, 0))
    plt.show()
plot_image(rgb_image)
print('Image type: ' + str(rgb_image.type()))
print('Image size: ' + str(rgb_image.size()))