-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResUnet.py
62 lines (42 loc) · 2.76 KB
/
ResUnet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.layers import Conv3D, Activation, MaxPooling3D, Conv3DTranspose, Add,BatchNormalization, Dropout, Input, concatenate
def build_network():
inputs = Input((None, None, None,1))
conv1 = Conv3D(32, (3, 3, 3), activation='relu', padding='same')(inputs)
conv1 = Conv3D(32, (3, 3, 3), activation='relu', padding='same')(conv1)
conc1 = concatenate([inputs, conv1], axis=4)
pool1 = MaxPooling3D(pool_size=(2, 2, 2))(conc1)
conv2 = Conv3D(64, (3, 3, 3), activation='relu', padding='same')(pool1)
conv2 = Conv3D(64, (3, 3, 3), activation='relu', padding='same')(conv2)
conc2 = concatenate([pool1, conv2], axis=4)
pool2 = MaxPooling3D(pool_size=(2, 2, 2))(conc2)
conv3 = Conv3D(128, (3, 3, 3), activation='relu', padding='same')(pool2)
conv3 = Conv3D(128, (3, 3, 3), activation='relu', padding='same')(conv3)
conc3 = concatenate([pool2, conv3], axis=4)
pool3 = MaxPooling3D(pool_size=(2, 2, 2))(conc3)
conv4 = Conv3D(256, (3, 3, 3), activation='relu', padding='same')(pool3)
conv4 = Conv3D(256, (3, 3, 3), activation='relu', padding='same')(conv4)
conc4 = concatenate([pool3, conv4], axis=4)
pool4 = MaxPooling3D(pool_size=(2, 2, 2))(conc4)
conv5 = Conv3D(512, (3, 3, 3), activation='relu', padding='same')(pool4)
conv5 = Conv3D(512, (3, 3, 3), activation='relu', padding='same')(conv5)
conc5 = concatenate([pool4, conv5], axis=4)
up6 = concatenate([Conv3DTranspose(256, (2, 2, 2), strides=(2, 2, 2), padding='same')(conc5), conv4], axis=4)
conv6 = Conv3D(256, (3, 3, 3), activation='relu', padding='same')(up6)
conv6 = Conv3D(256, (3, 3, 3), activation='relu', padding='same')(conv6)
conc6 = concatenate([up6, conv6], axis=4)
up7 = concatenate([Conv3DTranspose(128, (2, 2, 2), strides=(2, 2, 2), padding='same')(conc6), conv3], axis=4)
conv7 = Conv3D(128, (3, 3, 3), activation='relu', padding='same')(up7)
conv7 = Conv3D(128, (3, 3, 3), activation='relu', padding='same')(conv7)
conc7 = concatenate([up7, conv7], axis=4)
up8 = concatenate([Conv3DTranspose(64, (2, 2, 2), strides=(2, 2, 2), padding='same')(conc7), conv2], axis=4)
conv8 = Conv3D(64, (3, 3, 3), activation='relu', padding='same')(up8)
conv8 = Conv3D(64, (3, 3, 3), activation='relu', padding='same')(conv8)
conc8 = concatenate([up8, conv8], axis=4)
up9 = concatenate([Conv3DTranspose(32, (2, 2, 2), strides=(2, 2, 2), padding='same')(conc8), conv1], axis=4)
conv9 = Conv3D(32, (3, 3, 3), activation='relu', padding='same')(up9)
conv9 = Conv3D(32, (3, 3, 3), activation='relu', padding='same')(conv9)
conc9 = concatenate([up9, conv9], axis=4)
conv10 = Conv3D(2, (1, 1, 1), activation='softmax')(conc9)
return inputs, conv10