Transform your photos into stunning digital art using the power of Neural Style Transfer!
Neural Style Transfer (NST) is an innovative AI technique that combines the content of one image with the artistic style of another. This project implements a state-of-the-art NST model using TensorFlow and Keras, allowing you to create unique artworks from your photos.
- Explore and implement Neural Style Transfer techniques
- Develop a user-friendly interface for easy art creation
- Provide a platform for creating potential NFT artworks
NST leverages the power of Convolutional Neural Networks (CNNs) to separate and recombine the content and style of different images. The process involves:
- Using a pre-trained feature extractor (typically a VGG network)
- Implementing a transfer network with an encoder-decoder architecture
- Optimizing the output image to minimize both content and style losses
Our implementation uses a pre-trained "Arbitrary Neural Artistic Stylization Network," capable of applying various artistic styles to any input image in a single, efficient pass.
- Python 3.7+
- TensorFlow 2.x
- Keras
- Matplotlib
-
Clone the repository:
git clone https://github.com/yourusername/neural-style-transfer.git cd neural-style-transfer
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Download the pre-trained model from this link and place it in the
model
directory.
You can use the Neural Style Transfer model in two ways:
- Through the Python API:
import matplotlib.pyplot as plt
from API import transfer_style
model_path = "path/to/model/directory"
content_image_path = "path/to/your/content/image.jpg"
style_image_path = "path/to/your/style/image.jpg"
stylized_image = transfer_style(content_image_path, style_image_path, model_path)
plt.imsave('stylized_image.jpg', stylized_image)
plt.imshow(stylized_image)
plt.show()
- Through the provided application:
python app.py
To dive deeper into Neural Style Transfer, check out these resources:
- A Neural Algorithm of Artistic Style (original paper)
- Neural Style Transfer with Keras
- Exploring the structure of a real-time, arbitrary neural artistic stylization network
The project includes two custom Neural Style Transfer (NST) models, located in the notebooks
directory:
-
Full NST Model (VGG19): This model implements the original Neural Style Transfer algorithm. It uses VGG19 to the style from a given style image and applies it to a content image. This process can be computationally intensive but offers high flexibility in style application.
-
Pretrained Model: This is a fast Neural Style Transfer model that uses a pretrained network. It can apply style transfer much more quickly than the Pull NST model, making it suitable for real-time applications or processing large numbers of images.
Here are some examples of our Neural Style Transfer in action:
Each of these images demonstrates a unique style transfer, showcasing the versatility of our Neural Style Transfer model.
- TensorFlow Hub for the pre-trained model
- The authors of the original NST papers and implementations
- Aleksa Gordić Pytorch Implementation
Happy styling! Create, innovate, and share your AI-generated masterpieces with the world! 🎨🚀