| import tensorflow as tf | |
| from tensorflow.keras.applications import ResNet50 | |
| from tensorflow.keras.layers import GlobalAveragePooling2D, Dense | |
| from tensorflow.keras.models import Model | |
| def build_model(): | |
| base_model = ResNet50( | |
| weights="imagenet", | |
| include_top=False, | |
| input_shape=(224,224,3) | |
| ) | |
| x = base_model.output | |
| x = GlobalAveragePooling2D()(x) | |
| x = Dense(256, activation="relu")(x) | |
| output = Dense(1, activation="sigmoid")(x) | |
| model = Model(inputs=base_model.input, outputs=output) | |
| return model | |