Created
January 6, 2020 08:59
-
-
Save peter0749/8e806803ddd3c6bec9515845f32df553 to your computer and use it in GitHub Desktop.
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 ImageFolderEX(datasets.ImageFolder): | |
def __getitem__(self, index): | |
while True: | |
path, label = self.imgs[index] | |
try: | |
img = self.loader(os.path.join(self.root, path)) | |
if self.transform is not None: | |
img = self.transform(img) | |
except: | |
index = np.random.randint(self.__len__()) | |
continue | |
break | |
return [img, label] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment