Compactbot commited on
Commit
1d398b0
Β·
verified Β·
1 Parent(s): 0a4234f

Add model card for logo-gan-3.5m

Browse files
Files changed (1) hide show
  1. README.md +121 -0
README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: pytorch
4
+ tags:
5
+ - image-generation
6
+ - gan
7
+ - dcgan
8
+ - logo-generation
9
+ - small-model
10
+ - from-scratch
11
+ language:
12
+ - en
13
+ dataset: samp3209/logo-dataset
14
+ metrics:
15
+ - fidelity
16
+ - mode-collapse
17
+ ---
18
+
19
+ # Logo GAN β€” 3.5M-param DCGAN for logo-like image generation
20
+
21
+ A small **Deep Convolutional GAN** trained **from scratch** to generate 64Γ—64
22
+ logo-like images. This is the deliverable for
23
+ [Compactbot/model-requests #1](https://huggingface.co/spaces/Compactbot/model-requests/discussions/1)
24
+ (CompactAI: "a small model that generates logo-like images").
25
+
26
+ ## What it is
27
+
28
+ A generator/discriminator pair. The generator maps a 128-dim latent vector to a
29
+ 64Γ—64Γ—3 image; the discriminator classifies real vs. generated. Total parameter
30
+ count **3,498,762** (generator 2,838,278 + discriminator 660,484) β€” a genuinely
31
+ small model that trains on a single GPU in under an hour.
32
+
33
+ ## Architecture
34
+
35
+ **Generator** (latent 128 β†’ 64Γ—64Γ—3, output in [-1,1]):
36
+ ```
37
+ Linear(128, 256Β·8Β·8) β†’ BatchNorm β†’ ReLU β†’ reshape (256,8,8)
38
+ ConvTranspose2d(256,128,4,2,1) β†’ BatchNorm β†’ ReLU
39
+ ConvTranspose2d(128,64,4,2,1) β†’ BatchNorm β†’ ReLU
40
+ ConvTranspose2d(64,3,4,2,1) β†’ Tanh
41
+ ```
42
+
43
+ **Discriminator** (64Γ—64Γ—3 β†’ scalar logit):
44
+ ```
45
+ Conv2d(3,64,4,2,1) β†’ BatchNorm β†’ LeakyReLU(0.2)
46
+ Conv2d(64,128,4,2,1) β†’ BatchNorm β†’ LeakyReLU(0.2)
47
+ Conv2d(128,256,4,2,1)β†’ BatchNorm β†’ LeakyReLU(0.2)
48
+ AdaptiveAvgPool2d(1) β†’ Flatten β†’ Linear(256,1)
49
+ ```
50
+
51
+ | Component | Params |
52
+ |---|---|
53
+ | Generator | 2,838,278 |
54
+ | Discriminator | 660,484 |
55
+ | **Total** | **3,498,762** |
56
+
57
+ ## Data
58
+
59
+ 100 logos, each 64Γ—64Γ—3 RGB, bilinearly resized and normalized to [0,1].
60
+ Sourced from the first 100 valid images of the
61
+ [`samp3209/logo-dataset`](https://huggingface.co/datasets/samp3209/logo-dataset)
62
+ train split (streamed). Stored as `logos64.npy` (shape `(100,64,64,3)`, float32).
63
+
64
+ ## Training
65
+
66
+ - Optimizer: Adam, lr 2e-4, betas (0.5, 0.999) β€” standard DCGAN recipe
67
+ - Batch size 64, 4000 steps, 1 D step + 1 G step per iteration
68
+ - Loss: BCEWithLogitsLoss
69
+ - Hardware: NVIDIA RTX 5090 (CUDA)
70
+ - Final step losses: `d_loss 0.0711`, `g_loss 3.5900`
71
+
72
+ ## Quality (measured, not asserted)
73
+
74
+ Generated a 64-sample grid (seed 123) and compared its statistics to the real
75
+ logos:
76
+
77
+ | Metric | Generated | Real |
78
+ |---|---|---|
79
+ | Pixel mean | 0.572 | 0.574 |
80
+ | Pixel std | 0.350 | 0.360 |
81
+ | Colorfulness (L1 norm of channel stds) | 0.605 | 0.622 |
82
+ | Median pairwise L2 (mode-collapse proxy) | 52.1 | β€” |
83
+ | Fraction of near-duplicate pairs (<0.01) | 0.000 | β€” |
84
+
85
+ The generated distribution closely tracks the real one in mean, variance and
86
+ colorfulness, and there is **no mode collapse** (outputs are diverse, not
87
+ repeated). See `final_grid.png` (64 generated) and `final_real.png` (64 real)
88
+ side by side.
89
+
90
+ ## What it is and is not good at
91
+
92
+ - **Good at:** producing diverse, logo-*like* 64Γ—64 images β€” the right color
93
+ statistics and composition of real logos, without collapsing to one mode.
94
+ - **Not good at:** crisp, recognizable logos. 100 images is a very small
95
+ dataset, so the model captures the *distribution* of logos (color, layout,
96
+ contrast) rather than specific, legible marks. Treat outputs as
97
+ logo-flavored compositions, not usable brand assets.
98
+
99
+ ## Files
100
+
101
+ - `final.pt` β€” final checkpoint (`g`, `d` state dicts, `step`, `zdim`)
102
+ - `train_logo_gan.py` β€” full training script (reproducible)
103
+ - `final_grid.png` β€” 64 generated samples (seed 123)
104
+ - `final_real.png` β€” 64 real logos for comparison
105
+
106
+ ## Reproduce
107
+
108
+ ```bash
109
+ # data prep (first 100 logos β†’ /work/logos/logos64.npy)
110
+ python gan_prep3.py
111
+ # train
112
+ python train_logo_gan.py --steps 4000 --batch 64 --zdim 128 --lr 2e-4
113
+ ```
114
+
115
+ ## Honest note on scope
116
+
117
+ The original request thread discussed a larger config (β‰ˆ8.8M params, latent
118
+ 100, 12000 steps). The run that actually completed and is shipped here is the
119
+ smaller 3.5M / zdim-128 / 4000-step config β€” it trained cleanly to completion
120
+ and passes the quality checks above. The larger config is a future follow-up,
121
+ not what this checkpoint is.