hyperpose.Model package

Subpackages

Submodules

hyperpose.Model.backbones module

hyperpose.Model.common module

class hyperpose.Model.common.MPIIPart(value)

Bases: enum.Enum

An enumeration.

Head = 13
LAnkle = 5
LElbow = 10
LHip = 3
LKnee = 4
LShoulder = 9
LWrist = 11
Neck = 12
RAnkle = 0
RElbow = 7
RHip = 2
RKnee = 1
RShoulder = 8
RWrist = 6
static from_coco(human)
class hyperpose.Model.common.Profiler

Bases: object

Methods

__call__(self, name, duration)

Call self as a function.

report

report(self)
hyperpose.Model.common.draw_humans(npimg, humans)
hyperpose.Model.common.get_op(graph, name)
hyperpose.Model.common.get_optim(optim_type)
hyperpose.Model.common.get_sample_images(w, h)
hyperpose.Model.common.init_log(config)
hyperpose.Model.common.load_graph(model_file)

Load a freezed graph from file.

hyperpose.Model.common.log(msg)
hyperpose.Model.common.measure(f, name=None)
hyperpose.Model.common.pad_image(img, stride, pad_value=0.0)
hyperpose.Model.common.pad_image_shape(img, shape, pad_value=0.0)
hyperpose.Model.common.plot_humans(image, heatMat, pafMat, humans, name)
hyperpose.Model.common.read_imgfile(path, width, height, data_format='channels_last')

Read image file and resize to network input size.

hyperpose.Model.common.regulize_loss(target_model, weight_decay_factor)
hyperpose.Model.common.rename_tensor(x, name)
hyperpose.Model.common.scale_image(image, hin, win, scale_rate=0.95)
hyperpose.Model.common.tf_repeat(tensor, repeats)

Args:

input: A Tensor. 1-D or higher. repeats: A list. Number of repeat for each dimension, length must be the same as the number of dimensions in input

Returns:

A Tensor. Has the same type as input. Has the shape of tensor.shape * repeats

hyperpose.Model.human module

class hyperpose.Model.human.BodyPart(parts, u_idx, part_idx, x, y, score, w=- 1, h=- 1)

Bases: object

part_idx : part index(eg. 0 for nose) x, y: coordinate of body part score : confidence score

Methods

get_part_name

get_x

get_y

get_part_name(self)
get_x(self)
get_y(self)
class hyperpose.Model.human.Human(parts, limbs, colors)

Bases: object

body_parts: list of BodyPart

Methods

bias

draw_human

get_area

get_bbx

get_global_id

get_partnum

get_score

print

scale

bias(self, bias_w, bias_h)
draw_human(self, img)
get_area(self)
get_bbx(self)
get_global_id(self)
get_partnum(self)
get_score(self)
print(self)
scale(self, scale_w, scale_h)

Module contents

hyperpose.Model.get_evaluate(config)

get evaluate pipeline based on config object

construct evaluate pipeline based on the chosen model_type and dataset_type, the evaluation metric fellows the official metrics of the chosen dataset.

the returned evaluate pipeline can be easily used by evaluate(model,dataset), where model is obtained by Model.get_model(), dataset is obtained by Dataset.get_dataset()

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
arg1config object

the config object return by Config.get_config() function, which includes all the configuration information.

Returns
function

a evaluate pipeline function which takes model and dataset as input, and output model metrics

hyperpose.Model.get_model(config)

get model based on config object

construct and return a model based on the configured model_type and model_backbone. each preset model architecture has a default backbone, replace it with chosen common model_backbones allow user to change model computation complexity to adapt to application scene.

Parameters
arg1config object

the config object return by Config.get_config() function, which includes all the configuration information.

Returns
tensorlayer.models.MODEL

a model object inherited from tensorlayer.models.MODEL class, has configured model architecture and chosen model backbone. can be user defined architecture by using Config.set_model_architecture() function.

hyperpose.Model.get_postprocessor(model_type)

get a postprocessor class based on the specified model_type

get the postprocessor class of the specified kind of model to help user directly construct their own evaluate pipeline(rather than using the integrated evaluate pipeline) or infer pipeline(to check the model utility) when in need.

the postprocessor is able to parse the model output feature map and output parsed human objects of Human class, which contains all dectected keypoints.

Parameters
arg1Config.MODEL

a enum value of enum class Config.MODEL

Returns
function

a postprocessor class of the specified kind of model

hyperpose.Model.get_preprocessor(model_type)

get a preprocessor class based on the specified model_type

get the preprocessor class of the specified kind of model to help user directly construct their own train pipeline(rather than using the integrated train pipeline) when in need.

the preprocessor class is able to construct a preprocessor object that could convert the image and annotation to the model output format for training.

Parameters
arg1Config.MODEL

a enum value of enum class Config.MODEL

Returns
class

a preprocessor class of the specified kind of model

hyperpose.Model.get_pretrain(config)
hyperpose.Model.get_test(config)

get test pipeline based on config object

construct test pipeline based on the chosen model_type and dataset_type, the test metric fellows the official metrics of the chosen dataset.

the returned test pipeline can be easily used by test(model,dataset), where model is obtained by Model.get_model(), dataset is obtained by Dataset.get_dataset()

the test 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 test dataset 3.visualize model output in test in directory ./save_dir/model_name/test_vis_dir 4.output model test result file at path ./save_dir/model_name/test_vis_dir/pd_ann.json 5.the test dataset ground truth is often preserved by the dataset creator, you may need to upload the test result file to the official server to get model test metrics

Parameters
arg1config object

the config object return by Config.get_config() function, which includes all the configuration information.

Returns
function

a test pipeline function which takes model and dataset as input, and output model metrics

hyperpose.Model.get_train(config)

get train pipeline based on config object

construct train pipeline based on the chosen model_type and dataset_type, default is single train pipeline performed on single GPU, can be parallel train pipeline use function Config.set_train_type()

the returned train pipeline can be easily used by train(model,dataset), where model is obtained by Model.get_model(), dataset is obtained by Dataset.get_dataset()

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
arg1config object

the config object return by Config.get_config() function, which includes all the configuration information.

Returns
function

a train pipeline function which takes model and dataset as input, can be either single train or parallel train pipeline.

hyperpose.Model.get_visualize(model_type)

get visualize function based model_type

get the visualize function of the specified kind of model to help user construct thier own evaluate pipeline rather than using the integrated train or evaluate pipeline directly when in need

the visualize function is able to visualize model’s output feature map, which is helpful for training and evaluation analysis.

Parameters
arg1Config.MODEL

a enum value of enum class Config.MODEL

Returns
function

a visualize function of the specified kind of model