예제 #1
0
def _parse_function(imgId, is_train, ann=None):
    """
    :param imgId:
    :return:
    """

    global TRAIN_ANNO
    global VALID_ANNO

    if ann is not None:
        if is_train == True:
            TRAIN_ANNO = ann
        else:
            VALID_ANNO = ann
    else:
        if is_train == True:
            anno = TRAIN_ANNO
        else:
            anno = VALID_ANNO

    img_meta = anno.loadImgs([imgId])[0]
    anno_ids = anno.getAnnIds(imgIds=imgId)
    img_anno = anno.loadAnns(anno_ids)
    idx = img_meta['id']
    img_path = join(BASE, img_meta['file_name'])

    img_meta_data = CocoMetadata(idx, img_path, img_meta, img_anno, sigma=6.0)
    img_meta_data = pose_random_scale(img_meta_data)
    img_meta_data = pose_rotation(img_meta_data)
    img_meta_data = pose_flip(img_meta_data)
    img_meta_data = pose_resize_shortestedge_random(img_meta_data)
    img_meta_data = pose_crop_random(img_meta_data)
    return pose_to_img(img_meta_data)
예제 #2
0
파일: dataset.py 프로젝트: mozpp/SinglePose
def _parse_function(imgId, is_train, ann=None):
    """
    :param imgId:
    :return:
    """

    global TRAIN_ANNO
    global VALID_ANNO

    if ann is not None:
        if is_train == True:
            TRAIN_ANNO = ann
        else:
            VALID_ANNO = ann
    else:
        if is_train == True:
            anno = TRAIN_ANNO
        else:
            anno = VALID_ANNO

    img_meta = anno.loadImgs([imgId])[0]
    anno_ids = anno.getAnnIds(imgIds=imgId)
    img_anno = anno.loadAnns(anno_ids)
    idx = img_meta['id']

    img_path = join(BASE, img_meta['file_name'])
    if SEG_MASK:
        mask_path = join(BASE_MASK_PATH, img_meta['file_name'])
    else:
        mask_path = None
    # print('img_path==>', is_train, img_path)
    # exit()
    img_meta_data = CocoMetadata(idx, img_path, img_meta, img_anno, sigma=6.0, mask_path=mask_path)  # 加载图像和kp标注
    # 先数据增强,再把kp标注转换为heatmap
    img_meta_data = pose_random_scale(img_meta_data, SEG_MASK)
    img_meta_data = pose_rotation(img_meta_data, SEG_MASK)
    img_meta_data = pose_flip(img_meta_data, SEG_MASK) #todo:multi task1.22改到这里
    img_meta_data = pose_resize_shortestedge_random(img_meta_data, SEG_MASK)
    img_meta_data = pose_crop_random(img_meta_data, SEG_MASK)

    return pose_to_img(img_meta_data, imgId)