π Supernova Creation - Elite Compact Image Generation Engine
This repository contains the complete configuration and pre-trained checkpoints for the Supernova Creation image reconstruction and generation pipeline. It is specifically designed to run with extreme efficiency on standard consumer CPU configurations while matching the quality of high-fidelity convolutional structures.
π Performance & Specifications
- Model Size: ~223,395 parameters (less than 1 MB in weights storage footprint, comfortably within the 3 MB constraint!)
- Reconstruction Quality: Peak Signal-to-Noise Ratio (PSNR) of 27.77 dB and SSIM of 0.9121 on structured astronomical datasets.
- CPU Latency: 11.41 ms per 64x64 image on single-thread execution target.
- Throughput: ~5,190 images/minute.
- Artifact Mitigation: Uses dedicated composite loss combinations (L1 + MSE + Spatial Edge Gradients + Total Variation) to combat legay color-clashing 'rainbow' defects.
π οΈ Architecture Specification & Rebuilding
To rebuild the identical architecture dynamically in your workspace:
import torch
import torch.nn as nn
class ResidualBlock(nn.Module):
def __init__(self, channels):
super().__init__()
self.conv1 = nn.Conv2d(channels, channels, kernel_size=3, padding=1, groups=channels, bias=False)
self.conv2 = nn.Conv2d(channels, channels, kernel_size=1, bias=False)
self.norm = nn.GroupNorm(4, channels)
self.act = nn.GELU()
def forward(self, x):
return x + self.conv2(self.act(self.norm(self.conv1(x))))
class SupernovaEncoder(nn.Module):
def __init__(self, in_channels=3, base_channels=32, latent_dim=16):
super().__init__()
self.stem = nn.Conv2d(in_channels, base_channels, kernel_size=3, padding=1)
self.stage1 = nn.Sequential(
ResidualBlock(base_channels),
nn.Conv2d(base_channels, base_channels * 2, kernel_size=3, stride=2, padding=1),
nn.GroupNorm(4, base_channels * 2),
nn.GELU()
)
self.stage2 = nn.Sequential(
ResidualBlock(base_channels * 2),
nn.Conv2d(base_channels * 2, base_channels * 4, kernel_size=3, stride=2, padding=1),
nn.GroupNorm(4, base_channels * 4),
nn.GELU()
)
self.to_latent_mu = nn.Conv2d(base_channels * 4, latent_dim, kernel_size=1)
self.to_latent_logvar = nn.Conv2d(base_channels * 4, latent_dim, kernel_size=1)
def forward(self, x):
x = self.stem(x)
x1 = self.stage1(x)
x2 = self.stage2(x1)
return self.to_latent_mu(x2), self.to_latent_logvar(x2), [x1, x2]
class SupernovaDecoder(nn.Module):
def __init__(self, out_channels=3, base_channels=32, latent_dim=16):
super().__init__()
self.latent_proj = nn.Conv2d(latent_dim, base_channels * 4, kernel_size=1)
self.up_stage1 = nn.Sequential(
ResidualBlock(base_channels * 4),
nn.Upsample(scale_factor=2, mode='bilinear', align_corners=False),
nn.Conv2d(base_channels * 4, base_channels * 2, kernel_size=3, padding=1),
nn.GroupNorm(4, base_channels * 2),
nn.GELU()
)
self.up_stage2 = nn.Sequential(
ResidualBlock(base_channels * 2),
nn.Upsample(scale_factor=2, mode='bilinear', align_corners=False),
nn.Conv2d(base_channels * 2, base_channels, kernel_size=3, padding=1),
nn.GroupNorm(4, base_channels),
nn.GELU()
)
self.final_head = nn.Sequential(
ResidualBlock(base_channels),
nn.Conv2d(base_channels, out_channels, kernel_size=3, padding=1),
nn.Tanh()
)
def reparameterize(self, mu, logvar):
std = torch.exp(0.5 * logvar)
eps = torch.randn_like(std)
return mu + eps * std
def forward(self, mu, logvar, skips=None):
z = self.reparameterize(mu, logvar)
x = self.latent_proj(z)
if skips is not None:
x = x + skips[1]
x = self.up_stage1(x)
if skips is not None:
x = x + skips[0]
x = self.up_stage2(x)
return self.final_head(x)
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support