Training set for a car icon: Train.json
[{"Items": [{"label_id": "0028", "bbox": [198, 268, 222]}], "image_id": "500_0ak1_rpeqjujl_nbkbyijb.jpg"},
{"Items": [{"label_id": "0028", "bbox": [label_id, 117, [+]}, {"The": "0030", "bbox": [463, 102, 517, 157]}], "image_id ":" 500_0kzv_rqameftu_qgddh4lb.jpg "},
....
]
#-*-coding:utf-8-*-import json# Open json file F=open (' E:/bdci/bdci2017/train/train.json ', ' R ') # Dumps convert dictionary to string serialization # loads Convert a string to a dictionary # dump writes data to a JSON file # load converts a string to a data type. Image_label=[]image_bbox=[]image_name=[]train=json.load (f) for I in train: # There may be more than one car logo in a diagram Num=len (i[' Items ']) for K in range (num): image_label.append (i[' items '][k][' label_id ') image_bbox.append (i[' Items '][k [' Bbox ']) image_name.append (i[' image_id ')) F.close ()
Python read json file