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 |
Load 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:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Path to the DLC Project config.yaml file. |
required |
|
int
|
The shuffle of the model to export. Defaults to 1. |
1
|
|
int
|
The index of the training fraction for the model you wish to export. Defaults to 1. |
0
|
|
int
|
The snapshot index for the weights you wish to export. If None, uses the snapshotindex as defined in 'config.yaml'. Defaults to None. |
None
|
|
int
|
The model iteration (active learning loop) you wish to export. If None, the iteration listed in the config file is used. |
None
|
|
bool
|
Use the tensorflow inference model? Default = True. For inference using DeepLabCut-live, it is recommended to set TFGPIinference=False. |
True
|
|
bool
|
If the model you wish to export has already been exported, whether to overwrite. Defaults to False. |
False
|
|
bool
|
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. |
True
|
|
bool
|
Removes the actual path of your project and the init_weights from pose_cfg. |
False
|
Examples:
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
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 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 | |
load_model
Load a TensorFlow session with a DLC model from the associated configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
Configuration read from the project's main config.yaml file. |
required |
|
int
|
Which shuffle to use. |
1
|
|
int
|
Which training fraction to use, identified by its index. |
0
|
|
bool
|
Use tensorflow inference model? Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
sess, input, output, and dlc_cfg where sess is a tensorflow session with DLC model from the provided configuration, shuffle, and trainingsetindex. |
Source code in deeplabcut/pose_estimation_tensorflow/export.py
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:
| Name | Type | Description | Default |
|---|---|---|---|
|
Session with graph to be saved. |
required | |
|
string
|
Checkpoint of tensorflow model to be converted to protobuf
(output will be |
required |
|
list of strings
|
List of the names of output nodes (is returned by load_models). |
required |
|
string
|
Path to the directory that exported models should be saved to. If None, will export to the directory of the checkpoint file. |
None
|
Source code in deeplabcut/pose_estimation_tensorflow/export.py
write_deploy_config
CURRENTLY NOT IMPLEMENTED.
Write structured config file.