Skip to content

Commit

Permalink
add centering and boundary cropping for data
Browse files Browse the repository at this point in the history
  • Loading branch information
ychfan committed Apr 12, 2017
1 parent bbf83f5 commit 6526f17
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion data.py
Expand Up @@ -20,6 +20,8 @@ def dataset(hr_flist, lr_flist, scale, resize=resize, residual=residual):
hr_image = make_residual(hr_image, lr_image)
hr_patches0, lr_patches0 = make_patches(hr_image, lr_image, scale, resize)
hr_patches1, lr_patches1 = make_patches(tf.image.rot90(hr_image), tf.image.rot90(lr_image), scale, resize)
lr_patches0 -= 0.5
lr_patches1 -= 0.5
return tf.concat([hr_patches0, hr_patches1], 0), tf.concat([lr_patches0, lr_patches1], 0)

def make_residual(hr_image, lr_image):
Expand All @@ -31,7 +33,9 @@ def make_residual(hr_image, lr_image):

def make_patches(hr_image, lr_image, scale, resize):
hr_image = tf.stack(flip([hr_image]))
lr_image = tf.stack(flip([lr_image]))
lr_image = tf.stack(flip([lr_image]))
hr_image = util.crop_by_pixel(hr_image, 12)
lr_image = util.crop_by_pixel(lr_image, 12 / scale)
hr_patches = util.image_to_patches(hr_image)
if (resize):
lr_image = util.resize_func(lr_image, tf.shape(hr_image)[1:3])
Expand Down
2 changes: 1 addition & 1 deletion predict.py
Expand Up @@ -36,7 +36,7 @@
else:
lr_image = tf.reshape(lr_image, [1, lr_image_shape[0], lr_image_shape[1], 3])
lr_image_padded = util.pad_boundary(lr_image)
hr_image = model.build_model(lr_image_padded, FLAGS.scale, training=False, reuse=False)
hr_image = model.build_model(lr_image_padded - 0.5, FLAGS.scale, training=False, reuse=False)
hr_image = util.crop_center(hr_image, hr_image_shape)
if (data.residual):
if (data.resize):
Expand Down
2 changes: 1 addition & 1 deletion validate.py
Expand Up @@ -39,7 +39,7 @@
else:
lr_image = tf.reshape(lr_image, [1, lr_image_shape[0], lr_image_shape[1], 3])
lr_image_padded = util.pad_boundary(lr_image)
sr_image = model.build_model(lr_image_padded, FLAGS.scale, training=False, reuse=False)
sr_image = model.build_model(lr_image_padded - 0.5, FLAGS.scale, training=False, reuse=False)
sr_image = util.crop_center(sr_image, hr_image_shape)
if (data.residual):
if (data.resize):
Expand Down

0 comments on commit 6526f17

Please sign in to comment.