BruceFeng98 commited on
Commit
9f3980c
·
verified ·
1 Parent(s): 412667a

Upload 2 files

Browse files
Files changed (2) hide show
  1. metric/gpt_judge.py +9 -27
  2. metric/metric.py +175 -50
metric/gpt_judge.py CHANGED
@@ -51,12 +51,6 @@ def save_json_file(
51
  raise RuntimeError(f"save json failed: {e}") from e
52
 
53
  def read_json_file(file_path):
54
- """
55
- Reads a JSON file and returns the parsed data as a Python object.
56
-
57
- :param file_path: The path to the JSON file
58
- :return: The data parsed from the JSON file
59
- """
60
  with open(file_path, 'r', encoding='utf-8') as f:
61
  data = json.load(f)
62
  return data
@@ -67,7 +61,6 @@ def openai_api( prompt = None):
67
 
68
  client = OpenAI(
69
  base_url='your_url',
70
-
71
  api_key='your_key'
72
  )
73
  response = client.chat.completions.create(
@@ -86,25 +79,6 @@ def openai_api( prompt = None):
86
  return response
87
 
88
 
89
- def extract_last_bracket_list(s: str) -> list:
90
- """
91
- """
92
- last_open = s.rfind('[')
93
- last_close = s.rfind(']')
94
- content = s[last_open:last_close+1]
95
-
96
- try:
97
-
98
- result = json.loads(content)
99
- except:
100
- content = re.sub(r'[\n\t\r]', '', content)
101
- content = ' '.join(content.split())
102
- result = []
103
- content = content.split("\",")
104
- for item in content:
105
- for item2 in item.split("\',"):
106
- result.append(item2)
107
- return result
108
 
109
 
110
  def ads_task_llm_judge(jsonlist):
@@ -114,6 +88,7 @@ def ads_task_llm_judge(jsonlist):
114
  retry_wait = 10
115
  tasks = read_json_file(json_file)
116
  for item in tqdm(tasks):
 
117
  if "judge" in item: continue
118
 
119
  prompt_templet = 'Please help me determine if the content in the Description contains Key Information. If it does, answer directly with "Yes"; if it does not, answer directly with "No". Please respond only with "Yes" or "No", without any additional output.'
@@ -158,6 +133,13 @@ def ads_task_llm_judge(jsonlist):
158
 
159
  if __name__ == "__main__":
160
  jsonlist = [
161
- r"your_path/gpt4o_bench.json",
 
 
 
 
 
 
 
162
  ]
163
  ads_task_llm_judge(jsonlist)
 
51
  raise RuntimeError(f"save json failed: {e}") from e
52
 
53
  def read_json_file(file_path):
 
 
 
 
 
 
54
  with open(file_path, 'r', encoding='utf-8') as f:
55
  data = json.load(f)
56
  return data
 
61
 
62
  client = OpenAI(
63
  base_url='your_url',
 
64
  api_key='your_key'
65
  )
66
  response = client.chat.completions.create(
 
79
  return response
80
 
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
 
84
  def ads_task_llm_judge(jsonlist):
 
88
  retry_wait = 10
89
  tasks = read_json_file(json_file)
90
  for item in tqdm(tasks):
91
+ if item["task"]!="advertisement reasoning": continue
92
  if "judge" in item: continue
93
 
94
  prompt_templet = 'Please help me determine if the content in the Description contains Key Information. If it does, answer directly with "Yes"; if it does not, answer directly with "No". Please respond only with "Yes" or "No", without any additional output.'
 
133
 
134
  if __name__ == "__main__":
135
  jsonlist = [
136
+ # r"C:\Users\11978\Desktop\poster\metric\gpt-4o-mini_bench.json",
137
+ # r"C:\Users\11978\Desktop\poster\metric\gpt-4.5-preview-2025-02-27.json",
138
+ # r"C:\Users\11978\Desktop\poster\metric\gemini-2.0-pro-exp-02-05_bench.json",
139
+ # r"C:\Users\11978\Desktop\poster\metric\gemini-2.5-pro-preview-03-25_bench.json",
140
+ # r"C:\Users\11978\Desktop\poster\metric\doubao-1-5-vision-pro-250328_bench.json",
141
+ # r"C:\Users\11978\Desktop\poster\metric\gemma-3-27b-it.json",
142
+ # r"C:\Users\11978\Desktop\poster\metric\gemma-3-12b-it.json",
143
+ # r"C:\Users\11978\Desktop\poster\metric\gemma-3-4b-it.json"
144
  ]
145
  ads_task_llm_judge(jsonlist)
metric/metric.py CHANGED
@@ -243,11 +243,24 @@ def extract_numbers_float2(s):
243
  return numbers
244
  def group_numbers_into_fours(num_list):
245
  """
 
246
 
 
 
 
 
 
 
 
 
247
  """
248
  n = len(num_list)
249
 
 
 
 
250
 
 
251
  result = [num_list[i:i + 4] for i in range(0, n-3, 4)]
252
  return result
253
 
@@ -274,7 +287,7 @@ def parse_bbox_string2(bbox_str):
274
  """
275
  """
276
  try:
277
-
278
  bbox_str = clean_string_for_box(bbox_str)
279
  bbox_nums = extract_numbers_float2(bbox_str)
280
  bboxes = group_numbers_into_fours(bbox_nums)
@@ -288,7 +301,9 @@ def calculate_iou(box1, box2):
288
  """
289
  """
290
 
291
-
 
 
292
  x1_1, y1_1, x2_1, y2_1 = box1
293
  x1_2, y1_2, x2_2, y2_2 = box2
294
 
@@ -304,21 +319,21 @@ def calculate_iou(box1, box2):
304
  if x1_2 > x2_2: return 0.0
305
  if y1_2 > y2_2: return 0.0
306
 
307
-
308
  if x_right < x_left or y_bottom < y_top:
309
  return 0.0
310
 
311
-
312
  intersection_area = (x_right - x_left) * (y_bottom - y_top)
313
 
314
-
315
  box1_area = (x2_1 - x1_1) * (y2_1 - y1_1)
316
  box2_area = (x2_2 - x1_2) * (y2_2 - y1_2)
317
 
318
-
319
  union_area = box1_area + box2_area - intersection_area
320
 
321
-
322
  iou = intersection_area / union_area
323
  return iou
324
 
@@ -342,7 +357,9 @@ def calculate_area_ratio(box1, box2):
342
  """
343
  """
344
 
345
-
 
 
346
  x1_1, y1_1, x2_1, y2_1 = box1
347
  x1_2, y1_2, x2_2, y2_2 = box2
348
 
@@ -378,7 +395,10 @@ def norm_bbox(norm_bbox,size):
378
 
379
  def bbox_number_types(bboxes):
380
  """
 
381
 
 
 
382
  """
383
  result = []
384
  for box in bboxes:
@@ -431,11 +451,70 @@ def task_4_ocr(data):
431
  # # print(response)
432
  # continue
433
  colorful_words_ocr.append(word_level_ac(gt, response))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
 
435
- print("pure_char_ocr word-level accuracy: ", f"{sum(pure_char_ocr)/len(pure_char_ocr):.3f}", f" total imgs:{len(pure_char_ocr)/400}")
436
- print("colorful_char_ocr word-level accuracy: ", f"{sum(colorful_char_ocr)/len(colorful_char_ocr):.3f}", f" total imgs:{len(colorful_char_ocr)/400}")
437
- print("pure_words_ocr word-level accuracy: ", f"{sum(pure_words_ocr) / len(pure_words_ocr):.3f}", f" total imgs:{len(pure_words_ocr)/400}")
438
- print("colorful_words_ocr word-level accuracy: ", f"{sum(colorful_words_ocr) / len(colorful_words_ocr):.3f}", f" total imgs:{len(colorful_words_ocr)/400}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
 
440
  def task_font_size(data):
441
  """ font size robustness """
@@ -492,8 +571,9 @@ def task_font_size(data):
492
  mean_r = statistics.mean(recall_num)
493
 
494
  # print(f"Mean: {mean:.3f} Std: {std:.3f} Mean: {mean3:.3f} Std: {std3:.3f} reacall_num: {mean_r}")
495
- print(f"Mean: {mean:.3f} Std: {std:.3f} Mean: {mean3:.3f} Std: {std3:.3f} reacall_num: {mean_r:.3f}")
496
 
 
497
  def task_logo_cor(data):
498
  """ logo ocr """
499
  result = []
@@ -502,7 +582,8 @@ def task_logo_cor(data):
502
  gt = item["gt"]
503
  response = item["response"]
504
  result.append(logo_ocr_ac(gt, response))
505
- print(f"logo ocr accuracy: {sum(result)/len(result):.3f} total imgs: {len(result)}")
 
506
 
507
  def task_poster_ocr(data):
508
  """ real poster ocr """
@@ -517,7 +598,8 @@ def task_poster_ocr(data):
517
  ac = real_poster_ac(gt, response)
518
  if ac<0.05: continue
519
  result.append(ac)
520
- print(f"poster ocr accuracy (entity-level): {sum(result)/len(result):.3f} total imgs: {len(result)}")
 
521
 
522
  def task_font_matching_1(data):
523
  """ font matching 1 """
@@ -533,7 +615,7 @@ def task_font_matching_1(data):
533
  continue
534
  # print(response)
535
  result.append(font_matching_ac(gt, response))
536
- print(f"font matching 1 accuracy: {sum(result) / len(result):5f} total imgs: {len(result)}")
537
  return sum(result) / len(result)
538
 
539
  def task_font_matching_2(data):
@@ -550,7 +632,7 @@ def task_font_matching_2(data):
550
  continue
551
  # print(response)
552
  result.append(font_matching_ac(gt, response))
553
- print(f"font matching 2 accuracy: {sum(result) / len(result):5f} total imgs: {len(result)}")
554
  return sum(result) / len(result)
555
 
556
  def task_font_matching(data):
@@ -584,7 +666,7 @@ def task_font_attr(data):
584
  continue
585
  # print(response)
586
  result.append(font_attr_ac(gt, response))
587
- print(f"font attributes accuracy: {sum(result) / len(result):5f} total imgs: {len(result)}")
588
 
589
  font_attr_list = []
590
  font_attr_dic = {}
@@ -622,7 +704,7 @@ def task_font_effect(data):
622
  response = item["response"]
623
  # print(response)
624
  result.append(font_effect_ac(gt, response))
625
- print(f"font effect accuracy: {sum(result) / len(result):.5f} total imgs: {len(result)}")
626
 
627
  font_effect_list = []
628
  font_effect_dic = {}
@@ -664,8 +746,8 @@ def task_font_effect_2(data):
664
  if effect_ac != None:
665
  result_e.append(effect_ac)
666
 
667
- print(f"font effect 2 color accuracy: {sum(result_c) / len(result_c):5f} total imgs: {len(result_c)}")
668
- print(f"font effect 2 effect accuracy: {sum(result_e) / len(result_e):5f} total imgs: {len(result_e)}")
669
 
670
  return sum(result_c) / len(result_c), sum(result_e) / len(result_e)
671
 
@@ -681,7 +763,7 @@ def task_layout_comprison(data):
681
  response = item["response"]
682
  # print(response)
683
  result.append(font_effect_ac(gt, response))
684
- print(f"layout disorder comparison accuracy: {sum(result) / len(result):5f} total imgs: {len(result)}")
685
  return sum(result) / len(result)
686
 
687
 
@@ -745,10 +827,10 @@ def task_align_rotate(data):
745
  r_result.extend(r3_result)
746
 
747
 
748
- print(f"alignment accuracy: {sum(a_result) / len(a_result):5f} total imgs: {len(a_result)}")
749
- print(f"rotation accuracy: {sum(r1_result) / len(r1_result):5f} total imgs: {len(r1_result)}")
750
- print(f"rotation accuracy: {sum(r2_result) / len(r2_result):5f} total imgs: {len(r2_result)}")
751
- print(f"rotation accuracy: {sum(r3_result) / len(r3_result):5f} total imgs: {len(r3_result)}")
752
 
753
  return sum(a_result) / len(a_result), sum(r_result) / len(r_result)
754
 
@@ -1083,7 +1165,7 @@ def task_ads(data):
1083
  if item["task"]=="advertisement reasoning":
1084
  item_point_list = []
1085
  if "judge" in item:
1086
-
1087
  for content in item["judge"]:
1088
  if "Yes" in content:
1089
  points += 1
@@ -1094,37 +1176,80 @@ def task_ads(data):
1094
  score_list.append(score)
1095
 
1096
  # print(f"{sum(score_list)/len(score_list):.3f} {points} ")
1097
- print(f"{sum(score_list) / len(score_list):.3f}")
 
1098
 
1099
 
1100
  if __name__=="__main__":
1101
-
1102
- # # data = read_json_file(r"Llama-3.2-11B-Vision-Instruct_bench.json")
1103
- # task_4_ocr(data)
1104
- # task_logo_cor(data)
1105
- # task_poster_ocr(data)
1106
- # task_font_matching_1(data)
1107
- # task_font_matching_2(data)
1108
- # task_font_attr(data)
1109
- # task_font_effect(data)
1110
- # task_font_effect_2(data)
1111
- # task_font_size(data)
1112
- # task_layout_comprison(data)
1113
- # task_poster_detection(data)
1114
- # task_layout_generation(data)
1115
- # task_align_rotate(data)
1116
- # task_empty_space(data)
1117
  jsonlist = [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1118
  ]
 
1119
  for json_item in jsonlist:
1120
  print(os.path.basename(json_item))
1121
  data = read_json_file(json_item)
1122
- top1_iou, _ = task_poster_detection(data, max_box_num=1)
1123
- top3_iou, _ = task_poster_detection(data, max_box_num=3)
1124
- top5_iou, _ = task_poster_detection(data, max_box_num=5)
1125
- mean_iou, recall = task_poster_detection(data, max_box_num=30)
1126
- print(f"{top1_iou:.3f} & {top3_iou:.3f} & {top5_iou:.3f} & {mean_iou:.3f} & {recall:.3f}")
1127
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1128
  #
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1129
  # bias, area_rate, rate = task_layout_generation(data)
1130
  # print(f"{bias:.3f} & {area_rate:.3f} & {rate:.3f}")
 
 
 
 
243
  return numbers
244
  def group_numbers_into_fours(num_list):
245
  """
246
+ 将数字列表按每4个元素分组,并验证总长度是否为4的倍数
247
 
248
+ 参数:
249
+ num_list -- 全数字组成的列表,如 [1,2,3,4,5,6,7,8]
250
+
251
+ 返回:
252
+ 分组后的二维列表,如 [[1,2,3,4], [5,6,7,8]]
253
+
254
+ 异常:
255
+ ValueError -- 当输入列表长度不是4的倍数时抛出
256
  """
257
  n = len(num_list)
258
 
259
+ # 验证长度是否为4的倍数
260
+ # if n % 4 != 0:
261
+ # raise ValueError(f"数字个数 {n} 不是4的倍数,无法完整分组")
262
 
263
+ # 按步长4切割列表
264
  result = [num_list[i:i + 4] for i in range(0, n-3, 4)]
265
  return result
266
 
 
287
  """
288
  """
289
  try:
290
+ # 使用literal_eval将字符串解析为Python对象
291
  bbox_str = clean_string_for_box(bbox_str)
292
  bbox_nums = extract_numbers_float2(bbox_str)
293
  bboxes = group_numbers_into_fours(bbox_nums)
 
301
  """
302
  """
303
 
304
+ # 解析坐标
305
+ # print("box 1",box1)
306
+ # print("box 2",box2)
307
  x1_1, y1_1, x2_1, y2_1 = box1
308
  x1_2, y1_2, x2_2, y2_2 = box2
309
 
 
319
  if x1_2 > x2_2: return 0.0
320
  if y1_2 > y2_2: return 0.0
321
 
322
+ # 处理无交集情况
323
  if x_right < x_left or y_bottom < y_top:
324
  return 0.0
325
 
326
+ # 计算交集面积
327
  intersection_area = (x_right - x_left) * (y_bottom - y_top)
328
 
329
+ # 计算各自面积
330
  box1_area = (x2_1 - x1_1) * (y2_1 - y1_1)
331
  box2_area = (x2_2 - x1_2) * (y2_2 - y1_2)
332
 
333
+ # 计算并集面积
334
  union_area = box1_area + box2_area - intersection_area
335
 
336
+ # 计算IoU
337
  iou = intersection_area / union_area
338
  return iou
339
 
 
357
  """
358
  """
359
 
360
+ # 解析坐标
361
+ # print("box 1",box1)
362
+ # print("box 2",box2)
363
  x1_1, y1_1, x2_1, y2_1 = box1
364
  x1_2, y1_2, x2_2, y2_2 = box2
365
 
 
395
 
396
  def bbox_number_types(bboxes):
397
  """
398
+ 判断一组 bbox 列表中的每个数字是整数还是小数。
399
 
400
+ :param bboxes: List[List[float]],每个 bbox 为 [x1, y1, x2, y2]
401
+ :return: List[List[str]],与 bboxes 结构相同,每个位置返回 "int" 或 "float"
402
  """
403
  result = []
404
  for box in bboxes:
 
451
  # # print(response)
452
  # continue
453
  colorful_words_ocr.append(word_level_ac(gt, response))
454
+ pc_wr1 = sum(pure_char_ocr)/len(pure_char_ocr)
455
+ cc_wr1 = sum(colorful_char_ocr)/len(colorful_char_ocr)
456
+ pw_wr1 = sum(pure_words_ocr) / len(pure_words_ocr)
457
+ cw_wr1 = sum(colorful_words_ocr) / len(colorful_words_ocr)
458
+ # print("pure_char_ocr word-level accuracy: ", f"{sum(pure_char_ocr)/len(pure_char_ocr):.3f}", f" total imgs:{len(pure_char_ocr)/400}")
459
+ # print("colorful_char_ocr word-level accuracy: ", f"{sum(colorful_char_ocr)/len(colorful_char_ocr):.3f}", f" total imgs:{len(colorful_char_ocr)/400}")
460
+ # print("pure_words_ocr word-level accuracy: ", f"{sum(pure_words_ocr) / len(pure_words_ocr):.3f}", f" total imgs:{len(pure_words_ocr)/400}")
461
+ # print("colorful_words_ocr word-level accuracy: ", f"{sum(colorful_words_ocr) / len(colorful_words_ocr):.3f}", f" total imgs:{len(colorful_words_ocr)/400}")
462
+
463
+ """ character ocr and words ocr """
464
+ pure_char_ocr = []
465
+ colorful_char_ocr = []
466
+ pure_words_ocr = []
467
+ colorful_words_ocr = []
468
+ for item in data:
469
+ if item["task"] == "pure_char ocr":
470
+ gt = item["gt"]
471
+ response = item["response"]
472
+ if word_level_ac(gt, response) < 0.1:
473
+ # # print(response)
474
+ continue
475
+ pure_char_ocr.append(word_level_ac(gt, response))
476
 
477
+ if item["task"] == "colorful_char ocr":
478
+ gt = item["gt"]
479
+ response = item["response"]
480
+ if word_level_ac(gt, response) < 0.1:
481
+ # # print(response)
482
+ continue
483
+ colorful_char_ocr.append(word_level_ac(gt, response))
484
+
485
+ if item["task"] == "pure_words ocr":
486
+ gt = item["gt"]
487
+ response = item["response"]
488
+ if word_level_ac(gt, response) < 0.1:
489
+ # # print(response)
490
+ continue
491
+ pure_words_ocr.append(word_level_ac(gt, response))
492
+ if item["task"] == "colorful_words ocr":
493
+ gt = item["gt"]
494
+ response = item["response"]
495
+ if word_level_ac(gt, response)<0.1:
496
+ # # print(response)
497
+ continue
498
+ colorful_words_ocr.append(word_level_ac(gt, response))
499
+ pc_wr2 = sum(pure_char_ocr) / len(pure_char_ocr)
500
+ cc_wr2 = sum(colorful_char_ocr) / len(colorful_char_ocr)
501
+ pw_wr2 = sum(pure_words_ocr) / len(pure_words_ocr)
502
+ cw_wr2 = sum(colorful_words_ocr) / len(colorful_words_ocr)
503
+ pc_r = len(pure_char_ocr) / 400
504
+ cc_r = len(colorful_char_ocr) / 400
505
+ pw_r = len(pure_words_ocr) / 400
506
+ cW_r = len(colorful_words_ocr) / 400
507
+ # print("pure_char_ocr word-level accuracy: ", f"{sum(pure_char_ocr) / len(pure_char_ocr):.3f}",
508
+ # f" total imgs:{len(pure_char_ocr) / 400}")
509
+ # print("colorful_char_ocr word-level accuracy: ", f"{sum(colorful_char_ocr) / len(colorful_char_ocr):.3f}",
510
+ # f" total imgs:{len(colorful_char_ocr) / 400}")
511
+ # print("pure_words_ocr word-level accuracy: ", f"{sum(pure_words_ocr) / len(pure_words_ocr):.3f}",
512
+ # f" total imgs:{len(pure_words_ocr) / 400}")
513
+ # print("colorful_words_ocr word-level accuracy: ", f"{sum(colorful_words_ocr) / len(colorful_words_ocr):.3f}",
514
+ # f" total imgs:{len(colorful_words_ocr) / 400}")
515
+
516
+
517
+ return pc_wr1, pc_wr2, pc_r, cc_wr1, cc_wr2, cc_r, pw_wr1, pw_wr2, pw_r, cw_wr1, cw_wr2, cW_r
518
 
519
  def task_font_size(data):
520
  """ font size robustness """
 
571
  mean_r = statistics.mean(recall_num)
572
 
573
  # print(f"Mean: {mean:.3f} Std: {std:.3f} Mean: {mean3:.3f} Std: {std3:.3f} reacall_num: {mean_r}")
574
+ # print(f"Mean: {mean:.3f} Std: {std:.3f} Mean: {mean3:.3f} Std: {std3:.3f} reacall_num: {mean_r:.3f}")
575
 
576
+ return mean, std, mean3, std3, mean_r/100
577
  def task_logo_cor(data):
578
  """ logo ocr """
579
  result = []
 
582
  gt = item["gt"]
583
  response = item["response"]
584
  result.append(logo_ocr_ac(gt, response))
585
+ # print(f"logo ocr accuracy: {sum(result)/len(result):.3f} total imgs: {len(result)}")
586
+ return sum(result)/len(result)
587
 
588
  def task_poster_ocr(data):
589
  """ real poster ocr """
 
598
  ac = real_poster_ac(gt, response)
599
  if ac<0.05: continue
600
  result.append(ac)
601
+ # print(f"poster ocr accuracy (entity-level): {sum(result)/len(result):.3f} total imgs: {len(result)}")
602
+ return sum(result)/len(result)
603
 
604
  def task_font_matching_1(data):
605
  """ font matching 1 """
 
615
  continue
616
  # print(response)
617
  result.append(font_matching_ac(gt, response))
618
+ # print(f"font matching 1 accuracy: {sum(result) / len(result):5f} total imgs: {len(result)}")
619
  return sum(result) / len(result)
620
 
621
  def task_font_matching_2(data):
 
632
  continue
633
  # print(response)
634
  result.append(font_matching_ac(gt, response))
635
+ # print(f"font matching 2 accuracy: {sum(result) / len(result):5f} total imgs: {len(result)}")
636
  return sum(result) / len(result)
637
 
638
  def task_font_matching(data):
 
666
  continue
667
  # print(response)
668
  result.append(font_attr_ac(gt, response))
669
+ # print(f"font attributes accuracy: {sum(result) / len(result):5f} total imgs: {len(result)}")
670
 
671
  font_attr_list = []
672
  font_attr_dic = {}
 
704
  response = item["response"]
705
  # print(response)
706
  result.append(font_effect_ac(gt, response))
707
+ # print(f"font effect accuracy: {sum(result) / len(result):.5f} total imgs: {len(result)}")
708
 
709
  font_effect_list = []
710
  font_effect_dic = {}
 
746
  if effect_ac != None:
747
  result_e.append(effect_ac)
748
 
749
+ # print(f"font effect 2 color accuracy: {sum(result_c) / len(result_c):5f} total imgs: {len(result_c)}")
750
+ # print(f"font effect 2 effect accuracy: {sum(result_e) / len(result_e):5f} total imgs: {len(result_e)}")
751
 
752
  return sum(result_c) / len(result_c), sum(result_e) / len(result_e)
753
 
 
763
  response = item["response"]
764
  # print(response)
765
  result.append(font_effect_ac(gt, response))
766
+ # print(f"layout disorder comparison accuracy: {sum(result) / len(result):5f} total imgs: {len(result)}")
767
  return sum(result) / len(result)
768
 
769
 
 
827
  r_result.extend(r3_result)
828
 
829
 
830
+ # print(f"alignment accuracy: {sum(a_result) / len(a_result):5f} total imgs: {len(a_result)}")
831
+ # print(f"rotation accuracy: {sum(r1_result) / len(r1_result):5f} total imgs: {len(r1_result)}")
832
+ # print(f"rotation accuracy: {sum(r2_result) / len(r2_result):5f} total imgs: {len(r2_result)}")
833
+ # print(f"rotation accuracy: {sum(r3_result) / len(r3_result):5f} total imgs: {len(r3_result)}")
834
 
835
  return sum(a_result) / len(a_result), sum(r_result) / len(r_result)
836
 
 
1165
  if item["task"]=="advertisement reasoning":
1166
  item_point_list = []
1167
  if "judge" in item:
1168
+
1169
  for content in item["judge"]:
1170
  if "Yes" in content:
1171
  points += 1
 
1176
  score_list.append(score)
1177
 
1178
  # print(f"{sum(score_list)/len(score_list):.3f} {points} ")
1179
+ # print(f"{sum(score_list) / len(score_list):.3f}")
1180
+ return sum(score_list) / len(score_list)
1181
 
1182
 
1183
  if __name__=="__main__":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1184
  jsonlist = [
1185
+ r"C:\Users\11978\Desktop\poster\metric\gpt4o_bench.json",
1186
+ r"C:\Users\11978\Desktop\poster\metric\gemini_bench.json",
1187
+ r"C:\Users\11978\Desktop\poster\metric\claude_bench.json",
1188
+ r"C:\Users\11978\Desktop\poster\metric\tasks_intervl_8b.json",
1189
+ r"C:\Users\11978\Desktop\poster\metric\Kimi-VL-A3B-Instruct_bench.json",
1190
+ r"C:\Users\11978\Desktop\poster\metric\Phi-3.5-vision-instruct_bench.json",
1191
+ r"C:\Users\11978\Desktop\poster\metric\Llama-3.2-11B-Vision-Instruct_bench(1).json",
1192
+ r"C:\Users\11978\Desktop\poster\metric\qwen_32b_bench.json",
1193
+ r"C:\Users\11978\Desktop\poster\metric\tasks_qwen_7b.json",
1194
+ r"C:\Users\11978\Desktop\poster\metric\tasks_qwen_3b.json",
1195
+ r"C:\Users\11978\Desktop\poster\metric\gpt-4o-mini_bench.json",
1196
+ r"C:\Users\11978\Desktop\poster\metric\gpt-4.5-preview-2025-02-27.json",
1197
+ r"C:\Users\11978\Desktop\poster\metric\gemini-2.0-pro-exp-02-05_bench.json",
1198
+ r"C:\Users\11978\Desktop\poster\metric\gemini-2.5-pro-preview-03-25_bench.json",
1199
+ r"C:\Users\11978\Desktop\poster\metric\doubao-1-5-vision-pro-250328_bench.json",
1200
+ r"C:\Users\11978\Desktop\poster\metric\gemma-3-27b-it.json",
1201
+ r"C:\Users\11978\Desktop\poster\metric\gemma-3-12b-it.json",
1202
+ r"C:\Users\11978\Desktop\poster\metric\gemma-3-4b-it.json"
1203
  ]
1204
+
1205
  for json_item in jsonlist:
1206
  print(os.path.basename(json_item))
1207
  data = read_json_file(json_item)
1208
+ """ocr"""
1209
+ # logo_ac = task_logo_cor(data)
1210
+ # poster_ac = task_poster_ocr(data)
1211
+ # pc_wr1, pc_wr2, pc_r, cc_wr1, cc_wr2, cc_r, pw_wr1, pw_wr2, pw_r, cw_wr1, cw_wr2, cW_r = task_4_ocr(data)
1212
+ # print(f"& {logo_ac:.3f} & {poster_ac:.3f} & {pc_wr1:.3f} & {pc_wr2:.3f} & {pc_r:.3f} & {cc_wr1:.3f} & {cc_wr2:.3f} & {cc_r:.3f} & {pw_wr1:.3f} & {pw_wr2:.3f} & {pw_r:.3f} & {cw_wr1:.3f} & {cw_wr2:.3f} & {cW_r:.3f}")
1213
+ """font size ocr"""
1214
+ # mean, std, mean3, std3, mean_r = task_font_size(data)
1215
+ # print(f"& {mean:.3f} & {std:.3f} & {mean3:.3f} & {std3:.3f} & {mean_r:.3f}")
1216
+ """font task"""
1217
+ # fm1 = task_font_matching_1(data)
1218
+ # fm2 = task_font_matching_2(data)
1219
+ # fm = (fm1 + fm2) /2
1220
+ # fm_score = k_option_norm(fm, k=9)
1221
+ #
1222
+ # fattr = task_font_attr(data)
1223
+ # fattr_score = k_option_norm(fattr, k=2)
1224
+ #
1225
+ # fe1 = task_font_effect(data)
1226
+ # fc,fe2 = task_font_effect_2(data)
1227
+ # fe1_score = k_option_norm(fe1,k=9)
1228
+ # fc_score, fe2_score = k_option_norm(fc,k=16), k_option_norm(fe2, k=48)
1229
  #
1230
+ # print(f"& {fm_score:.3f} & {fattr_score:.3f} & {fe1_score:.3f} & {fc_score:.3f} & {fe2_score:.3f}")
1231
+
1232
+ """text localization"""
1233
+ # top1_iou, _ = task_poster_detection(data, max_box_num=1)
1234
+ # top3_iou, _ = task_poster_detection(data, max_box_num=3)
1235
+ # top5_iou, _ = task_poster_detection(data, max_box_num=5)
1236
+ # mean_iou, recall = task_poster_detection(data, max_box_num=30)
1237
+ # # print(f"{top1_iou:.3f} & {top3_iou:.3f} & {top5_iou:.3f} & {mean_iou:.3f} & {recall:.3f}")
1238
+ # print(f"{top1_iou:.3f} & {top3_iou:.3f} & {mean_iou:.3f} & {recall:.3f}")
1239
+ """text positioning"""
1240
+ # a, r = task_align_rotate(data)
1241
+ # a, r = k_option_norm(a, k=3), k_option_norm(r, k=3)
1242
+ # print(f"{a:.3f} & {r:.3f}")
1243
+ """empty space"""
1244
+ # iou, match = task_empty_space(data)
1245
+ # print(f"{iou:.3f} & {match:.3f}")
1246
+ """layout comparison"""
1247
+ # vs = task_layout_comprison(data)
1248
+ # vs_score = k_option_norm(vs, k=2)
1249
+ # print(f"& {vs_score:.3f} & ")
1250
+ """layout generation"""
1251
  # bias, area_rate, rate = task_layout_generation(data)
1252
  # print(f"{bias:.3f} & {area_rate:.3f} & {rate:.3f}")
1253
+ """advertisement understanding"""
1254
+ points = task_ads(data)
1255
+ print(f"& {points:.3f}")