@@ -76,7 +76,15 @@ def train_network(
7676 superanimal_name : str = "" ,
7777 superanimal_transfer_learning : bool = False ,
7878 engine : Engine | None = None ,
79- ** torch_kwargs ,
79+ device : str | None = None ,
80+ snapshot_path : str | Path | None = None ,
81+ detector_path : str | Path | None = None ,
82+ batch_size : int | None = None ,
83+ detector_batch_size : int | None = None ,
84+ detector_epochs : int | None = None ,
85+ detector_save_epochs : int | None = None ,
86+ pose_threshold : float | None = 0.1 ,
87+ pytorch_cfg_updates : dict | None = None ,
8088):
8189 """
8290 Trains the network with the labels in the training dataset.
@@ -135,6 +143,7 @@ def train_network(
135143 Only for the PyTorch engine (equivalent to the `saveiters` parameter for the
136144 TensorFlow engine). The number of epochs between each snapshot save. If
137145 None, the value will be read from the `pytorch_config.yaml` file.
146+
138147 allow_growth: bool, optional, default=True.
139148 Only for the TensorFlow engine.
140149 For some smaller GPUs the memory issues happen. If ``True``, the memory
@@ -180,18 +189,38 @@ def train_network(
180189 overwrite this by passing the engine as an argument, but this should generally
181190 not be done.
182191
183- torch_kwargs:
184- You can add any keyword arguments for the deeplabcut.pose_estimation_pytorch
185- train_network method here. These arguments are passed to the downstream method.
186- Some of the parameters that can be passed are
187- * ``device`` (the CUDA device to use for training)
188- * ``batch_size`` (the batch size to use while training)
189- * ``snapshot_path`` (the pose model snapshot to resume training from)
190- * ``detector_path`` (the detector model snapshot to resume training from)
192+ device: str, optional, default = None.
193+ Only for the PyTorch engine. The device to run the training on (e.g. "cuda:0")
194+
195+ snapshot_path: str or Path, optional, default = None.
196+ Only for the PyTorch engine. The path to the pose model snapshot to resume training from.
197+
198+ detector_path: str or Path, optional, default = None.
199+ Only for the PyTorch engine. The path to the detector model snapshot to resume training from.
200+
201+ batch_size: int, optional, default = None.
202+ Only for the PyTorch engine. The batch size to use while training.
203+
204+ detector_batch_size: int, optional, default = None.
205+ Only for the PyTorch engine. The batch size to use while training the detector.
206+
207+ detector_epochs: int, optional, default = None.
208+ Only for the PyTorch engine. The number of epochs to train the detector for.
209+
210+ detector_save_epochs: int, optional, default = None.
211+ Only for the PyTorch engine. The number of epochs between each detector snapshot save.
191212
192- When training a top-down model, these parameters are also available for the
193- detector, with the parameters ``detector_batch_size``, ``detector_epochs`` and
194- ``detector_save_epochs``.
213+ pose_threshold: float, optional, default = 0.1.
214+ Only for the PyTorch engine. Used for memory-replay. Pseudo-predictions with confidence lower
215+ than this threshold are discarded for memory-replay
216+
217+ pytorch_cfg_updates: dict, optional, default = None.
218+ A dictionary of updates to the pytorch config. The keys are the dot-separated
219+ paths to the values to update in the config.
220+ For example, to update the gpus to run the training on, you can use:
221+ ```
222+ pytorch_cfg_updates={"runner.gpus": [0,1,2,3]}
223+ ```
195224
196225 Returns
197226 -------
@@ -255,20 +284,25 @@ def train_network(
255284 elif engine == Engine .PYTORCH :
256285 from deeplabcut .pose_estimation_pytorch .apis import train_network
257286
258- _update_device (gputouse , torch_kwargs )
259- if "display_iters" not in torch_kwargs :
260- torch_kwargs ["display_iters" ] = displayiters
261-
262287 return train_network (
263288 config ,
264289 shuffle = shuffle ,
265290 trainingsetindex = trainingsetindex ,
266291 modelprefix = modelprefix ,
267- max_snapshots_to_keep = max_snapshots_to_keep ,
292+ device = device ,
293+ snapshot_path = snapshot_path ,
294+ detector_path = detector_path ,
268295 load_head_weights = keepdeconvweights ,
296+ batch_size = batch_size ,
269297 epochs = epochs ,
270298 save_epochs = save_epochs ,
271- ** torch_kwargs ,
299+ detector_batch_size = detector_batch_size ,
300+ detector_epochs = detector_epochs ,
301+ detector_save_epochs = detector_save_epochs ,
302+ display_iters = displayiters ,
303+ max_snapshots_to_keep = max_snapshots_to_keep ,
304+ pose_threshold = pose_threshold ,
305+ pytorch_cfg_updates = pytorch_cfg_updates ,
272306 )
273307
274308 raise NotImplementedError (f"This function is not implemented for { engine } " )
@@ -1110,6 +1144,7 @@ def analyze_images(
11101144
11111145 if engine == Engine .PYTORCH :
11121146 from deeplabcut .pose_estimation_pytorch import analyze_images
1147+
11131148 return analyze_images (
11141149 config = config ,
11151150 images = images ,
@@ -1218,6 +1253,7 @@ def analyze_time_lapse_frames(
12181253
12191254 if engine == Engine .TF :
12201255 from deeplabcut .pose_estimation_tensorflow import analyze_time_lapse_frames
1256+
12211257 return analyze_time_lapse_frames (
12221258 config ,
12231259 directory ,
@@ -1230,6 +1266,7 @@ def analyze_time_lapse_frames(
12301266 )
12311267 elif engine == Engine .PYTORCH :
12321268 from deeplabcut .pose_estimation_pytorch import analyze_images
1269+
12331270 return analyze_images (
12341271 config = config ,
12351272 images = directory ,
0 commit comments