-1

I'm trying to make a denoise autoencoder wherein the encoder part is vgg16 and decoder is opposite of vgg16(encoder) network. My dataset consists of 5K images in grayscale.

Now while training, the loss and accuracy doesn't changes. I can think of reducing filters in the initial decoder layers but i fear that's going to affect the autoencoder. Here, i'm really clueless about what approach to follow.

arizona_3
  • 1
  • 1

1 Answers1

1

VGG16 is not trained to be used as an encoder for image reconstruction, it is trained to extract features from an image using which we can do classification task on the image.
This is why, you cannot use VGG16 as the encoder part of your denoise autoencoder.
However, if you want, you can use that architecture of VGG16 as the encoder part of your autoencoder, by just retraining those layers of VGG16,

vggmodel = keras.applications.vgg16.VGG16()
model_encoder = Sequential() 
num = 0
for i, layer in enumerate(vggmodel.layers):
    if i<19:
      model_encoder.add(layer)

model_encoder.summary()
for layer in model_encoder.layers:
  layer.trainable=True # Set encoder to trainable, and your autoencoder should work.

Again, there is a problem with your current architecture of autoencoder -it downsamples too much, leading to a significant loss of data. A smaller architecture would work better. For example:

model = Sequential()
model.add(Input(shape=(224,224,3)))
model.add(Conv2D(64, (3,3), activation='relu', padding='same'))
model.add(Conv2D(64, (3,3), activation='relu', padding='same'))
model.add(MaxPool2D((2,2)))
model.add(Conv2D(128, (3,3), activation='relu', padding='same'))
model.add(Conv2D(128, (3,3), activation='relu', padding='same'))
model.add(MaxPool2D((2,2)))
model.add(Conv2D(256, (3,3), activation='relu', padding='same'))
model.add(Conv2D(256, (3,3), activation='relu', padding='same'))
model.add(Conv2D(256, (3,3), activation='relu', padding='same'))
model.add(UpSampling2D((2,2)))
model.add(Conv2D(128, (3,3), activation='relu', padding='same'))
model.add(Conv2D(128, (3,3), activation='relu', padding='same'))
model.add(UpSampling2D((2,2)))
model.add(Conv2D(64, (3,3), activation='relu', padding='same'))
model.add(Conv2D(64, (3,3), activation='relu', padding='same'))
model.add(Conv2D(3, (3,3), activation='relu', padding='same'))
  • thank you so much for your comment! Just a quick question, if now i go on train my network using vgg16 by obviously training it again would it be a good choice for something to modify/increase performance in denoise autoencoders?? Because my main aim was to increase the accuracy and denoise autoencoders performance. Or there could be any different approach that is thereb which i can follow. – arizona_3 Apr 28 '22 at 11:45
  • I will build a denoise autoencoder by today, and will share a link to the code. – MD Mushfirat Mohaimin Apr 28 '22 at 11:52
  • thank you! please do let me know...although i have tried making a basic denoise autoencoder the results were good but i'm expecting a better result because of which i jumped to transfer learning using vgg16 – arizona_3 Apr 28 '22 at 11:57
  • @arizona_3 I've made a notebook on this, here is the link: https://www.kaggle.com/code/mushfirat/denoise-images-with-convolutional-autoencoders/ The explanations may not be so good, so I'll update it if you face any problem understanding it. – MD Mushfirat Mohaimin Apr 29 '22 at 12:23
  • thanks a ton!! Really appreciate this_/ \_ – arizona_3 Apr 29 '22 at 19:53
  • just a doubt would mean_squared_error be a good choice above binary cross entropy?? – arizona_3 Apr 29 '22 at 20:04
  • @arizona_3 yes, MSE can be used, but binary crossentropy is like the standard loss function for calculating loss between images. And It would be better if you could ask your doubts at kaggle, not here. – MD Mushfirat Mohaimin Apr 29 '22 at 21:45
  • Alright!! sure will clear doubts there. Thanks again. – arizona_3 Apr 30 '22 at 08:05