Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 17 additions & 11 deletions deeplabcut/utils/make_labeled_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,6 @@ def proc_video(
df, filepath, _, _ = auxiliaryfunctions.load_analyzed_data(
destfolder, vname, DLCscorer, filtered, track_method
)
full_data = auxiliaryfunctions.load_video_full_data(
destfolder, vname, DLCscorer
)
metadata = auxiliaryfunctions.load_video_metadata(
destfolder, vname, DLCscorer
)
Expand All @@ -916,14 +913,23 @@ def proc_video(
if bp in bodyparts
]

frames_dict = {
int(key.replace("frame", "")): value
for key, value in full_data.items()
if key.startswith("frame") and key[5:].isdigit()
}
bboxes_list = None
if "bboxes" in frames_dict.get(min(frames_dict.keys()), {}):
bboxes_list = [frames_dict[key] for key in sorted(frames_dict.keys())]
# The full data file is not created for single-animal TensorFlow models
try:
full_data = auxiliaryfunctions.load_video_full_data(
destfolder, vname, DLCscorer
)
frames_dict = {
int(key.replace("frame", "")): value
for key, value in full_data.items()
if key.startswith("frame") and key[5:].isdigit()
}
bboxes_list = None
if "bboxes" in frames_dict.get(min(frames_dict.keys()), {}):
bboxes_list = [
frames_dict[key] for key in sorted(frames_dict.keys())
]
except FileNotFoundError:
bboxes_list = None

if keypoints_only:
# Mask rather than drop unwanted bodyparts to ensure consistent coloring
Expand Down
9 changes: 6 additions & 3 deletions examples/testscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ def make_frame(t):
)

print("CREATE VIDEO")
deeplabcut.create_labeled_video(
successful = deeplabcut.create_labeled_video(
path_config_file, [newvideo], destfolder=DESTFOLDER, save_frames=True
)
assert all(successful), f"Failed to create a labeled video!"

print("Making plots")
deeplabcut.plot_trajectories(path_config_file, [newvideo], destfolder=DESTFOLDER)
Expand Down Expand Up @@ -363,18 +364,20 @@ def make_frame(t):
)
deeplabcut.filterpredictions(path_config_file, [newvideo2])

deeplabcut.create_labeled_video(
successful = deeplabcut.create_labeled_video(
path_config_file,
[newvideo2],
destfolder=DESTFOLDER,
displaycropped=True,
filtered=True,
)
assert all(successful), f"Failed to create a labeled video!"

print("Creating a Johansson video!")
deeplabcut.create_labeled_video(
successful = deeplabcut.create_labeled_video(
path_config_file, [newvideo2], destfolder=DESTFOLDER, keypoints_only=True
)
assert all(successful), f"Failed to create a labeled video!"

deeplabcut.plot_trajectories(
path_config_file, [newvideo2], destfolder=DESTFOLDER, filtered=True
Expand Down