Combination of ResNet and ConvNet

Viewed 90

I have prepared a CNN model for image colorization:

"""Encoder - Input grayscale image (L)"""
model = Sequential()
model.add(Conv2D(32, (3, 3), activation='relu', padding='same', input_shape=(256, 256, 1)))

...

"""Latent space"""
model.add(Conv2D(512, (3,3), activation='relu', padding='same'))

"""Decoder - output (A,B)"""

...

model.add(Conv2D(2, (3, 3), activation='tanh', padding='same'))

Now i want to use ResNet as feature extractor and merge the output to Latent space.

I have already imported ResNet model as:

resnet50_imagnet_model = tf.keras.applications.resnet.ResNet50(weights = "imagenet", 
                           include_top=False, 
                           input_shape = (256, 256, 3),
                           pooling='max')
1 Answers

Encoder

"""Encoder - Input grayscale image (L)"""
encoder = Sequential()
model.add(Conv2D(32, (3, 3), activation='relu', padding='same', input_shape=(256, 256, 1)))

...

Decoder

decoder = """Decoder - output (A,B)"""

...

Use tf.keras.Sequential() to merge all models

comb_model = tf.keras.Sequential(
    [encoder,resnet50_imagnet_model, decoder]
)
Related