MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / main

Function main

examples/testscript_pytorch_single_animal.py:20–82  ·  view source on GitHub ↗
(
    synthetic_data: bool,
    net_types: list[str],
    epochs: int = 1,
    save_epochs: int = 1,
    max_snapshots_to_keep: int = 5,
    batch_size: int = 1,
    device: str = "cpu",
    logger: dict | None = None,
    synthetic_data_params: SyntheticProjectParameters = None,
    create_labeled_videos: bool = False,
    delete_after_test_run: bool = False,
)

Source from the content-addressed store, hash-verified

18
19
20def main(
21 synthetic_data: bool,
22 net_types: list[str],
23 epochs: int = 1,
24 save_epochs: int = 1,
25 max_snapshots_to_keep: int = 5,
26 batch_size: int = 1,
27 device: str = "cpu",
28 logger: dict | None = None,
29 synthetic_data_params: SyntheticProjectParameters = None,
30 create_labeled_videos: bool = False,
31 delete_after_test_run: bool = False,
32) -> None:
33 if synthetic_data_params is None:
34 synthetic_data_params = SyntheticProjectParameters(
35 multianimal=False,
36 num_bodyparts=6,
37 )
38 engine = Engine.PYTORCH
39 if synthetic_data:
40 project_path = Path("synthetic-data-niels-single-animal").resolve()
41 videos = [str(project_path / "videos" / "video.mp4")]
42 create_fake_project(path=project_path, params=synthetic_data_params)
43
44 else:
45 project_path = copy_project_for_test()
46 videos = [str(project_path / "videos" / "m3v1mp4.mp4")]
47
48 config_path = project_path / "config.yaml"
49 cfg = af.read_config(config_path)
50 trainset_index = 0
51 train_frac = cfg["TrainingFraction"][trainset_index]
52 try:
53 for net_type in net_types:
54 try:
55 run(
56 config_path=config_path,
57 train_fraction=train_frac,
58 trainset_index=trainset_index,
59 net_type=net_type,
60 videos=videos,
61 device=device,
62 engine=engine,
63 pytorch_cfg_updates={
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 "logger": logger,
71 },
72 create_labeled_videos=create_labeled_videos,
73 )
74
75 except Exception as err:
76 log_step(f"FAILED TO RUN {net_type}")
77 log_step(str(err))

Calls 7

create_fake_projectFunction · 0.90
copy_project_for_testFunction · 0.90
runFunction · 0.90
log_stepFunction · 0.90
cleanupFunction · 0.90
read_configMethod · 0.45

Tested by

no test coverage detected