File size: 928 Bytes
5f91254
b260fbd
 
 
 
 
bb3e0ce
0510130
 
b260fbd
 
 
 
532834a
b260fbd
 
 
 
252d810
 
b260fbd
6bc78c1
b260fbd
3342753
2e349c0
b260fbd
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
from diffusers import DiffusionPipeline
import torch
import PIL.Image
import gradio as gr
import numpy as np

pipeline = DiffusionPipeline.from_pretrained("1aurent/ddpm-mnist")
device = "cuda" if torch.cuda.is_available() else "cpu"
pipeline = pipeline.to(device=device)

def predict(steps, seed):
    generator = torch.manual_seed(seed)
    for i in range(1,steps):
        yield pipeline(generator=generator, num_inference_steps=i).images[0]

gr.Interface(
    predict,
    inputs=[
        gr.inputs.Slider(1, 100, label='Inference Steps', default=12, step=1),
        gr.inputs.Slider(0, 2147483647, label='Seed', default=69420, step=1),
    ],
    outputs=gr.Image(shape=[28,28], type="pil", elem_id="output_image"),
    css="#output_image{width: 256px}",
    title="Unconditional MNIST",
    description="A DDIM scheduler and UNet model trained on the MNIST dataset for unconditional image generation.",
).queue().launch()