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

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):

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

πŸ“ Files

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

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

Downloads last month
-
Safetensors
Model size
203k params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Spaces using bench-labs/pixelmodel 2

Collection including bench-labs/pixelmodel

Evaluation results