MCPcopy Create free account
hub / github.com/ChartGalaxy/ChartGalaxy / normalize_bbox

Function normalize_bbox

code_generation_benchmark/utils/utils_eval.py:57–74  ·  view source on GitHub ↗
(bbox, ref)

Source from the content-addressed store, hash-verified

55 return y
56
57def normalize_bbox(bbox, ref):
58 xx, yy, ww, hh = ref['x'], ref['y'], ref['width'], ref['height']
59 if isinstance(bbox, dict):
60 x_min, y_min, x_max, y_max = bbox['x'], bbox['y'], bbox['x'] + bbox['width'], bbox['y'] + bbox['height']
61 else:
62 # assert False, 'Do not support this bbox format'
63 x_min, y_min, x_max, y_max = bbox
64 x_min = (x_min - xx) / ww
65 y_min = (y_min - yy) / hh
66 x_max = (x_max - xx) / ww
67 y_max = (y_max - yy) / hh
68
69 x_min = min(1, max(0, x_min))
70 y_min = min(1, max(0, y_min))
71 x_max = min(1, max(x_min, x_max))
72 y_max = min(1, max(y_min, y_max))
73
74 return [x_min, y_min, x_max, y_max]
75
76def find_ele_in_tree(tree, ele_list, find_all=False, tag_name=None, class_name=None, id_name=None):
77 if not find_all and ele_list:

Callers 2

normalize_tree_leafsFunction · 0.85
normalize_leafsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected