hyperpose.Model.openpose package

Subpackages

Submodules

hyperpose.Model.openpose.define module

class hyperpose.Model.openpose.define.CocoPart(value)

Bases: enum.Enum

An enumeration.

Background = 18
LAnkle = 13
LEar = 17
LElbow = 6
LEye = 15
LHip = 11
LKnee = 12
LShoulder = 5
LWrist = 7
Neck = 1
Nose = 0
RAnkle = 10
REar = 16
RElbow = 3
REye = 14
RHip = 8
RKnee = 9
RShoulder = 2
RWrist = 4
class hyperpose.Model.openpose.define.MpiiPart(value)

Bases: enum.Enum

An enumeration.

Background = 15
Center = 14
Headtop = 0
LAnkle = 13
LElbow = 6
LHip = 11
LKnee = 12
LShoulder = 5
LWrist = 7
Neck = 1
RAnkle = 10
RElbow = 3
RHip = 8
RKnee = 9
RShoulder = 2
RWrist = 4
hyperpose.Model.openpose.define.get_coco_flip_list()
hyperpose.Model.openpose.define.get_mpii_flip_list()

hyperpose.Model.openpose.eval module

hyperpose.Model.openpose.eval.evaluate(model, dataset, config, vis_num=30, total_eval_num=10000, enable_multiscale_search=True)

evaluate pipeline of Openpose class models

input model and dataset, the evaluate pipeline will start automaticly the evaluate pipeline will: 1.loading newest model at path ./save_dir/model_name/model_dir/newest_model.npz 2.perform inference and parsing over the chosen evaluate dataset 3.visualize model output in evaluation in directory ./save_dir/model_name/eval_vis_dir 4.output model metrics by calling dataset.official_eval()

Parameters
arg1tensorlayer.models.MODEL

a preset or user defined model object, obtained by Model.get_model() function

arg2dataset

a constructed dataset object, obtained by Dataset.get_dataset() function

arg3Int

an Integer indicates how many model output should be visualized

arg4Int

an Integer indicates how many images should be evaluated

Returns
None
hyperpose.Model.openpose.eval.infer_one_img(model, post_processor, img, img_id=- 1, enable_multiscale_search=False, is_visual=False, save_dir='./vis_dir')
hyperpose.Model.openpose.eval.test(model, dataset, config, vis_num=30, total_test_num=10000, enable_multiscale_search=True)

evaluate pipeline of Openpose class models

input model and dataset, the evaluate pipeline will start automaticly the evaluate pipeline will: 1.loading newest model at path ./save_dir/model_name/model_dir/newest_model.npz 2.perform inference and parsing over the chosen evaluate dataset 3.visualize model output in evaluation in directory ./save_dir/model_name/eval_vis_dir 4.output model metrics by calling dataset.official_eval()

Parameters
arg1tensorlayer.models.MODEL

a preset or user defined model object, obtained by Model.get_model() function

arg2dataset

a constructed dataset object, obtained by Dataset.get_dataset() function

arg3Int

an Integer indicates how many model output should be visualized

arg4Int

an Integer indicates how many images should be evaluated

Returns
None
hyperpose.Model.openpose.eval.visualize(img, img_id, humans, conf_map, paf_map, save_dir)

hyperpose.Model.openpose.infer module

hyperpose.Model.openpose.train module

hyperpose.Model.openpose.train.get_paramed_map_fn(augmentor, preprocessor, data_format='channels_first')
hyperpose.Model.openpose.train.parallel_train(train_model, dataset, config)

Parallel train pipeline of openpose class models

input model and dataset, the train pipeline will start automaticly the train pipeline will: 1.store and restore ckpt in directory ./save_dir/model_name/model_dir 2.log loss information in directory ./save_dir/model_name/log.txt 3.visualize model output periodly during training in directory ./save_dir/model_name/train_vis_dir the newest model is at path ./save_dir/model_name/model_dir/newest_model.npz

Parameters
arg1tensorlayer.models.MODEL

a preset or user defined model object, obtained by Model.get_model() function

arg2dataset

a constructed dataset object, obtained by Dataset.get_dataset() function

Returns
None
hyperpose.Model.openpose.train.single_train(train_model, dataset, config)

Single train pipeline of Openpose class models

input model and dataset, the train pipeline will start automaticly the train pipeline will: 1.store and restore ckpt in directory ./save_dir/model_name/model_dir 2.log loss information in directory ./save_dir/model_name/log.txt 3.visualize model output periodly during training in directory ./save_dir/model_name/train_vis_dir the newest model is at path ./save_dir/model_name/model_dir/newest_model.npz

Parameters
arg1tensorlayer.models.MODEL

a preset or user defined model object, obtained by Model.get_model() function

arg2dataset

a constructed dataset object, obtained by Dataset.get_dataset() function

Returns
None

hyperpose.Model.openpose.utils module

hyperpose.Model.openpose.utils.cal_vectormap_fast(vectormap, countmap, i, v_start, v_end)
hyperpose.Model.openpose.utils.cal_vectormap_ori(vectormap, countmap, i, v_start, v_end)
hyperpose.Model.openpose.utils.draw_results(images, heats_ground, heats_result, pafs_ground, pafs_result, masks, save_dir, name='', data_format='channels_first')

Save results for debugging.

Parameters
imagesa list of RGB images
heats_grounda list of keypoint heat maps or None
heats_resulta list of keypoint heat maps or None
pafs_grounda list of paf vector maps or None
pafs_resulta list of paf vector maps or None
masksa list of mask for people
hyperpose.Model.openpose.utils.get_colors(dataset_type)
hyperpose.Model.openpose.utils.get_flip_list(dataset_type)
hyperpose.Model.openpose.utils.get_heatmap(annos, height, width, hout, wout, parts, limbs, data_format='channels_first')
hyperpose.Model.openpose.utils.get_limbs(dataset_type)
hyperpose.Model.openpose.utils.get_parts(dataset_type)
hyperpose.Model.openpose.utils.get_vectormap(annos, height, width, hout, wout, parts, limbs, data_format='channels_first')
hyperpose.Model.openpose.utils.postprocess(conf_map, paf_map, img_h, img_w, parts, limbs, data_format='channels_first', colors=None)

postprocess function of openpose class models

take model predicted feature maps, output parsed human objects, each one contains all detected keypoints of the person

Parameters
arg1numpy array

model predicted conf_map, heatmaps of keypoints, shape C*H*W(channels_first) or H*W*C(channels_last)

arg2numpy array

model predicted paf_map, heatmaps of limbs, shape C*H*W(channels_first) or H*W*C(channels_last)

arg3Config.DATA

an enum value of enum class Config.DATA width of the model output, will be the width of the generated maps

arg4string

data format speficied for channel order available input: ‘channels_first’: data_shape C*H*W ‘channels_last’: data_shape H*W*C

Returns
list

contain object of humans,see Model.Human for detail information of Human object

hyperpose.Model.openpose.utils.preprocess(annos, img_height, img_width, model_hout, model_wout, parts, limbs, data_format='channels_first')

preprocess function of openpose class models

take keypoints annotations, image height and width, model input height and width, and dataset type, return the constructed conf_map and paf_map

Parameters
arg1list

a list of annotation, each annotation is a list of keypoints that belongs to a person, each keypoint follows the format (x,y), and x<0 or y<0 if the keypoint is not visible or not annotated. the annotations must from a known dataset_type, other wise the keypoint and limbs order will not be correct.

arg2Int

height of the input image, need this to make use of keypoint annotation

arg3Int

width of the input image, need this to make use of keypoint annotation

arg4Int

height of the model output, will be the height of the generated maps

arg5Int

width of the model output, will be the width of the generated maps

arg6Config.DATA

a enum value of enum class Config.DATA dataset_type where the input annotation list from, because to generate correct conf_map and paf_map, the order of keypoints and limbs should be awared.

arg7string

data format speficied for channel order available input: ‘channels_first’: data_shape C*H*W ‘channels_last’: data_shape H*W*C

Returns
list

including two element conf_map: heatmaps of keypoints, shape C*H*W(channels_first) or H*W*C(channels_last) paf_map: heatmaps of limbs, shape C*H*W(channels_first) or H*W*C(channels_last)

hyperpose.Model.openpose.utils.put_heatmap(heatmap, plane_idx, center, stride, sigma)
hyperpose.Model.openpose.utils.vis_annos(image, annos, save_dir, name='')

Save results for debugging.

Parameters
imagessingle RGB image
annosannotation, list of lists
hyperpose.Model.openpose.utils.visualize(img, conf_map, paf_map, save_name='maps', save_dir='./save_dir/vis_dir', data_format='channels_first', save_tofile=True)

visualize function of openpose class models

take model predict feature maps, output visualized image. the image will be saved at ‘save_dir’/’save_name’_visualize.png

Parameters
arg1numpy array

image

arg2numpy array

model output conf_map, heatmaps of keypoints, shape C*H*W(channels_first) or H*W*C(channels_last)

arg3numpy array

model output paf_map, heatmaps of limbs, shape C*H*W(channels_first) or H*W*C(channels_last)

arg4String

specify output image name to distinguish.

arg5String

specify which directory to save the visualized image.

arg6string

data format speficied for channel order available input: ‘channels_first’: data_shape C*H*W ‘channels_last’: data_shape H*W*C

Returns
None

Module contents