Skip to main content

This package assists user to transfer style of images by training a GAN model.

Project description

GAN-Art

🎨 GAN-Art is a Python package designed to assist users in applying artistic style transfers to images using a GAN-based model. It provides a simple interface to transfer the artistic style of one image onto another using deep learning 🧠, specifically leveraging pre-trained TensorFlow models 🤖.

Introduction

The GAN-Art package allows users to generate artistic images by blending the style of one image (such as a famous painting) onto another (such as a photograph). This is done using a pre-trained GAN model from TensorFlow Hub, which is fine-tuned through training to adapt the content and style images.

The package is simple to use and requires minimal setup. By providing paths to a content image and a style image, users can stylize images, visualize the training process, and save the final stylized image.

Directory Structure

Assuming a standard installable Python package structure, your project directory should look like this:

gan-art/
│
├── gan_art/
│   ├── __init__.py          # Package Initialization
│   └── gan_art.py           # Main functionality (GANArt class)
│
├── tests/                   # Optional test cases
│   └── TODO.py      # Upcoming
│
├── README.md                # Project documentation (this file)
├── pyproject.toml           # Project dependencies and metadata
├── poetry.lock              # Poetry lock file with dependencies versions
├── LICENSE                  # License file (optional)
└── setup.py                 # Setup file for installation (optional)

User Manual

Installation

You can install the gan-art package using Poetry, or you can build and install the package locally using the following commands:

pip install gan-art

We simplified the dependencies of the package because we build the package for end users to solely use on Colab environment. For custom environment, one would need to install the following dependencies.

Dependencies

The project requires the following dependencies:

  • TensorFlow
  • TensorFlow Hub
  • NumPy
  • Matplotlib
  • Pillow (PIL)
  • IPython (optional for notebook functionality)

These will be automatically installed if you're using Poetry.

Basic Usage

Once the package is installed, you can use the GANArt class to apply artistic style transfer. Here's an example code snippet:

from gan_art.GANArt import *

# Initialize paths to your images
content_path = 'path_to_content_image.jpg'
style_path = 'path_to_style_image.jpg'

# Create an instance of the GANArt class
gan_art = GANArt(content_path, style_path)

# Plot initial content and style images
gan_art.plot_images()

# Train the model
output_image = gan_art.train_model(epochs=10, steps_per_epoch=100)

# Save the final stylized image
tensor_to_image(output_image).save('final_stylized_image.png')

Explanation:

  1. Initialization: The GANArt class is initialized with the paths to your content and style images.
  2. Plot Images: The plot_images method allows you to visualize both the content and style images before training.
  3. Training: The train_model method trains the GAN model using the provided images for the specified number of epochs and steps per epoch. This generates the stylized image.
  4. Saving the Image: Finally, you can save the resulting stylized image using the tensor_to_image() function.

Advanced Options

  • Epochs and Steps: You can modify the number of epochs and steps per epoch to control how long the model trains.
  • Stylization Visualization: During training, the image is periodically updated and displayed using Matplotlib to show the progress of the style transfer.

Customization

The GAN model uses a pre-trained VGG-19 model for style transfer, which can be further fine-tuned or extended for other types of artistic image generation tasks. The GANArt class is modular, allowing you to modify components like the style and content layers, style and content weights, and training parameters.

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gan_art-0.1.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gan_art-0.1.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file gan_art-0.1.4.tar.gz.

File metadata

  • Download URL: gan_art-0.1.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10

File hashes

Hashes for gan_art-0.1.4.tar.gz
Algorithm Hash digest
SHA256 14db8ace22a53a6887e7b7f730c9ab2b0a4cfc5e10522c31c9a249758bb5309c
MD5 846ded50f89bd13c19641f6c30080c98
BLAKE2b-256 73e6cef4c2c34d4e48a447cf61b92372224d9975279d99e9f6f701a858c4bce8

See more details on using hashes here.

File details

Details for the file gan_art-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: gan_art-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10

File hashes

Hashes for gan_art-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 90ba4ef79fd0e46e7408f8459f5f6e0f0a8cb74d1cab5a878e49a3d54e702949
MD5 64d419cda56cf1a98b86128ce53d5364
BLAKE2b-256 457fedf43e31c7602323c2054eb16986d2d25c122014b605dc96e01181b7548f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page