将像素坐标转为相对坐标(0-1000范围)
(ori_bbox, image_path)
| 63 | return rel_x, rel_y |
| 64 | |
| 65 | def 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 |
| 77 | def contain_chinese(prompts): |
| 78 | return True if any('\u4e00' <= c <= '\u9fff' for c in prompts) else False |
| 79 | def normalized_edit_distance(s1, s2): |