MCPcopy Create free account
hub / github.com/LoSealL/VideoSuperResolution / pixel_shift

Function pixel_shift

VSR/Util/Utility.py:89–110  ·  view source on GitHub ↗

Efficient Sub-pixel Convolution, see paper: https://arxiv.org/abs/1609.05158 Args: image: A 4-D tensor of [N, H, W, C*scale[0]*scale[1]] scale: A scalar or 1-D tensor with 2 elements, the scale factor for width and height respectively channel: specify the c

(image, scale, channel=1)

Source from the content-addressed store, hash-verified

87
88
89def pixel_shift(image, scale, channel=1):
90 """Efficient Sub-pixel Convolution,
91 see paper: https://arxiv.org/abs/1609.05158
92
93 Args:
94 image: A 4-D tensor of [N, H, W, C*scale[0]*scale[1]]
95 scale: A scalar or 1-D tensor with 2 elements, the scale factor for
96 width and height respectively
97 channel: specify the channel number
98
99 Return:
100 A 4-D tensor of [N, H*scale[1], W*scale[0], C]
101 """
102
103 with tf.name_scope('PixelShift'):
104 r = to_list(scale, 2)
105 shape = tf.shape(image)
106 h, w = shape[1], shape[2]
107 image = tf.reshape(image, [-1, h, w, r[1], r[0], channel])
108 image = tf.transpose(image, perm=[0, 1, 3, 2, 4, 5]) # B, H, r, W, r, C
109 image = tf.reshape(image, [-1, h * r[1], w * r[0], channel])
110 return image
111
112
113def crop_to_batch(image, scale):

Callers 4

_flow_coarseMethod · 0.90
_flow_fineMethod · 0.90
upsampleFunction · 0.85
upscaleMethod · 0.85

Calls 2

to_listFunction · 0.85
shapeMethod · 0.45

Tested by

no test coverage detected