Skip to content

Make the paper's inference and training settings the defaults - #3

Merged
smishra3 merged 1 commit into
mainfrom
fix/paper-defaults
Nov 11, 2026
Merged

smishra3 merged 1 commit into
mainfrom
fix/paper-defaults

Conversation

@smishra3

Copy link
Copy Markdown
Collaborator

What changed

  • subcellseg predict: default window overlap 0.5 -> 0.3 and blending gaussian -> constant. A voxel is foreground when its probability is at least the threshold (was: strictly above), so _seg.tif is exactly _prob.tif >= 128.
  • subcellseg train / finetune: default batch size 8 -> 32, max epochs 700 -> 1000, validation hold-out 10% -> 20%. Fine-tuning now uses learning rate 5e-5 and early-stopping patience 50; training from scratch keeps 1e-4 and 100.
  • Docs (SEGMENT.md, TRAINING.md), changelog and the README benchmark table updated. The two RELEASE TODOs that asked to confirm these settings are marked done rather than removed.
  • New test test_defaults_match_paper pins the defaults.

Why

The package is meant to reproduce the paper. The previous defaults were deliberate deviations (documented in SEGMENT.md) that changed the masks slightly. Sources for the values: the manuscript's Methods (Hyperparameters, Fine-tuning protocol, Probability map thresholding) and the cyto-dl model configs in MegaSeg (inference_args: overlap 0.3, no mode key, so MONAI's default constant blending; checked in the cyto-dl checkout that trained the released model, in commit fe8fa7ac, and in current main).

Kept as is, on purpose: validation uses the same fixed patches every epoch, whereas cyto-dl cut a fresh random patch; the paper does not specify this and fixed patches make the validation curve readable. Say the word if you want it changed too.

How it was tested

pytest on Linux with an A100: 11 passed. ruff check and ruff format --check clean.

tools/benchmark/bench_predict.sh cuda on the three variance images, Dice against SEG_STRUCT:

Image Before (0.5, gaussian) After (0.3, constant)
40 0.533 0.532
6919 0.877 0.874
11370 0.846 0.845

Peak GPU memory unchanged (2.0 to 2.5 GB). Image 40 now runs 140 windows instead of 252.

Checklist

  • Tests pass locally (pytest)
  • Docs updated if behaviour or commands changed
  • CHANGELOG.md has an entry under Unreleased (if a user would notice)
  • No weights, outputs or notebook outputs committed

🤖 Generated with Claude Code

predict: 30% window overlap and constant (uniform) blending instead of
50% and Gaussian; a voxel is foreground at probability >= threshold so
the mask equals the saved probability map thresholded at 128.
train/finetune: batch size 32, up to 1000 epochs, 20% validation
hold-out; fine-tuning uses lr 5e-5 and patience 50, from scratch keeps
1e-4 and 100. All values are from the paper's Methods and the cyto-dl
configs used for its experiments. Docs, changelog and README benchmark
numbers updated; a test pins the defaults.

Assisted-by: claude-code (claude-fable-5-1)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@smishra3
smishra3 merged commit 88c3351 into main Nov 11, 2026
7 checks passed
@smishra3
smishra3 deleted the fix/paper-defaults branch November 11, 2026 00:30
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.

1 participant