def __read_json(self, root_dir, json_path): item_list = [] for item in JsonHelper.load_file(json_path): img_path = os.path.join(root_dir, item['image_path']) if not os.path.exists(img_path) or not ImageHelper.is_img(img_path): Log.error('Image Path: {} is Invalid.'.format(img_path)) exit(1) item_list.append((img_path, '.'.join(item['image_path'].split('.')[:-1]))) Log.info('There are {} images..'.format(len(item_list))) return item_list
def __read_json_file(self, json_file): """ filename: JSON file return: three list: key_points list, centers list and scales list. """ json_dict = JsonHelper.load_file(json_file) kpts = list() bboxes = list() for object in json_dict['objects']: kpts.append(object['keypoints']) if 'bbox' in object: bboxes.append(object['bbox']) return np.array(kpts).astype(np.float32), np.array(bboxes).astype(np.float32)
def __read_json_file(self, json_file): """ filename: JSON file return: three list: key_points list, centers list and scales list. """ json_dict = JsonHelper.load_file(json_file) labels = list() bboxes = list() for object in json_dict['objects']: if 'difficult' in object and object[ 'difficult'] and not self.configer.get( 'data', 'keep_difficult'): continue labels.append(object['label']) bboxes.append(object['bbox']) return np.array(bboxes).astype(np.float32), np.array(labels)