Spaces:
Sleeping
Sleeping
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,10 +1,77 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CycleGAN Image Style Transfer (Horse to Zebra)
|
| 2 |
+
|
| 3 |
+
This project implements an end-to-end CycleGAN model for unpaired image style transfer, specifically focused on the **Horse to Zebra** dataset.
|
| 4 |
+
|
| 5 |
+
## Project Structure
|
| 6 |
+
### TensorFlow Version (Recommended for this system)
|
| 7 |
+
- `tf_dataset.py`: TensorFlow Data loader.
|
| 8 |
+
- `tf_models.py`: Keras/TF CycleGAN architectures.
|
| 9 |
+
- `tf_train.py`: TensorFlow training script.
|
| 10 |
+
- `tf_predict.py`: TensorFlow inference script.
|
| 11 |
+
|
| 12 |
+
### PyTorch Version
|
| 13 |
+
- `dataset.py`: PyTorch Dataset class.
|
| 14 |
+
- `models.py`: PyTorch Generator and Discriminator.
|
| 15 |
+
- `train.py`: PyTorch training script.
|
| 16 |
+
- `predict.py`: PyTorch inference script.
|
| 17 |
+
|
| 18 |
+
- `download_data.py`: Script to download and extract the Horse2Zebra dataset.
|
| 19 |
+
- `requirements.txt`: Project dependencies.
|
| 20 |
+
|
| 21 |
+
## Setup
|
| 22 |
+
1. Install dependencies:
|
| 23 |
+
```bash
|
| 24 |
+
pip install -r requirements.txt
|
| 25 |
+
```
|
| 26 |
+
2. Download the dataset:
|
| 27 |
+
```bash
|
| 28 |
+
python download_data.py
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
## Training
|
| 32 |
+
### TensorFlow
|
| 33 |
+
```bash
|
| 34 |
+
python tf_train.py
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
### PyTorch
|
| 38 |
+
```bash
|
| 39 |
+
python train.py
|
| 40 |
+
```
|
| 41 |
+
Checkpoints and sample results will be saved in the `saved_images/` directory or as `.h5` files.
|
| 42 |
+
|
| 43 |
+
## Inference
|
| 44 |
+
### TensorFlow
|
| 45 |
+
```bash
|
| 46 |
+
python tf_predict.py
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
### PyTorch
|
| 50 |
+
```bash
|
| 51 |
+
python predict.py
|
| 52 |
+
```
|
| 53 |
+
The result will be saved as `tf_prediction.png` or `prediction_result.png`.
|
| 54 |
+
|
| 55 |
+
## Web Application
|
| 56 |
+
A premium web interface is included for easy interaction with the models.
|
| 57 |
+
|
| 58 |
+
### Features
|
| 59 |
+
- **Bidirectional Style Transfer**: Switch between Horse ➔ Zebra and Zebra ➔ Horse.
|
| 60 |
+
- **Glassmorphic UI**: Modern, responsive design with smooth animations.
|
| 61 |
+
- **Real-time Preview**: See your uploaded image and stylized result side-by-side.
|
| 62 |
+
- **One-click Download**: Save your stylized art instantly.
|
| 63 |
+
|
| 64 |
+
### Running the App
|
| 65 |
+
1. Start the Flask server:
|
| 66 |
+
```bash
|
| 67 |
+
python app.py
|
| 68 |
+
```
|
| 69 |
+
2. Open your browser and go to `http://localhost:5000`.
|
| 70 |
+
|
| 71 |
+
## Notes
|
| 72 |
+
- The model uses **PatchGAN** for the discriminator and a **ResNet-based generator** with 9 residual blocks for 256x256 images.
|
| 73 |
+
- Training is optimized for both GPU and CPU.
|
| 74 |
+
- 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`).
|
| 75 |
+
|
| 76 |
+
## Troubleshooting
|
| 77 |
+
- **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.
|