YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

CycleGAN Image Style Transfer (Horse to Zebra)

This project implements an end-to-end CycleGAN model for unpaired image style transfer, specifically focused on the Horse to Zebra dataset.

Project Structure

TensorFlow Version (Recommended for this system)

  • tf_dataset.py: TensorFlow Data loader.
  • tf_models.py: Keras/TF CycleGAN architectures.
  • tf_train.py: TensorFlow training script.
  • tf_predict.py: TensorFlow inference script.

PyTorch Version

  • dataset.py: PyTorch Dataset class.

  • models.py: PyTorch Generator and Discriminator.

  • train.py: PyTorch training script.

  • predict.py: PyTorch inference script.

  • download_data.py: Script to download and extract the Horse2Zebra dataset.

  • requirements.txt: Project dependencies.

Setup

  1. Install dependencies:
    pip install -r requirements.txt
    
  2. Download the dataset:
    python download_data.py
    

Training

TensorFlow

python tf_train.py

PyTorch

python train.py

Checkpoints and sample results will be saved in the saved_images/ directory or as .h5 files.

Inference

TensorFlow

python tf_predict.py

PyTorch

python predict.py

The result will be saved as tf_prediction.png or prediction_result.png.

Web Application

A premium web interface is included for easy interaction with the models.

Features

  • Bidirectional Style Transfer: Switch between Horse โž” Zebra and Zebra โž” Horse.
  • Glassmorphic UI: Modern, responsive design with smooth animations.
  • Real-time Preview: See your uploaded image and stylized result side-by-side.
  • One-click Download: Save your stylized art instantly.

Running the App

  1. Start the Flask server:
    python app.py
    
  2. Open your browser and go to http://localhost:5000.

Notes

  • The model uses PatchGAN for the discriminator and a ResNet-based generator with 9 residual blocks for 256x256 images.
  • Training is optimized for both GPU and CPU.
  • The identity loss is currently set to 0 to speed up training, but can be adjusted in the training scripts (LAMBDA_IDENTITY or through identity_loss).

Troubleshooting

  • PyTorch DLL Error (WinError 1114): If you encounter this on Windows, it is often related to GPU driver conflicts or power management. It is recommended to use the TensorFlow version provided in this repository as it is confirmed to be stable in this environment.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support