Generation of watercolor-like paintings by NST
Last time, I used brightness intensity as a threshold to extract flowers, leaves, and stems from a cosmos flower photo. This time, I applied watercolor painting style to this photo using Neural Style Transfer (NST). I used the short code below to reverse left side right of the content image, to make the direction same as the style image (only 4 lines!).
from PIL import Image, ImageOps
img = Image.open('result.jpg')
img_mirror = ImageOps.mirror(img)
img_mirror.save('result_mirror.jpg')
The result is like this.
The right image was used as the content image, while the following image was used as the style image.
Firstly, I downloaded the NST code from the Tensorflow Tutorial from the link below. https://www.tensorflow.org/tutorials/generative/style_transfer
Here’s a conceptual diagram of NST from Kaggle. VGG19 is used as the pretrained model. NST needs to select content layer, style layers, content weight, and style weight.
https://www.kaggle.com/code/yashchoudhary/fast-neural-style-transfer
I tried Default first. The result was like this.
Next, I changed selection of layers and weights from the default condition as shown in the table below. Tests 2 and 3 tried deeper layers, because deeper convolutions would have more condensed feature of the style image.
The results were as follows. Train step was all 1000. It seems better not to change the weight, and I felt that the deeper layer selection make the better finish (bottom left), in this case.
Overall, however, these images are quite different from the original watercolor paintings. This tutorial also includes code for Fast NST. So I tried Fast NST also. The result is as follows.
Which one is the most watercolor-like? I thought the normal NST using deeper layers with no change in weights was the best.