I am trying to perform random cropping on an image. Here is my code. I tried following the examples given over here but got stuck.
import numpy as np
from sklearn.datasets import load_sample_images
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
def random_crop(imgs, out=84):
imgs = torch.tensor(84)
transforms = torch.nn.Sequential(
imgs.RandomCrop(84),
)
imgs = transforms.numpy()
return imgs
dataset = load_sample_images()
first_img_data = dataset.images[0]
first_img_data = first_img_data.reshape(-1, 427, 640)
first_img_data = first_img_data[1, :, :]
foo = random_crop(first_img_data.reshape(-1,1,427, 640), out=84)