| # 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: | |
| ```bash | |
| pip install -r requirements.txt | |
| ``` | |
| 2. Download the dataset: | |
| ```bash | |
| python download_data.py | |
| ``` | |
| ## Training | |
| ### TensorFlow | |
| ```bash | |
| python tf_train.py | |
| ``` | |
| ### PyTorch | |
| ```bash | |
| python train.py | |
| ``` | |
| Checkpoints and sample results will be saved in the `saved_images/` directory or as `.h5` files. | |
| ## Inference | |
| ### TensorFlow | |
| ```bash | |
| python tf_predict.py | |
| ``` | |
| ### PyTorch | |
| ```bash | |
| 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: | |
| ```bash | |
| 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. | |