| # 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 | |