Skip to content

Commit 7cd2406

Browse files
authored
Merge pull request #95 from DaWe35/grounding_model_resize_height
Add grounding model height option
2 parents 64f19ca + 00727e1 commit 7cd2406

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

gui_agents/s2/cli_app.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ def main():
185185
default=1366,
186186
help="Width of screenshot image after processor rescaling",
187187
)
188+
parser.add_argument(
189+
"--grounding_model_resize_height",
190+
type=int,
191+
default=None,
192+
help="Height of screenshot image after processor rescaling",
193+
)
188194

189195
# Grounding model config option 2: Self-hosted endpoint based
190196
parser.add_argument(
@@ -240,13 +246,16 @@ def main():
240246
"api_key": args.endpoint_api_key,
241247
}
242248
else:
249+
grounding_height = args.grounding_model_resize_height
250+
# If not provided, use the aspect ratio of the screen to compute the height
251+
if grounding_height is None:
252+
grounding_height = screen_height * args.grounding_model_resize_width / screen_width
253+
243254
engine_params_for_grounding = {
244255
"engine_type": args.grounding_model_provider,
245256
"model": args.grounding_model,
246257
"grounding_width": args.grounding_model_resize_width,
247-
"grounding_height": screen_height
248-
* args.grounding_model_resize_width
249-
/ screen_width,
258+
"grounding_height": grounding_height,
250259
}
251260

252261
grounding_agent = OSWorldACI(

osworld_setup/s2/run.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ def config() -> argparse.Namespace:
133133
default=1366,
134134
help="Width of screenshot image after processor rescaling",
135135
)
136+
parser.add_argument(
137+
"--grounding_model_resize_height",
138+
type=int,
139+
default=None,
140+
help="Height of screenshot image after processor rescaling",
141+
)
136142

137143
# Configuration 2
138144
parser.add_argument("--endpoint_provider", type=str, default="")
@@ -190,13 +196,16 @@ def test(args: argparse.Namespace, test_all_meta: dict) -> None:
190196
"api_key": args.endpoint_api_key,
191197
}
192198
else:
199+
grounding_height = args.grounding_model_resize_height
200+
# If not provided, use the aspect ratio of the screen to compute the height
201+
if grounding_height is None:
202+
grounding_height = args.screen_height * args.grounding_model_resize_width / args.screen_width
203+
193204
engine_params_for_grounding = {
194205
"engine_type": args.grounding_model_provider,
195206
"model": args.grounding_model,
196207
"grounding_width": args.grounding_model_resize_width,
197-
"grounding_height": args.screen_height
198-
* args.grounding_model_resize_width
199-
/ args.screen_width,
208+
"grounding_height": grounding_height,
200209
}
201210

202211
# NEW!

0 commit comments

Comments
 (0)