Returns an ordered list of existing snapshot names in the train folder, sorted by increasing training iterations. Raises: FileNotFoundError: if no snapshot_names are found in the train_folder.
(train_folder: Path)
| 611 | |
| 612 | |
| 613 | def get_snapshots_from_folder(train_folder: Path) -> list[str]: |
| 614 | """Returns an ordered list of existing snapshot names in the train folder, sorted by |
| 615 | increasing training iterations. |
| 616 | |
| 617 | Raises: |
| 618 | FileNotFoundError: if no snapshot_names are found in the train_folder. |
| 619 | """ |
| 620 | snapshot_names = [file.stem for file in train_folder.iterdir() if "index" in file.name] |
| 621 | |
| 622 | if len(snapshot_names) == 0: |
| 623 | raise FileNotFoundError( |
| 624 | f"No snapshots were found in {train_folder}! Please ensure the network has " |
| 625 | f"been trained and verify the iteration, shuffle and trainFraction are " |
| 626 | f"correct." |
| 627 | ) |
| 628 | |
| 629 | # sort in ascending order of iteration number |
| 630 | return sorted(snapshot_names, key=lambda name: int(name.split("-")[1])) |
| 631 | |
| 632 | |
| 633 | def get_deeplabcut_path(): |
no test coverage detected