def __init__(self, filters, activation, y_conditioned=False, splits=None): super(RefineNet, self).__init__() self.in_shape = None # Boolean is True when conditional information is concatenated to x self.y_conditioned = y_conditioned self.splits = splits self.increase_channels = layers.Conv2D(filters, kernel_size=3, padding="same") self.preact_1 = ConditionalFullPreActivationBlock(activation, filters, kernel_size=3) # FIXME: In this second preactivation block we used dilation=1, but it should have been 2 self.preact_2 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, pooling=True, dilation=2, padding=2) self.preact_3 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, dilation=2, padding=2) self.preact_4 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, dilation=4, padding=4) self.refine_block_1 = RefineBlock( activation, filters, n_blocks_crp=2, n_blocks_begin_rcu=2, n_blocks_end_rcu=3, ) self.refine_block_2 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.refine_block_3 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.refine_block_4 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.norm = ConditionalInstanceNormalizationPlusPlus2D() self.activation = activation self.decrease_channels = None
def __init__(self, filters, activation): super(RefineNet, self).__init__() self.in_shape = None self.increase_channels = layers.Conv2D(filters, kernel_size=3, padding='same') self.preact_1 = ConditionalFullPreActivationBlock(activation, filters, kernel_size=3) # FIXME: In this second preactivation block we used dilation=1, but it should have been 2 self.preact_2 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, pooling=True) self.preact_3 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, dilation=2, padding=2) self.preact_4 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, dilation=4, padding=4) self.refine_block_1 = RefineBlock(activation, filters, n_blocks_crp=2, n_blocks_begin_rcu=2, n_blocks_end_rcu=3) self.refine_block_2 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.refine_block_3 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.refine_block_4 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.norm = ConditionalInstanceNormalizationPlusPlus2D() self.activation = activation self.decrease_channels = None
def __init__(self, filters, activation, splits, y_conditioned=False): super(MaskedRefineNet, self).__init__() self.in_shape = None self.filters = filters # Describes how to split the conditioning information # Assumes x is concatenated with its pixel-wise conditioning info self.splits = splits # Concatenate x,y too feed into RefineNet block # Encourages local per-pixel conditioning self.y_conditioned = y_conditioned # Filters used for every channel when dotting # dotting with conditioning block self.conditional_embedding_size = 256 self.increase_channels = layers.Conv2D(filters, kernel_size=3, padding="same") self.preact_1 = ConditionalFullPreActivationBlock(activation, filters, kernel_size=3) # FIXME: In this second preactivation block we used dilation=1, but it should have been 2 self.preact_2 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, pooling=True) self.preact_3 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, dilation=2, padding=2) self.preact_4 = ConditionalFullPreActivationBlock(activation, filters * 2, kernel_size=3, dilation=4, padding=4) self.refine_block_1 = RefineBlock( activation, filters, n_blocks_crp=2, n_blocks_begin_rcu=2, n_blocks_end_rcu=3, ) self.refine_block_2 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.refine_block_3 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.refine_block_4 = RefineBlock(activation, filters * 2, n_blocks_crp=2, n_blocks_begin_rcu=2) self.norm = ConditionalInstanceNormalizationPlusPlus2D() self.activation = activation self.decrease_channels = None self.depth_extension = layers.Conv2D( self.conditional_embedding_size * self.splits[0], kernel_size=3, padding="same", ) # Added for conditioning block self.increase_conditional_channels = layers.Conv2D(filters, kernel_size=3, padding="same") # self.conditional_block = FullPreActivationBlock(activation, self.conditional_embedding_size*splits[0], kernel_size=3) self.conditional_block = FullPreActivationBlock( activation, self.conditional_embedding_size, kernel_size=3, dilation=2, padding=2, ) self.pool = GlobalAveragePooling2D(data_format="channels_last") self.dot = tf.keras.layers.Dot(axes=(4, 1), name="condition_dot")