scripts/models.py
def SEED_Netv1(input_img, n_filters, dropout, batchnorm = True, activation = 'relu'):
    """Function to define the UNET Model"""
    #Making image pyramids for concatinaing at later stages will simply resize the images
    avg_pyramid1, avg_pyramid2, avg_pyramid3, avg_pyramid4 = avg_img_pyramid(input_img) #via average pooling
    max_pyramid1, max_pyramid2, max_pyramid3, max_pyramid4 = max_img_pyramid(input_img) #via max pooling
    
    # Contracting Path
    c1 = SE_ResNet(input_img, 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 = 1, activation = activation)
    c3 = SE_ResNet0(c3, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, 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 = 1, activation = activation)
    c4 = SE_ResNet0(c4, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    p4 = MaxPooling2D((2, 2))(c4)
    p4 = Dropout(dropout)(p4)

    c5 = SE_ResNet(p4, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c5 = SE_ResNet0(c5, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)

    #connecting encoder decoder
    #c5 = parallel_dil(c5, n_filters * 16, kernel_size = 3) #with parallet dil
    c5 = dense_skip(c5, avg_pyramid4, max_pyramid4, n_filters * 16, kernel_size = 7)#with dense skip
    #c5 = PDC(c5, n_filters * 16)

    # Expanding Path
    u6 = Conv2DTranspose(n_filters * 8, (3, 3), strides = (2, 2), padding = 'same')(c5)
    ds6 = dense_skip(c4, avg_pyramid3, max_pyramid3, n_filters * 8, kernel_size = 9)
    u6 = concatenate([u6, ds6])
    u6 = Dropout(dropout)(u6)
    c6 = SE_ResNet(u6, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    
    u7 = Conv2DTranspose(n_filters * 4, (3, 3), strides = (2, 2), padding = 'same')(c6)
    ds7 = dense_skip(c3, avg_pyramid2, max_pyramid2, n_filters * 4, kernel_size = 11)
    u7 = concatenate([u7, ds7])
    u7 = Dropout(dropout)(u7)
    c7 = SE_ResNet(u7, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    
    u8 = Conv2DTranspose(n_filters * 2, (3, 3), strides = (2, 2), padding = 'same')(c7)
    ds8 = dense_skip(c2, avg_pyramid1, max_pyramid1, n_filters * 2, kernel_size = 13)
    u8 = concatenate([u8, ds8])
    u8 = Dropout(dropout)(u8)
    c8 = SE_ResNet(u8, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    
    u9 = Conv2DTranspose(n_filters * 1, (3, 3), strides = (2, 2), padding = 'same')(c8)
    ds9 = dense_skip0(c1, input_img, n_filters * 1, kernel_size = 15)
    u9 = concatenate([u9, ds9])
    u9 = Dropout(dropout)(u9)
    c9 = SE_ResNet(u9, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    
    c_out = ResNet_block_op(c9, output_ch, kernel_size = 3, batchnorm = batchnorm)
    outputs = Conv2D(output_ch, (1, 1))(c_out)#, 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_Netv1(input_img, n_filters, dropout, batchnorm = True, activation = 'relu'):
    avg_pyramid1, avg_pyramid2, avg_pyramid3, avg_pyramid4 = avg_img_pyramid(input_img) 
    max_pyramid1, max_pyramid2, max_pyramid3, max_pyramid4 = max_img_pyramid(input_img) 
    c1 = SE_ResNet(input_img, 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 = 1, activation = activation)
    c3 = SE_ResNet0(c3, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, 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 = 1, activation = activation)
    c4 = SE_ResNet0(c4, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    p4 = MaxPooling2D((2, 2))(c4)
    p4 = Dropout(dropout)(p4)
    c5 = SE_ResNet(p4, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c5 = SE_ResNet0(c5, n_filters = n_filters * 16, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c5 = dense_skip(c5, avg_pyramid4, max_pyramid4, n_filters * 16, kernel_size = 7)
    u6 = Conv2DTranspose(n_filters * 8, (3, 3), strides = (2, 2), padding = 'same')(c5)
    ds6 = dense_skip(c4, avg_pyramid3, max_pyramid3, n_filters * 8, kernel_size = 9)
    u6 = concatenate([u6, ds6])
    u6 = Dropout(dropout)(u6)
    c6 = SE_ResNet(u6, n_filters * 8, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1)
    u7 = Conv2DTranspose(n_filters * 4, (3, 3), strides = (2, 2), padding = 'same')(c6)
    ds7 = dense_skip(c3, avg_pyramid2, max_pyramid2, n_filters * 4, kernel_size = 11)
    u7 = concatenate([u7, ds7])
    u7 = Dropout(dropout)(u7)
    c7 = SE_ResNet(u7, n_filters * 4, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    u8 = Conv2DTranspose(n_filters * 2, (3, 3), strides = (2, 2), padding = 'same')(c7)
    ds8 = dense_skip(c2, avg_pyramid1, max_pyramid1, n_filters * 2, kernel_size = 13)
    u8 = concatenate([u8, ds8])
    u8 = Dropout(dropout)(u8)
    c8 = SE_ResNet(u8, n_filters * 2, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    u9 = Conv2DTranspose(n_filters * 1, (3, 3), strides = (2, 2), padding = 'same')(c8)
    ds9 = dense_skip0(c1, input_img, n_filters * 1, kernel_size = 15)
    u9 = concatenate([u9, ds9])
    u9 = Dropout(dropout)(u9)
    c9 = SE_ResNet(u9, n_filters * 1, kernel_size = 3, batchnorm = batchnorm, dil_rate = 1, activation = activation)
    c_out = ResNet_block_op(c9, output_ch, kernel_size = 3, batchnorm = batchnorm)
    outputs = Conv2D(output_ch, (1, 1))(c_out)
    model = Model(inputs=[input_img], outputs=[outputs])
    return model
def SEED_Netv1 ( input_img , n_filters , dropout , batchnorm = True , activation = 'relu' ) : avg_pyramid1 , avg_pyramid2 , avg_pyramid3 , avg_pyramid4 = avg_img_pyramid ( input_img ) max_pyramid1 , max_pyramid2 , max_pyramid3 , max_pyramid4 = max_img_pyramid ( input_img ) c1 = SE_ResNet ( input_img , 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 = 1 , activation = activation ) c3 = SE_ResNet0 ( c3 , n_filters * 4 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , 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 = 1 , activation = activation ) c4 = SE_ResNet0 ( c4 , n_filters * 8 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) p4 = MaxPooling2D ( ( 2 , 2 ) ) ( c4 ) p4 = Dropout ( dropout ) ( p4 ) c5 = SE_ResNet ( p4 , n_filters = n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) c5 = SE_ResNet0 ( c5 , n_filters = n_filters * 16 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) c5 = dense_skip ( c5 , avg_pyramid4 , max_pyramid4 , n_filters * 16 , kernel_size = 7 ) u6 = Conv2DTranspose ( n_filters * 8 , ( 3 , 3 ) , strides = ( 2 , 2 ) , padding = 'same' ) ( c5 ) ds6 = dense_skip ( c4 , avg_pyramid3 , max_pyramid3 , n_filters * 8 , kernel_size = 9 ) u6 = concatenate ( [ u6 , ds6 ] ) u6 = Dropout ( dropout ) ( u6 ) c6 = SE_ResNet ( u6 , n_filters * 8 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 ) u7 = Conv2DTranspose ( n_filters * 4 , ( 3 , 3 ) , strides = ( 2 , 2 ) , padding = 'same' ) ( c6 ) ds7 = dense_skip ( c3 , avg_pyramid2 , max_pyramid2 , n_filters * 4 , kernel_size = 11 ) u7 = concatenate ( [ u7 , ds7 ] ) u7 = Dropout ( dropout ) ( u7 ) c7 = SE_ResNet ( u7 , n_filters * 4 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) u8 = Conv2DTranspose ( n_filters * 2 , ( 3 , 3 ) , strides = ( 2 , 2 ) , padding = 'same' ) ( c7 ) ds8 = dense_skip ( c2 , avg_pyramid1 , max_pyramid1 , n_filters * 2 , kernel_size = 13 ) u8 = concatenate ( [ u8 , ds8 ] ) u8 = Dropout ( dropout ) ( u8 ) c8 = SE_ResNet ( u8 , n_filters * 2 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) u9 = Conv2DTranspose ( n_filters * 1 , ( 3 , 3 ) , strides = ( 2 , 2 ) , padding = 'same' ) ( c8 ) ds9 = dense_skip0 ( c1 , input_img , n_filters * 1 , kernel_size = 15 ) u9 = concatenate ( [ u9 , ds9 ] ) u9 = Dropout ( dropout ) ( u9 ) c9 = SE_ResNet ( u9 , n_filters * 1 , kernel_size = 3 , batchnorm = batchnorm , dil_rate = 1 , activation = activation ) c_out = ResNet_block_op ( c9 , output_ch , kernel_size = 3 , batchnorm = batchnorm ) outputs = Conv2D ( output_ch , ( 1 , 1 ) ) ( c_out ) 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""" #Making image pyramids for concatinaing at later stages will simply resize the images
 #via average pooling
 #via max pooling
 # Contracting Path
 #connecting encoder decoder
 #c5 = parallel_dil(c5, n_filters * 16, kernel_size = 3) #with parallet dil
 #with dense skip
 #c5 = PDC(c5, n_filters * 16)
 # Expanding Path
 #, activation='softmax'

input_img
n_filters
dropout
batchnorm
activation