Views
No views yet
| Dataset | Resolution | MSE | Fidelity | Params | Epochs |
|---|---|---|---|---|---|
| ImageNet-1K | 128×128 | 0.0000734 | 99.993% | 17M | 50 |
| ImageNet-1K | 128×128 | 0.000206 | 99.98% | 17M | 12 |
| TinyImageNet | 64×64 | 0.000478 | 99.95% | 17M | 200 |
F.normalize, one eigendecomposition, one convolution for stitching only, and a 2,272-parameter cross-attention.Image (B, 3, 128, 128)
→ 64 patches of 16×16
→ shared MLP encoder per patch (4 residual blocks, hidden=768)
→ (256, 16) matrix per patch
→ F.normalize(M, dim=-1) — rows to S^15
→ SVD via fp64 Gram + eigh
→ 64 spectral vectors S ∈ ℝ^16
→ 2-layer spectral cross-attention (learned per-mode α)
→ coordinated S + per-patch U, Vt
→ shared MLP decoder per patch (4 residual blocks)
→ stitch patches → boundary smooth
→ Reconstructed image (B, 3, 128, 128)(B, 16, 8, 8) = 1,024 values — 48:1 compression, nearly lossless.!pip install "git+https://github.com/AbstractEyes/geolip-core.git"1from transformers import AutoModel
2import torch
3
4model = AutoModel.from_pretrained("AbstractPhil/svae-fresnel-128", trust_remote_code=True)
5
6# Full reconstruction
7output = model(images)
8recon = output.recon # (B, 3, 128, 128)
9latent = output.latent # (B, 16, 8, 8) — omega tokens
10
11# Encode only (for downstream tasks)
12omega_tokens = model.encode(images) # (B, 16, 8, 8)
13
14# Full SVD decomposition
15svd = model.encode_full(images)
16# svd['U'], svd['S'], svd['Vt'], svd['M'] per patch
17
18# Decode from omega tokens (requires U, Vt for lossless)
19recon = model.decode(omega_tokens, U=svd['U'], Vt=svd['Vt'])1"""Fresnel 128×128 — AutoModel Inference Test"""
2
3import torch
4import torch.nn.functional as F
5import torchvision.transforms as T
6from transformers import AutoModel
7from datasets import load_dataset
8import matplotlib.pyplot as plt
9import numpy as np
10
11REPO = "AbstractPhil/svae-fresnel-128"
12DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
13
14# ── Load model ──
15print(f"Loading Fresnel from {REPO}...")
16model = AutoModel.from_pretrained(REPO, trust_remote_code=True).to(DEVICE).eval()
17config = model.config
18print(f" Params: {sum(p.numel() for p in model.parameters()):,}")
19print(f" Latent: ({config.latent_channels}, {config.latent_size}, {config.latent_size})")
20
21# ── Grab 4 images via streaming ──
22transform = T.Compose([
23 T.ToTensor(),
24 T.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
25])
26denorm_mean = torch.tensor([0.485, 0.456, 0.406]).reshape(1, 3, 1, 1).to(DEVICE)
27denorm_std = torch.tensor([0.229, 0.224, 0.225]).reshape(1, 3, 1, 1).to(DEVICE)
28def denorm(t):
29 return (t * denorm_std + denorm_mean).clamp(0, 1).cpu()
30
31ds = load_dataset('benjamin-paine/imagenet-1k-128x128', split='validation', streaming=True)
32images = []
33for i, sample in enumerate(ds):
34 img = sample['image'].convert('RGB')
35 images.append(transform(img))
36 if i >= 3:
37 break
38
39batch = torch.stack(images).to(DEVICE)
40print(f" Batch: {batch.shape}")
41
42# ── Full reconstruction ──
43with torch.no_grad():
44 output = model(batch)
45
46recon = output["recon"]
47latent = output["latent"]
48mse = F.mse_loss(recon, batch).item()
49print(f"\n Recon MSE: {mse:.6f} ({(1-mse)*100:.3f}% fidelity)")
50print(f" Latent: {latent.shape} — {batch.numel()//latent.numel()}:1 compression")
51
52# ── Encode omega tokens ──
53with torch.no_grad():
54 omega = model.encode(batch)
55print(f" Omega: {omega.shape}, mean={omega.mean():.3f}, std={omega.std():.3f}")
56
57# ── Full SVD ──
58with torch.no_grad():
59 svd = model.encode_full(batch)
60S = svd['S'][0].mean(0)
61print(f"\n Spectrum (mean over patches):")
62for i in range(len(S)):
63 print(f" S[{i:2d}]: {S[i]:.4f} {'#' * int(S[i].item() * 8)}")
64
65# ── Lossless round-trip ──
66with torch.no_grad():
67 lossless = model.decode(latent, U=svd['U'], Vt=svd['Vt'])
68print(f"\n Lossless MSE: {F.mse_loss(lossless, batch).item():.6f}")
69
70# ── Visualize ──
71n = len(images)
72fig, axes = plt.subplots(n, 4, figsize=(12, 3*n))
73for i in range(n):
74 axes[i,0].imshow(denorm(batch[i:i+1])[0].permute(1,2,0).numpy())
75 axes[i,1].imshow(denorm(recon[i:i+1])[0].permute(1,2,0).numpy())
76 axes[i,2].imshow((denorm(batch[i:i+1])-denorm(recon[i:i+1])).abs()[0].permute(1,2,0).numpy()*10)
77 omega_vis = omega[i,:3].cpu()
78 omega_vis = (omega_vis - omega_vis.min()) / (omega_vis.max() - omega_vis.min() + 1e-8)
79 axes[i,3].imshow(omega_vis.permute(1,2,0).numpy())
80 for j in range(4):
81 axes[i,j].axis('off')
82axes[0,0].set_title('Original')
83axes[0,1].set_title('Recon')
84axes[0,2].set_title('|Err|×10')
85axes[0,3].set_title('Omega (ch0-2)')
86plt.suptitle(f"Fresnel 128×128 — MSE={mse:.6f}", y=1.02)
87plt.tight_layout()
88plt.savefig('fresnel_inference.png', dpi=150, bbox_inches='tight')
89plt.show()(16, 8, 8) is 16× smaller than SD1.5's (4, 64, 64)F.normalize(M, dim=-1) — the single most important line1@misc{patchsvae2026,
2 title={The Geometric Engine: Structural Attractors in Neural Network Weight Space},
3 author={AbstractPhil},
4 year={2026},
5 url={https://huggingface.co/AbstractPhil/svae-fresnel-128}
6}