Complete the code to load an image and convert it to a tensor for image-to-image transformation.
from PIL import Image import torchvision.transforms as transforms image = Image.open('input.jpg') transform = transforms.Compose([ transforms.ToTensor(), ]) tensor_image = [1](image)
Complete the code to define a simple convolutional layer for image-to-image transformation.
import torch.nn as nn conv_layer = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=[1], padding=1)
Fix the error in the code to apply a ReLU activation after the convolutional layer.
import torch.nn.functional as F output = F.[1](conv_layer(input_tensor))
Fill both blanks to create a dictionary comprehension that maps image filenames to their transformed tensors if the image size is greater than 256.
image_tensors = {filename: [1] for filename, image in images.items() if image.size[0] [2] 256}Fill all three blanks to create a dictionary comprehension that maps image names to their grayscale tensors if the height is less than 128.
grayscale_images = {name: [1](image.convert([2])) for name, image in dataset.items() if image.size[1] [3] 128}