Spaces:
Configuration error
Configuration error
File size: 748 Bytes
e5ba844 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from __future__ import division
from PIL import Image, ImageOps
try:
import accimage
except ImportError:
accimage = None
import numpy as np
class RandomRotate(object):
def __init__(self, range):
self.range = range
assert len(range) == 2
def __call__(self, img):
angle = np.random.randint(self.range[0], self.range[1], 1)
return img.rotate(angle)
class RandomJitter(object):
def __init__(self, range):
self.range = range
assert len(range) == 2
def __call__(self, img):
pic = np.array(img)
noise = np.random.randint(self.range[0], self.range[1], pic.shape[-1])
pic = pic+noise
pic = pic.astype(np.uint8)
return Image.fromarray(pic)
|