ENH: Add BubbleSAM detection method#3
Conversation
|
Initial TODO items for reviewing this branch:
|
|
There are several files in this repo that are also included in PR #2, specifically |
|
Ok, I've provided a pretty detailed review here, good luck! This was presented for review pretty far past the original December 2025 deadline, and I probably can't provide reviews this detailed super regularly, so I do recommend presenting things for review roughly on time moving forward. |
* parameterize tests over cpu/gpu * modify yaml input to pass default model args * fix docstrings * remove vendored sam2 module * remove mock test params * modify CI to use new sam2 module imports * modify workflow to use updated sam2.1 model/weights * remove unnecessary tests * fix test assertions
|
I'd say make sure you have tested instructions for running on Chicoma here before pinging me for another round of review. |
README.md
Outdated
| ```bash | ||
| module load cudatoolkit/24.7_12.5 | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Let's get proper instructions for running on Chicoma--you've had a few months to reproduce the paper results there now, so I think that's fair to ask for. And you need to run there again for Mihee soon on block copolymer images.
There was a problem hiding this comment.
I was able to run the workflow incantation described in #3 (comment) (with the full mask_settings) on Chicoma using the allocation for this LDRD. I allocated an interactive node with the following command:
salloc -p gpu -C gpu40 -N 1 -n 1 -t 1:00:00 --account=w25_fly-aug_gand ran the workflow on a single GPU, which gave the following outputs:
[BubbleSAM]: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [25:30<00:00, 1530.90s/it] image_filepath median_radii_SAM num_blobs_SAM
0 /users/awitmer/.cache/test_images/images_raw.tiff 5.808687 11848I also ran the same workflow incantation on a back-end node with -C gpu80 and points_per_batch: 256, which gave the following outputs:
[BubbleSAM]: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [24:51<00:00, 1491.52s/it] image_filepath median_radii_SAM num_blobs_SAM
0 /users/awitmer/.cache/test_images/images_raw.tiff 5.808687 11847Both the iteration times and detection results are nearly identical between the two workflow runs, and the skimage post-processing steps still seem to be taking significant time on chicoma as well.
I pushed a commit to update the README with instructions on how to run the workflow on chicoma including download SAM2 checkpoints on the front-end node before running the workflow, and loading the cuda module with module load cudatoolkit/12.6.0
* modify handling of model_cfg in yaml file * add ValueError check for model_cfg input * add test for ValueError raise * update docs to reflect changes
* update bubblesam yaml file to reflect change in detection_cfg * update instructions for running workflow on chicoma
* remove leftover settings from vendoring sam2 * update README.md with flavored markdowns * add/fix inline comments and docstrings
* add cuda enabled image post-processing with `cucim` * add instructions for installing cucim on cuda enabled systems * modify contour finding to use opencv * fix test to enforce assertions for checking sam2.1 detections * update mypy types
* fix parquet data handling/saving/loading * add test to check that parquet logic behaves as expected * modify pyproject to install fastparquet instead of pyarrow * revert unnecessary change
* update README for clarity * remove unnecessary None type return in test signature
|
@tylerjereddy I believe I have addressed all remaining review comments, and responded to comments requiring further clarification. Specifically, I added instructions for running the workflow on I also modified the workflow to use user defined settings from the I re-read the diff again multiple times to check for additional improvements (I found several leftover |
This merge request introduces a new library module,
neat_ml/bubblesam, which wraps theSegment Anything‑2 (SAM‑2)model for detecting circular “bubble” features in microscopy images. It also adds an accompanying test suite with deterministic baseline image comparisons.What’s inside
neat_ml/bubblesam/SAM.py: Wrapper around SAM‑2 providing:Instructions for running
bubblesamdetection have been added to theREADME.mdfile