how to add transformation in pytorch object detection
I'm new to PyTorch &amp; going through the PyTorch object detection documentation tutorial pytorch docx.
At their collab version, I made the below changes to add some transformation techniques.

First change to the __getitem__ method of class PennFudanDataset(torch.utils.data.Dataset)

if self.transforms is not None:
   img = self.transforms(img)     
   target = T.ToTensor()(target)
   return img, target

In actual documentation it is 
if self.transforms is not None:
   img, target = self.transforms(img, target)  

Secondly, at the get_transform(train)function.
def get_transform(train):
  if train:
    transformed = T.Compose([             
           T.ToTensor(),
           T.GaussianBlur(kernel_size=5, sigma=(0.1, 2.0)),
          T.ColorJitter(brightness=[0.1, 0.2], contrast=[0.1, 0.2], saturation=[0, 0.2], hue=[0,0.5])
    ])
    return transformed

  else:
    return T.ToTensor()

**In the documentation it is-** 
def get_transform(train):
    transforms = []
    transforms.append(T.ToTensor())
    if train:
        transforms.append(T.RandomHorizontalFlip(0.5))
    return T.Compose(transforms)

While implementing the code, I'm getting the below error. I'm not able to get what I',m doing wrong.
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py&quot;, line 198, in _worker_loop
    data = fetcher.fetch(index)
  File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py&quot;, line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py&quot;, line 44, in &lt;listcomp&gt;
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataset.py&quot;, line 272, in __getitem__
    return self.dataset[self.indices[idx]]
  File &quot;&lt;ipython-input-41-94e93ff7a132&gt;&quot;, line 72, in __getitem__
    target = T.ToTensor()(target)
  File &quot;/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py&quot;, line 104, in __call__
    return F.to_tensor(pic)
  File &quot;/usr/local/lib/python3.6/dist-packages/torchvision/transforms/functional.py&quot;, line 64, in to_tensor
    raise TypeError('pic should be PIL Image or ndarray. Got {}'.format(type(pic)))
TypeError: pic should be PIL Image or ndarray. Got &lt;class 'dict'&gt;


I believe the Pytorch transforms only work on images (PIL images or np arrays in this case) and not labels (which are dicts according to the trace). As such, I don't think you need to &quot;tensorify&quot; the labels as in this line target = T.ToTensor()(target) in the __getitem__ function.
