笔记 解析COCO数据集(一)

captions = [coco.anns[ann_id]['caption'] for ann_id in coco.anns]
image_ids = [coco.anns[ann_id]['image_id'] for ann_id in coco.anns]
image_files = [os.path.join(config.train_image_dir,
                            coco.imgs[image_id]['file_name'])
                            for image_id in image_ids]
annotations = pd.DataFrame({'image_id': image_ids,
                            'image_file': image_files,
                             'caption': captions})

这几行代码巧妙地把data下的不同的键annotation以及images按照id的顺序连接到了一起

你可能感兴趣的:(python)