| import json | |
| # 打开并加载json文件 | |
| with open( | |
| "/mnt/petrelfs/zhuchenglin/LLaVA/playground/data/LLaVA-Pretrain/select_mscoco_200k.json", | |
| "r", | |
| ) as f: | |
| data = json.load(f) | |
| # 遍历json数据,修改image地址 | |
| for item in data: | |
| item["image"] = "LLaVA-Pretrain/images/" + item["image"] | |
| # 将修改后的数据写回json文件 | |
| with open("/mnt/petrelfs/zhuchenglin/LLaVA/playground/data/mscoco_200k.json", "w") as f: | |
| json.dump(data, f, indent=4) | |