File size: 2,488 Bytes
d3f4433 3e47932 d3f4433 c6fc64d 3e47932 |
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 |
# from tensorflow.keras.applications import VGG19, EfficientNetB0, DenseNet121
# from tensorflow.keras.models import Model
# from tensorflow.keras.layers import Dense, Flatten, GlobalAveragePooling2D, Input
# def create_vgg19_model():
# base_model = VGG19(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
# x = Flatten()(base_model.output)
# x = Dense(128, activation='relu')(x)
# output = Dense(2, activation='softmax')(x)
# model = Model(inputs=base_model.input, outputs=output)
# return model
# def create_efficientnet_model():
# base_model = EfficientNetB0(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
# x = GlobalAveragePooling2D()(base_model.output)
# x = Dense(128, activation='relu')(x)
# output = Dense(2, activation='softmax')(x)
# model = Model(inputs=base_model.input, outputs=output)
# return model
# def create_densenet_model():
# base_model = DenseNet121(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
# x = GlobalAveragePooling2D()(base_model.output)
# x = Dense(128, activation='relu')(x)
# output = Dense(2, activation='softmax')(x)
# model = Model(inputs=base_model.input, outputs=output)
# return model
# from tensorflow.keras.applications import VGG19, EfficientNetB0, DenseNet121
# from tensorflow.keras.models import Model
# def create_vgg19_model():
# base_model = VGG19(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
# model = Model(inputs=base_model.input, outputs=base_model.get_layer("block5_conv4").output)
# return model
# def create_efficientnet_model():
# base_model = EfficientNetB0(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
# model = Model(inputs=base_model.input, outputs=base_model.get_layer("top_conv").output)
# return model
# def create_densenet_model():
# base_model = DenseNet121(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
# model = Model(inputs=base_model.input, outputs=base_model.get_layer("conv5_block16_concat").output)
# return model
from tensorflow.keras.applications import VGG19
from tensorflow.keras.models import Model
def create_vgg19_model():
base_model = VGG19(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
# Use last convolutional layer directly
model = Model(inputs=base_model.input, outputs=base_model.get_layer("block5_conv4").output)
return model
|