Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,14 +13,11 @@ model = VariationalAutoEncoder(INPUT_DIM, H_DIM, Z_DIM)
|
|
13 |
model.load_state_dict(torch.load("MnistVAEmodel.pt"))
|
14 |
model.eval()
|
15 |
def predict(img):
|
16 |
-
img = img.convert('1')
|
17 |
img = transforms.ToTensor()(img)
|
18 |
-
img = transforms.CenterCrop(size=28)(img)
|
19 |
-
print(type(img), img.shape)
|
20 |
mu, sigma = model.encode(img.view(1, INPUT_DIM))
|
21 |
|
22 |
res = []
|
23 |
-
for example in range(
|
24 |
epsilon = torch.randn_like(sigma)
|
25 |
z = mu + sigma * epsilon
|
26 |
out = model.decode(z)
|
@@ -30,6 +27,6 @@ def predict(img):
|
|
30 |
|
31 |
title = "Variational-Autoencoder-on-MNIST "
|
32 |
description = "TO DO"
|
33 |
-
examples = ["
|
34 |
-
gr.Interface(fn=predict, inputs = gr.inputs.Image(), outputs= gr.Gallery(),
|
35 |
examples=examples, title=title, description=description).launch(inline=False)
|
|
|
13 |
model.load_state_dict(torch.load("MnistVAEmodel.pt"))
|
14 |
model.eval()
|
15 |
def predict(img):
|
|
|
16 |
img = transforms.ToTensor()(img)
|
|
|
|
|
17 |
mu, sigma = model.encode(img.view(1, INPUT_DIM))
|
18 |
|
19 |
res = []
|
20 |
+
for example in range(5):
|
21 |
epsilon = torch.randn_like(sigma)
|
22 |
z = mu + sigma * epsilon
|
23 |
out = model.decode(z)
|
|
|
27 |
|
28 |
title = "Variational-Autoencoder-on-MNIST "
|
29 |
description = "TO DO"
|
30 |
+
examples = ["original_8.png"]
|
31 |
+
gr.Interface(fn=predict, inputs = gr.inputs.Image(shape=(28,28), image_mode="L"), outputs= gr.Gallery(),
|
32 |
examples=examples, title=title, description=description).launch(inline=False)
|