LLaVA / utils /select_with_clipscore.py
starriver030515's picture
Upload folder using huggingface_hub
bd4d522 verified
import json
clipscore_coco_gen_path = "/mnt/petrelfs/zhuchenglin/clipscore/coco_gen_200k.json"
clipscore_coco_raw_path = "/mnt/petrelfs/zhuchenglin/clipscore/coco_raw_200k.json"
with open(clipscore_coco_gen_path) as f:
clipscore_coco_gen = json.load(f)
with open(clipscore_coco_raw_path) as f:
clipscore_coco_raw = json.load(f)
anno_coco_gen_path = "/mnt/petrelfs/zhuchenglin/LLaVA/playground/data/LLaVA-Pretrain/mscoco_gen_200k.json"
anno_coco_raw_path = "/mnt/petrelfs/zhuchenglin/LLaVA/playground/data/LLaVA-Pretrain/mscoco_raw_200k.json"
with open(anno_coco_gen_path) as f:
anno_coco_gen = json.load(f)
with open(anno_coco_raw_path) as f:
anno_coco_raw = json.load(f)
json_file = []
count = 0
for i in range(200000):
# print(i)
if clipscore_coco_gen[i]["clipscore"] > clipscore_coco_raw[i]["clipscore"] + 0.1:
json_file.append(anno_coco_gen[i])
count += 1
else:
json_file.append(anno_coco_raw[i])
with open(
"/mnt/petrelfs/zhuchenglin/LLaVA/playground/data/LLaVA-Pretrain/select_mscoco_200k.json",
"w",
) as f:
json.dump(json_file, f)
print(count)