|
|
import jsonlines |
|
|
import re |
|
|
import os |
|
|
from matplotlib import pyplot as plt |
|
|
|
|
|
def count_bbox(answer: str): |
|
|
PATTERN = re.compile(r'\((.*?)\),\((.*?)\)') |
|
|
bbox_num = len(re.findall(PATTERN, answer)) |
|
|
return bbox_num |
|
|
|
|
|
save_ckpt_lst = [350] |
|
|
|
|
|
mmmu_box_ratio, mmmu_avg_box_num = [], [] |
|
|
mathvista_box_ratio, mathvista_avg_box_num = [], [] |
|
|
wtq_box_ratio, wtq_avg_box_num = [], [] |
|
|
mmdocbench_box_ratio, mmdocbench_avg_box_num = [], [] |
|
|
tablefact_box_ratio, tablefact_avg_box_num = [], [] |
|
|
|
|
|
for results in os.listdir("/user/xuqixin/checkpoints/qwen25_vl-7b/grpo_v7_exp10_qwen25_vl_sft_bbox_grpo_opensource_doc/results"): |
|
|
for ckpt in save_ckpt_lst: |
|
|
if not results.endswith(f"_{ckpt}.jsonl"): |
|
|
continue |
|
|
with jsonlines.open(f"/user/xuqixin/checkpoints/qwen25_vl-7b/grpo_v7_exp10_qwen25_vl_sft_bbox_grpo_opensource_doc/results/{results}") as reader: |
|
|
total_num = 0 |
|
|
total_bbox_num = 0 |
|
|
bbox_sample_num = 0 |
|
|
already_print = 0 |
|
|
print("##############################################################################") |
|
|
print(f"results: {results}") |
|
|
for obj in reader: |
|
|
total_num += 1 |
|
|
answer = obj["output"] |
|
|
bbox_num = count_bbox(answer) |
|
|
total_bbox_num += bbox_num |
|
|
if bbox_num > 0: |
|
|
bbox_sample_num += 1 |
|
|
if already_print < 5: |
|
|
print(obj) |
|
|
print("\n") |
|
|
already_print += 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "mmmu" in results: |
|
|
|
|
|
mmmu_box_ratio.append(round(bbox_sample_num / total_num, 3)) |
|
|
mmmu_avg_box_num.append(round(total_bbox_num / bbox_sample_num, 3)) |
|
|
elif "mathvista" in results: |
|
|
mathvista_box_ratio.append(round(bbox_sample_num / total_num, 3)) |
|
|
mathvista_avg_box_num.append(round(total_bbox_num / bbox_sample_num, 3)) |
|
|
elif "wtq" in results: |
|
|
wtq_box_ratio.append(round(bbox_sample_num / total_num, 3)) |
|
|
wtq_avg_box_num.append(round(total_bbox_num / bbox_sample_num, 3)) |
|
|
elif "mmdocbench" in results: |
|
|
mmdocbench_box_ratio.append(round(bbox_sample_num / total_num, 3)) |
|
|
mmdocbench_avg_box_num.append(round(total_bbox_num / bbox_sample_num, 3)) |
|
|
elif "tablefact" in results: |
|
|
tablefact_box_ratio.append(round(bbox_sample_num / total_num, 3)) |
|
|
tablefact_avg_box_num.append(round(total_bbox_num / bbox_sample_num, 3)) |
|
|
|
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 5)) |
|
|
plt.subplot(1, 2, 1) |
|
|
plt.plot(save_ckpt_lst, mmmu_box_ratio, label='mmmu') |
|
|
plt.plot(save_ckpt_lst, mathvista_box_ratio, label='mathvista') |
|
|
plt.plot(save_ckpt_lst, wtq_box_ratio, label='wtq') |
|
|
plt.plot(save_ckpt_lst, mmdocbench_box_ratio, label='mmdocbench') |
|
|
plt.plot(save_ckpt_lst, tablefact_box_ratio, label='tablefact') |
|
|
plt.xlabel('Checkpoint') |
|
|
plt.ylabel('Box Ratio') |
|
|
plt.title('Box Ratio vs Checkpoint') |
|
|
plt.legend() |
|
|
plt.subplot(1, 2, 2) |
|
|
plt.plot(save_ckpt_lst, mmmu_avg_box_num, label='mmmu') |
|
|
plt.plot(save_ckpt_lst, mathvista_avg_box_num, label='mathvista') |
|
|
plt.plot(save_ckpt_lst, wtq_avg_box_num, label='wtq') |
|
|
plt.plot(save_ckpt_lst, mmdocbench_avg_box_num, label='mmdocbench') |
|
|
plt.plot(save_ckpt_lst, tablefact_avg_box_num, label='tablefact') |
|
|
plt.xlabel('Checkpoint') |
|
|
plt.ylabel('Average Box Number') |
|
|
plt.title('Average Box Number vs Checkpoint') |
|
|
plt.legend() |
|
|
plt.tight_layout() |
|
|
plt.savefig('/user/xuqixin/checkpoints/qwen25_vl-7b/grpo_v7_exp10_qwen25_vl_sft_bbox_grpo_opensource_doc/box_ratio.png') |
|
|
plt.show() |
|
|
|
|
|
print("##############################################################################") |
|
|
print("mmmu box ratio:", mmmu_box_ratio) |
|
|
print("mathvista box ratio:", mathvista_box_ratio) |
|
|
print("wtq box ratio:", wtq_box_ratio) |
|
|
print("mmdocbench box ratio:", mmdocbench_box_ratio) |
|
|
print("tablefact box ratio:", tablefact_box_ratio) |
|
|
|
|
|
print("mmmu avg box num:", mmmu_avg_box_num) |
|
|
print("mathvista avg box num:", mathvista_avg_box_num) |
|
|
print("wtq avg box num:", wtq_avg_box_num) |
|
|
print("mmdocbench avg box num:", mmdocbench_avg_box_num) |
|
|
print("tablefact avg box num:", tablefact_avg_box_num) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|