Spaces:
Sleeping
Sleeping
File size: 1,127 Bytes
71baad5 4c8064d 71baad5 |
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 |
import torch
import PIL.Image
import gradio as gr
import numpy as np
from pipeline import DDIMPipelineCustom
pipeline = DDIMPipelineCustom.from_pretrained("1aurent/ddpm-mnist-conditional")
def predict(steps, seed, value, guidance):
generator = torch.manual_seed(seed)
for i in range(1,steps):
yield pipeline(
generator=generator,
condition=torch.tensor([value]),
guidance=guidance,
num_inference_steps=steps
).images[0]
gr.Interface(
predict,
inputs=[
gr.components.Slider(1, 100, label='Inference Steps', value=20, step=1),
gr.components.Slider(0, 2147483647, label='Seed', value=69420, step=1),
gr.components.Slider(0, 9, label='Value', value=5, step=1),
gr.components.Slider(-2.5, 2.5, label='Guidance Factor', value=1),
],
outputs=gr.Image(shape=[28,28], type="pil", elem_id="output_image"),
css="#output_image img {width: 256px}",
title="Conditional MNIST",
description="A DDIM scheduler and UNet model trained on the MNIST dataset for conditional image generation.",
).queue().launch() |