Visitar URL original
Merge branch 'maxim/superanimal_humanbody_filtered_detector' into max… · DeepLabCut/DeepLabCut@f03c54a · GitHub
Skip to content

Commit f03c54a

Browse files
committed
Merge branch 'maxim/superanimal_humanbody_filtered_detector' into maxim/modelzoo_tab_fixes
2 parents c6ecb0f + eea470e commit f03c54a

5 files changed

Lines changed: 61 additions & 83 deletions

File tree

‎deeplabcut/modelzoo/video_inference.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,13 @@ def video_inference_superanimal(
395395
)
396396

397397
config = update_config(config, max_individuals, device)
398+
398399
output_suffix = "_before_adapt"
400+
401+
if superanimal_name == "superanimal_humanbody" and video_adapt:
402+
print(f"Video adaptation currently not supported for {superanimal_name}. Setting it to false.")
403+
video_adapt = False
404+
399405
if video_adapt:
400406
# the users can pass in many videos. For now, we only use one video for
401407
# video adaptation. As reported in Ye et al. 2024, one video should be
@@ -420,6 +426,7 @@ def video_inference_superanimal(
420426
plot_bboxes=plot_bboxes,
421427
bboxes_pcutoff=bbox_threshold,
422428
create_labeled_video=create_labeled_video,
429+
torchvision_detector_name=torchvision_detector_name,
423430
)
424431

425432
# we prepare the pseudo dataset in the same folder of the target video

‎examples/testscript_superanimal_inference.py‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,3 @@
4747
videotype=".avi",
4848
scale_list=scale_list,
4949
)
50-
51-
print("testing superanimal_humanbody")
52-
superanimal_name = "superanimal_humanbody"
53-
deeplabcut.video_inference_superanimal(
54-
video,
55-
superanimal_name,
56-
model_name="rtmpose_x",
57-
detector_name="fasterrcnn_mobilenet_v3_large_fpn",
58-
videotype=".avi",
59-
scale_list=scale_list,
60-
)

‎examples/utils.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ def generate_video_from_images(image_dir: Path, output_video: Path) -> None:
256256

257257
def create_fake_project(path: Path, params: SyntheticProjectParameters) -> None:
258258
if path.exists():
259-
print(f"[DEBUG] Path exists: {path} (is_dir={path.is_dir()}, is_file={path.is_file()})")
260259
raise ValueError(f"Cannot create a fake project at an existing path")
261260

262261
scorer = "synthetic"

‎test_superanimal_humanbody.py‎

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Test script for superanimal_humanbody with torchvision detector
4+
"""
5+
6+
from deeplabcut.pose_estimation_pytorch.apis.utils import TORCHVISION_DETECTORS, \
7+
get_filtered_coco_detector_inference_runner
8+
from deeplabcut.pose_estimation_pytorch.models.detectors.filtered_detector import FilteredDetector
9+
from deeplabcut.pose_estimation_pytorch.modelzoo import load_super_animal_config
10+
11+
def test_torchvision_detector():
12+
"""Test that the torchvision detector works with superanimal_humanbody"""
13+
for detector_name in TORCHVISION_DETECTORS:
14+
15+
# Load the superanimal_humanbody config
16+
superanimal_config = load_super_animal_config(
17+
super_animal="superanimal_humanbody",
18+
model_name="rtmpose_x",
19+
detector_name=detector_name,
20+
)
21+
print("Config loaded successfully!")
22+
23+
# Test loading the torchvision detector directly
24+
print("\nTesting torchvision detector loading...")
25+
entry = TORCHVISION_DETECTORS[detector_name]
26+
weights = entry["weights"]
27+
coco_detector = entry["fn"](weights=weights, box_score_thresh=0.6)
28+
coco_detector.eval()
29+
print("Torchvision detector loaded successfully!")
30+
31+
# Test loading the FilteredDetector
32+
COCO_PERSON = 1 # COCO class ID for person
33+
person_detector = FilteredDetector(coco_detector, class_id=COCO_PERSON)
34+
person_detector.eval()
35+
print("Filtered detector loaded successfully!")
36+
37+
_ = get_filtered_coco_detector_inference_runner(
38+
model_name=detector_name,
39+
category_id=COCO_PERSON,
40+
batch_size=1,
41+
model_config=superanimal_config,
42+
)
43+
print("Filtered detector runner created successfully!")
44+
45+
print("\n✅ All tests passed! The torchvision detector integration is working correctly.")
46+
return True
47+
48+
if __name__ == "__main__":
49+
print("Testing superanimal_humanbody with torchvision detector...")
50+
success = test_torchvision_detector()
51+
if success:
52+
print("\n✅ Test passed! The torchvision detector works with superanimal_humanbody")
53+
else:
54+
print("\n❌ Test failed! There's an issue with the torchvision detector integration")

0 commit comments

Comments
 (0)