File size: 643 Bytes
6c5e3e3
f24146d
0775485
f24146d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0775485
6c5e3e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
import torch
import gradio as gr
from vae import *
import matplotlib.image as mpimg


with open("vae.pt", "rb") as file:
    vae = torch.load(file)
    vae.eval()


def generate_image(filename):
    image = mpimg.imread(filename)[:, :, 0] / 255

    grayscale = vae(torch.Tensor(image))[0].reshape((28, 28))

    return grayscale.detach().numpy()


examples = [f"examples/{i}.jpg" for i in range(10)]

demo = gr.Interface(generate_image, 
    gr.Image(type="filepath"),
    "image",
    examples,
    title="VAE running on Fashion MNIST",
    description=".",
    article="...",
    allow_flagging=False,
)



demo.launch()