File size: 1,229 Bytes
3b47f00
 
823a27c
3b47f00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
823a27c
 
3b47f00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c30430
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import rerun as rr
import rerun.blueprint as rrb
import gradio as gr
from gradio_rerun import Rerun
import time
import cv2


@rr.thread_local_stream("rerun_example_streaming_blur")
def repeated_blur(img):
    stream = rr.binary_stream()

    blueprint = rrb.Blueprint(
        rrb.Horizontal(
            rrb.Spatial2DView(origin="image/original"),
            rrb.Spatial2DView(origin="image/blurred"),
        ),
        collapse_panels=True,
    )

    rr.send_blueprint(blueprint)

    rr.set_time_sequence("iteration", 0)

    rr.log("image/original", rr.Image(img))
    yield stream.read()

    blur = img

    for i in range(100):
        rr.set_time_sequence("iteration", i)

        # Pretend blurring takes a while
        time.sleep(0.1)
        blur = cv2.GaussianBlur(blur, (5, 5), 0)

        rr.log("image/blurred", rr.Image(blur))

        yield stream.read()


with gr.Blocks() as demo:
    with gr.Row():
        img = gr.Image(interactive=True, label="Image")
        with gr.Column():
            blur = gr.Button("Repeated Blur")
    with gr.Row():
        viewer = Rerun(streaming=True)

    blur.click(repeated_blur, inputs=[img], outputs=[viewer])


demo.queue(default_concurrency_limit=10)
demo.launch()