WaxFashionStyleGAN / README.md
paceunivai's picture
Update README.md
a13ab0e verified
---
tags:
- gan
- stylegan2
- image-generation
- fashion
- wax-pattern
license: mit
library_name: torch
---
# 🧡 WaxFashionStyleGAN
A **custom-trained StyleGAN2 model** for generating **African Wax Print-inspired fashion patterns**. This model explores the intersection of AI and African fashion, aiming to increase the representation of African textile design in digital spaces. Trained on a synthetic dataset of African Wax Print images, the model generates vibrant, culturally rich fashion patterns. It's designed for designers, researchers, and creators to generate unique fashion patterns.
### πŸ“Œ Model Overview
    **Model Type**: Fine-tuned StyleGAN2
    **Framework**: PyTorch, StyleGAN2-ADA
    **Resolution**: 1024x1024 images
    **Use Case**: Fashion design, textile prototyping, creative AI pattern generation
### 🎯 Use Cases
    Generate synthetic African Wax fabric designs
    Assist in textile prototyping and visual merchandising
    Enable designers to explore culturally diverse fashion patterns
### πŸ“ Dataset
    This model was trained on a synthetic dataset of African Wax Print patterns using the StyleGAN2 architecture.
    **Name**: AfricanWaxPatterns_5KDataset
    **Type**: Image dataset
    **Size**: ~5,000 curated samples
    **Dataset Link**: paceailab/AfricanWaxPatterns_5KDataset
### πŸ› οΈ How to Use
    πŸ”§ In Python (Colab or local):
```py
!git clone https://github.com/researchpace/waxfashion.git
from huggingface_hub import hf_hub_download
import torch
import legacy
import dnnlib
import sys
sys.path.append('/content/waxfashion/stylegan2-ada-pytorch')
# Load model
model_path = hf_hub_download("paceailab/Waxfashion_StyleGAN", "selected_models/styleGAN2ada_Africanwax.pkl")
# Load the pre-trained StyleGAN2 model
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
with dnnlib.util.open_url(model_path) as f:
G = legacy.load_network_pkl(f)['G_ema'].to(device) # Load the generator
# Generate and display image
import numpy as np
import PIL.Image
def generate_image(seed=42):
z = torch.from_numpy(np.random.RandomState(seed).randn(1, G.z_dim)).to(device)
img = G(z, None) # Generate image
img = (img.permute(0, 2, 3, 1) * 127.5 + 128).clamp(0, 255).to(torch.uint8)[0].cpu().numpy()
return PIL.Image.fromarray(img)
image = generate_image(seed=100)
image.show()
```
<h2>πŸ”— GitHub Repository</h2>
<p>For more information, code, please visit the GitHub repository:</p>
<ul>
<li><a href="https://github.com/researchpace/waxfashion" target="_blank">WaxFashion GitHub Repository</a></li>
</ul>
### πŸ” Training Details for Example Selected StyleGAN2 Model
&nbsp;&nbsp;&nbsp;&nbsp;Training was done on university **High Performance Computer**. Explored various parameters
<img src="https://cdn-uploads.huggingface.co/production/uploads/662301442e1aa351ad6248c7/KYJ-dO8MPxyHlMOwmbztW.png" width="400"/>
&nbsp;&nbsp;&nbsp;&nbsp;**Gpus** : 1
&nbsp;&nbsp;&nbsp;&nbsp;**Kimg** : 5000
&nbsp;&nbsp;&nbsp;&nbsp;**Cfg** : stylegan2
&nbsp;&nbsp;&nbsp;&nbsp;**Gamma** : 10
&nbsp;&nbsp;&nbsp;&nbsp;**Metrics** : fid50k_full, kid50k_full, pr50k3_full, ppl2_wend, is50k
&nbsp;&nbsp;&nbsp;&nbsp;**Learning Rate** : 0.002
&nbsp;&nbsp;&nbsp;&nbsp;**Training Batch Size** : 32
&nbsp;&nbsp;&nbsp;&nbsp;**Map depth** : 8
### πŸ“Έ Sample Outputs for the above trained model
&nbsp;&nbsp;&nbsp;&nbsp;Prompt Output
## At 1000 kimg
<img src="https://cdn-uploads.huggingface.co/production/uploads/662301442e1aa351ad6248c7/OVJ2Z0mOfF8SQ8PWJl60V.png" width="300"/>
## At 2000 kimg
<img src="https://cdn-uploads.huggingface.co/production/uploads/662301442e1aa351ad6248c7/5vqEZrYw46DZdb6cJ4Oxl.png" width="300"/>
## At 3000 kimg
<img src="https://cdn-uploads.huggingface.co/production/uploads/662301442e1aa351ad6248c7/yEUPxKCFGMIGK6cmYmNvI.png" width="300"/>
## At 4000 kimg
<img src="https://cdn-uploads.huggingface.co/production/uploads/662301442e1aa351ad6248c7/ZaUqp-S4FmJmMHdvfvhWe.png" width="300"/>
## At 5000 kimg
<img src="https://cdn-uploads.huggingface.co/production/uploads/662301442e1aa351ad6248c7/kE8ZBc0GEsPl0mKZ6W26I.png" width="300"/>
<h2>πŸ“Š Evaluation Metrics</h2>
<p>The performance of the <strong>WaxFashionStyleGAN</strong> model is evaluated using the following metrics:</p>
<ul>
<li><strong>FID50k_full</strong>: Frechet Inception Distance (FID) calculated over 50,000 images. A decrease in FID indicates better quality and diversity of generated images.</li>
<li><strong>KID50k_full</strong>: Kernel Inception Distance (KID) calculated over 50,000 images. A decrease in KID indicates better quality of the generated images.</li>
<li><strong>PR50k3_full</strong>: Precision-Recall (PR) score for 50,000 images. An increase in PR score indicates better coverage of the image distribution.</li>
<li><strong>PPL2_wend</strong>: Perplexity score at the 2nd generation stage. A higher value indicates better diversity in the generated images.</li>
<li><strong>IS50k</strong>: Inception Score (IS) calculated over 50,000 images. An increase in IS indicates that the generated images are diverse and of high quality.</li>
</ul>
<h2>πŸ—‚οΈ Files & Versioning</h2>
<p>This repository includes the necessary files for using the <strong>WaxFashionStyleGAN</strong> model:</p>
<ul>
<li><strong>stylegan2-ada-pytorch/</strong>: Contains the core StyleGAN2 implementation, including:
<ul>
<li><strong>dnnlib/</strong>: Helper library for managing configurations and other utilities.</li>
<li><strong>torch_utils/</strong>: Contains PyTorch-specific utilities for model manipulation.</li>
<li><strong>training/</strong>: Scripts for model training.</li>
<li><strong>metrics/</strong>: Contains code for calculating evaluation metrics like FID.</li>
<li><strong>generate.py</strong>: Script for generating images from the trained model.</li>
<li><strong>train.py</strong>: Main script to start training the StyleGAN2 model.</li>
<li><strong>trainv1.py</strong>: Alternate training script for different configurations.</li>
<li><strong>legacy.py</strong>: Code for compatibility with older versions of StyleGAN models.</li>
<li><strong>style_mixing.py</strong>: Script for mixing styles between different models or generated images.</li>
<li><strong>projector.py</strong>: Tool to project images into the latent space of the StyleGAN2 model.</li>
</ul>
</li>
<li><strong>selected_models/</strong>: Directory for storing pre-trained model checkpoints.</li>
<li><strong>metrics_graph.ipynb</strong>: Jupyter notebook for analyzing training metrics and model performance.</li>
<li><strong>config.yml</strong>: Configuration file for training parameters.</li>
<li><strong>requirements.txt</strong>: Lists dependencies for running the model.</li>
<li><strong>environment.yml</strong>: Conda environment file to set up the development environment.</li>
<li><strong>.gitattributes</strong>: Git LFS management for large model files.</li>
<li><strong>model_index.json</strong>: Metadata file for model configuration and indexing.</li>
</ul>
### πŸ“š Related Resources
&nbsp;&nbsp;&nbsp;&nbsp;πŸ”— [StyleGAN2 Paper](https://arxiv.org/abs/1912.04958)
&nbsp;&nbsp;&nbsp;&nbsp;πŸ”— [StyleGAN2-ADA GitHub](https://github.com/NVlabs/stylegan2-ada-pytorch)
### πŸ’‘ Citation
Β Β Β Β If you use this model, please cite or credit:
```py
@misc{stylegan2025,
title={WaxFashionStyleGAN},
author={Pace AI Lab},
year={2025},
howpublished={\url{https://huggingface.co/paceailab/WaxFashionStyleGAN}}
}
```