Expose detections_per_img and topk_candidates in config#1314
Expose detections_per_img and topk_candidates in config#1314vickysharma-prog wants to merge 1 commit intoweecology:mainfrom
Conversation
|
Thanks @bw4sz! Testing now will share results shortly. |
|
@bw4sz Test results with the shared image: Setup:
Results:
This image shows 719 raw predictions per tile, reduced to 396 after NMS — doesn't appear to hit the per-patch limit with this model. PR #1314 is ready whenever you'd like to review! |
|
But didn't you write above that the limit is 300 detections per image? |
|
The Since In this test, the model produced 719 total raw predictions across all tiles, reduced to 396 after NMS — so individual tiles weren't hitting the 300 cap with this image/model combination. |
|
@bw4sz Just following up would you like me to test with your checkpoint to demonstrate the limit being hit, or is this ready for review as-is? Happy to resolve conflicts and mark ready whenever. |
6993b05 to
8d20acd
Compare
8d20acd to
97e6ef3
Compare
97e6ef3 to
565ced1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1314 +/- ##
=======================================
Coverage 86.97% 86.98%
=======================================
Files 24 24
Lines 3009 3011 +2
=======================================
+ Hits 2617 2619 +2
Misses 392 392
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@bw4sz Rebased and added Testing with the shared image didn't hit the per-tile 300 cap. If you'd like, I can test with your alternate checkpoint to demonstrate the limit in a denser scenario. |
|
@jveitchmichaelis drop one of those tree images here. |
|
@jveitchmichaelis Hi! Would you mind sharing one of those tree images when you get a chance? Would love to test this out properly. Thanks! |

This PR exposes
detections_per_imgandtopk_candidatesas configurable parameters so users can adjust them for dense scenes.Currently, these values are hardcoded to the torchvision defaults (300 / 1000). In very dense imagery (e.g., large bird colonies or dense tree canopies), this limit can truncate valid detections.
Changes
detections_per_imgandtopk_candidatestoconfig.yamlwith current defaults.Model.create_model()→RetinaNetHub()→ torchvision RetinaNet.test_main.pyto verify the parameters are correctly applied to the model.Backwards Compatibility
Defaults remain unchanged (300 / 1000), so existing workflows are unaffected.
Benchmarks
See issue #1309 for details. On CPU, increasing the limit showed only modest overhead (~3–8%). The sample images in the repo did not reach the 300-detection cap, so I was not able to demonstrate detection differences locally. Happy to test further with denser imagery if available.
Fixes #1309