utils.py 486 Bytes
Newer Older
yongshk's avatar
yongshk committed
1
2
import scipy
import numpy as np
yongshk's avatar
yongshk committed
3
4
5
6
import imageio

# def get_imgs_fn(file_name):
#     return imageio.imread(file_name, pilmode='RGB')
yongshk's avatar
yongshk committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

def get_imgs_fn(file_name):
	return scipy.misc.imread(file_name, mode='RGB')

def augment_imgs_fn(x, add_noise=True):
	return x+0.1*x.std()*np.random.random(x.shape)

def normalize_imgs_fn(x):
    x = x * (2./ 255.) - 1.
    # x = x * (1./255.)
    return x

def truncate_imgs_fn(x):
	x = np.where(x > -1., x, -1.)
	x = np.where(x < 1., x, 1.)
	return x