Fashion GenAI — StyleGAN2 + VAE for product image generation
Conditional StyleGAN2 for generating synthetic fashion/product images, plus
autoencoders/VAEs that learn compact representations of the same domain.
Trained from scratch on GangHitman/fashion-recommendation-images
(44,239 white-background e-commerce product photos, 142 article types).
Intended for product design ideation, marketing prototypes, synthetic dataset generation and creative experimentation.
Models
| File | Type | Resolution | Step | Notes |
|---|---|---|---|---|
models/gan_main.pt | GAN | 128px | 7000 | Conditional StyleGAN2, 70 classes, EMA generator |
models/vae_256.pt | VAE | 256px | 7000 | Spatial latent 4x32x32 (48x compression) |
models/vae_global_128.pt | VAE | 128px | 7000 | Global latent 512-d (96x compression) |
Generation metrics
| Model | Truncation | FID | KID | LPIPS-diversity |
|---|---|---|---|---|
| gan_main | 1.0 | 77.43 | 0.0309 | 0.4494 |
FID/KID computed on 10000 generated vs real images. FID is biased by sample count, so do not compare these against numbers measured at a different count.
Reconstruction metrics (held-out split)
| Model | Compression | PSNR | SSIM | LPIPS | L1 |
|---|---|---|---|---|---|
| vae_256 | 48.0x | 27.40 | 0.9419 | 0.0504 | 0.0272 |
| vae_global_128 | 96.0x | 23.96 | 0.8995 | 0.0800 | 0.0409 |
Usage
git clone https://github.com/<your-fork>/fashion-genai # or copy src/
pip install torch torchvision pyyaml pillow numpy
from huggingface_hub import hf_hub_download
from fashiongen.inference import GANSampler, VAERunner, to_pil
gan = hf_hub_download("KartikSaste/fashion-genai-stylegan2-vae", "models/gan_main.pt")
sampler = GANSampler.from_checkpoint(gan, device="cuda")
# truncation < 1 trades diversity for fidelity
images = sampler.sample(8, class_name="Tshirts", truncation=0.8, seed=0)
to_pil(images)[0].save("design.png")
# latent walk between two designs
strip = sampler.interpolate(steps=8, class_name="Shirts")
vae = hf_hub_download("KartikSaste/fashion-genai-stylegan2-vae", "models/vae_256.pt")
runner = VAERunner.from_checkpoint(vae, device="cuda")
embedding = runner.embed(my_pil_image) # for retrieval / clustering
recon = runner.reconstruct(my_pil_image)
Every checkpoint embeds the config and class list it was trained with, so the
architecture is rebuilt from the .pt file alone.
Training setup
- 8x A100 80GB (Lambda Cloud). GAN on 6 GPUs, autoencoders on 1 GPU each, concurrently.
- StyleGAN2: non-saturating loss, lazy R1 (
gamma=1.0), lazy path-length, style mixing, EMA generator, ADA adaptive augmentation, projection conditioning. - VAE: L1 + LPIPS + KL + PatchGAN adversarial with VQGAN-style adaptive weighting.
- Gradients are averaged with an explicit all-reduce rather than
DistributedDataParallel, because R1/path-length need double backward which DDP does not support.
Limitations
- Trained on a modest compute budget;
gan_mainis undertrained relative to a full StyleGAN2 schedule (which is ~25M images) and samples show artefacts. - FIR resampling is pure PyTorch (no custom CUDA op), roughly 4x slower than NVIDIA's compiled kernel.
- Conditioning is categorical (
article_type); no text-to-image model is trained. - 128px/256px outputs; not suitable for print-resolution assets.
- Reflects the biases of the source catalogue (product mix, styling, demographics). Generated people are synthetic and should not be presented as real models.
License
MIT, matching the source dataset.