hp733 commited on
Commit
d3f4433
·
verified ·
1 Parent(s): a9947f7

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +46 -27
models.py CHANGED
@@ -1,27 +1,46 @@
1
- from tensorflow.keras.applications import VGG19, EfficientNetB0, DenseNet121
2
- from tensorflow.keras.models import Model
3
- from tensorflow.keras.layers import Dense, Flatten, GlobalAveragePooling2D, Input
4
-
5
- def create_vgg19_model():
6
- base_model = VGG19(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
7
- x = Flatten()(base_model.output)
8
- x = Dense(128, activation='relu')(x)
9
- output = Dense(2, activation='softmax')(x)
10
- model = Model(inputs=base_model.input, outputs=output)
11
- return model
12
-
13
- def create_efficientnet_model():
14
- base_model = EfficientNetB0(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
15
- x = GlobalAveragePooling2D()(base_model.output)
16
- x = Dense(128, activation='relu')(x)
17
- output = Dense(2, activation='softmax')(x)
18
- model = Model(inputs=base_model.input, outputs=output)
19
- return model
20
-
21
- def create_densenet_model():
22
- base_model = DenseNet121(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
23
- x = GlobalAveragePooling2D()(base_model.output)
24
- x = Dense(128, activation='relu')(x)
25
- output = Dense(2, activation='softmax')(x)
26
- model = Model(inputs=base_model.input, outputs=output)
27
- return model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # from tensorflow.keras.applications import VGG19, EfficientNetB0, DenseNet121
2
+ # from tensorflow.keras.models import Model
3
+ # from tensorflow.keras.layers import Dense, Flatten, GlobalAveragePooling2D, Input
4
+
5
+ # def create_vgg19_model():
6
+ # base_model = VGG19(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
7
+ # x = Flatten()(base_model.output)
8
+ # x = Dense(128, activation='relu')(x)
9
+ # output = Dense(2, activation='softmax')(x)
10
+ # model = Model(inputs=base_model.input, outputs=output)
11
+ # return model
12
+
13
+ # def create_efficientnet_model():
14
+ # base_model = EfficientNetB0(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
15
+ # x = GlobalAveragePooling2D()(base_model.output)
16
+ # x = Dense(128, activation='relu')(x)
17
+ # output = Dense(2, activation='softmax')(x)
18
+ # model = Model(inputs=base_model.input, outputs=output)
19
+ # return model
20
+
21
+ # def create_densenet_model():
22
+ # base_model = DenseNet121(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
23
+ # x = GlobalAveragePooling2D()(base_model.output)
24
+ # x = Dense(128, activation='relu')(x)
25
+ # output = Dense(2, activation='softmax')(x)
26
+ # model = Model(inputs=base_model.input, outputs=output)
27
+ # return model
28
+
29
+
30
+ from tensorflow.keras.applications import VGG19, EfficientNetB0, DenseNet121
31
+ from tensorflow.keras.models import Model
32
+
33
+ def create_vgg19_model():
34
+ base_model = VGG19(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
35
+ model = Model(inputs=base_model.input, outputs=base_model.get_layer("block5_conv4").output)
36
+ return model
37
+
38
+ def create_efficientnet_model():
39
+ base_model = EfficientNetB0(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
40
+ model = Model(inputs=base_model.input, outputs=base_model.get_layer("top_conv").output)
41
+ return model
42
+
43
+ def create_densenet_model():
44
+ base_model = DenseNet121(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
45
+ model = Model(inputs=base_model.input, outputs=base_model.get_layer("conv5_block16_concat").output)
46
+ return model