hellochick / ICNet-tensorflow

TensorFlow-based implementation of "ICNet for Real-Time Semantic Segmentation on High-Resolution Images".
405 stars 153 forks source link

interp layer implementation #70

Open deeptf opened 6 years ago

deeptf commented 6 years ago

Hi @hellochick , I wonder if the implementation of inerp layer is similar to the original implementation ? The current function does not have conditional statements to check if only shrink or zoom is given, also the shrink implementation doesn't seem to reduce the dimension. Is there a reason for this ?

Possible change:

def interp(self, input, s_factor, z_factor, name=None): 
     ori_h, ori_w = input.get_shape().as_list()[1:3]
     # shrink
     if s_factor and not z_factor: 
          ori_h = (ori_h - 1) / s_factor + 1  ## current usage is (ori_h - 1) * s_factor + 1
          ori_w = (ori_w - 1) / s_factor + 1  ## current usage is (ori_w - 1) * s_factor + 1
        # zoom
     elif z_factor and not s_factor: 
          ori_h = ori_h + (ori_h - 1) * (z_factor - 1)
          ori_w = ori_w + (ori_w - 1) * (z_factor - 1)        
     resize_shape = [int(ori_h), int(ori_w)]
     return tf.image.resize_bilinear(input, size=resize_shape, align_corners=True, name=name) 
hellochick commented 5 years ago

Hey @deeptf,

The original version of interp layer can shrink the image by just setting the parameter of (s_factor, z_factor) to (0.5, 1). Then it would downsample the original image to 1/2 resolutions