(anno_file, return_dict)
return annotations
Convert annotation JSON file.
Convert annotation JSON file.
Convert annotation JSON file .
def load_annotations(anno_file, return_dict):
    """Convert annotation JSON file."""

    annotations = dict()
    annotations['image_ids'] = set([])
    annotations['annos'] = dict()
    annotations['delta'] = 2*np.array([0.01388152, 0.01515228, 0.01057665, 0.01417709, \
                                       0.01497891, 0.01402144, 0.03909642, 0.03686941, 0.01981803, \
                                       0.03843971, 0.03412318, 0.02415081, 0.01291456, 0.01236173])
    try:
        annos = json.load(open(anno_file, 'r'))
    except Exception:
        return_dict['error'] = 'Annotation file does not exist or is an invalid JSON file.'
        exit(return_dict['error'])

    for anno in annos:
        annotations['image_ids'].add(anno['image_id'])
        annotations['annos'][anno['image_id']] = dict()
        annotations['annos'][anno['image_id']]['human_annos'] = anno['human_annotations']
        annotations['annos'][anno['image_id']]['keypoint_annos'] = anno['keypoint_annotations']

    return annotations
def load_annotations ( anno_file , return_dict ) : annotations = dict ( ) annotations [ 'image_ids' ] = set ( [ ] ) annotations [ 'annos' ] = dict ( ) annotations [ 'delta' ] = 2 * np . array ( [ 0.01388152 , 0.01515228 , 0.01057665 , 0.01417709 , 0.01497891 , 0.01402144 , 0.03909642 , 0.03686941 , 0.01981803 , 0.03843971 , 0.03412318 , 0.02415081 , 0.01291456 , 0.01236173 ] ) try : annos = json . load ( open ( anno_file , 'r' ) ) except Exception : return_dict [ 'error' ] = 'Annotation file does not exist or is an invalid JSON file.' exit ( return_dict [ 'error' ] ) for anno in annos : annotations [ 'image_ids' ] . add ( anno [ 'image_id' ] ) annotations [ 'annos' ] [ anno [ 'image_id' ] ] = dict ( ) annotations [ 'annos' ] [ anno [ 'image_id' ] ] [ 'human_annos' ] = anno [ 'human_annotations' ] annotations [ 'annos' ] [ anno [ 'image_id' ] ] [ 'keypoint_annos' ] = anno [ 'keypoint_annotations' ] return annotations