For Bells & Whistles, I will first stylize the Poisson blended images from the previous homework. And then I will try using image editing methods for style transformation and compare the results.
Since the style image and content image should be of the same size, I am cropping all images to be size (512, 512).
| Conv2 | Conv4 |
|---|---|
![]() |
![]() |
| Conv6 | Conv8 |
![]() |
![]() |
I choose Conv4 as my favorite layer because it preserve decent content information and also removes some textures of the content image, which will be better for further style transfer.
| Content Image | Seed=42, Conv4 | Seed=17, Conv4 |
|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
To implement the style_loss, I calculate the Gram matrix as described and calculate the MSE distance between that of the input image and the style image. The style_loss is inserted after each of the specified convolutional layers below.
For the style image, I am using the frida_kahlo.jpeg and trying to learn the textures represented in this image.
| Conv1 | Conv2 | Conv4 |
![]() |
![]() |
![]() |
| Conv6 | Conv8 | Conv1-Conv5 |
![]() |
![]() |
![]() |
| Style Image | seed=42, Conv1-Conv5 | seed=17, Conv1-Conv5 |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In my implementation, I am enabling style_loss and content_loss, and I make sure that the Gram matrix is normalized over feature pixels. From the previous experiments, I am using Conv4 for content_loss, and Conv1-5 for style_loss. The hyper-parameters that we need to tune is the content_weight and the style_weight for content_loss and style_loss separately.
| Content Image | Style Image |
![]() |
![]() |
| Style_weight=100 | Style_weight=1000 | Style_weight=10000 |
![]() |
![]() |
![]() |
| Style_weight=100000 | Style_weight=200000 | Style_weight=500000 |
![]() |
![]() |
![]() |
| Content Image\Style Image | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
| Random Noise Input | ![]() |
![]() |
![]() |
| Content Image Input | ![]() |
![]() |
![]() |
| Random Noise Input | ![]() |
![]() |
![]() |
| Content Image Input | ![]() |
![]() |
![]() |
| Content Image | Style Image | Output Image |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| Content Image | Style Image | Output Image |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
InstructPix2pix is one of the most recent work that can perform image editing in an end-to-end fashion without any fine-tuning. Therefore, I am testing the InstructPix2pix model's performance on the style transfer task.
For the prompt for InstructPix2pix, I am using "Make it a picasso painting." and "Turn this into the style of starry night of Van Gogh."
| Target Style | Content Image | InstructPix2pix Output | Style Transfer Output |
| Picasso Painting | ![]() |
![]() |
![]() |
| Picasso Painting | ![]() |
![]() |
![]() |
| Picasso Painting | ![]() |
![]() |
![]() |
| Picasso Painting | ![]() |
![]() |
![]() |
| Van Gogh Starry Night | ![]() |
![]() |
![]() |
| Van Gogh Starry Night | ![]() |
![]() |
![]() |
| Van Gogh Starry Night | ![]() |
![]() |
![]() |
| Van Gogh Starry Night | ![]() |
![]() |
![]() |
For computation statistics, the inference time for InstructPix2pix on A4500 is 15-16 seconds on average, which is about the same as running style transfer with 10 optimization steps. But the memory requirement for InstructPix2pix is about 18GB, while the requirement for style transfer is much smaller.
Overall, the end-to-end models usually have less guarantee on the output image structures, but generally are more creative and more prone to make huge changes. The style_loss and content_loss guided style transfer have more guarantee in the generated image's resemblence to the content image, and generally will pick up exactly the textural details of the provided style image.