fake_diffusion / app.py
aliabd's picture
aliabd HF staff
Upload with huggingface_hub
de78a61
raw
history blame
855 Bytes
# URL: https://huggingface.co/spaces/gradio/fake_diffusion
# DESCRIPTION: This demo uses a fake model to showcase iterative output. The Image output will update every time a generator is returned until the final image.
# imports
import gradio as gr
import numpy as np
import time
# define core fn, which returns a generator {steps} times before returning the image
def fake_diffusion(steps):
for _ in range(steps):
time.sleep(1)
image = np.random.random((600, 600, 3))
yield image
image = "https://i.picsum.photos/id/867/600/600.jpg?hmac=qE7QFJwLmlE_WKI7zMH6SgH5iY5fx8ec6ZJQBwKRT44"
yield image
# define Interface
demo = gr.Interface(fake_diffusion,
inputs=gr.Slider(1, 10, 3),
outputs="image")
# define queue - required for generators
demo.queue()
# launch
demo.launch()