train.py
Code adapted from the Mathis Lab MIT License Copyright (c) 2022 Mackenzie Mathis DataJoint Schema for DeepLabCut 2.x, Supports 2D and 3D DLC via triangulation.
activate(train_schema_name, *, create_schema=True, create_tables=True, linking_module=None)
¶
Activate this schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_schema_name |
str
|
schema name on the database server |
required |
create_schema |
bool
|
when True (default), create schema in the database if it does not yet exist. |
True
|
create_tables |
bool
|
when True (default), create schema tables in the database if they do not yet exist. |
True
|
linking_module |
str
|
a module (or name) containing the required dependencies. |
None
|
Dependencies: Functions: get_dlc_root_data_dir(): Returns absolute path for root data director(y/ies) with all behavioral recordings, as (list of) string(s). get_dlc_processed_data_dir(): Optional. Returns absolute path for processed data. Defaults to session video subfolder.
Source code in element_deeplabcut/train.py
21 22 23 24 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 |
|
get_dlc_root_data_dir()
¶
Pulls relevant func from parent namespace to specify root data dir(s).
It is recommended that all paths in DataJoint Elements stored as relative paths, with respect to some user-configured "root" director(y/ies). The root(s) may vary between data modalities and user machines. Returns a full path string or list of strings for possible root data directories.
Source code in element_deeplabcut/train.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
get_dlc_processed_data_dir()
¶
Pulls relevant func from parent namespace. Defaults to DLC's project /videos/.
Method in parent namespace should provide a string to a directory where DLC output files will be stored. If unspecified, output files will be stored in the session directory 'videos' folder, per DeepLabCut default.
Source code in element_deeplabcut/train.py
91 92 93 94 95 96 97 98 99 100 101 |
|
VideoSet
¶
Bases: Manual
Collection of videos included in a given training set.
Attributes:
Name | Type | Description |
---|---|---|
video_set_id |
int
|
Unique ID for collection of videos. |
Source code in element_deeplabcut/train.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
File
¶
Bases: Part
File IDs and paths in a given VideoSet
Attributes:
Name | Type | Description |
---|---|---|
VideoSet |
foreign key
|
VideoSet key. |
file_path |
varchar(255)
|
Path to file on disk relative to root. |
Source code in element_deeplabcut/train.py
118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
TrainingParamSet
¶
Bases: Lookup
Parameters used to train a model
Attributes:
Name | Type | Description |
---|---|---|
paramset_idx |
smallint
|
Index uniqely identifying paramset. |
paramset_desc |
varchar(128)
|
Description of paramset. |
param_set_hash |
uuid
|
Hash identifying this paramset. |
params |
longblob
|
Dictionary of all applicable parameters. |
Note |
longblob
|
param_set_hash must be unique. |
Source code in element_deeplabcut/train.py
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
insert_new_params(paramset_desc, params, paramset_idx=None)
classmethod
¶
Insert a new set of training parameters into dlc.TrainingParamSet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
paramset_desc |
str
|
Description of parameter set to be inserted |
required |
params |
dict
|
Dictionary including all settings to specify model training. Must include shuffle & trainingsetindex b/c not in config.yaml. project_path and video_sets will be overwritten by config.yaml. Note that trainingsetindex is 0-indexed |
required |
paramset_idx |
int
|
optional, integer to represent parameters. |
None
|
Source code in element_deeplabcut/train.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
TrainingTask
¶
Bases: Manual
Staging table for pairing videosets and training parameter sets
Attributes:
Name | Type | Description |
---|---|---|
VideoSet |
foreign key
|
VideoSet Key. |
TrainingParamSet |
foreign key
|
TrainingParamSet key. |
training_id |
int
|
Unique ID for training task. |
model_prefix |
varchar(32)
|
Optional. Prefix for model files. |
project_path |
varchar(255)
|
Optional. DLC's project_path in config relative to get_dlc_root_data_dir |
Source code in element_deeplabcut/train.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
ModelTraining
¶
Bases: Computed
Automated Model training information.
Attributes:
Name | Type | Description |
---|---|---|
TrainingTask |
foreign key
|
TrainingTask key. |
latest_snapshot |
int unsigned
|
Latest exact snapshot index (i.e., never -1). |
config_template |
longblob
|
Stored full config file. |
Source code in element_deeplabcut/train.py
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 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
|