Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from PIL import Image
|
|
| 9 |
# --------------------------
|
| 10 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 11 |
latent_dim = 100
|
| 12 |
-
model_path = "generator.pth"
|
| 13 |
|
| 14 |
# --------------------------
|
| 15 |
# تعریف Generator
|
|
@@ -43,7 +43,7 @@ G.eval()
|
|
| 43 |
def generate_images(seed=42, num_images=4):
|
| 44 |
torch.manual_seed(seed)
|
| 45 |
z = torch.randn(num_images, latent_dim).to(device)
|
| 46 |
-
imgs = G(z).detach().cpu().numpy()
|
| 47 |
|
| 48 |
pil_images = []
|
| 49 |
for i in range(num_images):
|
|
@@ -62,7 +62,7 @@ iface = gr.Interface(
|
|
| 62 |
gr.Slider(0, 10000, value=42, label="Seed"),
|
| 63 |
gr.Slider(1, 16, value=4, label="Number of Images")
|
| 64 |
],
|
| 65 |
-
outputs=gr.Gallery(label="Generated MNIST Images"
|
| 66 |
title="MNIST GAN Generator",
|
| 67 |
description="یک مدل GAN برای تولید چند تصویر اعداد دستنویس MNIST"
|
| 68 |
)
|
|
|
|
| 9 |
# --------------------------
|
| 10 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 11 |
latent_dim = 100
|
| 12 |
+
model_path = "generator.pth"
|
| 13 |
|
| 14 |
# --------------------------
|
| 15 |
# تعریف Generator
|
|
|
|
| 43 |
def generate_images(seed=42, num_images=4):
|
| 44 |
torch.manual_seed(seed)
|
| 45 |
z = torch.randn(num_images, latent_dim).to(device)
|
| 46 |
+
imgs = G(z).detach().cpu().numpy()
|
| 47 |
|
| 48 |
pil_images = []
|
| 49 |
for i in range(num_images):
|
|
|
|
| 62 |
gr.Slider(0, 10000, value=42, label="Seed"),
|
| 63 |
gr.Slider(1, 16, value=4, label="Number of Images")
|
| 64 |
],
|
| 65 |
+
outputs=gr.Gallery(label="Generated MNIST Images", columns=4, type="pil"),
|
| 66 |
title="MNIST GAN Generator",
|
| 67 |
description="یک مدل GAN برای تولید چند تصویر اعداد دستنویس MNIST"
|
| 68 |
)
|