Basically now I am getting all types of errors regarding the data and target types, maybe it has something to do with a way I convert to tensor, could something check it out?
if self.train == True:

        try:

          masks = Image.open(self.masks_dir + os.path.splitext(self.train_names[idx])[0]+'beard.jpg') ## change the end of the filename name depending of we want "beard" or "hair" or "_eyelid"

          target = 1

            #----------------------------------------------------------------------- 

        except:

          target = 0

      else:

        target = 0

      image=np.array(image)

      if image.shape[2] == 4:

        #convert the image from RGBA2R

        image = cv2.cvtColor(image, cv2.COLOR_BGR2BGR)

      image=resize(image, (self.im_size , self.im_size),anti_aliasing=True)

      image = transforms.ToTensor()(image)

      image=image.float() 

      #target = torch.Tensor(target)

      

      target = transforms.ToTensor()(target).float()

      

      sample = {'image': image, 'target': target}

When I try to iterate the dataloader, this happens:

TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
    data = fetcher.fetch(index)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "<ipython-input-83-577e6d24b257>", line 50, in __getitem__
    target = transforms.ToTensor()(target).float()
  File "/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py", line 92, in __call__
    return F.to_tensor(pic)
  File "/usr/local/lib/python3.6/dist-packages/torchvision/transforms/functional.py", line 46, 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 <class 'int'>