Spaces:
Sleeping
Sleeping
Apply Graio Block to control how much space is allocated to the simulation screen.
Browse files
app.py
CHANGED
|
@@ -8,18 +8,43 @@ def simulate_and_render(seed: int, azimuth: float=35, elevation: float=-20, dist
|
|
| 8 |
gif_path = run_tray_simulation(seed=seed, azimuth=azimuth, elevation=elevation, distance=distance)
|
| 9 |
return gif_path
|
| 10 |
|
| 11 |
-
iface = gr.Interface(
|
| 12 |
-
fn=simulate_and_render,
|
| 13 |
-
inputs=[
|
| 14 |
-
gr.Number(label="Random Seed", value=0),
|
| 15 |
-
gr.Slider(minimum=0, maximum=360, label="Azimuth", value=35),
|
| 16 |
-
gr.Slider(minimum=-90, maximum=90, label="Elevation", value=-20),
|
| 17 |
-
gr.Slider(minimum=0.2, maximum=1.0, label="Zoom (Distance)", value=1.0)
|
| 18 |
-
],
|
| 19 |
-
outputs=gr.Image(type="filepath", label="Simulation"),
|
| 20 |
-
title="TraySim Simulation Viewer",
|
| 21 |
-
description="Simulates object drop on a tray using MuJoCo and shows the result as a GIF."
|
| 22 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
iface.launch()
|
|
|
|
| 8 |
gif_path = run_tray_simulation(seed=seed, azimuth=azimuth, elevation=elevation, distance=distance)
|
| 9 |
return gif_path
|
| 10 |
|
| 11 |
+
#iface = gr.Interface(
|
| 12 |
+
# fn=simulate_and_render,
|
| 13 |
+
# inputs=[
|
| 14 |
+
# gr.Number(label="Random Seed", value=0),
|
| 15 |
+
# gr.Slider(minimum=0, maximum=360, label="Azimuth", value=35),
|
| 16 |
+
# gr.Slider(minimum=-90, maximum=90, label="Elevation", value=-20),
|
| 17 |
+
# gr.Slider(minimum=0.2, maximum=1.0, label="Zoom (Distance)", value=1.0)
|
| 18 |
+
# ],
|
| 19 |
+
# outputs=gr.Image(type="filepath", label="Simulation"),
|
| 20 |
+
# title="TraySim Simulation Viewer",
|
| 21 |
+
# description="Simulates object drop on a tray using MuJoCo and shows the result as a GIF."
|
| 22 |
+
#)
|
| 23 |
+
|
| 24 |
+
# Define the custom layout using Blocks
|
| 25 |
+
with gr.Blocks() as iface:
|
| 26 |
+
gr.Markdown("# TraySim Simulation Viewer")
|
| 27 |
+
gr.Markdown("Simulates object drop on a tray using MuJoCo and shows the result as a GIF.")
|
| 28 |
+
|
| 29 |
+
with gr.Row():
|
| 30 |
+
# Input column (30% width)
|
| 31 |
+
with gr.Column(scale=3): # scale=3 for 30% width
|
| 32 |
+
seed_input = gr.Number(label="Random Seed", value=0)
|
| 33 |
+
azimuth_input = gr.Slider(minimum=0, maximum=360, label="Azimuth", value=35)
|
| 34 |
+
elevation_input = gr.Slider(minimum=-90, maximum=90, label="Elevation", value=-20)
|
| 35 |
+
distance_input = gr.Slider(minimum=0.2, maximum=1.0, label="Zoom (Distance)", value=1.0)
|
| 36 |
+
submit_button = gr.Button("Run Simulation")
|
| 37 |
+
|
| 38 |
+
# Output column (70% width)
|
| 39 |
+
with gr.Column(scale=7): # scale=7 for 70% width
|
| 40 |
+
output_image = gr.Image(type="filepath", label="Simulation")
|
| 41 |
+
|
| 42 |
+
# Connect the button to the simulation function
|
| 43 |
+
submit_button.click(
|
| 44 |
+
fn=simulate_and_render,
|
| 45 |
+
inputs=[seed_input, azimuth_input, elevation_input, distance_input],
|
| 46 |
+
outputs=output_image
|
| 47 |
+
)
|
| 48 |
|
| 49 |
if __name__ == "__main__":
|
| 50 |
iface.launch()
|