Views
No views yet
| Feature | Value |
|---|---|
| Layers | 10 (5 Encoder, 5 Decoder) |
| Target Size | 1600x720 |
| Latent Space | 8x45x100 |
| Format | PyTorch (model.pt) |
| Test Case | Input Resolution | Aspect Ratio | Original Accuracy | Low-Noise Acc | High-Noise Acc | Primary Challenge |
|---|---|---|---|---|---|---|
| IRL Faces (Forest) | ~4k×3k (HQ) | 4:3 | 94.45% | 94.44% | 94.07% | Complex gradients & textures |
| AI Generated Art | 128×128 (LQ) | 1:1 | 96.68% | 96.61% | 95.85% | Upscaling/Interpolation noise |
| Digital Doodle | 720×720 (MD) | 1:1 | 95.91% | 95.90% | 95.71% | Sharp high-contrast edges |
1import torch
2import torch.nn as nn
3import numpy as np
4import requests
5from PIL import Image
6from torchvision import transforms
7import matplotlib.pyplot as plt
8
9class HeavyAE(nn.Module):
10 def __init__(self):
11 super(HeavyAE, self).__init__()
12 self.encoder = nn.Sequential(
13 nn.Conv2d(3, 128, 3, stride=2, padding=1), nn.LeakyReLU(0.2),
14 nn.Conv2d(128, 256, 3, stride=2, padding=1), nn.LeakyReLU(0.2),
15 nn.Conv2d(256, 512, 3, stride=2, padding=1), nn.LeakyReLU(0.2),
16 nn.Conv2d(512, 1024, 3, stride=2, padding=1), nn.LeakyReLU(0.2),
17 nn.Conv2d(1024, 8, 3, stride=1, padding=1)
18 )
19 self.decoder = nn.Sequential(
20 nn.ConvTranspose2d(8, 1024, 3, stride=2, padding=1, output_padding=1), nn.LeakyReLU(0.2),
21 nn.ConvTranspose2d(1024, 512, 3, stride=2, padding=1, output_padding=1), nn.LeakyReLU(0.2),
22 nn.ConvTranspose2d(512, 256, 3, stride=2, padding=1, output_padding=1), nn.LeakyReLU(0.2),
23 nn.ConvTranspose2d(256, 128, 3, stride=2, padding=1, output_padding=1), nn.LeakyReLU(0.2),
24 nn.ConvTranspose2d(128, 3, 3, stride=1, padding=1), nn.Sigmoid()
25 )
26 def forward(self, x): return self.decoder(self.encoder(x))
27
28# Setup
29device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
30model = HeavyAE().to(device)
31model_url = "https://huggingface.co/Parallax-labs-1/parallax_VISION-ValidPhone/resolve/main/model.pt"
32
33# Download weights
34response = requests.get(model_url)
35with open("model.pt", "wb") as f:
36 f.write(response.content)
37
38model.load_state_dict(torch.load("model.pt", map_location=device))
39model.eval()
40
41def test_model(img_path):
42 orig = Image.open(img_path).convert('RGB')
43 w, h = orig.size
44
45 preprocess = transforms.Compose([transforms.Resize((720, 1600)), transforms.ToTensor()])
46 input_t = preprocess(orig).unsqueeze(0).to(device)
47
48 with torch.no_grad():
49 recon = model(input_t)
50 # Stress Tests
51 noise_l = model(input_t + torch.randn_like(input_t) * 0.05)
52 noise_h = model(input_t + torch.randn_like(input_t) * 0.2)
53
54 # Metrics
55 def acc(a, b): return (1 - torch.mean(torch.abs(a - b)).item()) * 100
56 print(f"--- Log ---\nOriginal Accuracy: {acc(input_t, recon):.2f}%")
57 print(f"Low-Noise Accuracy: {acc(input_t, noise_l):.2f}%")
58 print(f"High-Noise Accuracy: {acc(input_t, noise_h):.2f}%")
59
60 # Output Images
61 res = transforms.ToPILImage()(recon.squeeze().cpu()).resize((w, h))
62 diff = np.abs(np.array(orig).astype(float) - np.array(res).astype(float)).astype(np.uint8)
63
64 fig, ax = plt.subplots(1, 3, figsize=(18, 6))
65 ax[0].imshow(orig); ax[0].set_title("Input")
66 ax[1].imshow(res); ax[1].set_title("Reconstruction")
67 ax[2].imshow(diff); ax[2].set_title("Error Map")
68 for a in ax: a.axis('off')
69 plt.show()