Created
June 9, 2020 11:04
-
-
Save BloodAxe/0f87be23904761cfbf13b327de54e0af 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 RAMDataset(Dataset): | |
def __init__(image_fnames, targets): | |
self.targets = targets | |
self.images = [] | |
for fname in tqdm(image_fnames, desc="Loading files in RAM"): | |
with open(fname, "rb") as f: | |
self.images.append(f.read()) | |
def __len__(self): | |
return len(self.targets) | |
def __getitem__(self, index): | |
target = self.targets[index] | |
image, retval = cv2.imdecode(self.images[index], cv2.IMREAD_COLOR) | |
return image, target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment