File size: 4,618 Bytes
077eb99 ae45f1c 22152a3 077eb99 1d88bd9 76164de 386f5a6 76164de 386f5a6 1d88bd9 b451f49 71891b4 b451f49 1d88bd9 b451f49 71891b4 b451f49 1d88bd9 38bfe91 1d88bd9 38bfe91 1d88bd9 b451f49 1d88bd9 b451f49 1d88bd9 ae45f1c | 1 2 3 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | ---
license: mit
pipeline_tag: text-to-image
language:
- en
tags:
- image
- t2i
- text-to-image
- custoom-code
model-index:
- name: PixelModel
results:
- task:
type: text-to-image
dataset:
name: fid
type: fid
metrics:
- name: fid
type: fid
value: 566.84
- task:
type: text-to-image
dataset:
name: clip
type: clip
metrics:
- name: clip
type: clip
value: 0.186
new_version: bench-labs/pixelmodel-v1
---
<table align="center">
<tr>
<td align="center">
<a href="https://huggingface.co/spaces/bench-labs/BenchLabs-Leaderboard">π BenchLabs Leaderboard</a> β’
<a href="https://huggingface.co/spaces/FlameF0X/Tiny-T2I-Leaderboard">π Tiny-T2I Leaderboard</a>
</td>
</tr>
</table>
# PixelModel πΌοΈ
A neural network where the weights **are** the image.
## π What is this?
`model.png` is not a picture β it *is* the model.
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.
Training directly optimizes pixel values via gradient descent until the PNG becomes the model itself.
---
## π¨ Weight Encoding
- **R channel** β weight magnitude (0β255 β 0.0β1.0)
- **B channel** β weight sign (<128 = negative, β₯128 = positive)
- **G channel** β unused / reserved
---
## π§ Architecture
```text
prompt string
β char embedding β 32-dim vector
β W1 (64Γ32) β tanh
β W2 (64Γ64) β tanh
β W3 (3072Γ64) β sigmoid
β reshape β 32Γ32Γ3 image
````
All weights live inside `model.png`.
---
## π¦ Standard weights (safetensors)
`model.png` is the canonical model β training writes to it directly, and it's what makes PixelModel PixelModel. For tooling that expects standard weight files, the same 3 matrices are also exported as `model.safetensors` (202,752 parameters total, no bias terms):
```bash
python convert_to_safetensors.py # model.png -> model.safetensors
python convert_to_safetensors.py --model model.png --out model.safetensors
```
Re-run this after training if you retrain into a new `model.png` β `model.safetensors` doesn't update itself.
Parameter count is verifiable two ways without running any code: `config.json` (`total_parameters: 202752`, full per-layer breakdown) and the safetensors file's own header metadata (`total_parameters`, `param_breakdown`, `has_bias`, `text_encoder_parameters`, `vae_parameters` β all 0 except the MLP itself).
---
## π§ͺ Dataset vs Outputs
| Target | Output |
| ------------------------------------------ | -------------------------------------- |
| <img src="dataset/red.png" width="120"> | <img src="out_red.png" width="120"> |
| <img src="dataset/green.png" width="120"> | <img src="out_green.png" width="120"> |
| <img src="dataset/blue.png" width="120"> | <img src="out_blue.png" width="120"> |
| <img src="dataset/white.png" width="120"> | <img src="out_white.png" width="120"> |
| <img src="dataset/yellow.png" width="120"> | <img src="out_yellow.png" width="120"> |
| <img src="dataset/dark.png" width="120"> | <img src="out_dark.png" width="120"> |
---
## π Files
```text
model.png β THE MODEL (64Γ3200 px)
model.safetensors β same weights, standard format (generated, see below)
config.json β architecture + parameter-count metadata
main.py β inference, loads model.png
INFERENCE.py β inference, loads model.safetensors
convert_to_safetensors.py β model.png -> model.safetensors
train.py β training
model.py β architecture
dataset/
red.png
red.txt β prompt: "red"
...
```
---
## βοΈ Usage
```bash
python train.py
python train.py --epochs 500 --lr 0.05
python main.py "red"
python main.py "a cat" --out cat.png --scale 8
# equivalent, but loads model.safetensors instead of model.png
python convert_to_safetensors.py
python INFERENCE.py "a cat" --out cat.png --scale 8
```
`main.py` and `INFERENCE.py` produce byte-identical output for the same prompt β they're the same architecture and weights, just loaded from different files.
---
## π Tips
* 6β20 samples are enough
* Simple patterns converge fastest
* 200β500 epochs typical
* Loss < 0.001 is strong for toy datasets
---
*Itβs a toy. Itβs not useful. But it works.*
Bench Labs Β· Simple, Reliable, Open sourced |