rerun-viewer / app.py
abreza's picture
refactor and organize files
ffbf761
raw
history blame
1.36 kB
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):
_, descriptions = load_simulation_data(file)
return gr.Dropdown(choices=descriptions if descriptions else [], value=None)
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"
)
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)