MCPcopy Create free account
hub / github.com/Depth2World/VLADBench / RoadSpeed_criterion_QA

Function RoadSpeed_criterion_QA

evaluate_utils.py:307–340  ·  view source on GitHub ↗
(third_task_data,MODEL=None)

Source from the content-addressed store, hash-verified

305 return ques_total_num,right_num/ques_total_num,obey_insytruction/ques_total_num,totol_improve_score*2/ques_total_num
306
307def RoadSpeed_criterion_QA(third_task_data,MODEL=None):
308 ques_total_num = 0
309 right_num = 0
310 obey_insytruction = 0
311 totol_improve_score = 0
312 for d_ind, sample in enumerate(third_task_data):
313 reference = sample['reference']
314 prediction = sample['prediction']
315 scores_list = []
316 for q_ind, pred in enumerate(prediction):
317 ques_total_num+=1
318 pattern = r'\[\s*(-?\d+)\s*,\s*(-?\d+)\s*\]'
319 matches = re.findall(pattern, pred)
320
321 matches_gt = re.findall(pattern, reference[q_ind])
322 # print(reference[q_ind])
323 ref_gt = [matches_gt[0][0],matches_gt[0][1]]
324 # print(ref_gt)
325 temp = 0
326 if len(matches)==1:
327 pred_limit = [matches[0][0],matches[0][1]]
328 obey_insytruction+=1
329 for a, b in zip(ref_gt,pred_limit):
330 if a==b:
331 temp+=0.5
332 right_num+=temp
333 scores_list.append(temp)
334
335 scores_list = np.array(scores_list)
336 scores = compare_and_count(scores_list[len(scores_list)//2:], scores_list[:len(scores_list)//2])
337 totol_improve_score += scores
338
339 return ques_total_num,right_num/ques_total_num,obey_insytruction/ques_total_num,totol_improve_score*2/ques_total_num
340 # return ques_total_num,right_num,obey_insytruction,totol_improve_score/2
341
342
343

Callers

nothing calls this directly

Calls 1

compare_and_countFunction · 0.85

Tested by

no test coverage detected