deeplabcut.pose_estimation_pytorch.apis.export
Code to export DeepLabCut models for DLCLive inference.
Functions:
| Name | Description |
|---|---|
export_model |
Export DeepLabCut models for live inference. |
get_export_filename |
Args: |
get_export_folder_name |
Args: |
wipe_paths_from_model_config |
Removes all paths from the contents of the |
export_model
export_model(
config: str | Path,
shuffle: int = 1,
trainingsetindex: int = 0,
snapshotindex: int | None = None,
detector_snapshot_index: int | None = None,
iteration: int | None = None,
overwrite: bool = False,
wipe_paths: bool = False,
without_detector: bool = False,
modelprefix: str | None = None,
) -> None
Export DeepLabCut models for live inference.
Saves the pytorch_config.yaml configuration, snapshot files, of the model to a directory named exported-models-pytorch within the project directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path
|
Path of the project configuration file |
required |
|
The shuffle of the model to export. |
required | |
|
int
|
The index of the training fraction for the model you wish to export. |
0
|
|
int | None
|
The snapshot index for the weights you wish to export. If None,
uses the snapshotindex as defined in |
None
|
|
int | None
|
Only for TD models. If defined, uses the detector with
the given index for pose estimation. If None, uses the snapshotindex as
defined in the project |
None
|
|
int | None
|
The project iteration (active learning loop) you wish to export. If None, the iteration listed in the project config file is used. |
None
|
|
bool, optional If the model you wish to export has already been exported, whether to overwrite. default = False |
required | |
|
bool, optional
Removes the actual path of your project and the init_weights from the
|
required | |
|
bool
|
bool, optional Exports top-down models without the detector. |
False
|
|
str | None
|
Directory containing the deeplabcut models to use when evaluating the network. By default, the models are assumed to exist in the project folder. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no snapshots could be found for the shuffle. |
ValueError
|
If a top-down model is exported but no detector snapshots are found. |
Examples:
Export the last stored snapshot for model trained with shuffle 3:
>>> import deeplabcut
>>> deeplabcut.export_model(
>>> "/analysis/project/reaching-task/config.yaml",
>>> shuffle=3,
>>> snapshotindex=-1,
>>> )
Source code in deeplabcut/pose_estimation_pytorch/apis/export.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 | |
get_export_filename
get_export_filename(loader: DLCLoader, snapshot: Snapshot, detector_snapshot: Snapshot | None = None) -> str
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
DLCLoader
|
The loader for the shuffle for which we want to export models. |
required |
|
Snapshot
|
The pose model snapshot to export. |
required |
|
Snapshot | None
|
The detector snapshot to export, for top-down models. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The name of the file in which the exported model should be stored. |
Source code in deeplabcut/pose_estimation_pytorch/apis/export.py
get_export_folder_name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
DLCLoader
|
The loader for the shuffle for which we want to export models. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The name of the folder in which exported models should be placed for a shuffle. |
Source code in deeplabcut/pose_estimation_pytorch/apis/export.py
wipe_paths_from_model_config
Removes all paths from the contents of the pytorch_config file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
The model configuration to wipe. |
required |