Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update snapshotindex and latest_snapshot designation #101

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions element_deeplabcut/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,23 +321,28 @@ def make(self, key):
except KeyboardInterrupt: # Instructions indicate to train until interrupt
print("DLC training stopped via Keyboard Interrupt")

snapshots = list(model_train_folder.glob("*index*"))
snapshots = sorted(list(model_train_folder.glob("*index*")))
max_modified_time = 0
# DLC goes by snapshot magnitude when judging 'latest' for evaluation
# Here, we mean most recently generated
for snapshot in snapshots:
modified_time = os.path.getmtime(snapshot)
if modified_time > max_modified_time:
latest_snapshot = int(snapshot.stem[9:])
latest_snapshot_file = snapshot
latest_snapshot = int(latest_snapshot_file.stem[9:])
max_modified_time = modified_time

# update snapshotindex in the config
dlc_config["snapshotindex"] = latest_snapshot
snapshotindex = snapshots.index(latest_snapshot_file)

dlc_config["snapshotindex"] = snapshotindex
edit_config(
dlc_cfg_filepath,
{"snapshotindex": latest_snapshot},
{"snapshotindex": snapshotindex},
)

self.insert1(
{**key, "latest_snapshot": latest_snapshot, "config_template": dlc_config}
)


Loading