Skip to content Skip to sidebar Skip to footer

How To Load A Dataset Of Images Starting From List Of Images Pytorch

I have a service that receives images in a binary format from another service (let's call it service B): from PIL import Image img_list = [] img_bin = get_image_from_service_B() i

Solution 1:

You can simply write a custom dataset:

classMyDataset(torch.utils.data.Dataset):
  def__init__(self, img_list, augmentations):
    super(MyDataset, self).__init__()
    self.img_list = img_list
    self.augmentations = augmentations

  def__len__(self):
    returnlen(self.img_list)

  def__getitem__(self, idx):
    img = self.img_list[idx]
    return self.augmentations(img)
  

You can now plug this custom dataset into DataLoader and you are done.

Post a Comment for "How To Load A Dataset Of Images Starting From List Of Images Pytorch"