File size: 1,791 Bytes
bdf752e |
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 57 58 59 60 61 62 63 64 65 66 67 68 |
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
)
frame_input = gr.Textbox(
label="Frame Selection",
placeholder="E.g. 1-30, 35, 40-50 (leave empty for all frames)"
)
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, frame_input],
outputs=[viewer]
)
frame_input.change(
visualize_simulation,
inputs=[file_input, simulation_dropdown, frame_input],
outputs=[viewer]
)
return demo
if __name__ == "__main__":
demo = create_app()
demo.queue().launch(share=False)
|