Skip to content

Instantly share code, notes, and snippets.

@abhishekkrthakur
Created June 11, 2019 19:52
Show Gist options
  • Save abhishekkrthakur/0d5ac0d2417de8c59c9cafba608c4fa9 to your computer and use it in GitHub Desktop.
Save abhishekkrthakur/0d5ac0d2417de8c59c9cafba608c4fa9 to your computer and use it in GitHub Desktop.
collections dataset test
class CollectionsDatasetTest(Dataset):
def __init__(self,
csv_file,
root_dir,
transform=None):
self.data = pd.read_csv(csv_file)
self.root_dir = root_dir
self.transform = transform
def __len__(self):
return len(self.data)
def __getitem__(self, idx):
img_name = os.path.join(self.root_dir,
self.data.loc[idx, 'id'] + '.png')
image = Image.open(img_name)
if self.transform:
image = self.transform(image)
return {'image': image}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment