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