File size: 758 Bytes
fa6cad4
 
 
 
 
 
 
 
 
 
 
b9d10b4
fa6cad4
 
88620c4
 
 
 
 
 
 
fa6cad4
88620c4
 
fa6cad4
 
 
 
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
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://gradio-builds.s3.amazonaws.com/diffusion_image/cute_dog.jpg" 
    yield image

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            slider = gr.Slider(minimum=1, maximum=10, value=3, step=1)
            submit = gr.Button(value="Submit")
        with gr.Column():
            image = gr.Image()

    submit.click(fake_diffusion, slider, image)
            
# define queue - required for generators
demo.queue()

demo.launch()