File size: 1,110 Bytes
08e690f
 
 
 
 
 
 
1d2d3bd
08e690f
 
 
 
 
 
 
 
 
 
dbf9632
 
08e690f
 
 
 
aa65b26
08e690f
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 random
import numpy as np

pipeline = DiffusionPipeline.from_pretrained("SeyedAli/ddpm-butterflies-128")

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]

random_seed = random.randint(0, 2147483647)
gr.Interface(
    predict,
    inputs=[
        gr.Slider(1, 100, label='Inference Steps', default=5, step=1),
        gr.Slider(0, 2147483647, label='Seed', default=random_seed, step=1),
    ],
    outputs=gr.Image(shape=[128,128], type="pil", elem_id="output_image"),
    css="#output_image{width: 256px}",
    title="Unconditional butterflies",
    description="A DDPM scheduler and UNet model trained (from this <a href=\"https://huggingface.co/SeyedAli/ddpm-butterflies-128\">checkpoint</a>) on a subset of the <a href=\"https://huggingface.co/datasets/huggan/smithsonian_butterflies_subset\">Smithsonian Butterflies</a> dataset for unconditional image generation.",
).queue().launch()