(
net_types: list[str],
params: SyntheticProjectParameters,
epochs: int = 1,
top_down_epochs: int = 1,
detector_epochs: int = 1,
save_epochs: int = 1,
batch_size: int = 1,
detector_batch_size: int = 1,
max_snapshots_to_keep: int = 5,
device: str = "cpu",
logger: dict | None = None,
conditions_shuffle: int = 0,
create_labeled_videos: bool = False,
delete_after_test_run: bool = False,
)
| 31 | |
| 32 | |
| 33 | def main( |
| 34 | net_types: list[str], |
| 35 | params: SyntheticProjectParameters, |
| 36 | epochs: int = 1, |
| 37 | top_down_epochs: int = 1, |
| 38 | detector_epochs: int = 1, |
| 39 | save_epochs: int = 1, |
| 40 | batch_size: int = 1, |
| 41 | detector_batch_size: int = 1, |
| 42 | max_snapshots_to_keep: int = 5, |
| 43 | device: str = "cpu", |
| 44 | logger: dict | None = None, |
| 45 | conditions_shuffle: int = 0, |
| 46 | create_labeled_videos: bool = False, |
| 47 | delete_after_test_run: bool = False, |
| 48 | ) -> None: |
| 49 | project_path = Path("synthetic-data-niels-multi-animal").resolve() |
| 50 | config_path = project_path / "config.yaml" |
| 51 | create_fake_project(path=project_path, params=params) |
| 52 | |
| 53 | engine = Engine.PYTORCH |
| 54 | cfg = af.read_config(config_path) |
| 55 | trainset_index = 0 |
| 56 | train_frac = cfg["TrainingFraction"][trainset_index] |
| 57 | try: |
| 58 | for net_type in net_types: |
| 59 | epochs_ = epochs |
| 60 | if is_model_top_down(net_type): |
| 61 | epochs_ = top_down_epochs |
| 62 | try: |
| 63 | pytorch_cfg_updates = { |
| 64 | "train_settings.display_iters": 50, |
| 65 | "train_settings.epochs": epochs_, |
| 66 | "train_settings.batch_size": batch_size, |
| 67 | "train_settings.dataloader_workers": 0, |
| 68 | "runner.device": device, |
| 69 | "runner.snapshots.save_epochs": save_epochs, |
| 70 | "runner.snapshots.max_snapshots": max_snapshots_to_keep, |
| 71 | "detector.train_settings.display_iters": 1, |
| 72 | "detector.train_settings.epochs": detector_epochs, |
| 73 | "detector.train_settings.batch_size": detector_batch_size, |
| 74 | "detector.train_settings.dataloader_workers": 0, |
| 75 | "detector.runner.snapshots.save_epochs": save_epochs, |
| 76 | "detector.runner.snapshots.max_snapshots": max_snapshots_to_keep, |
| 77 | "logger": logger, |
| 78 | } |
| 79 | if is_model_cond_top_down(net_type): |
| 80 | pytorch_cfg_updates["inference.conditions.shuffle"] = conditions_shuffle |
| 81 | pytorch_cfg_updates["inference.conditions.snapshot_index"] = -1 |
| 82 | run( |
| 83 | config_path=config_path, |
| 84 | train_fraction=train_frac, |
| 85 | trainset_index=trainset_index, |
| 86 | net_type=net_type, |
| 87 | videos=[str(project_path / "videos" / "video.mp4")], |
| 88 | device=device, |
| 89 | engine=engine, |
| 90 | pytorch_cfg_updates=pytorch_cfg_updates, |
no test coverage detected