{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using TensorFlow backend.\n" ] } ], "source": [ "import os\n", "import sys\n", "import six\n", "import glob\n", "import math\n", "import pandas as pd\n", "import numpy as np\n", "from keras.utils import to_categorical\n", "import scipy.ndimage as nd\n", "from scipy.ndimage import zoom\n", "import random" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import keras\n", "import tensorflow as tf\n", "from keras import Model\n", "from keras import backend as K\n", "from keras.regularizers import l2\n", "from keras.engine import Layer,InputSpec\n", "from keras.layers.merge import concatenate\n", "from keras.callbacks import TensorBoard,Callback\n", "from keras.layers.advanced_activations import LeakyReLU\n", "from keras.preprocessing.image import ImageDataGenerator\n", "from keras.layers.normalization import BatchNormalization\n", "from keras.callbacks import ModelCheckpoint, ReduceLROnPlateau\n", "from keras import initializers, regularizers, constraints,optimizers\n", "from keras.callbacks import ModelCheckpoint, LearningRateScheduler,TensorBoard\n", "from keras.layers import Add,Input,Conv3D,Convolution3D,Dropout,UpSampling3D,Concatenate,MaxPooling3D,\\\n", "GlobalAveragePooling3D,Dense,GlobalMaxPooling3D,Lambda,Activation,Reshape,Permute, PReLU, Deconvolution3D,Multiply,GlobalAveragePooling3D,Dense" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from InstanceNorm import InstanceNormalization" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "num_blocks = 5\n", "strides = [2,2,2,2,2]\n", "nodule_seg_strides = [1,2,2,2,2]\n", "atrous_rates = [1,1,2,4,8]\n", "base_filters = 32\n", "norm_func = InstanceNormalization\n", "activation_func = LeakyReLU\n", "kernel_size = 3\n", "padding = 'same'\n", "dropout_rate = 0\n", "input_shape = (64,64,64,1)\n", "num_classes = 1" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from ResNet import Resnet3DBuilder\n", "from VGGmodel import VGG\n", "from NoduleSegEncoder import NoduleSegEncoder_proxima\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "from CommonLayers import *" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "parameter_list = {\n", " 'num_blocks':num_blocks,\n", " 'strides':strides,\n", " 'atrous_rates':atrous_rates,\n", " 'base_filters':base_filters,\n", " 'norm_func':norm_func,\n", " 'activation_func':activation_func,\n", " 'kernel_size':kernel_size,\n", " 'padding':padding,\n", " 'dropout_rate':dropout_rate,\n", " 'num_classes':1,\n", " 'classification_layers':GlobalMaxPooling3D\n", "}" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "resnet_parameter_list = {\n", " 'base_filters':base_filters,\n", " 'norm_func':norm_func,\n", " 'activation_func':activation_func,\n", " 'kernel_size':kernel_size,\n", " 'padding':padding,\n", " 'dropout_rate':dropout_rate,\n", " 'num_classes':1,\n", " 'classification_layers':GlobalMaxPooling3D,\n", " 'init_kernel_size':1\n", "}" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "noduleseg_parameter_list = {\n", " 'num_blocks':num_blocks,\n", " 'strides':nodule_seg_strides,\n", " 'atrous_rates':[1 for _ in range(num_blocks)],\n", " 'base_filters':base_filters,\n", " 'norm_func':norm_func,\n", " 'activation_func':activation_func,\n", " 'kernel_size':kernel_size,\n", " 'padding':padding,\n", " 'dropout_rate':0.5,\n", " 'num_classes':1,\n", " 'classification_layers':GlobalMaxPooling3D\n", "}" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "result = NoduleSegEncoder_proxima(input_shape,**noduleseg_parameter_list)" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [], "source": [ "noduleseg_decoder_parameter_list = {\n", " 'kernel_initializer':'he_normal',\n", " 'kernel_regularizer':l2(1e-4),\n", " 'kernel_size':kernel_size,\n", " 'final_kernel_size':1,\n", " 'norm_func':norm_func,\n", " 'activation_func':activation_func,\n", " 'kernel_size':kernel_size,\n", " 'padding':padding,\n", " 'seg_num_class':1,\n", " 'merge_axis':-1,\n", " 'SEB_choice':True,\n", " 'ACR_choice':False,\n", " 'OCR_choice':False,\n", " 'deep_supervision':True,\n", " 'num_units':[3,3,3,3]\n", " \n", " \n", " \n", " \n", "}" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [], "source": [ "def SEB_block(x,**kwargs): \n", " kernel_initializer = kwargs.get('kernel_initializer','he_normal')\n", " kernel_regularizer = kwargs.get('kernel_regularizer',l2(1e-4))\n", "\n", " kernel_size = kwargs.get('kernel_size',3)\n", " norm_func = kwargs.get('norm_func')\n", " activation_func = kwargs.get('activation_func')\n", " \n", " num_filters = kwargs.get('num_filters')\n", " padding = kwargs.get('padding','same')\n", " \n", " atrous_rate = kwargs.get('atrous_rate',1)\n", " stride = kwargs.get('upsample_rate',2)\n", " conv_first = kwargs.get('conv_first',True)\n", " merge_axis = kwargs.get('merge_axis',-1)\n", " block_prefix = kwargs.get('block_prefix')\n", " \n", " block_prefix += '_SEB'\n", " \n", " x1_list,x2 = x\n", "\n", " if len(x1_list) == 1:\n", " x1 = x1_list[0]\n", " else:\n", " x1 = Concatenate(axis=merge_axis,name='%s_concatenate'%(block_prefix))(x1_list)\n", " \n", "\n", " \n", " x1 = ConvUnit(x1,norm_func=norm_func,activation_func=activation_func,num_filters=num_filters,\n", " kernel_size=kernel_size,atrous_rate=atrous_rate,padding=padding,block_prefix=block_prefix,\n", " kernel_initializer=kernel_initializer,kernel_regularizer=kernel_regularizer,\n", " layer_idx=1,conv_first=conv_first)\n", " \n", " x1 = UpSampling3D(size=(2, 2, 2),name='%s_upsample'%(block_prefix))(x1)\n", " return Multiply()([x1,x2])" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [], "source": [ "def NoduleSegDeepCombineBlock(input_tensors,**kwargs):\n", " kernel_initializer = kwargs.get('kernel_initializer','he_normal')\n", " kernel_regularizer = kwargs.get('kernel_regularizer',l2(1e-4))\n", " kernel_size = kwargs.get('kernel_size',3)\n", " norm_func = kwargs.get('norm_func')\n", " activation_func = kwargs.get('activation_func')\n", " \n", " num_filters = kwargs.get('num_filters')\n", " \n", " padding = kwargs.get('padding','same')\n", " atrous_rate = kwargs.get('atrous_rate',1)\n", " stride = kwargs.get('upsample_rate',2)\n", " conv_first = kwargs.get('conv_first',True)\n", " merge_axis = kwargs.get('merge_axis',-1)\n", " \n", " x1,x2,x3 = input_tensors\n", " block_prefix = 'NoduleSegDeepCombineBlock'\n", " \n", " x1 = ConvUnit(x1,norm_func=norm_func,activation_func=activation_func,num_filters=num_filters,\n", " kernel_size=kernel_size,atrous_rate=atrous_rate,padding=padding,block_prefix=block_prefix+'_block01_',\n", " kernel_initializer=kernel_initializer,kernel_regularizer=kernel_regularizer,\n", " layer_idx=1,conv_first=conv_first)\n", " up_x1 = UpSampling3D(size=2,name='%s_block01_upsample'%block_prefix)(x1)\n", " \n", " x2 = ConvUnit(x2,norm_func=norm_func,activation_func=activation_func,num_filters=num_filters,\n", " kernel_size=kernel_size,atrous_rate=atrous_rate,padding=padding,block_prefix=block_prefix+'_block02_',\n", " kernel_initializer=kernel_initializer,kernel_regularizer=kernel_regularizer,\n", " layer_idx=1,conv_first=conv_first)\n", " up_x2 = UpSampling3D(size=2,name='%s_block02_upsample'%block_prefix)(Add(name='%s_Add01'%block_prefix)([up_x1,x2]))\n", " \n", " \n", " x3 = ConvUnit(x3,norm_func=norm_func,activation_func=activation_func,num_filters=num_filters,\n", " kernel_size=kernel_size,atrous_rate=atrous_rate,padding=padding,block_prefix=block_prefix+'_block03_',\n", " kernel_initializer=kernel_initializer,kernel_regularizer=kernel_regularizer,\n", " layer_idx=1,conv_first=conv_first)\n", " \n", " final_result = Add(name='%s_Add02'%block_prefix)([up_x2,x3])\n", " \n", " return final_result,[x1,x2,x3]\n", " \n", " \n", " " ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [], "source": [ "def NoduleSegDecoderBlock(x,encoder_tensors,**kwargs):\n", " block_idx = kwargs.get('block_idx')\n", " num_units = kwargs.get('num_units')\n", " kernel_initializer = kwargs.get('kernel_initializer','he_normal')\n", " kernel_regularizer = kwargs.get('kernel_regularizer',l2(1e-4))\n", " SEB_choice = kwargs.get('SEB_choice',False)\n", " kernel_size = kwargs.get('kernel_size',3)\n", " norm_func = kwargs.get('norm_func')\n", " activation_func = kwargs.get('activation_func')\n", " \n", " \n", " num_filters = kwargs.get('num_filters')\n", " padding = kwargs.get('padding','same')\n", " \n", " atrous_rate = kwargs.get('atrous_rate',1)\n", " stride = kwargs.get('upsample_rate',2)\n", " conv_first = kwargs.get('conv_first',True)\n", " merge_axis = kwargs.get('merge_axis',-1)\n", " \n", " DIM1_AXIS,DIM2_AXIS,DIM3_AXIS = 1,2,3\n", " block_prefix = 'NoduleSegDecoder_Block%02d'%block_idx\n", "\n", " if stride>1:\n", " x = UpSampling3D(size=stride,name='%s_upsample_01'%(block_prefix))(x)\n", " \n", " x1 = ConvUnit(x,norm_func=norm_func,activation_func=activation_func,num_filters=num_filters,\n", " kernel_size=kernel_size,atrous_rate=atrous_rate,padding=padding,block_prefix=block_prefix,\n", " kernel_initializer=kernel_initializer,kernel_regularizer=kernel_regularizer,\n", " layer_idx=1,conv_first=conv_first)\n", "\n", " target_depth,target_height,target_width = x1._keras_shape[DIM1_AXIS],x1._keras_shape[DIM2_AXIS],x1._keras_shape[DIM3_AXIS]\n", " \n", " \n", " if not SEB_choice:\n", " encoder_target_tensor = encoder_tensors[-(block_idx+1)]\n", " else:\n", " target_tensor = encoder_tensors[-(block_idx+1)]\n", " SEB_tensors = encoder_tensors[-(block_idx):][::-1]\n", " \n", " upsample_tensor_list = []\n", " for layer_idx,current_tensor in enumerate(SEB_tensors):\n", " \n", " current_depth,current_height,current_width = current_tensor._keras_shape[DIM1_AXIS],current_tensor._keras_shape[DIM2_AXIS],current_tensor._keras_shape[DIM3_AXIS]\n", " upsample_rate = [int(target_depth/current_depth/2),int(target_height/current_height/2),int(target_width/current_width/2)]\n", " upsample_tensor = UpSampling3D(size=upsample_rate,name='%s_SEB_preUpsample%02d'%(block_prefix,layer_idx+1))(current_tensor)\n", " upsample_tensor_list.append(upsample_tensor)\n", " \n", " target_num_filters = target_tensor._keras_shape[-1]\n", " \n", " encoder_target_tensor = SEB_block([upsample_tensor_list,target_tensor],norm_func=norm_func,activation_func=activation_func,\n", " num_filters=target_num_filters,kernel_size=kernel_size,atrous_rate=atrous_rate,padding=padding,\n", " block_prefix=block_prefix,kernel_initializer=kernel_initializer,kernel_regularizer=kernel_regularizer,\n", " conv_first=conv_first,merge_axis=merge_axis)\n", " \n", "# x = encoder_target_tensor\n", " x = Concatenate(axis=merge_axis,name='%s_Concatenate'%(block_prefix))([encoder_target_tensor,x1])\n", " \n", " for layer_idx in range(1,num_units):\n", " x = ConvUnit(x,norm_func=norm_func,activation_func=activation_func,num_filters=num_filters,\n", " kernel_size=kernel_size,atrous_rate=atrous_rate,padding=padding,block_prefix=block_prefix,\n", " kernel_initializer=kernel_initializer,kernel_regularizer=kernel_regularizer,\n", " layer_idx=layer_idx+1,conv_first=conv_first)\n", " return x" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [], "source": [ "def NoduleSegDecoder_proxima(encoder_result,**kwargs):\n", " \n", " kernel_initializer = kwargs.get('kernel_initializer','he_normal')\n", " kernel_regularizer = kwargs.get('kernel_regularizer',l2(1e-4))\n", " kernel_size = kwargs.get('kernel_size',3)\n", " final_kernel_size = kwargs.get('final_kernel_size',3)\n", " norm_func = kwargs.get('norm_func')\n", " activation_func = kwargs.get('activation_func')\n", " padding = kwargs.get('padding','same')\n", " atrous_rate = kwargs.get('atrous_rate',1)\n", " conv_first = kwargs.get('conv_first',True)\n", " merge_axis = kwargs.get('merge_axis',-1)\n", " \n", " SEB_choice = kwargs.get('SEB_choice',True)\n", " ACF_choice = kwargs.get('ACF_choice',False)\n", " OCR_choice = kwargs.get('OCR_choice',False)\n", " deep_supervision = kwargs.get('deep_supervision',True)\n", " num_units = kwargs.get('num_units',[3,3,3,3])\n", " seg_num_class = kwargs.get('seg_num_class')\n", " \n", " \n", " encoder_model = encoder_result[0]\n", " encoder_tensors = encoder_result[1]\n", " \n", " input_tensor = encoder_model.input\n", " \n", " x = encoder_tensors[-1]\n", " decoder_tensors = []\n", "\n", " for block_idx in range(len(encoder_tensors)-2):\n", " current_stride = int(encoder_tensors[-(block_idx+2)]._keras_shape[1]/x._keras_shape[1])\n", " num_filters = int(x._keras_shape[-1]/2)\n", " if block_idx == len(encoder_tensors)-3:\n", " SEB_choice = False\n", " x = NoduleSegDecoderBlock(x,encoder_tensors,block_idx=block_idx+1,num_units=num_units[block_idx],\n", " kernel_initializer=kernel_initializer,kernel_regularizer=kernel_regularizer,\n", " SEB_choice=SEB_choice,kernel_size=kernel_size,norm_func=norm_func,activation_func=activation_func,\n", " num_filters=num_filters,padding=padding,atrous_rate=atrous_rate,upsample_rate=current_stride,conv_first=conv_first,\n", " merge_axis=merge_axis)\n", " decoder_tensors.append(x)\n", " \n", " combine_tensors = NoduleSegDeepCombineBlock(decoder_tensors[1:],kernel_initializer=kernel_initializer,\n", " kernel_regularizer=kernel_regularizer,kernel_size=kernel_size,norm_func=norm_func,\n", " activation_func=activation_func,num_filters=int(decoder_tensors[-1]._keras_shape[-1]/4),\n", " padding=padding,atrous_rate=atrous_rate,conv_first=conv_first,merge_axis=merge_axis)\n", " \n", "\n", " aux_conv_tensor = 0\n", " if seg_num_class==1:\n", " current_acti = 'sigmoid'\n", " else:\n", " current_acti = 'softmax'\n", " \n", " final_conv_func = Convolution3D(nb_filter = seg_num_class,kernel_size=final_kernel_size, \n", " kernel_initializer=kernel_initializer, kernel_regularizer=kernel_regularizer,\n", " border_mode='same',activation=current_acti,name='NoduleSegDecoder_conv3d_mins1')\n", "\n", " if not deep_supervision:\n", " block_prefix = 'NoduleSegDecoder_NotSupervision'\n", " conv_mins1 = final_conv_func(combine_tensors[0])\n", " aux_conv_tensor = conv_mins1\n", " \n", " if ACF_choice:\n", " coarse_feature_map = conv_mins1\n", "\n", " conv_mins1 = []\n", " feature_map_class = CCB([coarse_feature_map,combine_tensors[0]],num_classes=seg_num_class)\n", " CAB_feature_map = CAB([coarse_feature_map,feature_map_class],num_classes=seg_num_class,activaion=current_acti)\n", " concatenate_feature_map = Concatenate()([CAB_feature_map,combine_tensors[0]])\n", " aux_conv_tensor = concatenate_feature_map\n", " final_result = Convolution3D(nb_filter = seg_num_class,kernel_size=final_kernel_size, \n", " kernel_initializer=kernel_initializer, kernel_regularizer=kernel_regularizer,\n", " border_mode='same',activation=current_acti,name='NoduleSegDecoder_conv_ACF')(concatenate_feature_map)\n", " \n", " conv_mins1 = [coarse_feature_map,final_result]\n", " else:\n", " conv_mins1 = []\n", " input_tensors = combine_tensors[1]\n", " for idx in range(len(input_tensors)):\n", " rate = 2 ** (2-idx)\n", " current_tensor = UpSampling3D(size=rate,name='deep_supervision_upsample_%02d'%(idx+1))(input_tensors[idx])\n", " current_tensor = Convolution3D(nb_filter = seg_num_class,kernel_size=final_kernel_size, \n", " kernel_initializer=kernel_initializer, kernel_regularizer=kernel_regularizer,\n", " border_mode='same',activation=current_acti,name='NoduleSegDecoder_DeepSupervision_conv%02d'%(idx+1))(current_tensor) \n", " conv_mins1.append(current_tensor)\n", " \n", " \n", " output = conv_mins1\n", " \n", " \n", " \n", " model = Model(input_tensor,output)\n", " model.summary()\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " " ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "__________________________________________________________________________________________________\n", "Layer (type) Output Shape Param # Connected to \n", "==================================================================================================\n", "input_1 (InputLayer) (None, 64, 64, 64, 1 0 \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_conv_01 (C (None, 64, 64, 64, 3 896 input_1[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_norm_01 (I (None, 64, 64, 64, 3 2 NoduleSegConvBlock01_conv_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_activation (None, 64, 64, 64, 3 0 NoduleSegConvBlock01_norm_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_conv_02 (C (None, 64, 64, 64, 3 27680 NoduleSegConvBlock01_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_norm_02 (I (None, 64, 64, 64, 3 2 NoduleSegConvBlock01_conv_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_activation (None, 64, 64, 64, 3 0 NoduleSegConvBlock01_norm_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_conv_03 (C (None, 64, 64, 64, 3 27680 NoduleSegConvBlock01_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_norm_03 (I (None, 64, 64, 64, 3 2 NoduleSegConvBlock01_conv_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_activation (None, 64, 64, 64, 3 0 NoduleSegConvBlock01_norm_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock01_add (Add) (None, 64, 64, 64, 3 0 NoduleSegConvBlock01_activation_0\n", " NoduleSegConvBlock01_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegEncoderDropout01 (Drop (None, 64, 64, 64, 3 0 NoduleSegConvBlock01_add[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_conv_01 (C (None, 32, 32, 32, 6 55360 NoduleSegEncoderDropout01[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_norm_01 (I (None, 32, 32, 32, 6 2 NoduleSegConvBlock02_conv_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_activation (None, 32, 32, 32, 6 0 NoduleSegConvBlock02_norm_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_conv_02 (C (None, 32, 32, 32, 6 110656 NoduleSegConvBlock02_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_norm_02 (I (None, 32, 32, 32, 6 2 NoduleSegConvBlock02_conv_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_activation (None, 32, 32, 32, 6 0 NoduleSegConvBlock02_norm_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_conv_03 (C (None, 32, 32, 32, 6 110656 NoduleSegConvBlock02_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_norm_03 (I (None, 32, 32, 32, 6 2 NoduleSegConvBlock02_conv_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_activation (None, 32, 32, 32, 6 0 NoduleSegConvBlock02_norm_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock02_add (Add) (None, 32, 32, 32, 6 0 NoduleSegConvBlock02_activation_0\n", " NoduleSegConvBlock02_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegEncoderDropout02 (Drop (None, 32, 32, 32, 6 0 NoduleSegConvBlock02_add[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_conv_01 (C (None, 16, 16, 16, 1 221312 NoduleSegEncoderDropout02[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_norm_01 (I (None, 16, 16, 16, 1 2 NoduleSegConvBlock03_conv_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_activation (None, 16, 16, 16, 1 0 NoduleSegConvBlock03_norm_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_conv_02 (C (None, 16, 16, 16, 1 442496 NoduleSegConvBlock03_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_norm_02 (I (None, 16, 16, 16, 1 2 NoduleSegConvBlock03_conv_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_activation (None, 16, 16, 16, 1 0 NoduleSegConvBlock03_norm_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_conv_03 (C (None, 16, 16, 16, 1 442496 NoduleSegConvBlock03_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_norm_03 (I (None, 16, 16, 16, 1 2 NoduleSegConvBlock03_conv_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_activation (None, 16, 16, 16, 1 0 NoduleSegConvBlock03_norm_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock03_add (Add) (None, 16, 16, 16, 1 0 NoduleSegConvBlock03_activation_0\n", " NoduleSegConvBlock03_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegEncoderDropout03 (Drop (None, 16, 16, 16, 1 0 NoduleSegConvBlock03_add[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_conv_01 (C (None, 8, 8, 8, 256) 884992 NoduleSegEncoderDropout03[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_norm_01 (I (None, 8, 8, 8, 256) 2 NoduleSegConvBlock04_conv_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_activation (None, 8, 8, 8, 256) 0 NoduleSegConvBlock04_norm_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_conv_02 (C (None, 8, 8, 8, 256) 1769728 NoduleSegConvBlock04_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_norm_02 (I (None, 8, 8, 8, 256) 2 NoduleSegConvBlock04_conv_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_activation (None, 8, 8, 8, 256) 0 NoduleSegConvBlock04_norm_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_conv_03 (C (None, 8, 8, 8, 256) 1769728 NoduleSegConvBlock04_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_norm_03 (I (None, 8, 8, 8, 256) 2 NoduleSegConvBlock04_conv_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_activation (None, 8, 8, 8, 256) 0 NoduleSegConvBlock04_norm_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock04_add (Add) (None, 8, 8, 8, 256) 0 NoduleSegConvBlock04_activation_0\n", " NoduleSegConvBlock04_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegEncoderDropout04 (Drop (None, 8, 8, 8, 256) 0 NoduleSegConvBlock04_add[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_conv_01 (C (None, 4, 4, 4, 512) 3539456 NoduleSegEncoderDropout04[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_norm_01 (I (None, 4, 4, 4, 512) 2 NoduleSegConvBlock05_conv_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_activation (None, 4, 4, 4, 512) 0 NoduleSegConvBlock05_norm_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_conv_02 (C (None, 4, 4, 4, 512) 7078400 NoduleSegConvBlock05_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_norm_02 (I (None, 4, 4, 4, 512) 2 NoduleSegConvBlock05_conv_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_activation (None, 4, 4, 4, 512) 0 NoduleSegConvBlock05_norm_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_conv_03 (C (None, 4, 4, 4, 512) 7078400 NoduleSegConvBlock05_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_norm_03 (I (None, 4, 4, 4, 512) 2 NoduleSegConvBlock05_conv_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_activation (None, 4, 4, 4, 512) 0 NoduleSegConvBlock05_norm_03[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegConvBlock05_add (Add) (None, 4, 4, 4, 512) 0 NoduleSegConvBlock05_activation_0\n", " NoduleSegConvBlock05_activation_0\n", "__________________________________________________________________________________________________\n", "NoduleSegEncoderDropout05 (Drop (None, 4, 4, 4, 512) 0 NoduleSegConvBlock05_add[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_SEB_pr (None, 4, 4, 4, 512) 0 NoduleSegEncoderDropout05[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_SEB_co (None, 4, 4, 4, 256) 3539200 NoduleSegDecoder_Block01_SEB_preU\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_SEB_no (None, 4, 4, 4, 256) 2 NoduleSegDecoder_Block01_SEB_conv\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_upsamp (None, 8, 8, 8, 512) 0 NoduleSegEncoderDropout05[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_SEB_ac (None, 4, 4, 4, 256) 0 NoduleSegDecoder_Block01_SEB_norm\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_conv_0 (None, 8, 8, 8, 256) 3539200 NoduleSegDecoder_Block01_upsample\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_SEB_up (None, 8, 8, 8, 256) 0 NoduleSegDecoder_Block01_SEB_acti\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_norm_0 (None, 8, 8, 8, 256) 2 NoduleSegDecoder_Block01_conv_01[\n", "__________________________________________________________________________________________________\n", "multiply_19 (Multiply) (None, 8, 8, 8, 256) 0 NoduleSegDecoder_Block01_SEB_upsa\n", " NoduleSegEncoderDropout04[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_activa (None, 8, 8, 8, 256) 0 NoduleSegDecoder_Block01_norm_01[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_Concat (None, 8, 8, 8, 512) 0 multiply_19[0][0] \n", " NoduleSegDecoder_Block01_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_conv_0 (None, 8, 8, 8, 256) 3539200 NoduleSegDecoder_Block01_Concaten\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_norm_0 (None, 8, 8, 8, 256) 2 NoduleSegDecoder_Block01_conv_02[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_activa (None, 8, 8, 8, 256) 0 NoduleSegDecoder_Block01_norm_02[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_SEB_pr (None, 8, 8, 8, 512) 0 NoduleSegEncoderDropout05[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_SEB_pr (None, 8, 8, 8, 256) 0 NoduleSegEncoderDropout04[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_conv_0 (None, 8, 8, 8, 256) 1769728 NoduleSegDecoder_Block01_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_SEB_co (None, 8, 8, 8, 768) 0 NoduleSegDecoder_Block02_SEB_preU\n", " NoduleSegDecoder_Block02_SEB_preU\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_norm_0 (None, 8, 8, 8, 256) 2 NoduleSegDecoder_Block01_conv_03[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_SEB_co (None, 8, 8, 8, 128) 2654336 NoduleSegDecoder_Block02_SEB_conc\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block01_activa (None, 8, 8, 8, 256) 0 NoduleSegDecoder_Block01_norm_03[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_SEB_no (None, 8, 8, 8, 128) 2 NoduleSegDecoder_Block02_SEB_conv\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_upsamp (None, 16, 16, 16, 2 0 NoduleSegDecoder_Block01_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_SEB_ac (None, 8, 8, 8, 128) 0 NoduleSegDecoder_Block02_SEB_norm\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_conv_0 (None, 16, 16, 16, 1 884864 NoduleSegDecoder_Block02_upsample\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_SEB_up (None, 16, 16, 16, 1 0 NoduleSegDecoder_Block02_SEB_acti\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_norm_0 (None, 16, 16, 16, 1 2 NoduleSegDecoder_Block02_conv_01[\n", "__________________________________________________________________________________________________\n", "multiply_20 (Multiply) (None, 16, 16, 16, 1 0 NoduleSegDecoder_Block02_SEB_upsa\n", " NoduleSegEncoderDropout03[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_activa (None, 16, 16, 16, 1 0 NoduleSegDecoder_Block02_norm_01[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_Concat (None, 16, 16, 16, 2 0 multiply_20[0][0] \n", " NoduleSegDecoder_Block02_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_conv_0 (None, 16, 16, 16, 1 884864 NoduleSegDecoder_Block02_Concaten\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_norm_0 (None, 16, 16, 16, 1 2 NoduleSegDecoder_Block02_conv_02[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_activa (None, 16, 16, 16, 1 0 NoduleSegDecoder_Block02_norm_02[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_conv_0 (None, 16, 16, 16, 1 442496 NoduleSegDecoder_Block02_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_SEB_pr (None, 16, 16, 16, 5 0 NoduleSegEncoderDropout05[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_SEB_pr (None, 16, 16, 16, 2 0 NoduleSegEncoderDropout04[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_SEB_pr (None, 16, 16, 16, 1 0 NoduleSegEncoderDropout03[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_norm_0 (None, 16, 16, 16, 1 2 NoduleSegDecoder_Block02_conv_03[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_SEB_co (None, 16, 16, 16, 8 0 NoduleSegDecoder_Block03_SEB_preU\n", " NoduleSegDecoder_Block03_SEB_preU\n", " NoduleSegDecoder_Block03_SEB_preU\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block02_activa (None, 16, 16, 16, 1 0 NoduleSegDecoder_Block02_norm_03[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_SEB_co (None, 16, 16, 16, 6 1548352 NoduleSegDecoder_Block03_SEB_conc\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_SEB_no (None, 16, 16, 16, 6 2 NoduleSegDecoder_Block03_SEB_conv\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_upsamp (None, 32, 32, 32, 1 0 NoduleSegDecoder_Block02_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_SEB_ac (None, 16, 16, 16, 6 0 NoduleSegDecoder_Block03_SEB_norm\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_conv_0 (None, 32, 32, 32, 6 221248 NoduleSegDecoder_Block03_upsample\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_SEB_up (None, 32, 32, 32, 6 0 NoduleSegDecoder_Block03_SEB_acti\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_norm_0 (None, 32, 32, 32, 6 2 NoduleSegDecoder_Block03_conv_01[\n", "__________________________________________________________________________________________________\n", "multiply_21 (Multiply) (None, 32, 32, 32, 6 0 NoduleSegDecoder_Block03_SEB_upsa\n", " NoduleSegEncoderDropout02[0][0] \n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_activa (None, 32, 32, 32, 6 0 NoduleSegDecoder_Block03_norm_01[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_Concat (None, 32, 32, 32, 1 0 multiply_21[0][0] \n", " NoduleSegDecoder_Block03_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_conv_0 (None, 32, 32, 32, 6 221248 NoduleSegDecoder_Block03_Concaten\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_norm_0 (None, 32, 32, 32, 6 2 NoduleSegDecoder_Block03_conv_02[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_activa (None, 32, 32, 32, 6 0 NoduleSegDecoder_Block03_norm_02[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_conv_0 (None, 32, 32, 32, 6 110656 NoduleSegDecoder_Block03_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_norm_0 (None, 32, 32, 32, 6 2 NoduleSegDecoder_Block03_conv_03[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block03_activa (None, 32, 32, 32, 6 0 NoduleSegDecoder_Block03_norm_03[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_upsamp (None, 64, 64, 64, 6 0 NoduleSegDecoder_Block03_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_conv_0 (None, 64, 64, 64, 3 55328 NoduleSegDecoder_Block04_upsample\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_norm_0 (None, 64, 64, 64, 3 2 NoduleSegDecoder_Block04_conv_01[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_activa (None, 64, 64, 64, 3 0 NoduleSegDecoder_Block04_norm_01[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_Concat (None, 64, 64, 64, 6 0 NoduleSegEncoderDropout01[0][0] \n", " NoduleSegDecoder_Block04_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_conv_0 (None, 64, 64, 64, 3 55328 NoduleSegDecoder_Block04_Concaten\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_norm_0 (None, 64, 64, 64, 3 2 NoduleSegDecoder_Block04_conv_02[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_activa (None, 64, 64, 64, 3 0 NoduleSegDecoder_Block04_norm_02[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_conv_0 (None, 64, 64, 64, 3 27680 NoduleSegDecoder_Block04_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_norm_0 (None, 64, 64, 64, 3 2 NoduleSegDecoder_Block04_conv_03[\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_Block04_activa (None, 64, 64, 64, 3 0 NoduleSegDecoder_Block04_norm_03[\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 16, 16, 16, 8 27656 NoduleSegDecoder_Block02_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 32, 32, 32, 8 13832 NoduleSegDecoder_Block03_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 64, 64, 64, 8 6920 NoduleSegDecoder_Block04_activati\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 16, 16, 16, 8 2 NoduleSegDeepCombineBlock_block01\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 32, 32, 32, 8 2 NoduleSegDeepCombineBlock_block02\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 64, 64, 64, 8 2 NoduleSegDeepCombineBlock_block03\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 16, 16, 16, 8 0 NoduleSegDeepCombineBlock_block01\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 32, 32, 32, 8 0 NoduleSegDeepCombineBlock_block02\n", "__________________________________________________________________________________________________\n", "NoduleSegDeepCombineBlock_block (None, 64, 64, 64, 8 0 NoduleSegDeepCombineBlock_block03\n", "__________________________________________________________________________________________________\n", "deep_supervision_upsample_01 (U (None, 64, 64, 64, 8 0 NoduleSegDeepCombineBlock_block01\n", "__________________________________________________________________________________________________\n", "deep_supervision_upsample_02 (U (None, 64, 64, 64, 8 0 NoduleSegDeepCombineBlock_block02\n", "__________________________________________________________________________________________________\n", "deep_supervision_upsample_03 (U (None, 64, 64, 64, 8 0 NoduleSegDeepCombineBlock_block03\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_DeepSupervisio (None, 64, 64, 64, 1 9 deep_supervision_upsample_01[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_DeepSupervisio (None, 64, 64, 64, 1 9 deep_supervision_upsample_02[0][0\n", "__________________________________________________________________________________________________\n", "NoduleSegDecoder_DeepSupervisio (None, 64, 64, 64, 1 9 deep_supervision_upsample_03[0][0\n", "==================================================================================================\n", "Total params: 43,102,165\n", "Trainable params: 43,102,165\n", "Non-trainable params: 0\n", "__________________________________________________________________________________________________\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/opt/anaconda2/lib/python2.7/site-packages/ipykernel_launcher.py:56: UserWarning: Update your `Conv3D` call to the Keras 2 API: `Conv3D(kernel_initializer=\"he_normal\", name=\"NoduleSegDecoder_conv3d_mins1\", activation=\"sigmoid\", padding=\"same\", kernel_regularizer=