错误原因是json文件太大,改为单行读取:

with open("COCO_train.json", "r+") as f:
    data = json.load(f)

改为:

with open("COCO_train.json", "r+") as f:
    data = f.readline()