import json | |
import random | |
with open( | |
"/mnt/petrelfs/zhuchenglin/LLaVA/playground/data/llava_v1_5_mix665k.json" | |
) as f: | |
data = json.load(f) | |
selected_data = random.sample(data, 200000) | |
# 将选择的元素写入新的JSON文件 | |
with open( | |
"/mnt/petrelfs/zhuchenglin/LLaVA/playground/data/llava_v1_5_mix200k.json", | |
"w", | |
) as f: | |
json.dump(selected_data, f) | |