-1

this is the code i have tried but it gives me Input 0 is incompatible with layer model_21: expected shape=(None, 224, 224, 3), found shape=(1, 256, 256, 3)

 def loss_object(style_outputs, content_outputs, style_target, content_target):
          style_weight = 1e-2
          content_weight = 1e-1
          content_loss = tf.reduce_mean((content_outputs - content_target)**2)
          style_loss = tf.add_n([tf.reduce_mean((output_ - target_)**2) for output_, target_ in zip(style_outputs, style_target)])
          total_loss = content_weight*content_loss + style_weight*style_loss
          return total_loss
        vgg_model = load_vgg()
        content_target = vgg_model(np.array([content_image*255]))[0]
        style_target = vgg_model(np.array([style_image*255]))[1]

1 Answers1

0

As per the error, the pre-trained model which you are using expects the input to be of shape(None, 224, 224, 3), but you are feeding the input of shape(1, 256, 256, 3). You must resize the input to (224,224) and reshape it to (None,224,224,3). To reshape the image use similar code as below:

image=image.reshape(None,224,224,3)

Let us know if the issue still persists. Thanks!