Spaces:
Sleeping
Sleeping
Output via rrd file
Browse files
app.py
CHANGED
@@ -1,6 +1,13 @@
|
|
1 |
import rerun as rr
|
|
|
2 |
import numpy as np
|
3 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def show_cube():
|
6 |
rr.init("my data")
|
@@ -12,6 +19,24 @@ def show_cube():
|
|
12 |
colors[:,0] = np.linspace(0,255,10)
|
13 |
|
14 |
rr.log("my_points", rr.Points3D(positions=positions, colors=colors, radii=0.5))
|
15 |
-
return rr.as_html()
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import rerun as rr
|
2 |
+
import rerun.blueprint as rrb
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
5 |
+
import urllib
|
6 |
+
|
7 |
+
|
8 |
+
def html_template(rrd, width=950, height=712, app_url="https://app.rerun.io"):
|
9 |
+
encoded_url = urllib.parse.quote(rrd)
|
10 |
+
return f"""<iframe width="{width}" height="{height}" src="{app_url}?url={encoded_url}" frameborder="0" allowfullscreen=""></iframe>"""
|
11 |
|
12 |
def show_cube():
|
13 |
rr.init("my data")
|
|
|
19 |
colors[:,0] = np.linspace(0,255,10)
|
20 |
|
21 |
rr.log("my_points", rr.Points3D(positions=positions, colors=colors, radii=0.5))
|
|
|
22 |
|
23 |
+
blueprint = rrb.Spatial3DView(origin='my_points')
|
24 |
+
|
25 |
+
rr.save("cube.rrd", default_blueprint=blueprint)
|
26 |
+
|
27 |
+
return "cube.rrd"
|
28 |
+
|
29 |
+
|
30 |
+
with gr.Blocks() as demo:
|
31 |
+
with gr.Row():
|
32 |
+
button = gr.Button("Show Cube")
|
33 |
+
with gr.Row():
|
34 |
+
rrd = gr.File()
|
35 |
+
with gr.Row():
|
36 |
+
viewer = gr.HTML()
|
37 |
+
|
38 |
+
button.click(show_cube, outputs=rrd)
|
39 |
+
rrd.change(html_template, js="""(rrd) => { console.log(rrd.url); return rrd.url}""", inputs=[rrd], outputs=viewer, preprocess=False)
|
40 |
+
|
41 |
+
|
42 |
+
demo.launch()
|