Repository: OpenMined/PySyft

Issue:
Refactor TorchVision tests to use PIL Image
## Description
We can now support PIL images so the torchvision tests can be updated to take advantage of this.
As per this comment: https://github.com/OpenMined/PySyft/pull/5332#issuecomment-805979800

## Definition of Done

This method is enabled and tested and unused `imageTensor.pt` removed.
```python
allowlist["torchvision.transforms.functional.pil_to_tensor"] = "torch.Tensor"
```


Discussion:

Resolving patch:
diff --git a/src/syft/lib/torchvision/allowlist.py b/src/syft/lib/torchvision/allowlist.py
--- a/src/syft/lib/torchvision/allowlist.py
+++ b/src/syft/lib/torchvision/allowlist.py
@@ -2,10 +2,8 @@
 from typing import Dict
 from typing import Union
 
-# TODO: Refactor out all the test data.
-# Issue: https://github.com/OpenMined/PySyft/issues/5325
-
-allowlist: Dict[str, Union[str, Dict[str, str]]] = {}  # (path: str, return_type:type)
+# (path: str, return_type:type)
+allowlist: Dict[str, Union[str, Dict[str, str]]] = {}
 
 allowlist["torchvision.__version__"] = "syft.lib.python.String"
 # MNIST
@@ -23,288 +21,158 @@
 
 # Datasets
 
-allowlist["torchvision.datasets.MNIST"] = {
-    "return_type": "torchvision.datasets.MNIST",
-    "test_parameters": "('../data', download=False,)",
-}
-
+allowlist["torchvision.datasets.MNIST"] = "torchvision.datasets.MNIST"
 
 allowlist["torchvision.datasets.MNIST.__len__"] = "syft.lib.python.Int"
 
-
-allowlist["torchvision.datasets.CelebA"] = {
-    "return_type": "torchvision.datasets.CelebA",
-    "test_parameters": "('../data')",
-}
+allowlist["torchvision.datasets.CelebA"] = "torchvision.datasets.CelebA"
 allowlist["torchvision.datasets.CelebA.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.CIFAR10"] = {
-    "return_type": "torchvision.datasets.CIFAR10",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.CIFAR10"] = "torchvision.datasets.CIFAR10"
 allowlist["torchvision.datasets.CIFAR10.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.CIFAR100"] = {
-    "return_type": "torchvision.datasets.CIFAR100",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.CIFAR100"] = "torchvision.datasets.CIFAR100"
 allowlist["torchvision.datasets.CIFAR10.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.Cityscapes"] = {
-    "return_type": "torchvision.datasets.Cityscapes",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.Cityscapes"] = "torchvision.datasets.Cityscapes"
 allowlist["torchvision.datasets.Cityscapes.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.CocoCaptions"] = {
-    "return_type": "torchvision.datasets.CocoCaptions",
-    "test_parameters": "('../data','../data/captions.txt')",
-}
+allowlist["torchvision.datasets.CocoCaptions"] = "torchvision.datasets.CocoCaptions"
 allowlist["torchvision.datasets.CocoCaptions.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.CocoDetection"] = {
-    "return_type": "torchvision.datasets.CocoDetection",
-    "test_parameters": "('../data', '../data/captions.txt')",
-}
+allowlist["torchvision.datasets.CocoDetection"] = "torchvision.datasets.CocoDetection"
 allowlist["torchvision.datasets.CocoDetection.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.EMNIST"] = {
-    "return_type": "torchvision.datasets.EMNIST",
-    "test_parameters": "('../data',split = \"mnist\")",
-}
+allowlist["torchvision.datasets.EMNIST"] = "torchvision.datasets.EMNIST"
 allowlist["torchvision.datasets.EMNIST.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.FakeData"] = {
-    "return_type": "torchvision.datasets.FakeData",
-    "test_parameters": "('../data', )",
-}
+allowlist["torchvision.datasets.FakeData"] = "torchvision.datasets.FakeData"
 allowlist["torchvision.datasets.FakeData.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.FashionMNIST"] = {
-    "return_type": "torchvision.datasets.FashionMNIST",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.FashionMNIST"] = "torchvision.datasets.FashionMNIST"
 allowlist["torchvision.datasets.FashionMNIST.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.Flickr8k"] = {
-    "return_type": "torchvision.datasets.Flickr8k",
-    "test_parameters": "('../data', '../data/annfile.txt')",
-}
+allowlist["torchvision.datasets.Flickr8k"] = "torchvision.datasets.Flickr8k"
 allowlist["torchvision.datasets.Flickr8k.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.Flickr30k"] = {
-    "return_type": "torchvision.datasets.Flickr30k",
-    "test_parameters": "('../data', '../data/annfile.txt')",
-}
+allowlist["torchvision.datasets.Flickr30k"] = "torchvision.datasets.Flickr30k"
 allowlist["torchvision.datasets.Flickr30k.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.HMDB51"] = {
-    "return_type": "torchvision.datasets.HMDB51",
-    "test_parameters": "('../data', '../data/annfile.txt', 20,  )",
-}
+allowlist["torchvision.datasets.HMDB51"] = "torchvision.datasets.HMDB51"
 allowlist["torchvision.datasets.HMDB51.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.ImageNet"] = {
-    "return_type": "torchvision.datasets.ImageNet",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.ImageNet"] = "torchvision.datasets.ImageNet"
 allowlist["torchvision.datasets.ImageNet.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.Kinetics400"] = {
-    "return_type": "torchvision.datasets.Kinetics400",
-    "test_parameters": "('../data', 20)",
-}
+allowlist["torchvision.datasets.Kinetics400"] = "torchvision.datasets.Kinetics400"
 allowlist["torchvision.datasets.Kinetics400.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.KMNIST"] = {
-    "return_type": "torchvision.datasets.KMNIST",
-    "test_parameters": "('../data', )",
-}
+allowlist["torchvision.datasets.KMNIST"] = "torchvision.datasets.KMNIST"
 allowlist["torchvision.datasets.KMNIST.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.LSUN"] = {
-    "return_type": "torchvision.datasets.LSUN",
-    "test_parameters": "('../data', )",
-}
+allowlist["torchvision.datasets.LSUN"] = "torchvision.datasets.LSUN"
 allowlist["torchvision.datasets.LSUN.__len__"] = "syft.lib.python.Int"
 
 allowlist["torchvision.datasets.Omniglot"] = {
     "return_type": "torchvision.datasets.Omniglot",
     "min_version": "0.8.0",
-    "test_parameters": "('../data', )",
 }
 allowlist["torchvision.datasets.Omniglot.__len__"] = {
     "return_type": "syft.lib.python.Int",
     "min_version": "0.8.0",
 }
 
-allowlist["torchvision.datasets.PhotoTour"] = {
-    "return_type": "torchvision.datasets.PhotoTour",
-    "test_parameters": "('../data', name = 'data')",
-}
+allowlist["torchvision.datasets.PhotoTour"] = "torchvision.datasets.PhotoTour"
 allowlist["torchvision.datasets.PhotoTour.__len__"] = "syft.lib.python.Int"
 
 allowlist["torchvision.datasets.Places365"] = {
     "return_type": "torchvision.datasets.Places365",
     "min_version": "0.8.0",
-    "test_parameters": "('../data',)",
 }
 allowlist["torchvision.datasets.Places365.__len__"] = {
     "return_type": "syft.lib.python.Int",
     "min_version": "0.8.0",
 }
 
-allowlist["torchvision.datasets.QMNIST"] = {
-    "return_type": "torchvision.datasets.QMNIST",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.QMNIST"] = "torchvision.datasets.QMNIST"
 allowlist["torchvision.datasets.QMNIST.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.SBDataset"] = {
-    "return_type": "torchvision.datasets.SBDataset",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.SBDataset"] = "torchvision.datasets.SBDataset"
 allowlist["torchvision.datasets.SBDataset.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.SBU"] = {
-    "return_type": "torchvision.datasets.SBU",
-    "test_parameters": "('../data', download = False)",
-}
+allowlist["torchvision.datasets.SBU"] = "torchvision.datasets.SBU"
 allowlist["torchvision.datasets.SBU.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.STL10"] = {
-    "return_type": "torchvision.datasets.STL10",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.STL10"] = "torchvision.datasets.STL10"
 allowlist["torchvision.datasets.STL10.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.SVHN"] = {
-    "return_type": "torchvision.datasets.SVHN",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.SVHN"] = "torchvision.datasets.SVHN"
 allowlist["torchvision.datasets.SVHN.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.UCF101"] = {
-    "return_type": "torchvision.datasets.UCF101",
-    "test_parameters": "('../data', frames_per_clip = 20, annotation_path = '../data/annfile.txt')",
-}
+allowlist["torchvision.datasets.UCF101"] = "torchvision.datasets.UCF101"
 allowlist["torchvision.datasets.UCF101.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.USPS"] = {
-    "return_type": "torchvision.datasets.USPS",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.USPS"] = "torchvision.datasets.USPS"
 allowlist["torchvision.datasets.USPS.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.VOCSegmentation"] = {
-    "return_type": "torchvision.datasets.VOCSegmentation",
-    "test_parameters": "('../data',)",
-}
+allowlist[
+    "torchvision.datasets.VOCSegmentation"
+] = "torchvision.datasets.VOCSegmentation"
 allowlist["torchvision.datasets.VOCSegmentation.__len__"] = "syft.lib.python.Int"
 
-allowlist["torchvision.datasets.VOCDetection"] = {
-    "return_type": "torchvision.datasets.VOCDetection",
-    "test_parameters": "('../data',)",
-}
+allowlist["torchvision.datasets.VOCDetection"] = "torchvision.datasets.VOCDetection"
 allowlist[
     "torchvision.datasets.VOCDetection.__len__"
 ] = "torchvision.datasets.VOCDetection"
 
 # Transforms
-allowlist["torchvision.transforms.CenterCrop"] = {
-    "return_type": "torchvision.transforms.CenterCrop",
-    "test_parameters": "(10)",
-}
-allowlist["torchvision.transforms.ColorJitter"] = {
-    "return_type": "torchvision.transforms.ColorJitter",
-    "test_parameters": "(brightness=0, contrast=0, saturation=0, hue=0)",
-}
+allowlist["torchvision.transforms.CenterCrop"] = "torchvision.transforms.CenterCrop"
+allowlist["torchvision.transforms.ColorJitter"] = "torchvision.transforms.ColorJitter"
 
-# This is an interesting case, for some versions p = 0.2 is needed, for others its not needed
 
-allowlist["torchvision.transforms.FiveCrop"] = {
-    "return_type": "torchvision.transforms.FiveCrop",
-    #    "test_parameters": "(size = 10, p = 0.2)",
-}
+allowlist["torchvision.transforms.FiveCrop"] = "torchvision.transforms.FiveCrop"
 
 
-allowlist["torchvision.transforms.Grayscale"] = {
-    "return_type": "torchvision.transforms.Grayscale",
-    "test_parameters": "(num_output_channels=1)",
-}
-allowlist["torchvision.transforms.Pad"] = {
-    "return_type": "torchvision.transforms.Pad",
-    "test_parameters": "(2, fill=0, padding_mode='constant')",
-}
-allowlist["torchvision.transforms.RandomAffine"] = {
-    "return_type": "torchvision.transforms.RandomAffine",
-    "test_parameters": "(degrees = 2)",
-}
+allowlist["torchvision.transforms.Grayscale"] = "torchvision.transforms.Grayscale"
+allowlist["torchvision.transforms.Pad"] = "torchvision.transforms.Pad"
+allowlist["torchvision.transforms.RandomAffine"] = "torchvision.transforms.RandomAffine"
 
-# transforms error
-allowlist["torchvision.transforms.RandomApply"] = {
-    "return_type": "torchvision.transforms.RandomApply",
-    # "test_parameters": "(torchvision.transforms.CenterCrop(10))",
-}
+allowlist["torchvision.transforms.RandomApply"] = "torchvision.transforms.RandomApply"
 
-allowlist["torchvision.transforms.RandomCrop"] = {
-    "return_type": "torchvision.transforms.RandomCrop",
-    "test_parameters": "(size = 10)",
-}
-allowlist["torchvision.transforms.RandomGrayscale"] = {
-    "return_type": "torchvision.transforms.RandomGrayscale",
-    "test_parameters": "(p=0.1)",
-}
+allowlist["torchvision.transforms.RandomCrop"] = "torchvision.transforms.RandomCrop"
+allowlist[
+    "torchvision.transforms.RandomGrayscale"
+] = "torchvision.transforms.RandomGrayscale"
 
-allowlist["torchvision.transforms.RandomHorizontalFlip"] = {
-    "return_type": "torchvision.transforms.RandomHorizontalFlip",
-    "test_parameters": "(p=0.1)",
-}
-allowlist["torchvision.transforms.RandomPerspective"] = {
-    "return_type": "torchvision.transforms.RandomPerspective",
-    "test_parameters": "(distortion_scale=0.5, p=0.5)",
-}
+allowlist[
+    "torchvision.transforms.RandomHorizontalFlip"
+] = "torchvision.transforms.RandomHorizontalFlip"
+allowlist[
+    "torchvision.transforms.RandomPerspective"
+] = "torchvision.transforms.RandomPerspective"
 
-allowlist["torchvision.transforms.RandomResizedCrop"] = {
-    "return_type": "torchvision.transforms.RandomResizedCrop",
-    "test_parameters": "(10, scale=(0.08, 1.0), ratio=(0.75, 1.25))",
-}
-allowlist["torchvision.transforms.RandomRotation"] = {
-    "return_type": "torchvision.transforms.RandomRotation",
-    "test_parameters": "(degrees = 2)",
-}
-allowlist["torchvision.transforms.RandomSizedCrop"] = {
-    "return_type": "torchvision.transforms.RandomSizedCrop",
-    "test_parameters": "(10)",
-}
-allowlist["torchvision.transforms.RandomVerticalFlip"] = {
-    "return_type": "torchvision.transforms.RandomVerticalFlip",
-    "test_parameters": "(p=0.5)",
-}
-allowlist["torchvision.transforms.Resize"] = {
-    "return_type": "torchvision.transforms.Resize",
-    "test_parameters": "(size = 15)",
-}
-allowlist["torchvision.transforms.Scale"] = {
-    "return_type": "torchvision.transforms.Scale",
-    "test_parameters": "(10)",
-}
-allowlist["torchvision.transforms.TenCrop"] = {
-    "return_type": "torchvision.transforms.TenCrop",
-    "test_parameters": "(10)",
-}
+allowlist[
+    "torchvision.transforms.RandomResizedCrop"
+] = "torchvision.transforms.RandomResizedCrop"
+allowlist[
+    "torchvision.transforms.RandomRotation"
+] = "torchvision.transforms.RandomRotation"
+allowlist[
+    "torchvision.transforms.RandomSizedCrop"
+] = "torchvision.transforms.RandomSizedCrop"
+allowlist[
+    "torchvision.transforms.RandomVerticalFlip"
+] = "torchvision.transforms.RandomVerticalFlip"
+allowlist["torchvision.transforms.Resize"] = "torchvision.transforms.Resize"
+allowlist["torchvision.transforms.Scale"] = "torchvision.transforms.Scale"
+allowlist["torchvision.transforms.TenCrop"] = "torchvision.transforms.TenCrop"
 allowlist["torchvision.transforms.GaussianBlur"] = {
     "return_type": "torchvision.transforms.GaussianBlur",
     "min_version": "0.8.0",
-    "test_parameters": "(kernel_size = 3)",
 }
 
-allowlist["torchvision.transforms.RandomChoice"] = {
-    "return_type": "torchvision.transforms.RandomChoice",
-}
-allowlist["torchvision.transforms.RandomOrder"] = {
-    "return_type": "torchvision.transforms.RandomOrder",
-}
+allowlist["torchvision.transforms.RandomChoice"] = "torchvision.transforms.RandomChoice"
+allowlist["torchvision.transforms.RandomOrder"] = "torchvision.transforms.RandomOrder"
 
 allowlist[
     "torchvision.transforms.LinearTransformation"
@@ -320,162 +188,71 @@
 allowlist["torchvision.transforms.Lambda"] = "torchvision.transforms.Lambda"
 
 # Functional Transformers
-allowlist["torchvision.transforms.functional.adjust_brightness"] = {
-    "return_type": "torch.Tensor",
-    "min_version": "0.8.0",
-    "test_parameters": "(tens, 0.5)",
-}
-allowlist["torchvision.transforms.functional.adjust_contrast"] = {
-    "return_type": "torch.Tensor",
-    "min_version": "0.8.0",
-    "test_parameters": "(tens, 0.5)",
-}
-allowlist["torchvision.transforms.functional.adjust_gamma"] = {
-    "return_type": "torch.Tensor",
-    "min_version": "0.8.0",
-    "test_parameters": "(tens, 1, 0.5)",
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
-}
-allowlist["torchvision.transforms.functional.adjust_hue"] = {
-    "return_type": "torch.Tensor",
-    "min_version": "0.8.0",
-    "test_parameters": "(tens, 0)"
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
-}
-allowlist["torchvision.transforms.functional.adjust_saturation"] = {
-    "return_type": "torch.Tensor",
-    "min_version": "0.8.0",
-    "test_parameters": "(tens, 0.5)",
-}
+allowlist["torchvision.transforms.functional.adjust_brightness"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.adjust_contrast"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.adjust_gamma"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.adjust_hue"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.adjust_saturation"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.adjust_sharpness"] = {
     "return_type": "torch.Tensor",
     "min_version": "0.9.0",
-    "test_parameters": "(tens, 0.5)",
-}
-allowlist["torchvision.transforms.functional.affine"] = {
-    "return_type": "torch.Tensor",
-    "min_version": "0.8.0",
-    "test_parameters": "(tens,0.2,[1,2],0.2,[1,2])",
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
 }
+allowlist["torchvision.transforms.functional.affine"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.autocontrast"] = {
     "return_type": "torch.Tensor",
     "min_version": "0.9.0",
-    "test_parameters": "(tens)",
-}
-allowlist["torchvision.transforms.functional.center_crop"] = {
-    "return_type": "torch.Tensor",
-    "min_version": "0.8.0",
-    "test_parameters": "(tens, 10)",
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
 }
+allowlist["torchvision.transforms.functional.center_crop"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.convert_image_dtype"] = {
     "return_type": "torch.Tensor",
+    "min_version": "0.7.0",
 }
-allowlist["torchvision.transforms.functional.crop"] = {
-    "return_type": "torch.Tensor",
-    "min_version": "0.8.0",
-    "test_parameters": "(tens, 10 , 20, 30, 40)",
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
-}
+allowlist["torchvision.transforms.functional.crop"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.equalize"] = {
     "return_type": "torch.Tensor",
     "min_version": "0.9.0",
-    "test_parameters": "(tens)",
-}
-allowlist["torchvision.transforms.functional.erase"] = {
-    "return_type": "torch.Tensor",
-    "test_parameters": "(tens, 10, 20, 30, 40, 250)",
-    "min_version": "0.8.0"
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
-}
-allowlist["torchvision.transforms.functional.five_crop"] = {
-    "return_type": "torch.Tensor",
-    "test_parameters": "(tens, 10)",
-    "min_version": "0.8.0"
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
 }
+allowlist["torchvision.transforms.functional.erase"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.five_crop"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.gaussian_blur"] = {
     "return_type": "torch.Tensor",
     "min_version": "0.8.0",
-    "test_parameters": "(tens, 3)",
 }
 allowlist["torchvision.transforms.functional.hflip"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.invert"] = {
     "return_type": "torch.Tensor",
     "min_version": "0.9.0",
-    "test_parameters": "(tens)",
-}
-allowlist["torchvision.transforms.functional.normalize"] = {
-    "return_type": "torch.Tensor",
-    # "test_parameters": "(tens, [0.5, 0.5, 0.5], [1, 1, 1]).unsqueeze(0)",
-    # currently commenting because of test issues with hier versions
-    # (//) works for 1.6.0 and / works for higher version :(
 }
+allowlist["torchvision.transforms.functional.normalize"] = "torch.Tensor"
+# "test_parameters (tests/lib/torchvision/allowlist_test_parameters.json): (tens, [0.5,
+#  0.5, 0.5], [1, 1, 1]).unsqueeze(0)",
+# currently not added because of test issues with hier versions
+# (//) works for 1.6.0 and / works for higher version :(
+
 allowlist["torchvision.transforms.functional.pad"] = {
     "return_type": "torch.Tensor",
-    "test_parameters": "(tens, 10)",
-    "min_version": "0.8.0"
-    # # Torch 1.6 expects input to be PIL image, so commenting this currently
-}
-allowlist["torchvision.transforms.functional.perspective"] = {
-    "return_type": "torch.Tensor",
-    "test_parameters": "(tens, [[10,20],[20,30],[30, 40],[40,50]], [[20,30],[30,40],[40, 50],[50,60]])",
-    "min_version": "0.8.0"
-    # # Torch 1.6 expects input to be PIL image, so commenting this currently
+    "min_version": "0.6.0",
 }
+allowlist["torchvision.transforms.functional.perspective"] = "torch.Tensor"
 
-# Converts PIL to tensor, currently not supported
-# allowlist["torchvision.transforms.functional.pil_to_tensor"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.pil_to_tensor"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.posterize"] = {
     "return_type": "torch.Tensor",
     "min_version": "0.9.0",
-    "test_parameters": "(tens, 2)",
-}
-allowlist["torchvision.transforms.functional.resize"] = {
-    "return_type": "torch.Tensor",
-    "test_parameters": "(tens, 10)",
-    "min_version": "0.8.0"
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
-}
-allowlist["torchvision.transforms.functional.resized_crop"] = {
-    "return_type": "torch.Tensor",
-    "test_parameters": "(tens, 10, 15, 20, 25, 30)",
-    "min_version": "0.8.0"
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
 }
+allowlist["torchvision.transforms.functional.resize"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.resized_crop"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.rgb_to_grayscale"] = {
     "return_type": "torch.Tensor",
     "min_version": "0.8.0",
-    "test_parameters": "(tens)",
-}
-allowlist["torchvision.transforms.functional.rotate"] = {
-    "return_type": "torch.Tensor",
-    "test_parameters": "(tens, angle = 10)",
-    "min_version": "0.8.0"
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
 }
+allowlist["torchvision.transforms.functional.rotate"] = "torch.Tensor"
 allowlist["torchvision.transforms.functional.solarize"] = {
     "return_type": "torch.Tensor",
     "min_version": "0.9.0",
-    "test_parameters": "(tens, threshold = 0.5)",
-}
-allowlist["torchvision.transforms.functional.ten_crop"] = {
-    "return_type": "torch.Tensor",
-    "test_parameters": "(tens, size = 10)",
-    "min_version": "0.8.0"
-    # Torch 1.6 expects input to be PIL image, so minimum version as 0.7 (Torch 1.7.0)
-}
-allowlist["torchvision.transforms.functional.to_grayscale"] = {
-    "return_type": "PIL.Image.Image"
-}
-allowlist["torchvision.transforms.functional.to_pil_image"] = {
-    "return_type": "PIL.Image.Image",
-}
-allowlist["torchvision.transforms.functional.to_tensor"] = {
-    "return_type": "torch.Tensor",
-}
-allowlist["torchvision.transforms.functional.vflip"] = {
-    "return_type": "torch.Tensor",
-    "test_parameters": "(tens)",
 }
+allowlist["torchvision.transforms.functional.ten_crop"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.to_grayscale"] = "PIL.Image.Image"
+allowlist["torchvision.transforms.functional.to_pil_image"] = "PIL.Image.Image"
+allowlist["torchvision.transforms.functional.to_tensor"] = "torch.Tensor"
+allowlist["torchvision.transforms.functional.vflip"] = "torch.Tensor"


Test patch:
diff --git a/tests/syft/lib/torchvision/allowlist_test.py b/tests/syft/lib/torchvision/allowlist_test.py
--- a/tests/syft/lib/torchvision/allowlist_test.py
+++ b/tests/syft/lib/torchvision/allowlist_test.py
@@ -1,10 +1,12 @@
 # stdlib
+import json
+import os
 from os import path
-import os.path
 from typing import Dict
 from typing import Union
 
 # third party
+import PIL
 from packaging import version
 import pytest
 import torch
@@ -14,19 +16,23 @@
 import syft as sy
 from syft.lib.torchvision.allowlist import allowlist
 
-fileName = "imageTensor.pt"
-
 TORCHVISION_VERSION = version.parse(tv.__version__)
 
 
 @pytest.fixture(scope="function")
-def tens() -> torch.Tensor:
-    if path.isfile("imageTensor.pt"):
-        return torch.load("imageTensor.pt")
+def pil_img() -> PIL.Image.Image:
+    img_file = "../../../../docs/img/logo.png"
+    if path.isfile(img_file):
+        return PIL.Image.open(img_file).convert("RGB")
     else:
         cwd = os.getcwd()
-        path_file = cwd + "/tests/syft/lib/torchvision/" + fileName
-        return torch.load(path_file)
+        img_file = cwd + "/docs/img/logo.png"
+        return PIL.Image.open(img_file).convert("RGB")
+
+
+@pytest.fixture(scope="function")
+def tens(pil_img: PIL.Image.Image) -> torch.Tensor:
+    return tv.transforms.functional.to_tensor(pil_img).type(torch.uint8)
 
 
 def version_supported(support_dict: Union[str, Dict[str, str]]) -> bool:
@@ -38,7 +44,11 @@ def version_supported(support_dict: Union[str, Dict[str, str]]) -> bool:
         return TORCHVISION_VERSION >= version.parse(support_dict["min_version"])
 
 
-def test_allowlist(root_client: sy.VirtualMachineClient, tens: torch.Tensor) -> None:
+def test_allowlist(
+    root_client: sy.VirtualMachineClient, tens: torch.Tensor, pil_img: PIL.Image.Image
+) -> None:
+    # Required for testing on torchvision==1.6.0
+    sy.load("PIL")
     torchvision = root_client.torchvision
     torch = root_client.torch
     try:
@@ -46,6 +56,14 @@ def test_allowlist(root_client: sy.VirtualMachineClient, tens: torch.Tensor) ->
         tx = tx * 2
     except Exception as e:
         print(e)
+
+    try:
+        with open(__file__.replace(".py", "_params.json"), "r") as f:
+            TEST_PARAMS = json.loads(f.read())
+    except Exception as e:
+        print(f"Exception {e} triggered")
+        raise e
+
     transforms = torchvision.transforms
     transforms.RandomAffine(2)
     for item in allowlist:
@@ -54,13 +72,11 @@ def test_allowlist(root_client: sy.VirtualMachineClient, tens: torch.Tensor) ->
         if (
             arr[1] == "datasets"
             and len(arr) <= 3
-            and isinstance(allowlist[item], dict)
-            and "test_parameters" in allowlist[item].keys()
+            and item in TEST_PARAMS.keys()
             and version_supported(support_dict=allowlist[item])
         ):
-            print(item)
             try:
-                exec(item + allowlist[item]["test_parameters"])
+                exec(item + TEST_PARAMS[item])
             except RuntimeError as e:
                 assert (
                     "not found" in str(e)
@@ -75,9 +91,8 @@ def test_allowlist(root_client: sy.VirtualMachineClient, tens: torch.Tensor) ->
                 assert "No module named" in str(e)
             except KeyError:
                 pass
-        elif (
-            isinstance(allowlist[item], dict)
-            and version_supported(support_dict=allowlist[item])
-            and "test_parameters" in allowlist[item].keys()
+        elif item in TEST_PARAMS.keys() and version_supported(
+            support_dict=allowlist[item]
         ):
-            exec(item + allowlist[item]["test_parameters"])
+            print(item + TEST_PARAMS[item])
+            exec(item + TEST_PARAMS[item])
diff --git a/tests/syft/lib/torchvision/allowlist_test_params.json b/tests/syft/lib/torchvision/allowlist_test_params.json
new file mode 100644
--- /dev/null
+++ b/tests/syft/lib/torchvision/allowlist_test_params.json
@@ -0,0 +1,73 @@
+{
+    "torchvision.datasets.CIFAR10": "('../data',)",
+    "torchvision.datasets.CIFAR100": "('../data',)",
+    "torchvision.datasets.CelebA": "('../data')",
+    "torchvision.datasets.Cityscapes": "('../data',)",
+    "torchvision.datasets.CocoCaptions": "('../data','../data/captions.txt')",
+    "torchvision.datasets.CocoDetection": "('../data', '../data/captions.txt')",
+    "torchvision.datasets.EMNIST": "('../data',split = \"mnist\")",
+    "torchvision.datasets.FakeData": "('../data', )",
+    "torchvision.datasets.FashionMNIST": "('../data',)",
+    "torchvision.datasets.Flickr30k": "('../data', '../data/annfile.txt')",
+    "torchvision.datasets.Flickr8k": "('../data', '../data/annfile.txt')",
+    "torchvision.datasets.HMDB51": "('../data', '../data/annfile.txt', 20,  )",
+    "torchvision.datasets.ImageNet": "('../data',)",
+    "torchvision.datasets.KMNIST": "('../data', )",
+    "torchvision.datasets.Kinetics400": "('../data', 20)",
+    "torchvision.datasets.LSUN": "('../data', )",
+    "torchvision.datasets.MNIST": "('../data', download=False,)",
+    "torchvision.datasets.Omniglot": "('../data', )",
+    "torchvision.datasets.PhotoTour": "('../data', name = 'data')",
+    "torchvision.datasets.Places365": "('../data',)",
+    "torchvision.datasets.QMNIST": "('../data',)",
+    "torchvision.datasets.SBDataset": "('../data',)",
+    "torchvision.datasets.SBU": "('../data', download = False)",
+    "torchvision.datasets.STL10": "('../data',)",
+    "torchvision.datasets.SVHN": "('../data',)",
+    "torchvision.datasets.UCF101": "('../data', frames_per_clip = 20, annotation_path = '../data/annfile.txt')",
+    "torchvision.datasets.USPS": "('../data',)",
+    "torchvision.datasets.VOCDetection": "('../data',)",
+    "torchvision.datasets.VOCSegmentation": "('../data',)",
+    "torchvision.transforms.CenterCrop": "(10)",
+    "torchvision.transforms.ColorJitter": "(brightness=0, contrast=0, saturation=0, hue=0)",
+    "torchvision.transforms.GaussianBlur": "(kernel_size = 3)",
+    "torchvision.transforms.Grayscale": "(num_output_channels=1)",
+    "torchvision.transforms.Pad": "(2, fill=0, padding_mode='constant')",
+    "torchvision.transforms.RandomAffine": "(degrees = 2)",
+    "torchvision.transforms.RandomCrop": "(size = 10)",
+    "torchvision.transforms.RandomGrayscale": "(p=0.1)",
+    "torchvision.transforms.RandomHorizontalFlip": "(p=0.1)",
+    "torchvision.transforms.RandomPerspective": "(distortion_scale=0.5, p=0.5)",
+    "torchvision.transforms.RandomResizedCrop": "(10, scale=(0.08, 1.0), ratio=(0.75, 1.25))",
+    "torchvision.transforms.RandomRotation": "(degrees = 2)",
+    "torchvision.transforms.RandomSizedCrop": "(10)",
+    "torchvision.transforms.RandomVerticalFlip": "(p=0.5)",
+    "torchvision.transforms.Resize": "(size = 15)",
+    "torchvision.transforms.Scale": "(10)",
+    "torchvision.transforms.TenCrop": "(10)",
+    "torchvision.transforms.functional.adjust_brightness": "(pil_img, 0.5)",
+    "torchvision.transforms.functional.adjust_contrast": "(pil_img, 0.5)",
+    "torchvision.transforms.functional.adjust_gamma": "(pil_img, 1, 0.5)",
+    "torchvision.transforms.functional.adjust_hue": "(pil_img, 0)",
+    "torchvision.transforms.functional.adjust_saturation": "(pil_img, 0.5)",
+    "torchvision.transforms.functional.adjust_sharpness": "(pil_img, 0.5)",
+    "torchvision.transforms.functional.affine": "(pil_img,0.2,[1,2],0.2,[1,2])",
+    "torchvision.transforms.functional.autocontrast": "(pil_img)",
+    "torchvision.transforms.functional.center_crop": "(pil_img, 10)",
+    "torchvision.transforms.functional.crop": "(pil_img, 10 , 20, 30, 40)",
+    "torchvision.transforms.functional.equalize": "(tens)",
+    "torchvision.transforms.functional.erase": "(tens, 10, 20, 30, 40, 250)",
+    "torchvision.transforms.functional.five_crop": "(pil_img, 10)",
+    "torchvision.transforms.functional.gaussian_blur": "(tens, 3)",
+    "torchvision.transforms.functional.invert": "(tens)",
+    "torchvision.transforms.functional.pad": "(pil_img, 10)",
+    "torchvision.transforms.functional.perspective": "(pil_img, [[10,20],[20,30],[30, 40],[40,50]], [[20,30],[30,40],[40, 50],[50,60]])",
+    "torchvision.transforms.functional.posterize": "(tens, 2)",
+    "torchvision.transforms.functional.resize": "(pil_img, 10)",
+    "torchvision.transforms.functional.resized_crop": "(pil_img, 10, 15, 20, 25, 30)",
+    "torchvision.transforms.functional.rgb_to_grayscale": "(pil_img)",
+    "torchvision.transforms.functional.rotate": "(pil_img, angle = 10)",
+    "torchvision.transforms.functional.solarize": "(tens, threshold = 0.5)",
+    "torchvision.transforms.functional.ten_crop": "(pil_img, size = 10)",
+    "torchvision.transforms.functional.vflip": "(tens)"
+}
\ No newline at end of file
diff --git a/tests/syft/lib/torchvision/imageTensor.pt b/tests/syft/lib/torchvision/imageTensor.pt
deleted file mode 100644
Binary files a/tests/syft/lib/torchvision/imageTensor.pt and /dev/null differ
diff --git a/tests/syft/lib/torchvision/logo.png b/tests/syft/lib/torchvision/logo.png
new file mode 100644
Binary files /dev/null and b/tests/syft/lib/torchvision/logo.png differ