Costi Claude Sonnet 5 commited on
Commit
71891b4
Β·
1 Parent(s): b451f49

Add parameter-count metadata for verification

Browse files

Adds config.json with a full parameter breakdown (total, per-layer,
text-encoder/VAE = 0) and embeds the same info directly in the
model.safetensors header metadata, so total parameter count can be
verified by reading either file without running any code.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Files changed (4) hide show
  1. README.md +3 -0
  2. config.json +21 -0
  3. convert_to_safetensors.py +13 -6
  4. model.safetensors +2 -2
README.md CHANGED
@@ -51,6 +51,8 @@ python convert_to_safetensors.py --model model.png --out model.safetensors
51
 
52
  Re-run this after training if you retrain into a new `model.png` β€” `model.safetensors` doesn't update itself.
53
 
 
 
54
  ---
55
 
56
  ## πŸ§ͺ Dataset vs Outputs
@@ -71,6 +73,7 @@ Re-run this after training if you retrain into a new `model.png` β€” `model.safe
71
  ```text
72
  model.png ← THE MODEL (64Γ—3200 px)
73
  model.safetensors ← same weights, standard format (generated, see below)
 
74
  main.py ← inference, loads model.png
75
  INFERENCE.py ← inference, loads model.safetensors
76
  convert_to_safetensors.py ← model.png -> model.safetensors
 
51
 
52
  Re-run this after training if you retrain into a new `model.png` β€” `model.safetensors` doesn't update itself.
53
 
54
+ 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).
55
+
56
  ---
57
 
58
  ## πŸ§ͺ Dataset vs Outputs
 
73
  ```text
74
  model.png ← THE MODEL (64Γ—3200 px)
75
  model.safetensors ← same weights, standard format (generated, see below)
76
+ config.json ← architecture + parameter-count metadata
77
  main.py ← inference, loads model.png
78
  INFERENCE.py ← inference, loads model.safetensors
79
  convert_to_safetensors.py ← model.png -> model.safetensors
config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "pixelmodel",
3
+ "architecture": "3-layer MLP (char-embed -> tanh -> tanh -> sigmoid)",
4
+ "weights_file": "model.safetensors",
5
+ "total_parameters": 202752,
6
+ "parameter_breakdown": {
7
+ "text_encoder_parameters": 0,
8
+ "generative_backbone_parameters": 202752,
9
+ "vae_parameters": 0
10
+ },
11
+ "layers": {
12
+ "W1": { "shape": [64, 32], "role": "prompt_embedding -> hidden", "parameters": 2048 },
13
+ "W2": { "shape": [64, 64], "role": "hidden -> hidden", "parameters": 4096 },
14
+ "W3": { "shape": [3072, 64], "role": "hidden -> output (32x32x3 flattened)", "parameters": 196608 }
15
+ },
16
+ "has_bias": false,
17
+ "prompt_dim": 32,
18
+ "hidden_dim": 64,
19
+ "output_resolution": "32x32",
20
+ "output_channels": 3
21
+ }
convert_to_safetensors.py CHANGED
@@ -20,22 +20,29 @@ from model import load_model, pixels_to_weights
20
  def convert(model_path: str, out_path: str):
21
  pixels = load_model(model_path)
22
  W1, W2, W3 = pixels_to_weights(pixels)
 
 
 
23
 
24
  save_file(
25
- {
26
- "W1": W1.contiguous(),
27
- "W2": W2.contiguous(),
28
- "W3": W3.contiguous(),
29
- },
30
  out_path,
31
  metadata={
32
  "format": "pt",
33
  "source": model_path,
34
  "architecture": "PixelModel 3-layer MLP (char-embed -> tanh -> tanh -> sigmoid)",
 
 
 
 
 
 
 
 
 
35
  },
36
  )
37
 
38
- total = W1.numel() + W2.numel() + W3.numel()
39
  print(f"Wrote {out_path} ({total:,} parameters: W1={tuple(W1.shape)}, W2={tuple(W2.shape)}, W3={tuple(W3.shape)})")
40
 
41
 
 
20
  def convert(model_path: str, out_path: str):
21
  pixels = load_model(model_path)
22
  W1, W2, W3 = pixels_to_weights(pixels)
23
+ W1, W2, W3 = W1.contiguous(), W2.contiguous(), W3.contiguous()
24
+
25
+ total = W1.numel() + W2.numel() + W3.numel()
26
 
27
  save_file(
28
+ {"W1": W1, "W2": W2, "W3": W3},
 
 
 
 
29
  out_path,
30
  metadata={
31
  "format": "pt",
32
  "source": model_path,
33
  "architecture": "PixelModel 3-layer MLP (char-embed -> tanh -> tanh -> sigmoid)",
34
+ "total_parameters": str(total),
35
+ "param_breakdown": (
36
+ f"W1(prompt->hidden)={W1.numel()}, "
37
+ f"W2(hidden->hidden)={W2.numel()}, "
38
+ f"W3(hidden->output)={W3.numel()}"
39
+ ),
40
+ "has_bias": "false",
41
+ "text_encoder_parameters": "0",
42
+ "vae_parameters": "0",
43
  },
44
  )
45
 
 
46
  print(f"Wrote {out_path} ({total:,} parameters: W1={tuple(W1.shape)}, W2={tuple(W2.shape)}, W3={tuple(W3.shape)})")
47
 
48
 
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8c365a7f71955241d343da88796e7c221f88b040e93006e9f1a46ecf5b36f10a
3
- size 811344
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0e88c9e0b4fa233565ef1598b52b88d3e8853bf5ced0e507a3d319cce59d5d4
3
+ size 811544