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)
| 87 | |
| 88 | |
| 89 | def 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 | |
| 113 | def crop_to_batch(image, scale): |
no test coverage detected