1515
1616import deeplabcut .utils .auxiliaryfunctions as af
1717from deeplabcut .compat import Engine
18- from deeplabcut .pose_estimation_pytorch .config .utils import is_model_top_down
18+ from deeplabcut .pose_estimation_pytorch .config .utils import (
19+ is_model_top_down ,
20+ is_model_cond_top_down ,
21+ )
1922
2023from utils import (
2124 cleanup ,
@@ -38,6 +41,7 @@ def main(
3841 max_snapshots_to_keep : int = 5 ,
3942 device : str = "cpu" ,
4043 logger : dict | None = None ,
44+ conditions_shuffle : int = 0 ,
4145 create_labeled_videos : bool = False ,
4246 delete_after_test_run : bool = False ,
4347) -> None :
@@ -55,6 +59,23 @@ def main(
5559 if is_model_top_down (net_type ):
5660 epochs_ = top_down_epochs
5761 try :
62+ pytorch_cfg_updates = {
63+ "data.conditions.snapshot_index" : - 1 ,
64+ "train_settings.display_iters" : 50 ,
65+ "train_settings.epochs" : epochs_ ,
66+ "train_settings.batch_size" : batch_size ,
67+ "runner.device" : device ,
68+ "runner.snapshots.save_epochs" : save_epochs ,
69+ "runner.snapshots.max_snapshots" : max_snapshots_to_keep ,
70+ "detector.train_settings.display_iters" : 1 ,
71+ "detector.train_settings.epochs" : detector_epochs ,
72+ "detector.train_settings.batch_size" : detector_batch_size ,
73+ "detector.runner.snapshots.save_epochs" : save_epochs ,
74+ "detector.runner.snapshots.max_snapshots" : max_snapshots_to_keep ,
75+ "logger" : logger ,
76+ }
77+ if is_model_cond_top_down (net_type ):
78+ pytorch_cfg_updates ["data.conditions.shuffle" ] = conditions_shuffle
5879 run (
5980 config_path = config_path ,
6081 train_fraction = train_frac ,
@@ -63,20 +84,7 @@ def main(
6384 videos = [str (project_path / "videos" / "video.mp4" )],
6485 device = device ,
6586 engine = engine ,
66- pytorch_cfg_updates = {
67- "train_settings.display_iters" : 50 ,
68- "train_settings.epochs" : epochs_ ,
69- "train_settings.batch_size" : batch_size ,
70- "runner.device" : device ,
71- "runner.snapshots.save_epochs" : save_epochs ,
72- "runner.snapshots.max_snapshots" : max_snapshots_to_keep ,
73- "detector.train_settings.display_iters" : 1 ,
74- "detector.train_settings.epochs" : detector_epochs ,
75- "detector.train_settings.batch_size" : detector_batch_size ,
76- "detector.runner.snapshots.save_epochs" : save_epochs ,
77- "detector.runner.snapshots.max_snapshots" : max_snapshots_to_keep ,
78- "logger" : logger ,
79- },
87+ pytorch_cfg_updates = pytorch_cfg_updates ,
8088 create_labeled_videos = create_labeled_videos ,
8189 )
8290 except Exception as err :
@@ -96,8 +104,15 @@ def main(
96104 "project_name" : "testscript-dev" ,
97105 "run_name" : "test-logging" ,
98106 }
107+ net_types = [
108+ "top_down_resnet_50" ,
109+ "resnet_50" ,
110+ "dekr_w32" ,
111+ "rtmpose_m" ,
112+ "ctd_coam_w32" ,
113+ ]
99114 main (
100- net_types = [ "top_down_resnet_50" , "resnet_50" , "dekr_w32" , "rtmpose_m" ] ,
115+ net_types = net_types ,
101116 params = SyntheticProjectParameters (
102117 multianimal = True ,
103118 num_bodyparts = 4 ,
@@ -115,6 +130,8 @@ def main(
115130 max_snapshots_to_keep = 2 ,
116131 device = "cpu" , # "cpu", "cuda:0", "mps"
117132 logger = None ,
133+ conditions_shuffle = net_types .index ("resnet_50" )
134+ + 1 , # shuffles start at index 1
118135 create_labeled_videos = True ,
119136 delete_after_test_run = True ,
120137 )
0 commit comments