hyperpose.Config package¶
Submodules¶
hyperpose.Config.config_lopps module¶
hyperpose.Config.config_mbtopps module¶
hyperpose.Config.config_opps module¶
hyperpose.Config.config_ppn module¶
hyperpose.Config.define module¶
-
class
hyperpose.Config.define.
BACKBONE
(value)¶ Bases:
enum.Enum
An enumeration.
-
Default
= 0¶
-
Mobilenetv1
= 1¶
-
Mobilenetv2
= 6¶
-
Resnet18
= 3¶
-
Resnet50
= 4¶
-
Vgg16
= 7¶
-
Vgg19
= 2¶
-
Vggtiny
= 5¶
-
-
class
hyperpose.Config.define.
DATA
(value)¶ Bases:
enum.Enum
An enumeration.
-
MPII
= 1¶
-
MSCOCO
= 0¶
-
MULTIPLE
= 3¶
-
USERDEF
= 2¶
-
-
class
hyperpose.Config.define.
KUNGFU
(value)¶ Bases:
enum.Enum
An enumeration.
-
Pair_avg
= 2¶
-
Sync_avg
= 1¶
-
Sync_sgd
= 0¶
-
-
class
hyperpose.Config.define.
MODEL
(value)¶ Bases:
enum.Enum
An enumeration.
-
LightweightOpenpose
= 1¶
-
MobilenetThinOpenpose
= 3¶
-
Openpose
= 0¶
-
Pifpaf
= 4¶
-
PoseProposal
= 2¶
-
Module contents¶
-
hyperpose.Config.
get_config
()¶ get the config object with all the configuration information
get the config object based on the previous setting functions, the config object will be passed to the functions of Model and Dataset module to construct the system.
only the setting functions called before this get_config function is valid, thus use this function after all configuration done.
- Parameters
- None
- Returns
- config object
an edict object contains all the configuration information.
-
hyperpose.Config.
set_batch_size
(batch_size)¶ set the batch size in training
- Parameters
- arg1int
batch_size
- Returns
- None
-
hyperpose.Config.
set_data_format
(data_format)¶ set model dataformat
set the channel order of current model:
“channels_first” dataformat is faster in deployment“channels_last” dataformat is more common the integrated pipeline will automaticly adapt to the chosen data format- Parameters
- arg1string
available input:
- | ‘channels_first’: data_shape N*C*H*W
- | ‘channels_last’: data_shape N*H*W*C
- Returns
- None
-
hyperpose.Config.
set_dataset_filter
(dataset_filter)¶ set the user defined dataset filter
set the dataset filter as the input function. to uniformly format different dataset, Hyperpose organize the annotations of one image in one dataset in the similiar meta classes. for COCO dataset, it is COCOMeta; for MPII dataset, it is MPIIMeta. Meta classes will have some common information such as image_id, joint_list etc, they also have some dataset-specific imformation, such as mask, is_crowd, headbbx_list etc.
the dataset_fiter will perform on the Meta objects of the corresponding dataset, if it returns True, the image and annotaions the Meta object related will be kept, otherwise it will be filtered out. Please refer the Dataset.xxxMeta classes for better use.
- Parameters
- arg1function
a function receive a meta object as input, return a bool value indicates whether the meta should be kept or filtered out. return Ture for keeping and False for depricating the object. default: None
- Returns
- None
-
hyperpose.Config.
set_dataset_path
(dataset_path)¶ set the path of the dataset
set the path of the directory where dataset is,if the dataset doesn’t exist in this directory, then it will be automaticly download in this directory and decoded.
- Parameters
- arg1String
a string indicates the path of the dataset, default: ./data
- Returns
- None
-
hyperpose.Config.
set_dataset_type
(dataset_type)¶ set the dataset for train and evaluate
set which dataset to use, the process of downlaoding, decoding, reformatting of different type of dataset is automatic. the evaluation metric of different dataset follows their official metric, for COCO is MAP, for MPII is MPCH.
This API also receive user-defined dataset class, which should implement the following functions
__init__: take the config object with all configuration to init the datasetget_parts: return a enum class which defines the key point definition of the datasetget_limbs: return a [2*num_limbs] array which defines the limb definition of the datasetget_colors: return a list which defines the visualization color of the limbsget_train_dataset: return a tensorflow dataset which contains elements for training. each element should contains an image path and a target dict decoded in bytes by _pickleget_eval_dataset: return a tensorflow dataset which contains elements for evaluating. each element should contains an image path and an image idofficial_eval: if want to evaluate on this user-defined dataset, evalutation function should be implemented. one can refer the Dataset.mpii_dataset and Dataset.mscoco_dataset for detailed information.- Parameters
- arg1Config.DATA
a enum value of enum class Config.DATA or user-defined dataset available options:
- | Config.DATA.MSCOCO
- | Config.DATA.MPII
- | user-defined dataset
- Returns
- None
-
hyperpose.Config.
set_dataset_version
(dataset_version)¶
-
hyperpose.Config.
set_domainadapt_dataset
(domainadapt_train_img_paths, domainadapt_scale_rate=1)¶
-
hyperpose.Config.
set_kungfu_option
(kungfu_option)¶ set the optimizor of parallel training
kungfu distribute training library needs to wrap tensorflow optimizor in kungfu optimizor, this function is to choose kungfu optimizor wrap type
- Parameters
- arg1Config.KUNGFU
a enum value of enum class Config.KUNGFU available options:
- | Config.KUNGFU.Sync_sgd (SynchronousSGDOptimizer, hyper-parameter-robus)
- | Config.KUNGFU.Sync_avg (SynchronousAveragingOptimizer)
- | Config.KUNGFU.Pair_avg (PairAveragingOptimizer, communication-efficient)
- Returns
- None
-
hyperpose.Config.
set_learning_rate
(learning_rate)¶ set the learning rate in training
- Parameters
- arg1float
learning rate
- Returns
- None
-
hyperpose.Config.
set_log_interval
(log_interval)¶ set the frequency of logging
set the how many iteration intervals between two log information
- Parameters
- arg1Int
a int value indicates the iteration number bwteen two logs default: 1
- Returns
- None
-
hyperpose.Config.
set_model_arch
(model_arch)¶ set user defined model architecture
replace default model architecture with user-defined model architecture, use it in the following training and evaluation
- Parameters
- arg1tensorlayer.models.MODEL
An object of a model class inherit from tensorlayer.models.MODEL class, should implement forward function and cal_loss function to make it compatible with the existing pipeline
The forward funtion should follow the signature below:
- | openpose models: def forward(self,x,is_train=False) ,return conf_map,paf_map,stage_confs,stage_pafs
- | poseproposal models: def forward(self,x,is_train=False), return pc,pi,px,py,pw,ph,pe
The cal_loss function should follow the signature below:
- | openpose models: def cal_loss(self,stage_confs,stage_pafs,gt_conf,gt_paf,mask), return loss,loss_confs,loss_pafs
- | poseproposal models: def cal_loss(self,tc,tx,ty,tw,th,te,te_mask,pc,pi,px,py,pw,ph,pe):
return loss_rsp,loss_iou,loss_coor,loss_size,loss_limb
- Returns
- None
-
hyperpose.Config.
set_model_backbone
(model_backbone)¶ set preset model backbones
set current model backbone to other common backbones different backbones have different computation complexity this enable dynamicly adapt the model architecture to approriate size.
- Parameters
- arg1Config.BACKBONE
a enum value of enum class Config.BACKBONE available options:
- | Config.BACKBONE.DEFUALT (default backbone of the architecture)
- | Config.BACKBONE.MobilenetV1
- | Config.BACKBONE.MobilenetV2
- | Config.BACKBONE.Vggtiny
- | Config.BACKBONE.Vgg16
- | Config.BACKBONE.Vgg19
- | Config.BACKBONE.Resnet18
- | Config.BACKBONE.Resnet50
- Returns
- None
-
hyperpose.Config.
set_model_limbs
(userdef_limbs)¶
-
hyperpose.Config.
set_model_name
(model_name)¶ set the name of model
the models are distinguished by their names,so it is necessary to set model’s name when train multiple models at the same time. each model’s ckpt data and log are saved on the ‘save_dir/model_name’ directory, the following directory are determined:
directory to save model ./save_dir/model_name/model_dirdirectory to save train result ./save_dir/model_name/train_vis_dirdirectory to save evaluate result ./save_dir/model_name/eval_vis_dirdirectory to save dataset visualize result ./save_dir/model_name/data_vis_dirfile path to save train log ./save_dir/model_name/log.txt- Parameters
- arg1string
name of the model
- Returns
- None
-
hyperpose.Config.
set_model_parts
(userdef_parts)¶
-
hyperpose.Config.
set_model_type
(model_type)¶ set preset model architecture
configure the model architecture as one of the desired preset model architectures
- Parameters
- arg1Config.MODEL
a enum value of enum class Config.MODEL, available options:
- | Config.MODEL.Openpose (original Openpose)
- | Config.MODEL.LightweightOpenpose (lightweight variant version of Openpose,real-time on cpu)
- | Config.MODEL.PoseProposal (pose proposal network)
- | Config.MODEL.MobilenetThinOpenpose (lightweight variant version of openpose)
- Returns
- None
-
hyperpose.Config.
set_multiple_dataset
(multiple_dataset_configs)¶
-
hyperpose.Config.
set_official_dataset
(official_flag)¶
-
hyperpose.Config.
set_optim_type
(optim_type)¶
-
hyperpose.Config.
set_pretrain
(enable)¶
-
hyperpose.Config.
set_pretrain_dataset_path
(pretrain_dataset_path)¶
-
hyperpose.Config.
set_save_interval
(save_interval)¶
-
hyperpose.Config.
set_train_type
(train_type)¶ set single_train or parallel train
default using single train, which train the model on one GPU. set parallel train will use Kungfu library to accelerate training on multiple GPU.
to use parallel train better, it is also allow to set parallel training optimizor by set_kungfu_option.
- Parameters
- arg1Config.TRAIN
a enum value of enum class Config.TRAIN,available options:
- | Config.TRAIN.Single_train
- | Config.TRAIN.Parallel_train
- Returns
- None
-
hyperpose.Config.
set_useradd_data
(useradd_train_img_paths, useradd_train_targets, useradd_scale_rate=1)¶
-
hyperpose.Config.
set_userdef_dataset
(userdef_dataset)¶