Diff of /MI-DESS_IWTSE/ModelDCB.py [000000] .. [6a4082]

Switch to unified view

a b/MI-DESS_IWTSE/ModelDCB.py
1
# ==============================================================================
2
# Copyright (C) 2023 Haresh Rengaraj Rajamohan, Tianyu Wang, Kevin Leung, 
3
# Gregory Chang, Kyunghyun Cho, Richard Kijowski & Cem M. Deniz 
4
#
5
# This file is part of OAI-MRI-TKR
6
#
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as published
9
# by the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU Affero General Public License for more details.
16
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
# ==============================================================================
20
#!/usr/bin/env python3
21
22
from keras.models import Sequential,Model
23
from keras.optimizers import SGD, Adam
24
from keras.layers import Input#, Dropout, Dense, Conv3D, MaxPooling3D, GlobalMaxPooling3D ,GlobalAveragePooling3D, Activation, BatchNormalization,Flatten
25
#from keras.models import Sequential
26
#from keras.layers import Dropout, Dense, Conv3D, MaxPooling3D,GlobalMaxPooling3D, GlobalAveragePooling3D, Activation, BatchNormalization,Flatten
27
from resnet3d import Resnet3DBuilder
28
#from keras.regularizers import l2
29
30
31
def generate_model(learning_rate = 1 * 10 **(-4)):
32
    
33
    print('**************************')
34
    
35
    
36
    model = Resnet3DBuilder.build_resnet_18((48, 96, 18, 32), 1)
37
    model.compile(loss='binary_crossentropy',
38
                      metrics = ['accuracy'],
39
                      optimizer = Adam(lr=learning_rate,beta_1=0.99, beta_2=0.999))#SGD(lr=1e-2, momentum = 0.9))
40
    return model
41
42
    #input1 = Input(shape=(384, 384, 36, 1))
43
    #input2 = Input(shape=(352, 352, 144, 1))
44
45
    #out = Resnet3DBuilder.build_resnet_18((48, 96, 18, 32),input1,input2,1)
46
       
47
    #merged_model = Model([input1, input2], out)
48
    
49
    merged_model.compile(loss='binary_crossentropy',
50
                      metrics = ['accuracy'],
51
                      optimizer = Adam(lr=learning_rate,beta_1=0.99, beta_2=0.999))#SGD(lr=1e-2, momentum = 0.9))
52
    #loss='categorical_crossentropy'
53
54
    return merged_model
55
56
57
58
59