I'm working through the style transfer tutorial on tensorflow, see: style transfer

I made a few adjustments to my notebook, but it works fine for the base case:

[ content_image | transfer_image | style_image ] for all images:

enter image description here

However, I wanted to understand why the train_step() calls tf.keras.applications.vgg19.preprocess_input() on each step. I modified the notebook to precalculate the VGG preprocessing below. Notice that the input for the transfer_image is the same as the content_image and both have been preprocessed to BGR pixel ordering and mean centered.

enter image description here

I ran the same optimization with the following result: enter image description here

And here is the same result with vgg19.preprocess_input() reversed. Note that the original content_image and style_image reverse correctly, so I assume the same must be true for the transfer_image.

enter image description here

Obviously, the transfer_image that is optimized in the BGR+mean_centered domain is not the same as the one that was optimized in the normal RGB domain. I checked my code and the train_step is not adding a 2nd preprocessing step to the BGR+mean_centered input.

Intuitively, can anyone tell why this is the case?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.