Skip to content

Commit

Permalink
fix resize_w_pad
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmanderson committed Apr 17, 2020
1 parent 3341b12 commit 5978c9b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions model_tf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def Deeplabv3(weights='pascal_voc', input_tensor=None, input_shape=(512, 512, 3)
# upsample. have to use compat because of the option align_corners
size_before = K.int_shape(x)

b4 = Lambda(lambda x: tf.image.resize_with_pad(x, size_before[1:3], method='bilinear'))(b4)
b4 = Lambda(lambda x: tf.image.resize_with_pad(x, target_height=size_before[1], target_width=size_before[2]))(b4)
# b4 = UpSampling2D(size=(size_before[1],size_before[2]),interpolation='bilinear')(b4)
# simple 1x1
b0 = Conv2D(256, (1, 1), padding='same', use_bias=False, name='aspp0')(x)
Expand Down Expand Up @@ -412,7 +412,7 @@ def Deeplabv3(weights='pascal_voc', input_tensor=None, input_shape=(512, 512, 3)
# size_in = K.int_shape(x)
# size_out = K.int_shape(skip1)
# x = UpSampling2D(size=(size_out[1]//size_in[1],size_out[2]//size_in[2]),interpolation='bilinear')(x)
x = Lambda(lambda xx: tf.image.resize_with_pad(xx, skip1.shape[1:3], method='bilinear'))(x)
x = Lambda(lambda xx: tf.image.resize_with_pad(xx, target_height=skip1.shape[1], target_width=skip1.shape[2]))(x)
dec_skip1 = Conv2D(48, (1, 1), padding='same',
use_bias=False, name='feature_projection0')(skip1)
dec_skip1 = BatchNormalization(
Expand All @@ -436,7 +436,7 @@ def Deeplabv3(weights='pascal_voc', input_tensor=None, input_shape=(512, 512, 3)
# size_out = K.int_shape(img_input)
# x = UpSampling2D(size=(size_out[1] // size_in[1], size_out[2] // size_in[2]), interpolation='bilinear')(x)
size_before3 = K.int_shape(img_input)
x = Lambda(lambda xx: tf.image.resize_with_pad(xx, size_before3[1:3], method='bilinear'))(x)
x = Lambda(lambda xx: tf.image.resize_with_pad(xx, target_height=size_before3[1], target_width=size_before3[2]))(x)
# Ensure that the model takes into account
# any potential predecessors of `input_tensor`.
if input_tensor is not None:
Expand Down

0 comments on commit 5978c9b

Please sign in to comment.