<jupyter_start><jupyter_text>Load necessary libraries<jupyter_code>import torch
import matplotlib.pyplot as plt
%matplotlib inline

from models import AutoEncoder, VAE
from dataset import FontsLoader
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('Device:', device)<jupyter_output>Device: cuda<jupyter_text>Load example data<jupyter_code>dataset = FontsLoader._get_set()<jupyter_output><empty_output><jupyter_text>Load Model<jupyter_code>net = AutoEncoder(
    latent_dim=512,
    in_channels=1,
    num_hiddens=256,
    num_res_hiddens=64,
    num_res_layers=4,
    out_channels=1,
).to(device)

net.load_state_dict(
    torch.load(open('./checkpoints/ae-512-224x224-loss-0.024.pth', 'rb'), map_location=device)
)
net.eval()
index = 100
image = dataset[index]['image'].unsqueeze(0).to(device)
z, recon = net(image)
plt.imshow(dataset[index]['image'].squeeze(), cmap='gray');
plt.imshow(recon[0].squeeze().cpu().detach().numpy(), cmap='gray');
net.loss_function(image, recon).item()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup