Created
May 19, 2020 12:18
-
-
Save davidefiocco/33f9c4e447eb38c1b014819c17ad7b8e to your computer and use it in GitHub Desktop.
Test torchvision tranforms on a bunch of images
This file contains hidden or 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
from torchvision import datasets, models, transforms | |
from PIL import Image | |
import torch | |
import matplotlib.pyplot as plt | |
from pathlib import Path | |
images = list(Path('../foo').glob('**/*.*')) | |
example = images.pop() | |
img = Image.open(example).convert('RGB') | |
transform = transforms.ColorJitter(brightness=0.5, contrast=0.4, saturation=0.9, hue=0.15) | |
plt.subplots(3, 3) | |
ax = plt.gca() | |
for i in range(3): | |
for i in range(3): | |
transformed = transform(img) | |
ax[i, j].imshow(transformed) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment