uSAM2 implementation#1196
Draft
constantinpape wants to merge 26 commits into
Draft
Conversation
* Test claude code by implementing 'Segment Slice' for SAM2 in the 3D annotator (not yet checked) * Refactor per-slice segmentation into PromptableSegmentation3D class Move SAM2 single-slice segmentation logic from _widgets.py into the PromptableSegmentation3D class for better encapsulation and reusability. This consolidates all SAM2 segmentation functionality in the v2 module. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Refactor SAM2 inference state initialization to use volume directly Replace disk-based frame initialization with direct volume passing in AnnotatorState. This aligns with PromptableSegmentation3D implementation and removes unnecessary disk I/O overhead. Changes: - Remove _sam2_temp_dir attribute - Simplify _initialize_sam2_inference_state to pass volume directly - Remove temporary file cleanup from clear_inference_state Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Simplify and add notes * Clean up * Fix axis order --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
…cell-analytics/micro-sam into add-sam2-backbone
* Enable precomputing and loading image embeddings * Remove debugging artefacts * Ensure mandatory embeddings to video predictor * Make set_precomputed work with expected signature compatibility * Move volumetric promptable segmentation to state and flush prompts at commit or clear * Switch to running interactive_segmenter for segment_slice feature * Update micro_sam/sam_annotator/_widgets.py * Refactor sam model getter to state to support hvit in python function and CLI --------- Co-authored-by: Constantin Pape <constantin.pape@informatik.uni-goettingen.de>
* Unify 2D and 3D annotators into single implementation This commit consolidates the 2D and 3D annotator implementations into a unified Annotator class that handles both dimensions automatically. Key changes: - Add new annotator.py with unified Annotator class and annotator() function - Implement _detect_ndim() helper for automatic dimensionality detection - Simplify annotator_2d.py and annotator_3d.py to thin wrapper classes - Add comprehensive test suite in test_annotator.py - Maintain full backward compatibility with existing APIs - Export new unified API alongside existing functions in __init__.py The unified implementation: - Auto-detects 2D vs 3D from image shape when ndim=None - Conditionally creates dimension-specific widgets - Validates ndim parameter matches image dimensions - Loads AMG state only for 3D volumes (as per original behavior) - Preserves all existing function signatures and CLI entrypoints All existing code using annotator_2d(), annotator_3d(), Annotator2d, or Annotator3d continues to work unchanged. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Cosmetics * Fix sam predictor selection logic * Remove annotator_2d and 3d, update image_series_annotator * Update CLI tests * Disable GUI tests on windows * Unify per slice and volumetric segmentation widget * Update tests --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This was referenced May 4, 2026
Closed
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.
This is the most up-to-date version of SAM2 integration and UI-Updates / redesign. The goals for redesign are summarized here: https://github.com/computational-cell-analytics/SAM2_Experiments/issues/48
@anwai98 we should continue here for integrating the first joint trained model and continuing streamlining of the UI.