Created
June 11, 2019 19:52
-
-
Save abhishekkrthakur/0d5ac0d2417de8c59c9cafba608c4fa9 to your computer and use it in GitHub Desktop.
collections dataset test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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