Conversation
aymuos15
marked this pull request as ready for review
August 14, 2026 05:19
aymuos15
force-pushed
the
ssk/2d-model-registry
branch
from
August 14, 2026 05:25
eb3f000 to
9e1181d
Compare
aymuos15
force-pushed
the
ssk/2d-model-registry
branch
from
August 14, 2026 06:30
9e1181d to
e2a7c20
Compare
Add resnet50_2d and resnet50_2d_1ch to the download registry, hosted on Hugging Face alongside the existing single-channel model. Record each model's dimensionality and channel count so callers can pick the variant matching their processing mode, and expose helpers to list the models for a mode, resolve the default for a mode, and reject a mismatched choice.
The default model now resolves from both the processing mode and whether a background channel is present, generalising the existing single-channel fallback, and an explicitly chosen model whose dimensionality disagrees is rejected with a clear error rather than failing later on a shape mismatch. The napari training widget offers only the models matching the selected dimensionality, and its default is named rather than positional so adding registry entries cannot silently change it.
The cache key was the literal string `brainglobe`, and actions/cache never overwrites an existing key. The saved entry therefore predated the HuggingFace-hosted weights, so every job restored a cache without them, re-downloaded from HuggingFace, and then declined to save. Across the test matrix this was enough to hit HuggingFace rate limits. Key on the runner OS and a hash of the model registry, with a prefix restore-key so adding a model only re-downloads the new file. The brainmapper job never checks out cellfinder, so add a scoped checkout for the hash to resolve against.
Reassigning the dropdown choices already resets the value, so the explicit fallback never ran.
alessandrofelder
force-pushed
the
ssk/2d-model-registry
branch
from
September 7, 2026 13:08
317daac to
96363a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Registers the pretrained 2D classification models and resolves the default model from the processing mode. 3D behaviour is unchanged: the 3D defaults are exactly as before.
Stack: fourth of four. Builds on
ssk/2d-napari-selection.Progresses #298.
Changes
Adds
resnet50_2dandresnet50_2d_1chto the download registry, hosted on Hugging Face atbrainglobe/cellfinder_2d_default.Records each model's dimensionality and channel count, so the default model resolves from the processing mode and whether a background channel is present. This generalises the existing single-channel fallback:
resnet50_tvresnet50_1chresnet50_2dresnet50_2d_1chSubstitution only applies when the model is still the default, so an explicit choice is never overridden.
A model whose dimensionality disagrees with the requested mode is now rejected up front, instead of failing later on a shape mismatch.
The napari model dropdown lists only models matching the selected dimensionality.
Tests: registry consistency, the mode/channel matrix, mismatch rejection, dropdown filtering.
CI cache key
Also rolls the
brainglobecache key, which was the literal stringbrainglobe. Sinceactions/cachenever overwrites an existing key, the saved entry predated the Hugging Face hosted weights, so every job restored a cache without them, re-downloaded, and then declined to save, which was enough to hit Hugging Face rate limits across the matrix. The key now includes a hash of the model registry with a prefix restore-key, so adding a model only re-downloads the new file. This rides with this layer because it is this layer that changes the registry.Model provenance
Trained on serial2p data with a held-out test set (n = 10,756), resnet50, 100 epochs. Both are the best-validation checkpoint of their run.
resnet50_2d(50, 50, 2)resnet50_2d_1ch(50, 50, 1)Both are uploaded and public. Verified from a clean environment:
download_modelsfetches each over the registered URL, pooch's hash check passes against the pinned sha256, and the loaded networks report the input shapes above with a 2-class output.The rest of the stack
ssk/2d-detectionssk/2d-trainingssk/2d-napari-selectionssk/2d-model-registryReview bottom up. Branches live in this repository rather than a fork, since GitHub stacks cannot span forks.