Style Transfer Introduction This project is an implementation of style transfer, a fascinating technique that allows us to apply the artistic style of one image to the content of another image. By leveraging the power of deep learning and neural networks, we can transform ordinary photos into stunning artwork.
The core concept behind style transfer involves using a pre-trained convolutional neural network (CNN) to extract the content and style features from the input images. These features are then combined to generate a new image that preserves the content of the original while adopting the style of the reference image.
How to Use
Installation Clone this repository to your local machine using the following command: bash Copy code git clone https://github.com/santhk2512/style-transfer.git Install the required Python packages: bash Copy code pip install -r requirements.txt Running Style Transfer To apply style transfer to your images, follow these steps:
Place the content image and the style image in the input directory.
Open a terminal and navigate to the project directory.
Run the style transfer script:
bash Copy code python style_transfer.py --content_image input/content.jpg --style_image input/style.jpg --output_image output/result.jpg Replace content.jpg and style.jpg with the filenames of your content and style images, respectively. The generated stylized image will be saved as result.jpg in the output directory.
Customizing Style Transfer The style_transfer.py script provides various parameters that allow you to customize the style transfer process:
--content_weight: Controls the weight given to the content loss. Higher values retain more of the content from the original image. --style_weight: Controls the weight given to the style loss. Higher values result in a stronger style transfer effect. --num_iterations: The number of iterations the algorithm runs. More iterations can enhance the quality of the stylized image but may also increase processing time. --content_layer: Specifies the layer used to extract content features. Different layers may produce varying results. --style_layers: A list of layers used to extract style features. Experiment with different combinations to achieve diverse styles. Acknowledgments This project is inspired by the groundbreaking work of Gatys et al. in their paper "A Neural Algorithm of Artistic Style." Special thanks to the open-source community for providing pre-trained CNN models and valuable resources.
License This project is licensed under the MIT License.
Contact If you have any questions, suggestions, or feedback, feel free to contact me.