Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from tensorflow.keras.layers import BatchNormalization
# Internal libraries/scripts
from miscnn.neural_network.architecture.abstract_architecture import Abstract_Architecture
#-----------------------------------------------------#
# Architecture class: U-Net Residual #
#-----------------------------------------------------#
""" The Residual variant of the popular U-Net architecture.
It uses additional concatenate layers after each convolutional block (2x conv layers).
Methods:
__init__ Object creation function
create_model_2D: Creating the 2D U-Net Residual model using Keras
create_model_3D: Creating the 3D U-Net Residual model using Keras
"""
class Architecture(Abstract_Architecture):
#---------------------------------------------#
# Initialization #
#---------------------------------------------#
def __init__(self, n_filters=32, depth=4, activation='sigmoid',
batch_normalization=True):
# Parse parameter
self.n_filters = n_filters
self.depth = depth
self.activation = activation
# Batch normalization settings
self.ba_norm = batch_normalization
self.ba_norm_momentum = 0.99
#---------------------------------------------#
# Create 2D Model #
#---------------------------------------------#
from tensorflow.keras.layers import ELU, LeakyReLU
# Internal libraries/scripts
from miscnn.neural_network.architecture.abstract_architecture import Abstract_Architecture
#-----------------------------------------------------#
# Architecture class: U-Net MultiRes #
#-----------------------------------------------------#
""" The MultiRes variant of the popular U-Net architecture.
Methods:
__init__ Object creation function
create_model_2D: Creating the 2D U-Net standard model using Keras
create_model_3D: Creating the 3D U-Net standard model using Keras
"""
class Architecture(Abstract_Architecture):
#---------------------------------------------#
# Initialization #
#---------------------------------------------#
def __init__(self, activation='sigmoid'):
# Parse parameter
self.activation = activation
#---------------------------------------------#
# Create 2D Model #
#---------------------------------------------#
def create_model_2D(self, input_shape, n_labels=2):
# Input layer
inputs = Input(input_shape)
mresblock1 = MultiResBlock_2D(32, inputs)
pool1 = MaxPooling2D(pool_size=(2, 2))(mresblock1)
from tensorflow.keras.layers import BatchNormalization
# Internal libraries/scripts
from miscnn.neural_network.architecture.abstract_architecture import Abstract_Architecture
#-----------------------------------------------------#
# Architecture class: U-Net Compact #
#-----------------------------------------------------#
""" The Compact variant of the popular U-Net architecture.
It uses additional concatenate layers after each convolutional block (2x conv layers).
Methods:
__init__ Object creation function
create_model_2D: Creating the 2D U-Net Compact model using Keras
create_model_3D: Creating the 3D U-Net Compact model using Keras
"""
class Architecture(Abstract_Architecture):
#---------------------------------------------#
# Initialization #
#---------------------------------------------#
def __init__(self, n_filters=32, depth=4, activation='sigmoid',
batch_normalization=True):
# Parse parameter
self.n_filters = n_filters
self.depth = depth
self.activation = activation
# Batch normalization settings
self.ba_norm = batch_normalization
self.ba_norm_momentum = 0.99
#---------------------------------------------#
# Create 2D Model #
#---------------------------------------------#
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Conv2DTranspose
from tensorflow.keras.layers import BatchNormalization
# Internal libraries/scripts
from miscnn.neural_network.architecture.abstract_architecture import Abstract_Architecture
#-----------------------------------------------------#
# Architecture class: U-Net Standard #
#-----------------------------------------------------#
""" The Standard variant of the popular U-Net architecture.
Methods:
__init__ Object creation function
create_model_2D: Creating the 2D U-Net standard model using Keras
create_model_3D: Creating the 3D U-Net standard model using Keras
"""
class Architecture(Abstract_Architecture):
#---------------------------------------------#
# Initialization #
#---------------------------------------------#
def __init__(self, n_filters=32, depth=4, activation='softmax',
batch_normalization=True):
# Parse parameter
self.n_filters = n_filters
self.depth = depth
self.activation = activation
# Batch normalization settings
self.ba_norm = batch_normalization
self.ba_norm_momentum = 0.99
#---------------------------------------------#
# Create 2D Model #
#---------------------------------------------#
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Conv2DTranspose
from tensorflow.keras.layers import BatchNormalization
# Internal libraries/scripts
from miscnn.neural_network.architecture.abstract_architecture import Abstract_Architecture
#-----------------------------------------------------#
# Architecture class: U-Net Plain #
#-----------------------------------------------------#
""" The Plain variant of the popular U-Net architecture.
Methods:
__init__ Object creation function
create_model_2D: Creating the 2D U-Net plain model using Keras
create_model_3D: Creating the 3D U-Net plain model using Keras
"""
class Architecture(Abstract_Architecture):
#---------------------------------------------#
# Initialization #
#---------------------------------------------#
def __init__(self, activation='softmax', batch_normalization=True):
# Parse parameter
self.activation = activation
# Batch normalization settings
self.ba_norm = batch_normalization
# Create list of filters
self.feature_map = [30, 60, 120, 240, 320]
#---------------------------------------------#
# Create 2D Model #
#---------------------------------------------#
def create_model_2D(self, input_shape, n_labels=2):
# Input layer
from tensorflow.keras.layers import BatchNormalization
# Internal libraries/scripts
from miscnn.neural_network.architecture.abstract_architecture import Abstract_Architecture
#-----------------------------------------------------#
# Architecture class: U-Net Dense #
#-----------------------------------------------------#
""" The Dense variant of the popular U-Net architecture.
It uses additional concatenate layers after each convolutional layer.
Methods:
__init__ Object creation function
create_model_2D: Creating the 2D U-Net Dense model using Keras
create_model_3D: Creating the 3D U-Net Dense model using Keras
"""
class Architecture(Abstract_Architecture):
#---------------------------------------------#
# Initialization #
#---------------------------------------------#
def __init__(self, n_filters=32, depth=4, activation='sigmoid',
batch_normalization=True):
# Parse parameter
self.n_filters = n_filters
self.depth = depth
self.activation = activation
# Batch normalization settings
self.ba_norm = batch_normalization
self.ba_norm_momentum = 0.99
#---------------------------------------------#
# Create 2D Model #
#---------------------------------------------#