forked from tensorlayer/SRGAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
executable file
·29 lines (25 loc) · 863 Bytes
/
utils.py
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
import tensorflow as tf
import tensorlayer as tl
from tensorlayer.prepro import *
# from config import config, log_config
#
# img_path = config.TRAIN.img_path
import scipy
import numpy as np
def get_imgs_fn(file_name, path):
""" Input an image path and name, return an image array """
# return scipy.misc.imread(path + file_name).astype(np.float)
return scipy.misc.imread(path + file_name, mode='RGB')
def crop_sub_imgs_fn(x, is_random=True):
x = crop(x, wrg=384, hrg=384, is_random=is_random)
x = x / (255. / 2.)
x = x - 1.
# x = (x - 0.5)*2
return x
def downsample_fn(x):
# We obtained the LR images by downsampling the HR images using bicubic kernel with downsampling factor r = 4.
x = imresize(x, size=[96, 96], interp='bicubic', mode=None)
x = x / (255. / 2.)
x = x - 1.
# x = (x - 0.5)*2
return x