Skip to content

Instantly share code, notes, and snippets.

@davidefiocco
Created May 19, 2020 12:18
Show Gist options
  • Save davidefiocco/33f9c4e447eb38c1b014819c17ad7b8e to your computer and use it in GitHub Desktop.
Save davidefiocco/33f9c4e447eb38c1b014819c17ad7b8e to your computer and use it in GitHub Desktop.
Test torchvision tranforms on a bunch of images
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