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

Function _resize_annotation_bounding_boxes

eval/utils/evaluator.py:30–51  ·  view source on GitHub ↗

Uniformly enlarge bbox(es) by the given factors.

(
    annotation_position: Union[List[float], List[List[float]]],
    width_factor: float = 1.2,
    height_factor: float = 1.2,
)

Source from the content-addressed store, hash-verified

28
29
30def _resize_annotation_bounding_boxes(
31 annotation_position: Union[List[float], List[List[float]]],
32 width_factor: float = 1.2,
33 height_factor: float = 1.2,
34):
35 """Uniformly enlarge bbox(es) by the given factors."""
36
37 def _resize(box: List[float]):
38 y, x, h, w = box
39 h_delta = (height_factor - 1) * h
40 w_delta = (width_factor - 1) * w
41 y = max(0, y - h_delta / 2)
42 x = max(0, x - w_delta / 2)
43 h = min(1, h + h_delta)
44 w = min(1, w + w_delta)
45 return [y, x, h, w]
46
47 if not annotation_position:
48 return []
49 if isinstance(annotation_position[0], list):
50 return [_resize(b) for b in annotation_position]
51 return _resize(annotation_position)
52
53
54def is_tap_action(normalized_start_yx, normalized_end_yx):

Callers 1

__call__Method · 0.70

Calls 1

_resizeFunction · 0.85

Tested by

no test coverage detected