Spaces:
Sleeping
Sleeping
Anonymous
commited on
Commit
·
96b30d4
1
Parent(s):
ea3417c
init
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
import sys
|
|
|
|
| 4 |
import os
|
| 5 |
import argparse
|
| 6 |
import random
|
|
@@ -517,6 +518,28 @@ def demo_update_w(mode):
|
|
| 517 |
w_positions.append(gr.Slider())
|
| 518 |
return w_positions
|
| 519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
with gr.Blocks(css=css) as demo:
|
| 521 |
with gr.Column(elem_id="col-container"):
|
| 522 |
gr.Markdown(
|
|
@@ -608,6 +631,22 @@ with gr.Blocks(css=css) as demo:
|
|
| 608 |
dropdown_demo.change(demo_update_w, dropdown_demo, w_positions)
|
| 609 |
radio_mode.change(mode_update, radio_mode, [row_demo, row_diy])
|
| 610 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 611 |
|
| 612 |
with gr.Row():
|
| 613 |
with gr.Accordion('Useful FreeTraj Parameters (feel free to adjust these parameters based on your prompt): ', open=True):
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
import sys
|
| 4 |
+
import pandas as pd
|
| 5 |
import os
|
| 6 |
import argparse
|
| 7 |
import random
|
|
|
|
| 518 |
w_positions.append(gr.Slider())
|
| 519 |
return w_positions
|
| 520 |
|
| 521 |
+
def plot_update(*positions):
|
| 522 |
+
key_length = int(positions[-1])
|
| 523 |
+
frame_indices = positions[:key_length]
|
| 524 |
+
h_positions = positions[MAX_KEYS:MAX_KEYS+key_length]
|
| 525 |
+
h_positions_re = []
|
| 526 |
+
for i in h_positions:
|
| 527 |
+
h_positions_re.append(-i)
|
| 528 |
+
w_positions = positions[2*MAX_KEYS:2*MAX_KEYS+key_length]
|
| 529 |
+
traj_plot = gr.ScatterPlot(
|
| 530 |
+
value=pd.DataFrame({"x": w_positions, "y": h_positions_re, "frame": frame_indices}),
|
| 531 |
+
x="x",
|
| 532 |
+
y="y",
|
| 533 |
+
color='frame',
|
| 534 |
+
x_lim= [-0.05, 1.05],
|
| 535 |
+
y_lim= [-1.05, 0.05],
|
| 536 |
+
label="Trajectory",
|
| 537 |
+
width=512,
|
| 538 |
+
height=320,
|
| 539 |
+
)
|
| 540 |
+
return traj_plot
|
| 541 |
+
|
| 542 |
+
|
| 543 |
with gr.Blocks(css=css) as demo:
|
| 544 |
with gr.Column(elem_id="col-container"):
|
| 545 |
gr.Markdown(
|
|
|
|
| 631 |
dropdown_demo.change(demo_update_w, dropdown_demo, w_positions)
|
| 632 |
radio_mode.change(mode_update, radio_mode, [row_demo, row_diy])
|
| 633 |
|
| 634 |
+
traj_plot = gr.ScatterPlot(
|
| 635 |
+
label="Trajectory",
|
| 636 |
+
width=512,
|
| 637 |
+
height=320,
|
| 638 |
+
)
|
| 639 |
+
|
| 640 |
+
h_positions[0].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 641 |
+
h_positions[1].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 642 |
+
h_positions[2].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 643 |
+
h_positions[3].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 644 |
+
h_positions[4].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 645 |
+
w_positions[0].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 646 |
+
w_positions[1].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 647 |
+
w_positions[2].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 648 |
+
w_positions[3].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 649 |
+
w_positions[4].change(plot_update, frame_indices + h_positions + w_positions + [dropdown_diy], traj_plot)
|
| 650 |
|
| 651 |
with gr.Row():
|
| 652 |
with gr.Accordion('Useful FreeTraj Parameters (feel free to adjust these parameters based on your prompt): ', open=True):
|