liruilong940607 / OCHumanApi

API for the dataset proposed in "Pose2Seg: Detection Free Human Instance Segmentation" @ CVPR2019.
http://www.liruilong.cn/projects/pose2seg/index.html
MIT License
257 stars 44 forks source link

Unable to read test or val annotations using the code given in demo.ipynb #4

Closed yxchng closed 5 years ago

yxchng commented 5 years ago

I use the following code:

import os
import cv2
import json
from ochumanApi.ochuman import OCHuman

data_dir = './images'
annot_file = './ochuman.json'
annot_file = './ochuman_coco_format_val_range_0.00_1.00.json'

ochuman = OCHuman(AnnoFile=annot_file, Filter='kpt&segm')
image_ids = ochuman.getImgIds()
print ('Total images: %d'%len(image_ids))

data = ochuman.loadImgs(imgIds=[image_ids[2]])[0]
img = cv2.imread(os.path.join(data_dir, data['file_name']))
height, width = data['height'], data['width']

But it gives the error

Traceback (most recent call last):
  File "visualize_val.py", line 10, in <module>
    ochuman = OCHuman(AnnoFile=annot_file, Filter='kpt&segm')
  File "/usr/local/lib/python3.6/dist-packages/ochumanApi/ochuman.py", line 53, in __init__
    self.keypoint_names = self.dataset['keypoint_names']
KeyError: 'keypoint_names
liruilong940607 commented 5 years ago

You should comment this line in your code: annot_file = './ochuman_coco_format_val_range_0.00_1.00.json'

ochuman_coco_format_XXX.json has COCO format so it should be loaded by coco api.