deeplabcut.pose_estimation_tensorflow.export
Functions:
| Name | Description |
|---|---|
create_deploy_config_template |
TODO: WIP |
export_model |
Export DeepLabCut models for the model zoo or for live inference. |
load_model |
Loads a tensorflow session with a DLC model from the associated configuration |
tf_to_pb |
Saves a frozen tensorflow graph (a protobuf file). |
write_deploy_config |
CURRENTLY NOT IMPLEMENTED. |
create_deploy_config_template
TODO: WIP
Creates a template for config.yaml file. This specific order is preserved while saving as yaml file.
Source code in deeplabcut/pose_estimation_tensorflow/export.py
export_model
export_model(
cfg_path,
shuffle=1,
trainingsetindex=0,
snapshotindex=None,
iteration=None,
TFGPUinference=True,
overwrite=False,
make_tar=True,
wipepaths=False,
modelprefix="",
)
Export DeepLabCut models for the model zoo or for live inference.
Saves the pose configuration, snapshot files, and frozen TF graph of the model to directory named exported-models within the project directory
Parameters
string
path to the DLC Project config.yaml file
int, optional
the shuffle of the model to export. default = 1
int, optional
the index of the training fraction for the model you wish to export. default = 1
int, optional
the snapshot index for the weights you wish to export. If None, uses the snapshotindex as defined in 'config.yaml'. Default = None
int, optional
The model iteration (active learning loop) you wish to export. If None, the iteration listed in the config file is used.
bool, optional
use the tensorflow inference model? Default = True For inference using DeepLabCut-live, it is recommended to set TFGPIinference=False
bool, optional
if the model you wish to export has already been exported, whether to overwrite. default = False
bool, optional
Do you want to compress the exported directory to a tar file? Default = True This is necessary to export to the model zoo, but not for live inference.
bool, optional
Removes the actual path of your project and the init_weights from pose_cfg.
Example:
Export the first stored snapshot for model trained with shuffle 3:
deeplabcut.export_model('/analysis/project/reaching-task/config.yaml',shuffle=3, snapshotindex=-1)
Source code in deeplabcut/pose_estimation_tensorflow/export.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
load_model
Loads a tensorflow session with a DLC model from the associated configuration Return a tensorflow session with DLC model given cfg and shuffle.
Parameters:
cfg : dict Configuration read from the project's main config.yaml file
int, optional
which shuffle to use
int. optional
which training fraction to use, identified by its index
bool, optional
use tensorflow inference model? default = True
Returns:
sess : tensorflow session tensorflow session with DLC model from the provided configuration, shuffle, and trainingsetindex
string
the path to the checkpoint file associated with the loaded model
Source code in deeplabcut/pose_estimation_tensorflow/export.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
tf_to_pb
Saves a frozen tensorflow graph (a protobuf file). See also https://leimao.github.io/blog/Save-Load-Inference-From-TF-Frozen-Graph/
Parameters
sess : tensorflow session session with graph to be saved
string
checkpoint of tensorflow model to be converted to protobuf (output will be
list of strings
list of the names of output nodes (is returned by load_models)
string, optional
path to the directory that exported models should be saved to. If None, will export to the directory of the checkpoint file.
Source code in deeplabcut/pose_estimation_tensorflow/export.py
write_deploy_config
CURRENTLY NOT IMPLEMENTED.
Write structured config file.