Spaces:
Build error
Build error
Commit
·
9bf5ef6
1
Parent(s):
25a1345
more
Browse files
app.py
CHANGED
|
@@ -62,10 +62,10 @@ r_coverage = 10
|
|
| 62 |
# ---------------------------- #
|
| 63 |
def create_standing_animation():
|
| 64 |
path = [(agent_pos.x, agent_pos.y)]
|
| 65 |
-
return create_animation(path,
|
| 66 |
|
| 67 |
|
| 68 |
-
def create_animation(path,
|
| 69 |
# path = [(i,i) for i in range(90)]
|
| 70 |
# targets_x = [20, 80, 80, 20]
|
| 71 |
# targets_y = [20, 20, 80, 80]
|
|
@@ -76,9 +76,14 @@ def create_animation(path, targets_x, targets_y, r_coverage):
|
|
| 76 |
ln1, = plt.plot([path[0][0]], [path[0][1]], marker='o', color='b', alpha=0.5, linewidth=5, markersize=15)
|
| 77 |
|
| 78 |
# targets
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
ln2, = plt.plot(targets_x, targets_y, marker='X', color='orange', alpha=0.5, linestyle='none', markersize=15)
|
| 80 |
-
for t_x, t_y in
|
| 81 |
circle = Circle((t_x, t_y), r_coverage, color='orange', fill=True, alpha=0.3)
|
|
|
|
| 82 |
ax.add_patch(circle)
|
| 83 |
# plt.tight_layout()
|
| 84 |
|
|
@@ -130,7 +135,7 @@ def move_agent(target_input: int):
|
|
| 130 |
agent_pos.x = path[-1][0]
|
| 131 |
agent_pos.y = path[-1][1]
|
| 132 |
# create animation
|
| 133 |
-
video_output = create_animation(path,
|
| 134 |
|
| 135 |
# update status
|
| 136 |
status = f'Went to target {target_input}.'
|
|
@@ -167,8 +172,8 @@ def get_target_from_request(request_text):
|
|
| 167 |
def create_demo():
|
| 168 |
# main blocks
|
| 169 |
with gr.Blocks() as demo:
|
| 170 |
-
gr.Markdown("
|
| 171 |
-
gr.Markdown('
|
| 172 |
|
| 173 |
with gr.Row():
|
| 174 |
with gr.Column():
|
|
@@ -179,6 +184,13 @@ def create_demo():
|
|
| 179 |
status = gr.Textbox(label='Plan status:', lines=2)
|
| 180 |
with gr.Column():
|
| 181 |
output_env = gr.Video(label="Env:", autoplay=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
# EVENTS:
|
| 184 |
# gr.on(triggers=["load"], fn=load_image_on_start, outputs=output_env_image)
|
|
|
|
| 62 |
# ---------------------------- #
|
| 63 |
def create_standing_animation():
|
| 64 |
path = [(agent_pos.x, agent_pos.y)]
|
| 65 |
+
return create_animation(path, r_coverage)
|
| 66 |
|
| 67 |
|
| 68 |
+
def create_animation(path, r_coverage):
|
| 69 |
# path = [(i,i) for i in range(90)]
|
| 70 |
# targets_x = [20, 80, 80, 20]
|
| 71 |
# targets_y = [20, 20, 80, 80]
|
|
|
|
| 76 |
ln1, = plt.plot([path[0][0]], [path[0][1]], marker='o', color='b', alpha=0.5, linewidth=5, markersize=15)
|
| 77 |
|
| 78 |
# targets
|
| 79 |
+
targets_x, targets_y = [], []
|
| 80 |
+
for k, v in goal_dict.items():
|
| 81 |
+
targets_x.append(v[0])
|
| 82 |
+
targets_y.append(v[1])
|
| 83 |
ln2, = plt.plot(targets_x, targets_y, marker='X', color='orange', alpha=0.5, linestyle='none', markersize=15)
|
| 84 |
+
for t_name, (t_x, t_y) in goal_dict.items():
|
| 85 |
circle = Circle((t_x, t_y), r_coverage, color='orange', fill=True, alpha=0.3)
|
| 86 |
+
plt.text(t_x, t_y, f"{t_name}", fontsize=20, color='k')
|
| 87 |
ax.add_patch(circle)
|
| 88 |
# plt.tight_layout()
|
| 89 |
|
|
|
|
| 135 |
agent_pos.x = path[-1][0]
|
| 136 |
agent_pos.y = path[-1][1]
|
| 137 |
# create animation
|
| 138 |
+
video_output = create_animation(path, r_coverage)
|
| 139 |
|
| 140 |
# update status
|
| 141 |
status = f'Went to target {target_input}.'
|
|
|
|
| 172 |
def create_demo():
|
| 173 |
# main blocks
|
| 174 |
with gr.Blocks() as demo:
|
| 175 |
+
gr.Markdown("# Agent Control with Language")
|
| 176 |
+
gr.Markdown('Say the agent where to go and what to do')
|
| 177 |
|
| 178 |
with gr.Row():
|
| 179 |
with gr.Column():
|
|
|
|
| 184 |
status = gr.Textbox(label='Plan status:', lines=2)
|
| 185 |
with gr.Column():
|
| 186 |
output_env = gr.Video(label="Env:", autoplay=True)
|
| 187 |
+
with gr.Accordion("TODO List", open=False):
|
| 188 |
+
gr.Markdown("""
|
| 189 |
+
## Thing to improve
|
| 190 |
+
- insert a model that understands the desired goal and not to use a simple function for it that can produce false goals
|
| 191 |
+
- to incorporate a longer chain of goals; for example, go there and pick the package, then come back
|
| 192 |
+
- to introduce additional learnt capabilities
|
| 193 |
+
""")
|
| 194 |
|
| 195 |
# EVENTS:
|
| 196 |
# gr.on(triggers=["load"], fn=load_image_on_start, outputs=output_env_image)
|