File size: 1,450 Bytes
3167cfe
 
ffbf761
 
247f6df
 
ffbf761
cc5f32c
 
 
 
a90126e
cc5f32c
247f6df
 
ffbf761
 
 
 
 
 
247f6df
ffbf761
 
 
 
247f6df
ffbf761
 
 
cc5f32c
 
247f6df
 
ffbf761
 
3167cfe
ffbf761
 
 
 
3167cfe
 
ffbf761
 
 
 
 
247f6df
ffbf761
247f6df
3167cfe
247f6df
ffbf761
247f6df
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
56
import gradio as gr
from gradio_rerun import Rerun
from data.loader import load_simulation_data
from visualization.visualizer import visualize_simulation


def update_simulation_dropdown(file):
    simulations, descriptions = load_simulation_data(file)
    return gr.Dropdown(
        choices=descriptions if descriptions else [],
        value=None,
        allow_custom_value=False
    )


def create_app():
    with gr.Blocks() as demo:
        gr.Markdown("""
        # Camera Simulation Visualizer
        Upload a JSON file containing camera simulation data and select a simulation to visualize.
        """)

        with gr.Row():
            file_input = gr.File(
                label="Upload Simulation JSON",
                file_types=[".json"]
            )
            simulation_dropdown = gr.Dropdown(
                label="Select Simulation",
                choices=[],
                type="index",
                scale=2
            )

        with gr.Row():
            viewer = Rerun(streaming=False)

        file_input.change(
            update_simulation_dropdown,
            inputs=[file_input],
            outputs=[simulation_dropdown]
        )

        simulation_dropdown.change(
            visualize_simulation,
            inputs=[file_input, simulation_dropdown],
            outputs=[viewer]
        )

    return demo


if __name__ == "__main__":
    demo = create_app()
    demo.queue().launch(share=False)