8000 Trace the object on a sheet that is small in the frame by jasonmadigan · Pull Request #255 · tracefinity/tracefinity · GitHub
[go: up one dir, main page]

Skip to content

Trace the object on a sheet that is small in the frame - #255

Merged
jasonmadigan merged 1 commit into
mainfrom
fix/253-small-sheet-trace
Nov 14, 2026
Merged

jasonmadigan merged 1 commit into
mainfrom
fix/253-small-sheet-trace

Conversation

@jasonmadigan
Copy link
Copy Markdown
Collaborator

A sheet photographed from further away covers a few percent of the corrected image. Two floors in the tracer assumed it fills the frame:

  • The saliency crop discarded a bright region under 10% of the corrected image, so the model ran on the whole image and returned the sheet's outline.
  • Traced regions under 5000 px were dropped, which at that scale is several square centimetres.

The trace route now passes the paper size and scale factor to the tracer. The sheet floors are measured against the sheet's own area. The smallest kept region is 150 mm² or 5000 px, whichever is fewer pixels. Callers that pass no scale keep the previous behaviour.

Behaviour change

Nothing changes while an A4 sheet's long side spans more than about 85% of the corrected image. Below that, regions between 150 mm² and 5000 px are now kept, which can surface a small object or blemish that was previously dropped.

Verification

  • cd backend && venv/bin/python -m pytest: 878 passed.
  • ruff check backend/: clean.
  • The new tests fail without the change. They cover the sheet being found from its own area, a small bright patch being rejected, the model receiving the sheet crop, and the trace route returning the 80 × 30 mm tool on a synthetic distant sheet.
  • A 24 mm-equivalent phone photo of A4 from about 65 cm with a card-sized object on it: before, one outline of 297 × 211 mm; after, 85.2 × 54.0 mm with BiRefNet Lite and 85.5 × 54.2 mm with IS-Net. The object is 85.6 × 54.0 mm.
  • Frontend untouched, so pnpm test and make test-e2e-accuracy were left to CI.

Closes #253

The saliency crop discarded a bright region under 10% of the corrected
image. That image covers the whole visible frame, so a sheet photographed
from further away fell below the floor, the model ran on the full image
and returned the sheet's outline. Traced regions under 5000 px were also
dropped, which on such a sheet removes tools of several square
centimetres.

The trace route now passes the paper size and scale factor to the tracer.
The sheet floors are measured against the sheet's own area, and the
smallest kept region is 150 mm2 or 5000 px, whichever is fewer pixels.
Callers that pass no scale keep the previous behaviour.

Closes #253

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
@jasonmadigan
jasonmadigan marked this pull request as ready for review November 14, 2026 20:01
@jasonmadigan
jasonmadigan deleted the fix/253-small-sheet-trace branch November 14, 2026 20:01
@jasonmadigan
jasonmadigan restored the fix/253-small-sheet-trace branch November 14, 2026 20:02
@jasonmadigan jasonmadigan reopened this Nov 14, 2026
@jasonmadigan
jasonmadigan merged commit a8979e0 into main Nov 14, 2026
12 checks passed
@jasonmadigan
jasonmadigan deleted the fix/253-small-sheet-trace branch November 14, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracing returns the sheet's outline when the sheet is small in the frame

1 participant

0