/fusionX

Flask web application for artistic neural style transfer

Primary LanguageHTMLMIT LicenseMIT

GitHub contributors

Fusion Xperience 🔥 ⚡

FusionX is a Flask-based web application that brings the power of neural style transfer to your fingertips. Transform ordinary images into extraordinary pieces of art by applying the styles of famous paintings.

fusionX App

✨ Repository Vision

The goal of this repository is to provide a simple and easy-to-use web application for neural style transfer. The application is built using the Flask framework and the PyTorch library. The neural style transfer model is based on the A Neural Algorithm of Artistic Style paper by Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge.

📑 Table of Contents

Features ✨

  • Upload or Generate content images
    • Upload from your device
    • Generate using Hugging Face Text-to-Image API
  • Apply styles to content images
    • Upload from your device
    • Choose from a gallery of pre-loaded styles
    • Generate using Hugging Face Text-to-Image API
  • Customize the style transfer process with advanced options
    • Adjust the style weight
    • Adjust the content weight
    • Adjust the total variation weight
    • Adjust the number of iterations
  • Use the Editor to fine-tune the stylized image
    • Crop and Resize the image
    • Super Resolution using Real-ESRGAN
  • Download the stylized image

Application Preview 📷

The Studio page allows you to upload content and style images.

Upload Image

The Studio page also allows you to generate content and style images using the Hugging Face Text-to-Image API.

Generate Image

The Gallery page showcases a collection of pre-loaded style images that can be applied to your content images.

Gallery

Once both the content and style images are selected, you can customize the style transfer process using advanced options.

Advanced Options

The Editor page allows you to fine-tune the stylized image by cropping, resizing, and enhancing the image.

Editor

Getting Started 🚀

Prerequisites 📋

  • Python 3.9 or higher
  • Torch

Environment Variables 🔑

Create a .env file in the root directory of the project and add the following environment variables:

SECRET_KEY="your_secret_key"
HF_API_KEY="your_hugging_face_api_key"

# Hugging Face Text-to-Image API Models that fusionX uses
STABLE_DIFFUSION_V15="https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5"
STABLE_DIFFUSION_V21="https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1"
STABLE_DIFFUSION_XL_BASE_1.0="https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
ANYTHING_V5="https://api-inference.huggingface.co/models/stablediffusionapi/anything-v5"
DREAMLIKE_PHOTO_REAL="https://api-inference.huggingface.co/models/dreamlike-art/dreamlike-photoreal-2.0"
DREAM_SHAPER="https://api-inference.huggingface.co/models/Lykon/DreamShaper"
NITRO_DIFFUSION="https://api-inference.huggingface.co/models/nitrosocke/Nitro-Diffusion"
DREAMLIKE_ANIME_V10="https://api-inference.huggingface.co/models/dreamlike-art/dreamlike-anime-1.0"
REALISTIC_VISION_V14="https://api-inference.huggingface.co/models/SG161222/Realistic_Vision_V1.4"

Installation 💻

# 1. Clone the repository
git clone https://github.com/yourusername/fusionX.git

# 2. Navigate to the project directory
cd fusionX

# 3. Create a virtual environment (optional)
python -m venv venv

# 4. Activate the virtual environment
source venv/bin/activate

# 5. Install the required packages
pip install -r requirements.txt

# 6. Run the application
python run.py

For Mac/Unix Users 🐚

To set up your environment and run the application on Mac or Unix systems, follow these steps:

  1. Create the Install Script: Create a file named install.sh in the root directory of the project. This script will contain all the necessary commands to install your project's dependencies.

    #!/bin/bash
    
    # Install common dependencies
    pip install -r requirements.txt
    
    # Install PyTorch with CUDA support
    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
  2. Make the Script Executable: Run the following command in your terminal to make the script executable.

    chmod +x install.sh
  3. Execute the Install Script: Now, run the script to install your dependencies.

    ./install.sh

For Windows Users 🪟

Windows users should follow these steps to prepare their environment and run the application:

  1. Create the Install Script: Create a file named install.ps1 in the root directory of the project. This PowerShell script will install the necessary dependencies for the project.

    # Install common dependencies
    pip install -r .\requirements.txt
    
    # Install PyTorch with CUDA support
    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
  2. Execute the Install Script: Open PowerShell as an administrator, navigate to the project's root directory, and run the script with the following command:

    Powershell -ExecutionPolicy Bypass -File .\install.ps1

Contributing 🤝

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. Please refer to the Contributing Guidelines for more details.

License 📄

Distributed under the MIT License. See LICENSE for more information.