Skip to content

Instantly share code, notes, and snippets.

@FavioVazquez
Created October 3, 2018 17:18
Show Gist options
  • Save FavioVazquez/106c32c2f9668628eca51bfb2eb490c7 to your computer and use it in GitHub Desktop.
Save FavioVazquez/106c32c2f9668628eca51bfb2eb490c7 to your computer and use it in GitHub Desktop.
%matplotlib inline
from urllib.request import urlopen
import numpy as np
import cv2
from matplotlib import pyplot as plt
from albumentations import (
HorizontalFlip, IAAPerspective, ShiftScaleRotate, CLAHE, RandomRotate90,
Transpose, ShiftScaleRotate, Blur, OpticalDistortion, GridDistortion, HueSaturationValue,
IAAAdditiveGaussianNoise, GaussNoise, MotionBlur, MedianBlur, IAAPiecewiseAffine,
IAASharpen, IAAEmboss, RandomContrast, RandomBrightness, Flip, OneOf, Compose
)
def download_image(url):
data = urlopen(url).read()
data = np.frombuffer(data, np.uint8)
image = cv2.imdecode(data, cv2.IMREAD_COLOR)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
return image
image = download_image('https://d177hi9zlsijyy.cloudfront.net/wp-content/uploads/sites/2/2018/05/11202041/180511105900-atlas-boston-dynamics-robot-running-super-tease.jpg')
plt.figure(figsize=(10, 10))
plt.imshow(image)
plt.show()
def augment_and_show(aug, image):
image = aug(image=image)['image']
plt.figure(figsize=(10, 10))
plt.imshow(image)
aug = HorizontalFlip(p=1)
augment_and_show(aug, image)
aug = IAAPerspective(scale=0.2, p=1)
augment_and_show(aug, image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment