MCPcopy Create free account
hub / github.com/OpenBMB/AgentCPM-GUI / _check_tap_actions_match

Function _check_tap_actions_match

eval/utils/action_utils.py:183–211  ·  view source on GitHub ↗

Determines if two tap actions are the same.

(
    tap_1_yx,
    tap_2_yx,
    annotation_positions,
    matching_tap_distance_threshold_screen_percentage,
    annotation_width_augment_fraction,
    annotation_height_augment_fraction,
)

Source from the content-addressed store, hash-verified

181
182
183def _check_tap_actions_match(
184 tap_1_yx,
185 tap_2_yx,
186 annotation_positions,
187 matching_tap_distance_threshold_screen_percentage,
188 annotation_width_augment_fraction,
189 annotation_height_augment_fraction,
190):
191 """Determines if two tap actions are the same."""
192 resized_annotation_positions = _resize_annotation_bounding_boxes(
193 annotation_positions,
194 annotation_width_augment_fraction,
195 annotation_height_augment_fraction,
196 )
197
198 # Check if the ground truth tap action falls in an annotation's bounding box.
199 tap1_in_box = _yx_in_bounding_boxes(tap_1_yx, resized_annotation_positions)
200 tap2_in_box = _yx_in_bounding_boxes(tap_2_yx, resized_annotation_positions)
201 both_in_box = jnp.max(tap1_in_box & tap2_in_box)
202
203 # If the ground-truth tap action falls outside any of the annotation
204 # bounding boxes or one of the actions is inside a bounding box and the other
205 # is outside bounding box or vice versa, compare the points using Euclidean
206 # distance.
207 within_threshold = (
208 jnp.linalg.norm(jnp.array(tap_1_yx) - jnp.array(tap_2_yx))
209 <= matching_tap_distance_threshold_screen_percentage
210 )
211 return jnp.logical_or(both_in_box, within_threshold)
212
213
214def _check_drag_actions_match(

Callers 1

check_actions_matchFunction · 0.85

Calls 2

_yx_in_bounding_boxesFunction · 0.85

Tested by

no test coverage detected