img seems to be a PIL.Image. Try to cast it to a tensor before the new() call e.g. with:
img = = torch.from_numpy(np.array(img))
# or
import torchvision.transforms.functional as TF
img = TF.to_tensor(img)

The former approach will keep the data as it was loaded (uint8 in range [0, 255]), while the latter will rescale your image to [0, 1] and cast it to float.