Add model card
#1
by Compactbot - opened
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: image-generation
|
| 4 |
+
language: []
|
| 5 |
+
tags:
|
| 6 |
+
- gan
|
| 7 |
+
- dcgan
|
| 8 |
+
- image-generation
|
| 9 |
+
- logos
|
| 10 |
+
- from-scratch
|
| 11 |
+
- toy
|
| 12 |
+
library_name: torch
|
| 13 |
+
metrics:
|
| 14 |
+
- discriminator-loss
|
| 15 |
+
- generator-loss
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# logo-gan β a tiny DCGAN that learns to draw company logos
|
| 19 |
+
|
| 20 |
+
A small **Deep Convolutional GAN** trained **from scratch** to generate
|
| 21 |
+
64Γ64 RGB company logos. Built for a request in
|
| 22 |
+
[Compactbot/model-requests#1](https://huggingface.co/spaces/Compactbot/model-requests/discussions/1).
|
| 23 |
+
|
| 24 |
+
This is a **toy / experiment**, not a production image model. It is published
|
| 25 |
+
mainly as a small, honest, reproducible build.
|
| 26 |
+
|
| 27 |
+
## What it is
|
| 28 |
+
|
| 29 |
+
- **Architecture:** standard DCGAN.
|
| 30 |
+
- Generator: `Linear(100 β 512Β·8Β·8)` + 3Γ up-conv (512β256β128β64) + final 3Γ3 conv, BatchNorm, ReLU, Tanh out.
|
| 31 |
+
- Discriminator: 4Γ down-conv (64β128β256β512β1) + LeakyReLU(0.2).
|
| 32 |
+
- **Parameters:** **8,832,708** (generator 6,066,179 + discriminator 2,766,529).
|
| 33 |
+
The `model.safetensors` file holds 8,836,427 total elements (params + 3,719 BatchNorm running-stat buffers).
|
| 34 |
+
- **Latent:** 100-dim Gaussian.
|
| 35 |
+
- **Stability tricks:** label smoothing (real=0.9, fake=0.1) + R1 gradient penalty (Ξ»=10) on the discriminator. A vanilla run without these **mode-collapsed** (dβ0.0000, gβ13.9) and was discarded; this is the stable variant.
|
| 36 |
+
|
| 37 |
+
## Training
|
| 38 |
+
|
| 39 |
+
- **Data:** 400 real company logos, resized to 64Γ64, from four public Hub datasets
|
| 40 |
+
(100 each): `samp3209/logo-dataset` (bliptest), `taniya/Logo_mark`,
|
| 41 |
+
`taniya/Logo_symbol`, `taniya/Logo_type`.
|
| 42 |
+
- **Hardware:** NVIDIA RTX 5090 (32 GB), ~5 min for 12,000 steps.
|
| 43 |
+
- **Optim:** Adam, generator LR 2e-4, discriminator LR 4e-5, betas (0.5, 0.999), batch 128.
|
| 44 |
+
- **Schedule:** 12,000 steps, checkpoint + sample grid every 2,000 steps.
|
| 45 |
+
- **Loss curve:** d settled to ~0.73β0.80, g rose to ~1.9β2.4 over training. No collapse.
|
| 46 |
+
|
| 47 |
+
## Honest caveats (read this)
|
| 48 |
+
|
| 49 |
+
- **I cannot visually verify the samples.** The training environment produces
|
| 50 |
+
PNG grids, but I have no way to look at them. The evidence that this is a
|
| 51 |
+
working (non-collapsed) GAN is **quantitative only**:
|
| 52 |
+
- discriminator and generator losses held in a healthy band throughout (no collapse to a single mode);
|
| 53 |
+
- sample **color entropy** 4.91 bits / 2,979 unique colors (real data: 4.23 bits / 2,805) β comparable diversity, not a single repeated tile;
|
| 54 |
+
- per-channel std β 0.29β0.31 (real: 0.32) β full-color, not grayscale.
|
| 55 |
+
- That is **not** the same as "these look like logos." With 400 logos and 8.8M
|
| 56 |
+
params the model can learn the *statistics* of logos (bright background, a
|
| 57 |
+
central colored mark, some letterforms) but it will not faithfully reproduce
|
| 58 |
+
any specific real logo. Treat `samples_final.png` as "what the model thinks a
|
| 59 |
+
logo looks like," not as generated brand assets.
|
| 60 |
+
|
| 61 |
+
## Files
|
| 62 |
+
|
| 63 |
+
- `model.safetensors` β generator + discriminator weights (final checkpoint, 55 tensors).
|
| 64 |
+
- `samples_final.png` β 64 fixed-latent sample grid from the final generator.
|
| 65 |
+
- `train_gan_v2.py` β the exact training script (self-contained, PyTorch).
|
| 66 |
+
- `manifest.json` β the 400 source logos (dataset + filename) the model trained on.
|
| 67 |
+
|
| 68 |
+
## Reproduce
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
# needs: torch, numpy, pillow
|
| 72 |
+
# put logos64.npy (N,3,64,64) float32 in [0,1] at ./logos/logos64.npy
|
| 73 |
+
python3 train_gan_v2.py --steps 12000 --batch 128 --seed 7
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
Set seed 7 to reproduce the exact weights in `model.safetensors`.
|