CenterCrop keeps GT boxes outside the crop as [0, 0, 0, 0], so they count as false negatives

Open Beginner friendly
#704 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Start by locating TorchImageDetectionModel and ImageDetectionTorchDataset, then trace how the crop is added to the dataset transforms and how ground-truth boxes and labels are handled. Check existing transform tests and add a case where a box falls fully outside the center crop. Done means the degenerate box and its label are removed, so the visible object’s metrics are not reduced by an unmatched ground-truth box.

Written by the indexing model from the issue text.

Description

When a detection model config has crop, TorchImageDetectionModel adds CenterCrop to transform_input, and ImageDetectionTorchDataset applies it to the GT boxes too. torchvision v2 clamps GT boxes that are fully outside the crop to [0, 0, 0, 0] but keeps them, with their labels. They can never be matched, so each one counts as a FN.

Small example:a 400x400 image with 2 GT boxes, [150,150,250,250] (inside a 200x200 center crop) and [0,0,50,50] (outside it):

GT boxes after crop: [[50, 50, 150, 150], [0, 0, 0, 0]]
metrics for a perfect prediction: Recall 0.5, AP 0.545, FN 1

The model finds the only visible object but recall is cut in half.

Possible fix:add SanitizeBoundingBoxes() after the crop in the dataset transform, so degenerate GT boxes are removed together with their labels. I can open a PR.

Dominant language
Python
Stars
117
Forks
121
Avg merge
1d 3h
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JdeRobot/PerceptionMetrics

All issues in JdeRobot/PerceptionMetrics

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.