scripts/models.py
def DAN_net(input_img, n_filters, dropout, batchnorm = True):
    '''
    For this model output is 1/8 of the input size
    '''
    c0 = Conv2D(starting_ch, kernel_size = (7, 7), kernel_initializer = 'he_normal', padding = 'same')(input_img)
    c0 = BatchNormalization()(c0)
    c0 = Activation('relu')(c0)
    # Contracting Path
    c1 = SE_ResNet(c0, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    c1 = SE_ResNet0(c1, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)  
    p1 = MaxPooling2D((2, 2))(c1)
    p1 = Dropout(dropout)(p1)
    
    c2 = SE_ResNet(p1, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    c2 = SE_ResNet0(c2, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    p2 = MaxPooling2D((2, 2))(c2)
    p2 = Dropout(dropout)(p2)
    
    c3 = SE_ResNet(p2, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 2)
    c3 = SE_ResNet0(c3, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 2)
    p3 = MaxPooling2D((2, 2))(c3)
    p3 = Dropout(dropout)(p3)
    
    c4 = SE_ResNet(p3, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 4)
    c4 = SE_ResNet0(c4, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 4)
    #c4 = MaxPooling2D((2, 2))(c4)
    p4 = Dropout(dropout)(c4)
    
    c5 = SE_ResNet(p4, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 8)
    c5 = SE_ResNet0(c5, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 8)
    c5 = Dropout(dropout)(c5)
    c5 = SE_ResNet(p4, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    c5 = SE_ResNet0(c5, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    
    #Transition
    '''
    **([c5, n_filters])** For giving more than 1 tensor as an input to lambda layer.
    Now this list will be passed on to the function inside lambda layer. We can call the values by normal indexing 
    operation in order. e.g.
    
    def custom_layer(tensor):
        tensor1 = tensor[0]
        tensor2 = tensor[1]
        return tensor1 + tensor2
    '''
    ctrp = Lambda(PAM, name="lambda_PAM")(c5)
    ctrc = Lambda(CAM, name="lambda_CAM")(c5)
    ctr = add([ctrp, ctrc])
    
    outputs = Conv2D(output_ch, (1, 1))(ctr)#, activation='softmax'
    model = Model(inputs=[input_img], outputs=[outputs])
    return model

    For this model output is 1/8 of the input size
    
For this model output is 1/8 of the input size
For this model output is 1 / 8 of the input size
def DAN_net(input_img, n_filters, dropout, batchnorm = True):
    c0 = Conv2D(starting_ch, kernel_size = (7, 7), kernel_initializer = 'he_normal', padding = 'same')(input_img)
    c0 = BatchNormalization()(c0)
    c0 = Activation('relu')(c0)
    c1 = SE_ResNet(c0, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    c1 = SE_ResNet0(c1, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)  
    p1 = MaxPooling2D((2, 2))(c1)
    p1 = Dropout(dropout)(p1)
    c2 = SE_ResNet(p1, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    c2 = SE_ResNet0(c2, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    p2 = MaxPooling2D((2, 2))(c2)
    p2 = Dropout(dropout)(p2)
    c3 = SE_ResNet(p2, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 2)
    c3 = SE_ResNet0(c3, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 2)
    p3 = MaxPooling2D((2, 2))(c3)
    p3 = Dropout(dropout)(p3)
    c4 = SE_ResNet(p3, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 4)
    c4 = SE_ResNet0(c4, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 4)
    p4 = Dropout(dropout)(c4)
    c5 = SE_ResNet(p4, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 8)
    c5 = SE_ResNet0(c5, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 8)
    c5 = Dropout(dropout)(c5)
    c5 = SE_ResNet(p4, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    c5 = SE_ResNet0(c5, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    ctrp = Lambda(PAM, name="lambda_PAM")(c5)
    ctrc = Lambda(CAM, name="lambda_CAM")(c5)
    ctr = add([ctrp, ctrc])
    outputs = Conv2D(output_ch, (1, 1))(ctr)
    model = Model(inputs=[input_img], outputs=[outputs])
    return model
def DAN_net ( input_img , n_filters , dropout , batchnorm = True ) : c0 = Conv2D ( starting_ch , kernel_size = ( 7 , 7 ) , kernel_initializer = 'he_normal' , padding = 'same' ) ( input_img ) c0 = BatchNormalization ( ) ( c0 ) c0 = Activation ( 'relu' ) ( c0 ) c1 = SE_ResNet ( c0 , n_filters * 1 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 ) c1 = SE_ResNet0 ( c1 , n_filters * 1 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 ) p1 = MaxPooling2D ( ( 2 , 2 ) ) ( c1 ) p1 = Dropout ( dropout ) ( p1 ) c2 = SE_ResNet ( p1 , n_filters * 2 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 ) c2 = SE_ResNet0 ( c2 , n_filters * 2 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 ) p2 = MaxPooling2D ( ( 2 , 2 ) ) ( c2 ) p2 = Dropout ( dropout ) ( p2 ) c3 = SE_ResNet ( p2 , n_filters * 4 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 2 ) c3 = SE_ResNet0 ( c3 , n_filters * 4 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 2 ) p3 = MaxPooling2D ( ( 2 , 2 ) ) ( c3 ) p3 = Dropout ( dropout ) ( p3 ) c4 = SE_ResNet ( p3 , n_filters * 8 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 4 ) c4 = SE_ResNet0 ( c4 , n_filters * 8 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 4 ) p4 = Dropout ( dropout ) ( c4 ) c5 = SE_ResNet ( p4 , n_filters = n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 8 ) c5 = SE_ResNet0 ( c5 , n_filters = n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 8 ) c5 = Dropout ( dropout ) ( c5 ) c5 = SE_ResNet ( p4 , n_filters = n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 ) c5 = SE_ResNet0 ( c5 , n_filters = n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 ) '''
    **([c5, n_filters])** For giving more than 1 tensor as an input to lambda layer.
    Now this list will be passed on to the function inside lambda layer. We can call the values by normal indexing 
    operation in order. e.g.
    
    def custom_layer(tensor):
        tensor1 = tensor[0]
        tensor2 = tensor[1]
        return tensor1 + tensor2
    ''' ctrp = Lambda ( PAM , name = "lambda_PAM" ) ( c5 ) ctrc = Lambda ( CAM , name = "lambda_CAM" ) ( c5 ) ctr = add ( [ ctrp , ctrc ] ) outputs = Conv2D ( output_ch , ( 1 , 1 ) ) ( ctr ) model = Model ( inputs = [ input_img ] , outputs = [ outputs ] ) return model
For this model output is 1/8 of the input size
For this model output is 1 / 8 of the input size
'''
    For this model output is 1/8 of the input size
    ''' # Contracting Path
 #c4 = MaxPooling2D((2, 2))(c4)
 #Transition
 '''
    **([c5, n_filters])** For giving more than 1 tensor as an input to lambda layer.
    Now this list will be passed on to the function inside lambda layer. We can call the values by normal indexing 
    operation in order. e.g.
    
    def custom_layer(tensor):
        tensor1 = tensor[0]
        tensor2 = tensor[1]
        return tensor1 + tensor2
    ''' #, activation='softmax'

input_img
n_filters
dropout
batchnorm