This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fcn32model = fcn32_blank() | |
fcn32shape = fcn32model.layers[-1].output_shape | |
fcn32size = fcn32shape[2] # INFO: =32 when images are 512x512 | |
sp4 = Convolution2D(21, 1, 1, | |
border_mode='same', # INFO : border_mode does not matter for 1x1 | |
activation=None, | |
name='score_pool4') | |
# INFO : Keras sum is a special case of the merge function | |
summed = merge([sp4(fcn32model.layers[14].output), fcn32model.layers[-1].output], mode='sum') | |
# INFO : | |
# deconv setting is valid if (528-32)/16 + 1 = deconv_input_dim (= fcn32size) | |
deconv_output_size = (fcn32size-1)*16+32 # INFO: =528 when images are 512x512 | |
upnew = Deconvolution2D(21, 32, 32, | |
output_shape=(None, 21, deconv_output_size, deconv_output_size), | |
border_mode='valid', # WARNING : valid, same or full ? | |
subsample=(16, 16), | |
activation=None, | |
name = 'upsample_new') | |
# INFO : cropping as deconv gained pixels | |
extra_margin = deconv_output_size - fcn32size*16 # INFO: =16 when images are 512x512 | |
crop_margin = Cropping2D(cropping=((extra_margin/2, extra_margin/2), | |
(extra_margin/2, extra_margin/2))) | |
fcn16model = Model(fcn32model.input, crop_margin(upnew(summed))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment