Skip to content

Fix/inpaint halo - #156

Open
qgeissmann wants to merge 3 commits into
developfrom
fix/inpaint-halo
Open

qgeissmann wants to merge 3 commits into
developfrom
fix/inpaint-halo

Conversation

@qgeissmann

Copy link
Copy Markdown
Contributor

Fixes #155

qgeissmann and others added 3 commits September 4, 2026 10:49
…D val

telea_inpaint_polys dilated the union of the polygons to inpaint and the polygons to
exclude, then subtracted only the undilated exclusions. The dilation ring around each
EXCLUDED polygon therefore stayed in the mask and was overwritten with inpainted content,
painting a band roughly `downscale_factor` px wide that traces the outline of every instance
that survived the crop.

FixInstances calls this from the VALIDATION pipeline as well as the training one, so the
band sat on both sides of the train/val split. A ring hugging every labelled instance is a
cue a model can learn in place of the animal and then be rewarded for at validation time, so
metrics computed before this fix were measured against crops carrying an outline of their
own ground truth. Measured on real crops: 0.2-1.1% of each crop altered, concentrated
entirely on instance boundaries.

Nothing on disk was affected - the function mutates the in-memory crop, so the prepared
dataset is unchanged and only the consumed crops carried it.

Fix: subtract a dilated exclude mask, using the same kernel and iterations that created the
ring. Regression check goes from 43.9% to 0.0% of pixels altered in a 25px band outside kept
instances, while the instances being removed are still fully inpainted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyKzVebNKNYj82VZWTZU6Y
One config, two source trees: ARM=before runs develop with the halo present, ARM=after runs
the patched tree. Everything else is held fixed, including the pyramid bug, so the pair
attributes any difference to the halo alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyKzVebNKNYj82VZWTZU6Y
The controlled 50-epoch pair (1724716/1724717, one file different) settles what the cropped
benchmark could not: the fix looks like an 8-point mAP regression on validation crops and is
a decisive improvement in real inference - end-to-end F1 0.849 -> 0.878, recall 0.850 ->
0.895, touching-instance recall 0.749 -> 0.819, 1,244 more ground-truth instances matched.
The cropped benchmark carried an outline of its own ground truth, so it was measuring the
artefact.

Also documents the pyramid native-scale bug, which is deliberately NOT fixed on this branch
so the halo change stays attributable on its own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyKzVebNKNYj82VZWTZU6Y

@asgersvenning asgersvenning left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

This branch has not been deployed

No deployments
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.

2 participants