fix: let MegaDetector load explicit weights via get_checkpoint_path#31
Open
JasonWildMe wants to merge 1 commit into
Open
fix: let MegaDetector load explicit weights via get_checkpoint_path#31JasonWildMe wants to merge 1 commit into
JasonWildMe wants to merge 1 commit into
Conversation
MegaDetector was the only model type that could not take an explicit weight file: it always let PytorchWildlife fetch its hardcoded zenodo URL at load time — a hidden internet download on every cold start that deployment config could neither pin nor serve locally. An optional checkpoint_path config key now resolves through the shared get_checkpoint_path resolver (local path or URL) and is passed to MegaDetectorV6 as weights. Absent, behavior is unchanged (auto-download). A configured-but-missing local weight fails fast instead of silently downloading something else. Written test-first: tests/test_megadetector_checkpoint.py (stubbed PytorchWildlife; 2 failing tests drove the change, 1 pins the auto-download default). Carved out of #26 (its review found this gap in the MODEL_BASE story). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
MegaDetector was the only model type that couldn't take an explicit weight file: it always let PytorchWildlife fetch its hardcoded zenodo URL at load time — a hidden internet download on every cold start that deployment config could neither pin nor serve locally.
An optional
checkpoint_pathconfig key now resolves through the sharedget_checkpoint_pathresolver (local path or URL) and is passed toMegaDetectorV6asweights=. Verified against the installed PytorchWildlife source: the base loader prioritizes a truthyweightsbefore its version URL, andweights=Nonefollows the existing auto-download branch — so absentcheckpoint_path, behavior is byte-for-byte unchanged. A configured-but-missing local weight fails fast instead of silently downloading something else.app/model_config.jsonis deliberately untouched (prod bind-mounts it; flipping the megadetector entry tocheckpoint_pathrequires the weight present inMODELS_DIRfirst). This PR adds the capability; #26 can flip the config when the weights are staged.Why
Closes the gap #26's review found in its
MODEL_BASEstory: 'every model loader resolves through get_checkpoint_path' was untrue for MegaDetector, which added an unpinnable third-party download to every serverless cold start.Testing
TDD:
tests/test_megadetector_checkpoint.py(PytorchWildlife stubbed — it isn't importable without GPU extras). Two failing tests drove the change (explicit path reaches the constructor; missing local path fails before construction), one pins the auto-download default. Full suite: 45 passed.Provenance
Carved out of #26. Reviewed by Codex 5.6 (gpt-5.6-terra): converged on round 1, no findings — it independently verified the
weights=semantics in the installed package source and the kwargs flow from config to constructor.🤖 Generated with Claude Code