Visitar URL original
Harden path-handling after pathlib migration by deruyter92 · Pull Request #3421 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
auxfun_multianimal migrate to Path in Load and Save MA data
  • Loading branch information
deruyter92 committed Jul 21, 2026
commit 849644a46d126a463df68aa33ad69f18a2d46201
18 changes: 11 additions & 7 deletions deeplabcut/utils/auxfun_multianimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,29 @@ def SaveFullMultiAnimalData(data, metadata, dataname, suffix="_full"):
"""Save predicted data as h5 file and metadata as pickle file; created by
predict_videos.py.
"""
data_path = dataname.split(".h5")[0] + suffix + ".pickle"
metadata_path = dataname.split(".h5")[0] + "_meta.pickle"
dataname = Path(dataname)
data_path = dataname.with_name(dataname.stem + suffix + ".pickle")
metadata_path = dataname.with_name(dataname.stem + "_meta.pickle")

with Path(data_path).open("wb") as f:
data_path.parent.mkdir(parents=True, exist_ok=True)
with data_path.open("wb") as f:
pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
with Path(metadata_path).open("wb") as f:
with metadata_path.open("wb") as f:
pickle.dump(metadata, f, pickle.HIGHEST_PROTOCOL)
return data_path, metadata_path


def LoadFullMultiAnimalData(dataname):
"""Load predicted data and metadata from pickle files created by predict_videos.py."""
data_file = dataname.split(".h5")[0] + "_full.pickle"
dataname = Path(dataname)
data_file = dataname.with_name(dataname.stem + "_full.pickle")
metadata_file = dataname.with_name(dataname.stem + "_meta.pickle")
try:
with Path(data_file).open("rb") as handle:
with data_file.open("rb") as handle:
data = pickle.load(handle)
except (pickle.UnpicklingError, FileNotFoundError):
data = shelve.open(data_file, flag="r")
with Path(data_file.replace("_full.", "_meta.")).open("rb") as handle:
with metadata_file.open("rb") as handle:
metadata = pickle.load(handle)
return data, metadata

Expand Down
Loading