Visitar URL original
Fix Faster R-CNN detector inference crashing on box_score_thresh: null by rysk-t · Pull Request #3470 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make ProjectConfig.bboxes_pcutoff` a property rather than a field
This avoids breaking compatibility, and keeps the config schema internally consistent for the current version
  • Loading branch information
deruyter92 committed Sep 1, 2026
commit 2a00c40ae9260ecc00547e552c7341a947f33ed7
15 changes: 13 additions & 2 deletions deeplabcut/core/config/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class ProjectConfig(DLCVersionedConfig):
skeleton: Skeleton connectivity for plotting.
skeleton_color: Skeleton color for plotting.
pcutoff: Confidence cutoff for plotting.
bboxes_pcutoff: Confidence cutoff for plotting bounding boxes from detectors.
dotsize: Dot size for visualization.
alphavalue: Alpha value for visualization.
colormap: Colormap for visualization.
Expand Down Expand Up @@ -131,7 +130,6 @@ class ProjectConfig(DLCVersionedConfig):
)
skeleton_color: str = "black"
pcutoff: Fraction = 0.6
bboxes_pcutoff: Fraction = 0.6
dotsize: NonNegativeInt = 12
alphavalue: Fraction = 0.7
colormap: str = "rainbow"
Expand Down Expand Up @@ -191,6 +189,19 @@ class ProjectConfig(DLCVersionedConfig):
)
croppedtraining: bool | None = None

# TODO @deruyter92 2026-09-01: This should be included as field in the
# config. It requires a version bump of the schema version.
# see https://github.com/DeepLabCut/DeepLabCut/pull/3470
@property
def bboxes_pcutoff(self) -> Fraction:
"""Default confidence cutoff for plotting bounding boxes from detectors.

Note: This property is introduced in v3.1.0 as prospective config
field, but is intentionally not yet defined as such in the schema to
avoid breaking compatibility with older configs.
"""
return 0.6

@property
def bodyparts_list(self) -> list[str]:
# Animal-count agnostic; Always return a list (never "MULTI!", None, etc.)
Expand Down
10 changes: 7 additions & 3 deletions deeplabcut/pose_estimation_pytorch/apis/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ def evaluate_snapshot(
per_keypoint_evaluation: bool = False,
detector_snapshot: Snapshot | None = None,
pcutoff: float | list[float] | dict[str, float] | None = None,
bboxes_pcutoff: float | None = None,
) -> pd.DataFrame:
"""Evaluates a snapshot. The evaluation results are stored in the .h5 and .csv file
under the subdirectory 'evaluation_results'.
Expand Down Expand Up @@ -490,7 +491,12 @@ def evaluate_snapshot(
(if there are any). If a dict is provided, the keys should be bodyparts
mapping to pcutoff values for each bodypart. Bodyparts that are not defined
in the dict will have pcutoff set to 0.6.
bboxes_pcutoff: The cutoff to use for plotting bounding boxes from detectors.
When `None`, the cutoff will be loaded from the project config.
"""
if bboxes_pcutoff is None:
bboxes_pcutoff = cfg.bboxes_pcutoff

head_type = loader.model_cfg["model"]["heads"]["bodypart"]["type"]
if head_type == "DLCRNetHead":
prune_paf_graph.benchmark_paf_graphs(
Expand Down Expand Up @@ -622,8 +628,6 @@ def evaluate_snapshot(

df_ground_truth = ensure_multianimal_df_format(loader.df)

bboxes_cutoff = cfg.bboxes_pcutoff

for mode in ["train", "test"]:
df_combined = predictions[mode].merge(df_ground_truth, left_index=True, right_index=True)
bboxes_split = bounding_boxes[mode]
Expand All @@ -642,7 +646,7 @@ def evaluate_snapshot(
alpha_value=cfg["alphavalue"],
p_cutoff=cfg["pcutoff"],
bounding_boxes=bboxes_split,
bboxes_cutoff=bboxes_cutoff,
bboxes_cutoff=bboxes_pcutoff,
)

return df_predictions
Expand Down