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

Function verify

eval/grounding_eval/code/UI-TARS/fun2bbox_eval_uitars.py:84–113  ·  view source on GitHub ↗

接受模型的字符串输入,判断是否正确

(response, ground_truth, w, h)

Source from the content-addressed store, hash-verified

82 return response.strip("\n").replace(" ","")
83
84async def verify(response, ground_truth, w, h):
85 """
86 接受模型的字符串输入,判断是否正确
87 """
88 pattern = r'(\d+,\d+)'
89 matches = re.findall(pattern, response)
90 # 将输入字符串转换为整数列表
91 if matches:
92 match = matches[0]
93 try:
94 x, y = map(int, match.split(','))
95 x = x/1000*w
96 y = y/1000*h
97 gt_bbox = list(map(int, ground_truth.strip('<>').split(',')))
98 # 遍历每个值,检查是否在ground truth对应值的±5范围内
99 gt_x_min = gt_bbox[0]
100 gt_x_max = gt_bbox[2]
101 gt_y_min = gt_bbox[1]
102 gt_y_max = gt_bbox[3]
103 print([x,y], [gt_x_min,gt_y_min,gt_x_max,gt_y_max])
104 if gt_x_min<=x<=gt_x_max and gt_y_min<=y<=gt_y_max:
105 return 1
106 else:
107 return 0
108 except:
109 return 0
110
111 else:
112 print("wrong response: {}".format(response))
113 return 0
114
115async def process_item_async(item, client, model_name, semaphore):
116 async with semaphore:

Callers 1

process_item_asyncFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected