scripts/models.py
def SEED_Netv101(input_img, n_filters, dropout, weight_decay=False, batchnorm = True, activation = 'relu'):
    """Function to define the UNET Model"""
    if weight_decay == True:
        weight_decay = l2(5e-4)
    else:
        weight_decay = None
    c0 = Conv2D(16, kernel_size = (7, 7), strides=(2, 2), kernel_initializer = 'he_normal', padding = 'same')(input_img)
    c0 = BatchNormalization()(c0)
    c0 = Activation(activation)(c0)
    # Contracting Path
    c1 = SE_ResNet(c0, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c1 = SE_ResNet0(c1, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)  
    p1 = MaxPooling2D((2, 2))(c1)
    p1 = Dropout(dropout)(p1)
    
    c2 = SE_ResNet(p1, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c2 = SE_ResNet0(c2, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    p2 = MaxPooling2D((2, 2))(c2)
    p2 = Dropout(dropout)(p2)
    
    c3 = SE_ResNet(p2, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 2, activation = activation)
    c3 = SE_ResNet0(c3, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 2, activation = activation)
    p3 = MaxPooling2D((2, 2))(c3)
    p3 = Dropout(dropout)(p3)
    
    c4 = SE_ResNet(p3, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 4, activation = activation)
    c4 = SE_ResNet0(c4, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 4, activation = activation)
    #p4 = MaxPooling2D((2, 2))(c4)
    p4 = Dropout(dropout)(c4)
    
    c5 = SE_ResNet(p4, n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 8, activation = activation)
    c5 = SE_ResNet0(c5, n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 8, activation = activation)
    #p4 = MaxPooling2D((2, 2))(c4)
    p5 = Dropout(dropout)(c5)
    
    c6 = SE_ResNet(p5, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c6 = SE_ResNet0(c6, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)

    #connecting encoder decoder
    c6 = PDC(c6, n_filters * 16)
    #c6 = PSP_module(c6, n_filters * 16)
    #c6 = ASPP_v3(c6, n_filters*16, input_img, downsample_by = 16)
    #c6 = ASPP_v2(c6, n_filters*16)
    
    # Expanding Path
    dam6 = DAM(c3, c6, n_filters*16, 15, input_img, 8)
    u6 = UpSampling2D(interpolation='bilinear')(dam6)

    dam7 = DAM(c2, u6, n_filters*8, 15, input_img, 4)   
    u7 = UpSampling2D(interpolation='bilinear')(dam7)
    
    dam8 = DAM(c1, u7, n_filters*4, 15, input_img, 2)   
    u8 = UpSampling2D(size=(4,4), interpolation='bilinear')(dam8)
    
    outputs = Conv2D(output_ch, (1, 1), kernel_initializer = 'he_normal')(u8)#, activation='softmax'
    model = Model(inputs=[input_img], outputs=[outputs])
    return model
Function to define the UNET Model
Function to define the UNET Model
Function to define the UNET Model
def SEED_Netv101(input_img, n_filters, dropout, weight_decay=False, batchnorm = True, activation = 'relu'):
    if weight_decay == True:
        weight_decay = l2(5e-4)
    else:
        weight_decay = None
    c0 = Conv2D(16, kernel_size = (7, 7), strides=(2, 2), kernel_initializer = 'he_normal', padding = 'same')(input_img)
    c0 = BatchNormalization()(c0)
    c0 = Activation(activation)(c0)
    c1 = SE_ResNet(c0, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c1 = SE_ResNet0(c1, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)  
    p1 = MaxPooling2D((2, 2))(c1)
    p1 = Dropout(dropout)(p1)
    c2 = SE_ResNet(p1, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c2 = SE_ResNet0(c2, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    p2 = MaxPooling2D((2, 2))(c2)
    p2 = Dropout(dropout)(p2)
    c3 = SE_ResNet(p2, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 2, activation = activation)
    c3 = SE_ResNet0(c3, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 2, activation = activation)
    p3 = MaxPooling2D((2, 2))(c3)
    p3 = Dropout(dropout)(p3)
    c4 = SE_ResNet(p3, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 4, activation = activation)
    c4 = SE_ResNet0(c4, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 4, activation = activation)
    p4 = Dropout(dropout)(c4)
    c5 = SE_ResNet(p4, n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 8, activation = activation)
    c5 = SE_ResNet0(c5, n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 8, activation = activation)
    p5 = Dropout(dropout)(c5)
    c6 = SE_ResNet(p5, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c6 = SE_ResNet0(c6, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c6 = PDC(c6, n_filters * 16)
    dam6 = DAM(c3, c6, n_filters*16, 15, input_img, 8)
    u6 = UpSampling2D(interpolation='bilinear')(dam6)
    dam7 = DAM(c2, u6, n_filters*8, 15, input_img, 4)   
    u7 = UpSampling2D(interpolation='bilinear')(dam7)
    dam8 = DAM(c1, u7, n_filters*4, 15, input_img, 2)   
    u8 = UpSampling2D(size=(4,4), interpolation='bilinear')(dam8)
    outputs = Conv2D(output_ch, (1, 1), kernel_initializer = 'he_normal')(u8)
    model = Model(inputs=[input_img], outputs=[outputs])
    return model
def SEED_Netv101 ( input_img , n_filters , dropout , weight_decay = False , batchnorm = True , activation = 'relu' ) : if weight_decay == True : weight_decay = l2 ( 5e-4 ) else : weight_decay = None c0 = Conv2D ( 16 , kernel_size = ( 7 , 7 ) , strides = ( 2 , 2 ) , kernel_initializer = 'he_normal' , padding = 'same' ) ( input_img ) c0 = BatchNormalization ( ) ( c0 ) c0 = Activation ( activation ) ( c0 ) c1 = SE_ResNet ( c0 , n_filters * 1 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) c1 = SE_ResNet0 ( c1 , n_filters * 1 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) p1 = MaxPooling2D ( ( 2 , 2 ) ) ( c1 ) p1 = Dropout ( dropout ) ( p1 ) c2 = SE_ResNet ( p1 , n_filters * 2 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) c2 = SE_ResNet0 ( c2 , n_filters * 2 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) p2 = MaxPooling2D ( ( 2 , 2 ) ) ( c2 ) p2 = Dropout ( dropout ) ( p2 ) c3 = SE_ResNet ( p2 , n_filters * 4 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 2 , activation = activation ) c3 = SE_ResNet0 ( c3 , n_filters * 4 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 2 , activation = activation ) p3 = MaxPooling2D ( ( 2 , 2 ) ) ( c3 ) p3 = Dropout ( dropout ) ( p3 ) c4 = SE_ResNet ( p3 , n_filters * 8 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 4 , activation = activation ) c4 = SE_ResNet0 ( c4 , n_filters * 8 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 4 , activation = activation ) p4 = Dropout ( dropout ) ( c4 ) c5 = SE_ResNet ( p4 , n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 8 , activation = activation ) c5 = SE_ResNet0 ( c5 , n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 8 , activation = activation ) p5 = Dropout ( dropout ) ( c5 ) c6 = SE_ResNet ( p5 , n_filters = n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) c6 = SE_ResNet0 ( c6 , n_filters = n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) c6 = PDC ( c6 , n_filters * 16 ) dam6 = DAM ( c3 , c6 , n_filters * 16 , 15 , input_img , 8 ) u6 = UpSampling2D ( interpolation = 'bilinear' ) ( dam6 ) dam7 = DAM ( c2 , u6 , n_filters * 8 , 15 , input_img , 4 ) u7 = UpSampling2D ( interpolation = 'bilinear' ) ( dam7 ) dam8 = DAM ( c1 , u7 , n_filters * 4 , 15 , input_img , 2 ) u8 = UpSampling2D ( size = ( 4 , 4 ) , interpolation = 'bilinear' ) ( dam8 ) outputs = Conv2D ( output_ch , ( 1 , 1 ) , kernel_initializer = 'he_normal' ) ( u8 ) model = Model ( inputs = [ input_img ] , outputs = [ outputs ] ) return model
Function to define the UNET Model
Function to define the UNET Model
"""Function to define the UNET Model""" # Contracting Path
 #p4 = MaxPooling2D((2, 2))(c4)
 #p4 = MaxPooling2D((2, 2))(c4)
 #connecting encoder decoder
 #c6 = PSP_module(c6, n_filters * 16)
 #c6 = ASPP_v3(c6, n_filters*16, input_img, downsample_by = 16)
 #c6 = ASPP_v2(c6, n_filters*16)
 # Expanding Path
 #, activation='softmax'

input_img
n_filters
dropout
weight_decay
batchnorm
activation