Skip to content

Commit 7d988a8

Browse files
hack to fix bbox issue
1 parent dbc332f commit 7d988a8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/agentlab/agents/agent_utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,17 @@ def overlay_action(obs, action):
139139
"""Overlays actions on screenshot in-place"""
140140
act_img = copy.deepcopy(obs["screenshot"])
141141
act_img = Image.fromarray(act_img)
142-
overlay_utils.annotate_action(act_img, action, properties=obs["extra_element_properties"])
142+
143+
new_obs_properties = copy.deepcopy(obs["extra_element_properties"])
144+
import os
145+
if os.getenv("AGENTLAB_USE_RETINA"):
146+
# HACK: divide everything by 2 in the obs
147+
# TODO: make this more robust by changing login in annotate_action directly (or maybe in the obs section?)
148+
for key, value in new_obs_properties.items():
149+
try:
150+
new_obs_properties[key]["bbox"] = [elem / 2 for elem in value["bbox"]]
151+
except:
152+
pass
153+
154+
overlay_utils.annotate_action(act_img, action, properties=new_obs_properties)
143155
return img_to_base_64(act_img)

0 commit comments

Comments
 (0)