Views
No views yet
z (latent dim = 100) + label embedding (dim = 10)(1, 28, 28) grayscale image1from huggingface_hub import hf_hub_download
2import torch
3from cgan_model import Generator
4
5model = Generator(latent_dim=100, num_classes=10)
6weights_path = hf_hub_download(repo_id="beatrizfarias/mnist-conditional-gan", filename="mnist_cgan_generator.pth")
7model.load_state_dict(torch.load(weights_path, map_location="cpu"))
8model.eval()
9
10z = torch.randn(1, 100)
11y = torch.tensor([7]) # generate a "7"
12with torch.no_grad():
13 img = model(z, y) # shape: (1, 1, 28, 28)