Update README.md
Browse files
README.md
CHANGED
|
@@ -2,156 +2,93 @@
|
|
| 2 |
license: mit
|
| 3 |
pipeline_tag: text-to-image
|
| 4 |
---
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
<img src="dataset/yellow.png" style="width: 100px; image-rendering: pixelated; border-radius: 6px; display: block; margin: auto;" />
|
| 60 |
-
<div style="font-size: 0.75rem; color: #555; margin: 4px 0;">output</div>
|
| 61 |
-
<img src="out_yellow.png" style="width: 100px; image-rendering: pixelated; border-radius: 6px; display: block; margin: auto;" />
|
| 62 |
-
</td>
|
| 63 |
-
<td style="padding: 8px;">
|
| 64 |
-
<div style="font-size: 0.75rem; color: #555; margin-bottom: 4px;">dataset</div>
|
| 65 |
-
<img src="dataset/dark.png" style="width: 100px; image-rendering: pixelated; border-radius: 6px; display: block; margin: auto;" />
|
| 66 |
-
<div style="font-size: 0.75rem; color: #555; margin: 4px 0;">output</div>
|
| 67 |
-
<img src="out_dark.png" style="width: 100px; image-rendering: pixelated; border-radius: 6px; display: block; margin: auto;" />
|
| 68 |
-
</td>
|
| 69 |
-
</tr>
|
| 70 |
-
</table>
|
| 71 |
-
</div>
|
| 72 |
-
|
| 73 |
-
<!-- WHAT IS THIS -->
|
| 74 |
-
<div style="background: #161616; border: 1px solid #222; padding: 1.4rem; border-radius: 12px; margin-bottom: 1.5rem;">
|
| 75 |
-
<h2 style="color: #fff; font-size: 1rem; margin: 0 0 0.6rem;">What is this?</h2>
|
| 76 |
-
<p style="color: #aaa; font-size: 0.875rem; line-height: 1.7; margin: 0 0 0.75rem;">
|
| 77 |
-
<code style="background: #1e1e1e; padding: 2px 6px; border-radius: 4px;">model.png</code> is not a picture of anything β it <em>is</em> the model.
|
| 78 |
-
Every pixel's RGB values encode neural network weights:
|
| 79 |
-
</p>
|
| 80 |
-
<ul style="color: #aaa; font-size: 0.875rem; line-height: 1.7; margin: 0 0 0.75rem; padding-left: 1.1rem;">
|
| 81 |
-
<li><strong style="color: #ddd;">R channel</strong> β weight magnitude</li>
|
| 82 |
-
<li><strong style="color: #ddd;">B channel</strong> β weight sign (β₯128 = positive)</li>
|
| 83 |
-
<li><strong style="color: #ddd;">G channel</strong> β bias values</li>
|
| 84 |
-
</ul>
|
| 85 |
-
<p style="color: #aaa; font-size: 0.875rem; line-height: 1.7; margin: 0;">
|
| 86 |
-
At inference, pixels are parsed into 3 weight matrices forming a tiny MLP.
|
| 87 |
-
The prompt is embedded into a vector, then a forward pass generates a 32Γ32 image.
|
| 88 |
-
Training directly optimizes pixel values via gradient descent until the PNG itself becomes the model.
|
| 89 |
-
</p>
|
| 90 |
-
</div>
|
| 91 |
-
|
| 92 |
-
<!-- FILES -->
|
| 93 |
-
<div style="background: #161616; border: 1px solid #222; padding: 1.4rem; border-radius: 12px; margin-bottom: 1.5rem;">
|
| 94 |
-
<h2 style="color: #fff; font-size: 1rem; margin: 0 0 0.75rem;">π Files</h2>
|
| 95 |
-
<pre style="background: #111; border: 1px solid #1e1e1e; padding: 1rem; border-radius: 8px; color: #aaa; font-size: 0.8rem; overflow-x: auto; margin: 0;">
|
| 96 |
model.png β THE MODEL (64Γ3200 px)
|
| 97 |
main.py β inference
|
| 98 |
train.py β training
|
| 99 |
model.py β architecture
|
| 100 |
-
dataset/
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
...
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
python train.py
|
| 112 |
-
python train.py --epochs 500 --lr 0.05
|
| 113 |
-
|
| 114 |
-
<pre style="background: #111; border: 1px solid #1e1e1e; padding: 0.9rem; border-radius: 8px; color: #aaa; font-size: 0.8rem; margin: 0 0 0.75rem;">
|
| 115 |
python main.py "red"
|
| 116 |
-
python main.py "a cat" --out
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
All weights live inside <code style="background: #1e1e1e; padding: 2px 6px; border-radius: 4px;">model.png</code>. Opening the PNG is literally opening the neural network.
|
| 134 |
-
</p>
|
| 135 |
-
</div>
|
| 136 |
-
|
| 137 |
-
<!-- DATASET TIPS -->
|
| 138 |
-
<div style="background: #161616; border: 1px solid #222; padding: 1.4rem; border-radius: 12px; margin-bottom: 1.5rem;">
|
| 139 |
-
<h2 style="color: #fff; font-size: 1rem; margin: 0 0 0.6rem;">π Dataset Tips</h2>
|
| 140 |
-
<ul style="color: #aaa; font-size: 0.875rem; line-height: 1.7; margin: 0; padding-left: 1.1rem;">
|
| 141 |
-
<li>6β20 image-prompt pairs is enough</li>
|
| 142 |
-
<li>Simple targets converge fastest (solid colors, gradients, shapes)</li>
|
| 143 |
-
<li>200β500 epochs typically sufficient</li>
|
| 144 |
-
<li>Loss below 0.001 is good for simple datasets</li>
|
| 145 |
-
<li>Model capacity is fixed (~600K implicit parameters)</li>
|
| 146 |
-
</ul>
|
| 147 |
-
</div>
|
| 148 |
-
|
| 149 |
-
<!-- FOOTER -->
|
| 150 |
-
<div style="background: #161616; border: 1px solid #222; padding: 1.2rem; border-radius: 12px; text-align: center;">
|
| 151 |
-
<p style="color: #aaa; font-size: 0.875rem; margin: 0 0 0.25rem;">
|
| 152 |
-
It's a toy. It's not useful. But it's cool that it works.
|
| 153 |
-
</p>
|
| 154 |
-
<p style="color: #444; font-size: 0.8rem; margin: 0;">Bench Labs Β· Simple, Reliable, Open sourced</p>
|
| 155 |
-
</div>
|
| 156 |
-
|
| 157 |
-
</div>
|
|
|
|
| 2 |
license: mit
|
| 3 |
pipeline_tag: text-to-image
|
| 4 |
---
|
| 5 |
+
|
| 6 |
+
# PixelModel πΌοΈ
|
| 7 |
+
|
| 8 |
+
A neural network where the weights **are** the image.
|
| 9 |
+
|
| 10 |
+
## π What is this?
|
| 11 |
+
|
| 12 |
+
`model.png` is not a picture β it *is* the model.
|
| 13 |
+
|
| 14 |
+
Every pixel encodes neural network weights. At inference, the PNG is decoded into weight matrices forming a tiny MLP. The prompt is embedded into a vector, and the model generates a 32Γ32 image.
|
| 15 |
+
|
| 16 |
+
Training directly optimizes pixel values via gradient descent until the PNG becomes the model itself.
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## π¨ Weight Encoding
|
| 21 |
+
|
| 22 |
+
- **R channel** β weight magnitude (0β255 β 0.0β1.0)
|
| 23 |
+
- **B channel** β weight sign (<128 = negative, β₯128 = positive)
|
| 24 |
+
- **G channel** β unused / reserved
|
| 25 |
+
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
## π§ Architecture
|
| 29 |
+
|
| 30 |
+
```text
|
| 31 |
+
prompt string
|
| 32 |
+
β char embedding β 32-dim vector
|
| 33 |
+
β W1 (64Γ32) β tanh
|
| 34 |
+
β W2 (64Γ64) β tanh
|
| 35 |
+
β W3 (3072Γ64) β sigmoid
|
| 36 |
+
β reshape β 32Γ32Γ3 image
|
| 37 |
+
````
|
| 38 |
+
|
| 39 |
+
All weights live inside `model.png`.
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## π§ͺ Dataset vs Outputs
|
| 44 |
+
|
| 45 |
+
| Target | Output |
|
| 46 |
+
| ------------------------------------------ | -------------------------------------- |
|
| 47 |
+
| <img src="dataset/red.png" width="120"> | <img src="out_red.png" width="120"> |
|
| 48 |
+
| <img src="dataset/green.png" width="120"> | <img src="out_green.png" width="120"> |
|
| 49 |
+
| <img src="dataset/blue.png" width="120"> | <img src="out_blue.png" width="120"> |
|
| 50 |
+
| <img src="dataset/white.png" width="120"> | <img src="out_white.png" width="120"> |
|
| 51 |
+
| <img src="dataset/yellow.png" width="120"> | <img src="out_yellow.png" width="120"> |
|
| 52 |
+
| <img src="dataset/dark.png" width="120"> | <img src="out_dark.png" width="120"> |
|
| 53 |
+
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
+
## π Files
|
| 57 |
+
|
| 58 |
+
```text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
model.png β THE MODEL (64Γ3200 px)
|
| 60 |
main.py β inference
|
| 61 |
train.py β training
|
| 62 |
model.py β architecture
|
| 63 |
+
dataset/
|
| 64 |
+
red.png
|
| 65 |
+
red.txt β prompt: "red"
|
| 66 |
+
...
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
+
## βοΈ Usage
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
python train.py
|
| 75 |
+
python train.py --epochs 500 --lr 0.05
|
| 76 |
+
|
|
|
|
| 77 |
python main.py "red"
|
| 78 |
+
python main.py "a cat" --out cat.png --scale 8
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
## π Tips
|
| 84 |
+
|
| 85 |
+
* 6β20 samples are enough
|
| 86 |
+
* Simple patterns converge fastest
|
| 87 |
+
* 200β500 epochs typical
|
| 88 |
+
* Loss < 0.001 is strong for toy datasets
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
*Itβs a toy. Itβs not useful. But it works.*
|
| 93 |
+
|
| 94 |
+
Bench Labs Β· Simple, Reliable, Open sourced
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|