-
Notifications
You must be signed in to change notification settings - Fork 0
/
AttentionUnet.py
executable file
·376 lines (294 loc) · 22 KB
/
AttentionUnet.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
from tensorflow.keras.layers import Input,Add, Conv2D, MaxPooling2D, UpSampling2D, concatenate, Dropout, Activation, Attention, BatchNormalization
from tensorflow.keras.models import Model
class attUnet:
'''Attention Unet Model'''
def __init__(self, inp, kernel, dropout):
self.kernel = kernel
self.dropout = dropout
self.input_layers = Input(shape=inp)
self.generateModel()
def generateModel(self) -> Model:
conv1 = Conv2D(32, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(self.input_layers)
conv1 = Dropout(self.dropout)(conv1)
conv1 = Conv2D(32, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv1)
conv1 = BatchNormalization()(conv1)
mxpool = MaxPooling2D(pool_size=(2, 2))(conv1)
conv = Conv2D(64, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(mxpool)
conv = Dropout(self.dropout)(conv)
conv = Conv2D(64, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv)
conv = BatchNormalization()(conv)
mxpool1 = MaxPooling2D(pool_size=(2, 2))(conv)
conv2 = Conv2D(128, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(mxpool1)
conv2 = Dropout(self.dropout)(conv2)
conv2 = Conv2D(128, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv2)
conv2 = BatchNormalization()(conv2)
mxpool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
conv3 = Conv2D(256, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(mxpool2)
conv3 = Dropout(self.dropout)(conv3)
conv3 = Conv2D(256, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv3)
conv3 = BatchNormalization()(conv3)
mxpool3 = MaxPooling2D(pool_size=(2, 2))(conv3)
conv5 = Conv2D(512, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(mxpool3)
conv5 = Dropout(self.dropout)(conv5)
conv5 = Conv2D(512, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv5)
drop5 = Dropout(self.dropout)(conv5)
up7 = Conv2D(256, 2, activation='relu', padding='same', kernel_initializer=self.kernel)(
UpSampling2D(size=(2, 2))(drop5))
merge7 = concatenate([conv3, up7], axis=3)
att7 = Attention(use_scale=False)([conv3, up7])
merge7 = concatenate([att7, merge7], axis=3)
conv7 = Conv2D(256, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(merge7)
conv7 = Conv2D(256, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv7)
up8 = Conv2D(128, 2, activation='relu', padding='same', kernel_initializer=self.kernel)(
UpSampling2D(size=(2, 2))(conv7))
merge8 = concatenate([conv2, up8], axis=3)
att8 = Attention(use_scale=False)([conv2, up8])
merge8 = concatenate([att8, merge8], axis=3)
conv8 = Conv2D(128, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(merge8)
conv8 = Conv2D(128, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv8)
up9 = Conv2D(64, 2, activation='relu', padding='same', kernel_initializer=self.kernel)(
UpSampling2D(size=(2, 2))(conv8))
merge9 = concatenate([conv, up9], axis=3)
att9 = Attention(use_scale=False)([conv, up9])
merge9 = concatenate([att9, merge9], axis=3)
conv9 = Conv2D(64, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(merge9)
conv9 = Conv2D(64, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv9)
up = Conv2D(32, 2, activation='relu', padding='same', kernel_initializer=self.kernel)(
UpSampling2D(size=(2, 2))(conv9))
merge = concatenate([conv1, up], axis=3)
att10 = Attention(use_scale=False)([conv1, up])
merge = concatenate([att10, merge], axis=3)
conv = Conv2D(32, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(merge)
conv = Conv2D(32, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv)
conv10 = Conv2D(4, (1, 1), activation='softmax')(conv)
return Model(inputs = self.input_layers, outputs = conv10)
#==========================================================
class simpleUnet():
'''simple unet model'''
def __init__(self, inp, kernel, dropout):
self.kernel = kernel
self.dropout = dropout
self.input_layer = Input(shape=inp)
self.generateModel()
def generateModel(self) -> Model :
conv1 = Conv2D(32, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(self.input_layer)
conv1 = Conv2D(32, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv1)
mxpool = MaxPooling2D(pool_size=(2, 2))(conv1)
conv = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool)
conv = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv)
mxpool1 = MaxPooling2D(pool_size=(2, 2))(conv)
conv2 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool1)
conv2 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv2)
mxpool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
conv3 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool2)
conv3 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv3)
mxpool4 = MaxPooling2D(pool_size=(2, 2))(conv3)
conv5 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool4)
conv5 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv5)
drop5 = Dropout(self.dropout)(conv5)
up7 = Conv2D(256, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(drop5))
merge7 = concatenate([conv3,up7], axis = 3)
conv7 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge7)
conv7 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv7)
up8 = Conv2D(128, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv7))
merge8 = concatenate([conv2,up8], axis = 3)
conv8 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge8)
conv8 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv8)
up9 = Conv2D(64, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv8))
merge9 = concatenate([conv,up9], axis = 3)
conv9 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge9)
conv9 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv9)
up = Conv2D(32, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv9))
merge = concatenate([conv1,up], axis = 3)
conv = Conv2D(32, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge)
conv = Conv2D(32, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv)
conv10 = Conv2D(4, (1,1), activation = 'softmax')(conv)
return Model(inputs = self.input_layer, outputs = conv10)
class simpleUnet2():
'''simple unet model'''
def __init__(self, inp, kernel, dropout):
self.kernel = kernel
self.dropout = dropout
self.input_layer = Input(shape=inp)
self.generateModel()
def generateModel(self) -> Model :
conv1 = Conv2D(32, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(self.input_layer)
conv1 = Dropout(self.dropout)(conv1)
conv1 = Conv2D(32, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv1)
conv1 = BatchNormalization()(conv1)
mxpool = MaxPooling2D(pool_size=(2, 2))(conv1)
conv = Conv2D(64, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(mxpool)
conv = Dropout(self.dropout)(conv)
conv = Conv2D(64, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv)
conv = BatchNormalization()(conv)
mxpool1 = MaxPooling2D(pool_size=(2, 2))(conv)
conv2 = Conv2D(128, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(mxpool1)
conv2 = Dropout(self.dropout)(conv2)
conv2 = Conv2D(128, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv2)
conv2 = BatchNormalization()(conv2)
mxpool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
conv3 = Conv2D(256, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(mxpool2)
conv3 = Dropout(self.dropout)(conv3)
conv3 = Conv2D(256, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv3)
conv3 = BatchNormalization()(conv3)
mxpool4 = MaxPooling2D(pool_size=(2, 2))(conv3)
conv5 = Conv2D(512, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(mxpool4)
drop5 = Dropout(self.dropout)(conv5)
conv5 = Conv2D(512, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv5)
conv5 = BatchNormalization()(conv5)
up7 = Conv2D(256, 2, activation='relu', padding='same', kernel_initializer=self.kernel)(UpSampling2D(size=(2, 2))(drop5))
merge7 = concatenate([conv3, up7], axis=3)
conv7 = Conv2D(256, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(merge7)
conv7 = Conv2D(256, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv7)
up8 = Conv2D(128, 2, activation='relu', padding='same', kernel_initializer=self.kernel)(UpSampling2D(size=(2, 2))(conv7))
merge8 = concatenate([conv2, up8], axis=3)
conv8 = Conv2D(128, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(merge8)
conv8 = Conv2D(128, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv8)
up9 = Conv2D(64, 2, activation='relu', padding='same', kernel_initializer=self.kernel)(UpSampling2D(size=(2, 2))(conv8))
merge9 = concatenate([conv, up9], axis=3)
conv9 = Conv2D(64, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(merge9)
conv9 = Conv2D(64, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv9)
up = Conv2D(32, 2, activation='relu', padding='same', kernel_initializer=self.kernel)(UpSampling2D(size=(2, 2))(conv9))
merge = concatenate([conv1, up], axis=3)
conv = Conv2D(32, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(merge)
conv = Conv2D(32, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv)
conv10 = Conv2D(4, (1, 1), activation='softmax')(conv)
return Model(inputs=self.input_layer, outputs=conv10)
#==========================================================
class testUnet():
'''simple unet model'''
def __init__(self, inp, kernel, dropout):
self.kernel = kernel
self.dropout = dropout
self.input_layer = Input(shape=inp)
self.generateModel()
def generateModel(self) -> Model :
conv1 = Conv2D(32, 7, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(self.input_layer)
conv1 = Conv2D(32, 7, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv1)
conv1 = BatchNormalization()(conv1)
mxpool = MaxPooling2D(pool_size=(2, 2))(conv1)
conv = Conv2D(64, 5, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool)
conv = Conv2D(64, 5, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv)
conv = BatchNormalization()(conv)
mxpool1 = MaxPooling2D(pool_size=(2, 2))(conv)
conv2 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool1)
conv2 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv2)
conv2 = BatchNormalization()(conv2)
mxpool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
conv3 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool2)
conv3 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv3)
conv3 = BatchNormalization()(conv3)
mxpool3 = MaxPooling2D(pool_size=(2, 2))(conv3)
conv5 = Conv2D(512, 1, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool3)
conv5 = Conv2D(512, 1, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv5)
conv5 = BatchNormalization()(conv5)
drop5 = Dropout(self.dropout)(conv5)
up7 = Conv2D(256, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(drop5))
merge7 = concatenate([conv3,up7], axis = 3)
# att7 = Attention(use_scale=False)([conv3, up7])
# merge7 = concatenate([att7, merge7], axis=3)
conv7 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge7)
conv7 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv7)
up8 = Conv2D(128, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv7))
merge8 = concatenate([conv2,up8], axis = 3)
# att8 = Attention(use_scale=False)([conv2, up8])
# merge8 = concatenate([att8, merge8], axis=3)
conv8 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge8)
conv8 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv8)
up9 = Conv2D(64, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv8))
merge9 = concatenate([conv,up9], axis = 3)
# att9 = Attention(use_scale=False)([conv, up9])
# merge9 = concatenate([att9, merge9], axis=3)
conv9 = Conv2D(64, 5, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge9)
conv9 = Conv2D(64, 5, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv9)
up = Conv2D(32, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv9))
merge = concatenate([conv1,up], axis = 3)
# att10 = Attention(use_scale=False)([conv1, up])
# merge = concatenate([att10, merge], axis=3)
conv = Conv2D(32, 7, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge)
conv = Conv2D(32, 7, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv)
conv10 = Conv2D(4, (1,1), activation = 'softmax')(conv)
return Model(inputs = self.input_layer, outputs = conv10)
class compUnet():
'''simple unet model'''
def __init__(self, inp, kernel, dropout):
self.kernel = kernel
self.dropout = dropout
self.input_layer = Input(shape=inp)
self.generateModel()
def residual_block(self, input_layer, filters):
conv1 = Conv2D(filters, 7, activation='relu', padding='same', kernel_initializer=self.kernel)(input_layer)
conv1 = BatchNormalization()(conv1)
conv2 = Conv2D(filters, 5, activation='relu', padding='same', kernel_initializer=self.kernel)(conv1)
conv2 = BatchNormalization()(conv2)
conv3 = Conv2D(filters, 3, activation='relu', padding='same', kernel_initializer=self.kernel)(conv2)
conv3 = BatchNormalization()(conv3)
residual_output = Add()([input_layer, conv3])
return residual_output
def generateModel(self) -> Model :
conv1 = Conv2D(8, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(self.input_layer)
conv1 = Conv2D(8, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv1)
conv1 = BatchNormalization()(conv1)
mxpool1 = MaxPooling2D(pool_size=(2, 2))(conv1)
conv2 = Conv2D(16, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool1)
conv2 = Conv2D(16, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv2)
conv2 = BatchNormalization()(conv2)
mxpool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
conv3 = Conv2D(32, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool2)
conv3 = Conv2D(32, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv3)
conv3 = BatchNormalization()(conv3)
mxpool3 = MaxPooling2D(pool_size=(2, 2))(conv3)
conv4 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool3)
conv4 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv4)
conv4 = BatchNormalization()(conv4)
mxpool4 = MaxPooling2D(pool_size=(2, 2))(conv4)
conv5 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool4)
conv5 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv5)
conv5 = BatchNormalization()(conv5)
mxpool5 = MaxPooling2D(pool_size=(2, 2))(conv5)
conv6 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool5)
conv6 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv6)
conv6 = BatchNormalization()(conv6)
mxpool6 = MaxPooling2D(pool_size=(2, 2))(conv6)
conv7 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(mxpool6)
conv7 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv7)
conv7 = BatchNormalization()(conv7)
drop7 = Dropout(self.dropout)(conv7)
up8 = Conv2D(256, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(drop7))
merge8 = concatenate([conv6,up8], axis = 3)
att8 = Attention(use_scale=False)([conv6, up8])
merge8 = concatenate([att8, merge8], axis=3)
conv8 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge8)
conv8 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv8)
up9 = Conv2D(128, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv8))
merge9 = concatenate([conv5,up9], axis = 3)
att9 = Attention(use_scale=False)([conv5, up9])
merge9 = concatenate([att9, merge9], axis=3)
conv9 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge9)
conv9 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv9)
up10 = Conv2D(64, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv9))
merge10 = concatenate([conv4,up10], axis = 3)
att10 = Attention(use_scale=False)([conv4, up10])
merge10 = concatenate([att10, merge10], axis=3)
conv10 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge10)
conv10 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv10)
up11 = Conv2D(32, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv10))
merge11 = concatenate([conv3,up11], axis = 3)
att11 = Attention(use_scale=False)([conv3, up11])
merge11 = concatenate([att11, merge11], axis=3)
conv11 = Conv2D(32, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge11)
conv11 = Conv2D(32, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv11)
up12 = Conv2D(16, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv11))
merge12 = concatenate([conv2,up12], axis = 3)
att12 = Attention(use_scale=False)([conv2, up12])
merge12 = concatenate([att12, merge12], axis=3)
conv12 = Conv2D(16, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge12)
conv12 = Conv2D(16, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv12)
up13 = Conv2D(8, 2, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(UpSampling2D(size = (2,2))(conv12))
merge13 = concatenate([conv1,up13], axis = 3)
att13 = Attention(use_scale=False)([conv1, up13])
merge13 = concatenate([att13, merge13], axis=3)
conv13 = Conv2D(8, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(merge13)
conv13 = Conv2D(8, 3, activation = 'relu', padding = 'same', kernel_initializer = self.kernel)(conv13)
conv14 = Conv2D(4, (1,1), activation = 'softmax')(conv13) # output layer
return Model(inputs = self.input_layer, outputs = conv14)