I wrote this code to transform image:
import torchvision.transforms as trasnfroms import PIL.Image as Image mean = [0.485, 0.456, 0.406] std = [0.229, 0.224, 0.225] transform = transforms.Compose([transforms.resize(size=256), transforms.RandomCrop(size=224), transforms.to_tensor(), transorms.normalize(mean=mean,std=std)]) img = Image.open(imgname) tensor = transform(img)
It seems no problem. And this code raise a type error:
TypeError: resize missing 1 required positional argument: 'img'
I can’t find the errors.