Bake flat-field profiles to a self-contained file store - #720
Merged
Conversation
Flat-field correction relied on the original reference image staying put: the per-image edit stored its filesystem path and the gain map was re-decoded from that file every render, so moving or deleting the reference silently dropped the correction. Bake it instead, following the sensor/crosstalk file-store pattern. - New FlatFieldProfiles service: one <uuid>.npz per profile in APP_CONFIG.flatfield_dir holding the baked per-channel gain map plus k1, display name and provenance. Keyed by an opaque id (name lives inside the file) so renames and cross-machine name collisions never break the per-image reference. - FlatFieldConfig.reference_path -> profile_id. The numpy logic layer stays storage-free: apply_flatfield/flatfield_token resolve gains through an injected provider (set_gain_provider), wired to the store in main.py and cached; the source-hash token is profile_id + a content hash of the gain. - One-shot startup migration bakes legacy flatfield_profiles DB rows into npz files, rewrites edits' reference_path -> profile_id, remaps the active profile setting, and drops the retired table. reference_path added to DROPPED_KEYS for stragglers. - Retired the flatfield_profiles table, repo methods and DB-dialog row; profiles now live on disk like sensor/crosstalk, so Reset Everything leaves them alone. - Tests for the store and migration; docs updated (USER_GUIDE, PIPELINE, CLAUDE invariant on the provider seam).
Two follow-ups to the file-store profiles. - get()/list_profiles() read only the small metadata members of the npz (a zip — untouched members aren't decompressed), never the ~MB gain array. The sidebar rebuilds the profile list on every config sync, so the old full read decompressed every profile's gain on each settled edit; metadata-only reads keep it cheap. load_gain()/set_k1() still read the gain. - Show a wait cursor while "Add…" bakes a profile: it decodes the reference RAW synchronously on the GUI thread, a brief blocking beat.
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.
Flat-field correction relied on the original reference image staying put: the per-image edit stored its filesystem path and the gain map was re-decoded from that file every render, so moving or deleting the reference silently dropped the correction. Bake it instead, following the sensor/crosstalk file-store pattern.