def load_mpii_pose_dataset(path='<STR_LIT:data>', is_16_pos_only=False):
path = os.path.join(path, '<STR_LIT>')<EOL>logging.info("<STR_LIT>".format(path))<EOL>url = "<STR_LIT>"<EOL>tar_filename = "<STR_LIT>"<EOL>extracted_filename = "<STR_LIT>"<EOL>if folder_exists(os.path.join(path, extracted_filename)) is False:<EOL><INDENT>logging.info("<STR_LIT>".format(extracted_filename, path))<EOL>maybe_download_and_extract(tar_filename, path, url, extract=True)<EOL>del_file(os.path.join(path, tar_filename))<EOL><DEDENT>url = "<STR_LIT>"<EOL>tar_filename = "<STR_LIT>"<EOL>extracted_filename2 = "<STR_LIT>"<EOL>if folder_exists(os.path.join(path, extracted_filename2)) is False:<EOL><INDENT>logging.info("<STR_LIT>".format(extracted_filename, path))<EOL>maybe_download_and_extract(tar_filename, path, url, extract=True)<EOL>del_file(os.path.join(path, tar_filename))<EOL><DEDENT>logging.info("<STR_LIT>")<EOL>ann_train_list = []<EOL>ann_test_list = []<EOL>img_train_list = []<EOL>img_test_list = []<EOL>def save_joints():<EOL><INDENT>mat = sio.loadmat(os.path.join(path, extracted_filename, "<STR_LIT>"))<EOL>for _, (anno, train_flag) in enumerate(  <EOL>zip(mat['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>, <NUM_LIT:0>][<NUM_LIT:0>], mat['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>, <NUM_LIT:0>][<NUM_LIT:0>])):<EOL><INDENT>img_fn = anno['<STR_LIT:image>']['<STR_LIT:name>'][<NUM_LIT:0>, <NUM_LIT:0>][<NUM_LIT:0>]<EOL>train_flag = int(train_flag)<EOL>if train_flag:<EOL><INDENT>img_train_list.append(img_fn)<EOL>ann_train_list.append([])<EOL><DEDENT>else:<EOL><INDENT>img_test_list.append(img_fn)<EOL>ann_test_list.append([])<EOL><DEDENT>head_rect = []<EOL>if '<STR_LIT>' in str(anno['<STR_LIT>'].dtype):<EOL><INDENT>head_rect = zip(<EOL>[x1[<NUM_LIT:0>, <NUM_LIT:0>] for x1 in anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]], [y1[<NUM_LIT:0>, <NUM_LIT:0>] for y1 in anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]],<EOL>[x2[<NUM_LIT:0>, <NUM_LIT:0>] for x2 in anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]], [y2[<NUM_LIT:0>, <NUM_LIT:0>] for y2 in anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]]<EOL>)<EOL><DEDENT>else:<EOL><INDENT>head_rect = []  <EOL><DEDENT>if '<STR_LIT>' in str(anno['<STR_LIT>'].dtype):<EOL><INDENT>annopoints = anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]<EOL>head_x1s = anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]<EOL>head_y1s = anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]<EOL>head_x2s = anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]<EOL>head_y2s = anno['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]<EOL>for annopoint, head_x1, head_y1, head_x2, head_y2 in zip(annopoints, head_x1s, head_y1s, head_x2s,<EOL>head_y2s):<EOL><INDENT>if annopoint.size:<EOL><INDENT>head_rect = [<EOL>float(head_x1[<NUM_LIT:0>, <NUM_LIT:0>]),<EOL>float(head_y1[<NUM_LIT:0>, <NUM_LIT:0>]),<EOL>float(head_x2[<NUM_LIT:0>, <NUM_LIT:0>]),<EOL>float(head_y2[<NUM_LIT:0>, <NUM_LIT:0>])<EOL>]<EOL>annopoint = annopoint['<STR_LIT>'][<NUM_LIT:0>, <NUM_LIT:0>]<EOL>j_id = [str(j_i[<NUM_LIT:0>, <NUM_LIT:0>]) for j_i in annopoint['<STR_LIT:id>'][<NUM_LIT:0>]]<EOL>x = [x[<NUM_LIT:0>, <NUM_LIT:0>] for x in annopoint['<STR_LIT:x>'][<NUM_LIT:0>]]<EOL>y = [y[<NUM_LIT:0>, <NUM_LIT:0>] for y in annopoint['<STR_LIT:y>'][<NUM_LIT:0>]]<EOL>joint_pos = {}<EOL>for _j_id, (_x, _y) in zip(j_id, zip(x, y)):<EOL><INDENT>joint_pos[int(_j_id)] = [float(_x), float(_y)]<EOL><DEDENT>if '<STR_LIT>' in str(annopoint.dtype):<EOL><INDENT>vis = [v[<NUM_LIT:0>] if v.size > <NUM_LIT:0> else [<NUM_LIT:0>] for v in annopoint['<STR_LIT>'][<NUM_LIT:0>]]<EOL>vis = dict([(k, int(v[<NUM_LIT:0>])) if len(v) > <NUM_LIT:0> else v for k, v in zip(j_id, vis)])<EOL><DEDENT>else:<EOL><INDENT>vis = None<EOL><DEDENT>if ((is_16_pos_only ==True) and (len(joint_pos) == <NUM_LIT:16>)) or (is_16_pos_only == False):<EOL><INDENT>data = {<EOL>'<STR_LIT:filename>': img_fn,<EOL>'<STR_LIT:train>': train_flag,<EOL>'<STR_LIT>': head_rect,<EOL>'<STR_LIT>': vis,<EOL>'<STR_LIT>': joint_pos<EOL>}<EOL>if train_flag:<EOL><INDENT>ann_train_list[-<NUM_LIT:1>].append(data)<EOL><DEDENT>else:<EOL><INDENT>ann_test_list[-<NUM_LIT:1>].append(data)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>save_joints()<EOL>logging.info("<STR_LIT>")<EOL>img_dir = os.path.join(path, extracted_filename2)<EOL>_img_list = load_file_list(path=os.path.join(path, extracted_filename2), regx='<STR_LIT>', printable=False)<EOL>for i, im in enumerate(img_train_list):<EOL><INDENT>if im not in _img_list:<EOL><INDENT>print('<STR_LIT>'.format(im, img_dir))<EOL>del img_train_list[i]<EOL>del ann_train_list[i]<EOL><DEDENT><DEDENT>for i, im in enumerate(img_test_list):<EOL><INDENT>if im not in _img_list:<EOL><INDENT>print('<STR_LIT>'.format(im, img_dir))<EOL>del img_train_list[i]<EOL>del ann_train_list[i]<EOL><DEDENT><DEDENT>n_train_images = len(img_train_list)<EOL>n_test_images = len(img_test_list)<EOL>n_images = n_train_images + n_test_images<EOL>logging.info("<STR_LIT>".format(n_images, n_train_images, n_test_images))<EOL>n_train_ann = len(ann_train_list)<EOL>n_test_ann = len(ann_test_list)<EOL>n_ann = n_train_ann + n_test_ann<EOL>logging.info("<STR_LIT>".format(n_ann, n_train_ann, n_test_ann))<EOL>n_train_people = len(sum(ann_train_list, []))<EOL>n_test_people = len(sum(ann_test_list, []))<EOL>n_people = n_train_people + n_test_people<EOL>logging.info("<STR_LIT>".format(n_people, n_train_people, n_test_people))<EOL>for i, value in enumerate(img_train_list):<EOL><INDENT>img_train_list[i] = os.path.join(img_dir, value)<EOL><DEDENT>for i, value in enumerate(img_test_list):<EOL><INDENT>img_test_list[i] = os.path.join(img_dir, value)<EOL><DEDENT>return img_train_list, ann_train_list, img_test_list, ann_test_list<EOL>
Load MPII Human Pose Dataset.

    Parameters
    -----------
    path : str
        The path that the data is downloaded to.
    is_16_pos_only : boolean
        If True, only return the peoples contain 16 pose keypoints. (Usually be used for single person pose estimation)

    Returns
    ----------
    img_train_list : list of str
        The image directories of training data.
    ann_train_list : list of dict
        The annotations of training data.
    img_test_list : list of str
        The image directories of testing data.
    ann_test_list : list of dict
        The annotations of testing data.

    Examples
    --------
    >>> import pprint
    >>> import tensorlayer as tl
    >>> img_train_list, ann_train_list, img_test_list, ann_test_list = tl.files.load_mpii_pose_dataset()
    >>> image = tl.vis.read_image(img_train_list[0])
    >>> tl.vis.draw_mpii_pose_to_image(image, ann_train_list[0], 'image.png')
    >>> pprint.pprint(ann_train_list[0])

    References
    -----------
    - `MPII Human Pose Dataset. CVPR 14 <http://human-pose.mpi-inf.mpg.de>`__
    - `MPII Human Pose Models. CVPR 16 <http://pose.mpi-inf.mpg.de>`__
    - `MPII Human Shape, Poselet Conditioned Pictorial Structures and etc <http://pose.mpi-inf.mpg.de/#related>`__
    - `MPII Keyponts and ID <http://human-pose.mpi-inf.mpg.de/#download>`__