이미지_설명


Assignment 4 : Neural Style Transfer


이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명
이미지_설명



Table of Contents

1. Assignment summary
2. Content Reconstruction
3. Texture Generation
4. Neural Style Transfer
5. Bells & Whistles
For Bells & whistles, I implemented grumpy cats and temporal smoothness for videos.

1. Assignment summary

2. Content Reconstruction

3. Texture Generation

4. Neural Style Transfer

1. Tune the hyper-parameters until you are satisfied. Pay special attention to whether your gram matrix is normalized over feature pixels or not. It will result in different hyper-parameters by an order of 4-5. Please briefly describe your implementation details on the website. [10 points]

I choose content layer to be conv_2 and style layer to be conv_1, conv_2, conv_3, conv_4, conv_5. The Gram matrix is meticulously normalized relative to the dimensions of the input, which is a critical step for ensuring that the values within the matrix reflect relative, rather than absolute, correlations between feature activations. This normalization is instrumental in balancing the magnitude of the style loss, particularly when juxtaposed with the content loss. For this specific implementation, the style loss has been weighted significantly higher, by a factor of 100,000, compared to the content loss, which has been assigned a weight of 1. This disparity in weighting underscores the primary focus on style in the optimization process. Over the course of 300 iterations, the LBFGS algorithm—an optimizer known for its efficacy in dealing with large-scale optimization problems—was employed. LBFGS is particularly well-suited for tasks like style transfer due to its capacity for handling non-linear objectives and its requirement for relatively few line searches, which makes it more efficient compared to other gradient descent strategies. The computation time for the optimization process, initiated from a state of random noise versus using the content image as a starting point, was observed to be comparable. This suggests that the initial conditions, whether they be random noise or content-derived, do not significantly affect the computational effort required to achieve convergence, given the architecture and hyperparameters of this model.

2. Please report at least a 2x2 grid of results that are optimized from two content images mixing with two style images accordingly. (Remember to also include content and style images therefore the grid is actually 3x3) [10 points]

이미지_설명

3. Take input as random noise and a content image respectively. Compare their results in terms of quality and running time. [10 points]

이미지_설명

When starting with random noise, the resulting image may take longer to coherently form the content structures. On the other hand, beginning with a content image should immediately provide a clearer content structure. This method typically results in a faster convergence to a high-quality image where the content is recognizable and the style is effectively overlaid. Starting with noise requires more iterations for the content to become recognizable and for the style to be adequately applied, leading to longer run times.

4. Try style transfer on some of your favorite images. [10 points]

이미지_설명 이미지_설명

Other results

이미지_설명
이미지_설명

escher_sphere

이미지_설명

frida_kahlo

이미지_설명

picasso

이미지_설명

the_scream

이미지_설명

starry_night

이미지_설명

wally

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch -> 3000 epoch; result below

이미지_설명

fallingwater

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

phipps

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

tubingen

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

dancing

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

이미지_설명

started from noise 2000 epoch

Bells & Whistles (Extra Points)

1. Stylize your grump cats or Poisson blended images from the previous homework. (2pts)

이미지_설명

2. Apply style transfer to a video. You could try frame by frame method (2pts) or applying temporal smoothness for better output(4pts).

이미지_설명

I made create_smooth_transition_gif function to to generate videos from a sequence of images, introducing smooth transitions to enhance visual flow. Utilizing the OpenCV library for image manipulation and the PIL for creating video, this function calculates intermediate frames for each pair of consecutive images. This is achieved by linearly blending the images using OpenCV's addWeighted function, with the blend ratio gradually shifting from the first image to the second. This blending creates a smooth transition effect between images. After adding the original and interpolated frames to a list, the script compiles these into a single video, setting the frame duration and enabling looping. number of frame increased from 54 to 377 through this function

이미지_설명

50 epoch

이미지_설명

500 epoch

이미지_설명

1000 epoch

이미지_설명

1500 epoch

이미지_설명

2000 epoch

이미지_설명

2000 epoch (frame 54)

이미지_설명

2000 epoch + smooth function (frame 377)