Neural Style Transfer (NST) is a technique that allows combining the content of one image with the style of another image to create a composite image that maintains the content of the original but adopts the stylistic elements of the second image. This project showcases the use of NST for artistic applications, photo editing, and more.
Neural Style Transfer (NST) leverages Convolutional Neural Networks (CNNs), particularly using pre-trained models like VGG-19, to perform style transfer by optimizing the pixel values of the input image.
- Feature Extraction
- Gram Matrix
- Loss Function
- Generating the Stylized Image
- Installation
- Libraries Used
- Examples
- Content and Style Images
- Content Image
- Style Image
- Result
- Author
Feature extraction is performed using a pre-trained VGG-19 model to get the content and style representations of the images. These features are then used to compute the content and style losses.
The Gram matrix is used to capture the style of the image by representing the correlations between different filter responses of the CNN.
Content Loss: Measures how much the content of the generated image deviates from the content image.
Style Loss: Measures how much the style of the generated image deviates from the style image.
The stylized image is generated by optimizing the pixel values of the content image to minimize the combined content and style loss.
To run this project, follow these steps:
- Clone the repository:git clone https://github.com/archie-a18/Neural-Style-Transfer.git
- Copy code
- Upload the code file to Google Colab.
- Run all the code cells in the Jupyter notebook to perform the style transfer.
- Choose your content and style images.
-
Numpy: Used for a variety of mathematical operations on arrays. It is efficient and fast.
-
TensorFlow: A comprehensive library for machine learning and artificial intelligence, providing tools to build and train models, including pre-trained VGG models.
-
VGG: Visual Geometry Group's standard deep CNN architecture. VGG-19 is used for feature extraction in this project.
-
OS: Provides functions for interacting with the operating system.
-
CV2: OpenCV for Python, used for image processing tasks such as reading and manipulating images.
-
PIL: Python Imaging Library, used for opening, manipulating, and saving different image file formats.
The following is an example of a style transfer result using this project:
Author Archie Agarwal - If you have any questions or suggestions, feel free to contact me at [email protected]