Skip to content

xsatvik/Neural-Style-Transfer

Repository files navigation

Neural Style Transfer with VGG19

This project implements neural style transfer using a pre-trained VGG19 model. The process involves transferring the style of one image onto another while preserving the content of the latter.

Prerequisites

Make sure you have the following libraries installed:

  • torch
  • torchvision
  • numpy
  • matplotlib
  • opencv-python
  • pillow

You can install them using pip:

pip install torch torchvision numpy matplotlib opencv-python pillow

Steps

Import Libraries and Load Model

Import necessary libraries and load the pre-trained VGG19 model.

Set Device

Set the device for computation (CPU or GPU).

Load Images

Load the content and style images using OpenCV.

Resize Images

Resize the images to a suitable size for processing.

Visualize Images

Visualize the content, target, and style images using Matplotlib.

Extract Feature Maps

Extract feature maps from the VGG19 model for both content and style images.

Compute Gram Matrix

Compute the Gram matrix for style representation.

Run Style Transfer

Optimize the target image to match the content and style representations.

Visualize Result

Visualize the final stylized image alongside the content and style images.

Results

Content Image

content

Style Image

style

Result Image

Screenshot 2024-06-21 at 12 29 51 AM

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors