Spaces:
Running
Running
Update pages/23_GANs.py
Browse files- pages/23_GANs.py +5 -4
pages/23_GANs.py
CHANGED
|
@@ -106,11 +106,12 @@ if train_gan:
|
|
| 106 |
|
| 107 |
# Generate and display images
|
| 108 |
z = torch.randn(16, latent_dim)
|
| 109 |
-
generated_imgs = generator(z).view(-1, 1, 28, 28).
|
| 110 |
-
grid = np.transpose(np.array([generated_imgs[i].numpy() for i in range(16)]), (1, 2, 0))
|
| 111 |
|
| 112 |
-
fig,
|
| 113 |
-
ax
|
|
|
|
|
|
|
| 114 |
st.pyplot(fig)
|
| 115 |
else:
|
| 116 |
st.write("Use the slider to select the number of epochs and click the button to start training the GAN")
|
|
|
|
| 106 |
|
| 107 |
# Generate and display images
|
| 108 |
z = torch.randn(16, latent_dim)
|
| 109 |
+
generated_imgs = generator(z).view(-1, 1, 28, 28).detach().cpu().numpy()
|
|
|
|
| 110 |
|
| 111 |
+
fig, axes = plt.subplots(4, 4, figsize=(8, 8))
|
| 112 |
+
for img, ax in zip(generated_imgs, axes.flatten()):
|
| 113 |
+
ax.imshow(img.reshape(28, 28), cmap="gray")
|
| 114 |
+
ax.axis('off')
|
| 115 |
st.pyplot(fig)
|
| 116 |
else:
|
| 117 |
st.write("Use the slider to select the number of epochs and click the button to start training the GAN")
|