Created
July 6, 2022 00:48
-
-
Save TransMux/5c70567b3b8cd142acb7bcaaecec49d9 to your computer and use it in GitHub Desktop.
Show picture examples of DataLoader/Dataset images with masks
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
# example of train images with masks | |
ds = HuBMAPDataset(transforms=augmentations) | |
dl = DataLoader(ds, batch_size=bs, shuffle=False, num_workers=NUM_WORKERS) | |
imgs, masks = next(iter(dl)) | |
plt.figure(figsize=(16, 16)) | |
for i, (img, mask) in enumerate(zip(imgs, masks)): | |
img = ((img.permute(1, 2, 0) * std + mean) * 255.0).numpy().astype(np.uint8) | |
plt.subplot(8, 8, i + 1) | |
plt.imshow(img, vmin=0, vmax=255) | |
plt.imshow(mask.squeeze().numpy(), alpha=0.2) | |
plt.axis('off') | |
plt.subplots_adjust(wspace=None, hspace=None) | |
del ds, dl, imgs, masks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment