Closed yxchng closed 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
You should comment this line in your code: annot_file = './ochuman_coco_format_val_range_0.00_1.00.json'
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.
ochuman_coco_format_XXX.json
I use the following code:
But it gives the error