MCPcopy Create free account
hub / github.com/CIawevy/TextPecker / process_box_input

Function process_box_input

eval/TextPecker_eval/parse_utils_pecker.py:65–76  ·  view source on GitHub ↗

将像素坐标转为相对坐标(0-1000范围)

(ori_bbox, image_path)

Source from the content-addressed store, hash-verified

63 return rel_x, rel_y
64
65def process_box_input(ori_bbox, image_path):
66 """将像素坐标转为相对坐标(0-1000范围)"""
67 xmin_px, ymin_px, xmax_px, ymax_px = ori_bbox
68
69 with Image.open(image_path) as img:
70 W, H = img.size # W=图像宽度,H=图像高度
71
72 xmin_rel, ymin_rel = px_to_rel((xmin_px, ymin_px), W, H)
73 xmax_rel, ymax_rel = px_to_rel((xmax_px, ymax_px), W, H)
74 normalized_bbox = f"bbox_2d:[{xmin_rel}, {ymin_rel}, {xmax_rel}, {ymax_rel}]"
75
76 return normalized_bbox
77def contain_chinese(prompts):
78 return True if any('\u4e00' <= c <= '\u9fff' for c in prompts) else False
79def normalized_edit_distance(s1, s2):

Callers 1

mainFunction · 0.90

Calls 1

px_to_relFunction · 0.70

Tested by

no test coverage detected