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
9 changes: 9 additions & 0 deletions deeplabcut/refine_training_dataset/outlier_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,20 @@ def extract_outlier_frames(
df, dataname, _, _ = auxiliaryfunctions.load_analyzed_data(
videofolder, vname, DLCscorer, track_method=track_method
)
metadata = auxiliaryfunctions.load_video_metadata(
videofolder, vname, DLCscorer
)
nframes = len(df)
startindex = max([int(np.floor(nframes * cfg["start"])), 0])
stopindex = min([int(np.ceil(nframes * cfg["stop"])), nframes])
Index = np.arange(stopindex - startindex) + startindex

# offset if the data was cropped
if metadata.get("data", {}).get("cropping"):
x1, _, y1, _ = metadata["data"]["cropping_parameters"]
df.iloc[:, df.columns.get_level_values(level="coords") == "x"] += x1
df.iloc[:, df.columns.get_level_values(level="coords") == "y"] += y1

df = df.iloc[Index]
mask = df.columns.get_level_values("bodyparts").isin(bodyparts)
df_temp = df.loc[:, mask]
Expand Down
13 changes: 7 additions & 6 deletions deeplabcut/utils/make_labeled_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,11 +1088,17 @@ def create_video_with_all_detections(
video_name = str(Path(video).stem)
print("Creating labeled video for ", video_name)
h5file = full_pickle.replace("_full.pickle", ".h5")
data, _ = auxfun_multianimal.LoadFullMultiAnimalData(h5file)
data, metadata = auxfun_multianimal.LoadFullMultiAnimalData(h5file)
data = dict(
data
) # Cast to dict (making a copy) so items can safely be popped

x1, y1 = 0, 0
if cropping is not None:
x1, _, y1, _ = cropping
elif metadata.get("data", {}).get("cropping"):
x1, _, y1, _ = metadata["data"]["cropping_parameters"]

header = data.pop("metadata")
all_jointnames = header["all_joints_names"]

Expand All @@ -1116,11 +1122,6 @@ def create_video_with_all_detections(
clip = vp(fname=video, sname=outputname, codec="mp4v")
ny, nx = clip.height(), clip.width()

x1 = 0
y1 = 0
if cropping is not None:
x1, _, y1, _ = cropping

for n in trange(clip.nframes):
frame = clip.load_frame()
if frame is None:
Expand Down