Visitar URL original
Miscellaneous imports and code fixes by C-Achard · Pull Request #3411 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0b3e0f3
Fix bone likelihood in analyzebone to use both bodyparts
claude Jul 15, 2026
b253a90
Fix SORTSkeleton removing the wrong tracker on cleanup
claude Jul 15, 2026
8fed1c4
Fix CTD tracklet-age reset writing to a non-existent attribute
claude Jul 15, 2026
05c3e1f
Fix destfolder leaking across videos in filter/skeleton loops
claude Jul 15, 2026
44b61a6
Fix except clause catching a ValueError instance instead of the type
claude Jul 15, 2026
3e577d3
Import scipy.ndimage functions directly (drop removed measurements na…
claude Jul 15, 2026
7e5ce73
Replace removed np.object alias with builtin object
claude Jul 15, 2026
5b93ead
Fix operator precedence in condition NaN/non-positive mask
claude Jul 15, 2026
b79c7f9
Fix scipy.stats.mode usage for keepdims=False default (scipy>=1.11)
claude Jul 15, 2026
e374837
Merge branch 'main' into fix/skeleton-bone-likelihood
Denny-Hwang Jul 15, 2026
b2d21cb
Merge pull request #3401 from Denny-Hwang/fix/skeleton-bone-likelihood
C-Achard Jul 16, 2026
c94fdd0
Merge pull request #3405 from Denny-Hwang/fix/except-valueerror-call
C-Achard Jul 16, 2026
cffb979
Merge pull request #3406 from Denny-Hwang/fix/scipy-ndimage-measurements
C-Achard Jul 16, 2026
252cf16
Merge pull request #3407 from Denny-Hwang/fix/np-object-removed
C-Achard Jul 16, 2026
e0f4abf
Merge pull request #3409 from Denny-Hwang/fix/scipy-mode-keepdims
C-Achard Jul 16, 2026
2271e6d
Merge pull request #3408 from Denny-Hwang/fix/conds-mask-precedence
C-Achard Jul 16, 2026
3755158
Merge pull request #3403 from Denny-Hwang/fix/sortskeleton-pop-index
C-Achard Jul 16, 2026
d35dd81
Merge pull request #3404 from Denny-Hwang/fix/ctd-track-ages-reset
C-Achard Jul 16, 2026
f726fb7
Merge pull request #3410 from Denny-Hwang/fix/destfolder-per-video
C-Achard Jul 16, 2026
bc940fa
Merge branch 'main' into external/hwang-misc-fixes
C-Achard Jul 16, 2026
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
6 changes: 3 additions & 3 deletions deeplabcut/core/trackingutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def track(self, poses, identities=None):
if el is not None:
ellipses.append(el)
if identities is not None:
pred_ids.append(mode(identities[i])[0][0])
pred_ids.append(mode(identities[i], keepdims=False)[0])
if not len(trackers):
matches = np.empty((0, 2), dtype=int)
unmatched_detections = np.arange(len(ellipses))
Expand Down Expand Up @@ -480,7 +480,7 @@ def track(self, poses, identities=None):
for i in unmatched_detections:
trk = EllipseTracker(ellipses[i].parameters)
if identities is not None:
trk.id_ = mode(identities[i])[0][0]
trk.id_ = mode(identities[i], keepdims=False)[0]
self.trackers.append(trk)
animalindex.append(i)

Expand Down Expand Up @@ -611,7 +611,7 @@ def track(self, poses):
for tracker in reversed(self.trackers):
i -= 1
if tracker.time_since_update > self.max_age:
self.trackers.pop()
self.trackers.pop(i)
continue
state = tracker.predict()
states.append(np.r_[state, [tracker.id, int(animalindex[i])]])
Expand Down
4 changes: 2 additions & 2 deletions deeplabcut/pose_estimation_pytorch/runners/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ def add_conditions(

# Extract the conditions
conds = predictions["bodyparts"][..., :3]
pred_mask = ~np.all(np.any(conds <= 0 | np.isnan(conds), axis=2), axis=1)
pred_mask = ~np.all(np.any((conds <= 0) | np.isnan(conds), axis=2), axis=1)
if np.sum(pred_mask) > 0:
conds = conds[pred_mask]
else:
Expand Down Expand Up @@ -802,7 +802,7 @@ def _ctd_tracking_postprocess(
else:
self._prev_pose = None
self._idx_to_id = None
self._idx_ages = None
self._ctd_track_ages = None

def _merge_conditions(self, bu_cond: np.ndarray) -> np.ndarray:
"""Merges conditions made by a BU model with existing conditions from CTD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import numpy as np
import tensorflow as tf
from scipy.ndimage import measurements
from scipy.ndimage import center_of_mass, label
from skimage.feature import peak_local_max


Expand Down Expand Up @@ -263,8 +263,8 @@ def find_local_maxima(scmap, radius, threshold):
peak_idx = peak_local_max(scmap, min_distance=radius, threshold_abs=threshold, exclude_border=False)
grid = np.zeros_like(scmap, dtype=bool)
grid[tuple(peak_idx.T)] = True
labels = measurements.label(grid)[0]
xy = measurements.center_of_mass(grid, labels, range(1, np.max(labels) + 1))
labels = label(grid)[0]
xy = center_of_mass(grid, labels, range(1, np.max(labels) + 1))
return np.asarray(xy, dtype=int).reshape((-1, 2))


Expand Down
2 changes: 1 addition & 1 deletion deeplabcut/pose_estimation_tensorflow/core/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_net(visualise, cache_scoremaps):
Path(out_dir).mkdir(parents=True)

num_images = dataset.num_images
predictions = np.zeros((num_images,), dtype=np.object)
predictions = np.zeros((num_images,), dtype=object)

for k in range(num_images):
print(f"processing image {k}/{num_images - 1}")
Expand Down
9 changes: 5 additions & 4 deletions deeplabcut/post_processing/analyze_skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def analyzebone(bp1, bp2):
bone_orientation = calc_angle_between_vectors_of_points_2d(bp1_pos.T, bp2_pos.T)

# keep the smallest of the two likelihoods
likelihoods = np.vstack([bp2.likelihood.values, bp2.likelihood.values]).T
likelihoods = np.vstack([bp1.likelihood.values, bp2.likelihood.values]).T
likelihood = np.min(likelihoods, 1)

# Create dataframe and return
Expand Down Expand Up @@ -256,13 +256,14 @@ def analyzeskeleton(
Videos = collect_video_paths(videos, extensions=video_extensions)
for video in Videos:
print(f"Processing {video}")
if destfolder is None:
destfolder = str(Path(video).parents[0])
videofolder = destfolder
if videofolder is None:
videofolder = str(Path(video).parents[0])

vname = Path(video).stem
try:
df, filepath, scorer, _ = auxiliaryfunctions.load_analyzed_data(
destfolder, vname, DLCscorer, filtered, track_method
videofolder, vname, DLCscorer, filtered, track_method
)
except FileNotFoundError as e:
print(e)
Expand Down
11 changes: 7 additions & 4 deletions deeplabcut/post_processing/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,17 @@ def filterpredictions(
return video_to_filtered_df

for video in Videos:
if destfolder is None:
destfolder = str(Path(video).parents[0])
videofolder = destfolder
if videofolder is None:
videofolder = str(Path(video).parents[0])

print(f"Filtering with {filtertype} model {video}")
vname = Path(video).stem

try:
df, filepath, _, _ = auxiliaryfunctions.load_analyzed_data(destfolder, vname, DLCscorer, True, track_method)
df, filepath, _, _ = auxiliaryfunctions.load_analyzed_data(
videofolder, vname, DLCscorer, True, track_method
)
print(f"Data from {vname} were already filtered. Skipping...")
video_to_filtered_df[video] = df
# Data has been filtered so continue to the next video
Expand All @@ -215,7 +218,7 @@ def filterpredictions(
# Data haven't been filtered yet
try:
df, filepath, _, _ = auxiliaryfunctions.load_analyzed_data(
destfolder, vname, DLCscorer, track_method=track_method
videofolder, vname, DLCscorer, track_method=track_method
)
except FileNotFoundError as e:
video_to_filtered_df[video] = None
Expand Down
2 changes: 1 addition & 1 deletion deeplabcut/refine_training_dataset/outlier_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def extract_outlier_frames(
if frames2use is not None:
try:
frames2use = np.array(frames2use).astype("int")
except ValueError():
except ValueError:
print(
"Could not cast frames2use into np array, "
"please check that frames2use is a simply a list of integers!"
Expand Down
Loading