some-noon-7401
03/07/2023, 8:06 AMdef __getitem__(self, index):
with S3() as s3:
byte_data = s3.get(self.data.iloc[index]['url']).blob
if byte_data is None:
return self.__getitem__((index + 1) % len(self.data))
img = Image.open(BytesIO(byte_data)).convert('RGB')
if self.transform is not None:
img = self.transform(img)
if self.target_transform is not None:
label = self.target_transform(self.data.iloc[index]['label'])
else:
label = self.data.iloc[index]['label']
return img, label
Is there anything which I might have missed out in the code which is slowing the loading process?