Skip to content
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2abf37c
Trim superanimal_humanbody.yaml default project config
maximpavliv Jul 21, 2025
a1a6be1
Trim superanimal_humanbody_colors
maximpavliv Jul 21, 2025
dfbce1d
Correct get_checkpoint_epoch
maximpavliv Jul 21, 2025
1432a73
Add rtmpose_x modelzoo model config
maximpavliv Jul 21, 2025
a4d74cc
Add FilteredDetector
maximpavliv Jul 21, 2025
0cbfe59
Add get_filtered_coco_detector_inference_runner() method
maximpavliv Jul 21, 2025
84b230e
Add ScaleToUnitRange transform
maximpavliv Jul 21, 2025
c4c1318
Superanimal humanbody inference: use filtered detector runner
maximpavliv Jul 21, 2025
dc511cd
ModelZoo tab: make humanbody general case
maximpavliv Jul 21, 2025
479cc66
get_super_animal_scorer(): add torchvision_detector_name arg
maximpavliv Jul 21, 2025
6a14584
Remove superanimal_humanbody_video_inference.py module
maximpavliv Jul 21, 2025
6774812
Regularize get_super_animal_model_config_path()
maximpavliv Jul 21, 2025
424ac92
Regularize load_super_animal_config()
maximpavliv Jul 21, 2025
04438f8
Regularize download_super_animal_snapshot()
maximpavliv Jul 21, 2025
256977b
update_config(): superanimal_humanbody - compatible
maximpavliv Jul 21, 2025
8d4cf20
Revert video_inference()
maximpavliv Jul 21, 2025
edf4f9d
Revert create_df_from_prediction()
maximpavliv Jul 21, 2025
cded581
Restore CTDInferenceRunner
maximpavliv Jul 21, 2025
7eaf923
Remove TorchvisionDetectorInferenceRunner
maximpavliv Jul 21, 2025
feb34d1
Revert DetectorInferenceRunner
maximpavliv Jul 21, 2025
711a47e
superanimal_analyze_images() - make humanbody compatible
maximpavliv Jul 21, 2025
28e4dd0
Revert build_predictions_dataframe()
maximpavliv Jul 21, 2025
193f935
Revert get_inference_runners()
maximpavliv Jul 21, 2025
613b2ac
Revert detectors/fasterRCNN.py
maximpavliv Jul 21, 2025
d848741
Revert detectors/torchvision.py
maximpavliv Jul 21, 2025
bba8689
Revert base Runner
maximpavliv Jul 21, 2025
25fa08d
Fix superanimal_humanbody unit test
maximpavliv Jul 31, 2025
425484b
Disable video adaptation for superanimal_humanbody
maximpavliv Jul 31, 2025
4b04013
Fix testscript_superanimal_inference.py
maximpavliv Jul 31, 2025
eea470e
Remove debug print
maximpavliv Jul 31, 2025
3d47a36
Black formatting
maximpavliv Jul 31, 2025
87f44e7
Clean dlc_torch.analyze_videos()
maximpavliv Aug 22, 2025
5c6165d
Merge branch 'main' into maxim/clean_pytorch_analyze_videos
MMathisLab Aug 24, 2025
87bf0c9
Merge branch 'main' into maxim/clean_pytorch_analyze_videos
maximpavliv Sep 5, 2025
04ab76a
Merge branch 'main' into maxim/clean_pytorch_analyze_videos
maximpavliv Sep 12, 2025
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
153 changes: 6 additions & 147 deletions deeplabcut/pose_estimation_pytorch/apis/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,70 +452,9 @@ def analyze_videos(
print(f"Creating a TopDownDynamicCropper with configuration {top_down_dynamic}")
dynamic = TopDownDynamicCropper(**top_down_dynamic)

try:
snapshot = utils.get_model_snapshots(
snapshot_index, loader.model_folder, loader.pose_task
)[0]
except (ValueError, IndexError) as e:
print(f"Error loading snapshot with index {snapshot_index}: {e}")
print("Attempting to find available snapshots...")

# Try to get all available snapshots
try:
all_snapshots = utils.get_model_snapshots(
"all", loader.model_folder, loader.pose_task
)
if all_snapshots:
# Try to find a "best" snapshot first
best_snapshots = [s for s in all_snapshots if s.best]
if best_snapshots:
snapshot = best_snapshots[0]
print(f"Found and using best snapshot: {snapshot.path}")
else:
# Use the last available snapshot
snapshot = all_snapshots[-1]
print(
f"No best snapshot found, using last available: {snapshot.path}"
)
else:
raise FileNotFoundError(f"No snapshots found in {loader.model_folder}")
except Exception as fallback_error:
raise FileNotFoundError(
f"Failed to load any snapshots from {loader.model_folder}. Original error: {e}. Fallback error: {fallback_error}"
)

# Additional validation for best snapshots
if "best" in str(snapshot.path) and not snapshot.path.exists():
print(
f"Warning: Best snapshot path {snapshot.path} does not exist. Checking for alternative snapshots..."
)
# Try to find any available snapshot
try:
all_snapshots = utils.get_model_snapshots(
"all", loader.model_folder, loader.pose_task
)
if all_snapshots:
# Try to find a different best snapshot
best_snapshots = [
s for s in all_snapshots if s.best and s.path.exists()
]
if best_snapshots:
snapshot = best_snapshots[0]
print(f"Using alternative best snapshot: {snapshot.path}")
else:
# Use the last available snapshot
snapshot = all_snapshots[-1]
print(f"Using alternative snapshot: {snapshot.path}")
else:
raise FileNotFoundError(f"No snapshots found in {loader.model_folder}")
except Exception as e:
raise FileNotFoundError(f"Failed to find alternative snapshots: {e}")

# Verify the snapshot file exists
if not snapshot.path.exists():
raise FileNotFoundError(f"Snapshot file not found: {snapshot.path}")

print(f"Successfully loaded snapshot: {snapshot.path}")
snapshot = utils.get_model_snapshots(
snapshot_index, loader.model_folder, loader.pose_task
)[0]

# Load the BU model for the conditions provider
cond_provider = None
Expand Down Expand Up @@ -562,89 +501,9 @@ def analyze_videos(
if detector_batch_size is None:
detector_batch_size = loader.project_cfg.get("detector_batch_size", 1)

try:
detector_snapshot = utils.get_model_snapshots(
detector_snapshot_index, loader.model_folder, Task.DETECT
)[0]
except (ValueError, IndexError) as e:
print(
f"Error loading detector snapshot with index {detector_snapshot_index}: {e}"
)
print("Attempting to find available detector snapshots...")

# Try to get all available detector snapshots
try:
all_detector_snapshots = utils.get_model_snapshots(
"all", loader.model_folder, Task.DETECT
)
if all_detector_snapshots:
# Try to find a "best" detector snapshot first
best_detector_snapshots = [
s for s in all_detector_snapshots if s.best
]
if best_detector_snapshots:
detector_snapshot = best_detector_snapshots[0]
print(
f"Found and using best detector snapshot: {detector_snapshot.path}"
)
else:
# Use the last available detector snapshot
detector_snapshot = all_detector_snapshots[-1]
print(
f"No best detector snapshot found, using last available: {detector_snapshot.path}"
)
else:
raise FileNotFoundError(
f"No detector snapshots found in {loader.model_folder}"
)
except Exception as fallback_error:
raise FileNotFoundError(
f"Failed to load any detector snapshots from {loader.model_folder}. Original error: {e}. Fallback error: {fallback_error}"
)

# Additional validation for detector snapshots
if (
"best" in str(detector_snapshot.path)
and not detector_snapshot.path.exists()
):
print(
f"Warning: Best detector snapshot path {detector_snapshot.path} does not exist. Checking for alternative detector snapshots..."
)
try:
all_detector_snapshots = utils.get_model_snapshots(
"all", loader.model_folder, Task.DETECT
)
if all_detector_snapshots:
# Try to find a different best detector snapshot
best_detector_snapshots = [
s for s in all_detector_snapshots if s.best and s.path.exists()
]
if best_detector_snapshots:
detector_snapshot = best_detector_snapshots[0]
print(
f"Using alternative best detector snapshot: {detector_snapshot.path}"
)
else:
# Use the last available detector snapshot
detector_snapshot = all_detector_snapshots[-1]
print(
f"Using alternative detector snapshot: {detector_snapshot.path}"
)
else:
raise FileNotFoundError(
f"No detector snapshots found in {loader.model_folder}"
)
except Exception as e:
raise FileNotFoundError(
f"Failed to find alternative detector snapshots: {e}"
)

# Verify the detector snapshot file exists
if not detector_snapshot.path.exists():
raise FileNotFoundError(
f"Detector snapshot file not found: {detector_snapshot.path}"
)

detector_snapshot = utils.get_model_snapshots(
detector_snapshot_index, loader.model_folder, Task.DETECT
)[0]
print(f" -> Using detector {detector_snapshot.path}")
detector_runner = utils.get_detector_inference_runner(
model_config=loader.model_cfg,
Expand Down
Loading