From f183b2f2c6c0da33ed3c951514130ce366775622 Mon Sep 17 00:00:00 2001 From: Taylla Theodoro Date: Fri, 20 Nov 2026 10:50:06 -0800 Subject: [PATCH 1/7] feat(segment): micro-sam 2 as a segmentation backend (backend: microsam) A segment model can now set `backend: microsam` to run micro-sam 2 (SAM2) automatic instance segmentation instead of cellpose 4. Configs without `backend` stay cellpose, and a cellpose model's recorded settings and resume token are unchanged (the field is excluded from dumps). - MicroSamModel: pretrained_model (micro-sam 2 name or checkpoint path), one channel, engine ais|apg|amg, downsample (stride, labels scaled back to the input grid), eval_args forwarded to micro-sam's post-processing. 2D (Z=1) plates only. Models of both backends can share one config. - --init stops when micro_sam is missing (names the extra), on an unknown model, or on a SAM2 backbone with ais/apg (no decoder); it fetches the weights once on the head node. - Opt-in extra `microsam` (not in `all`): micro_sam==2.0.1 plus Meta's SAM2 from git. micro_sam pins the PyPI `sam2`, a third-party fork upload; a uv override drops it. The lock now resolves pydantic 2.13.5 (micro_sam caps <2.14). --- .../references/caveats.md | 6 + README.md | 6 + biahub/segment.py | 94 ++- biahub/settings.py | 97 ++- biahub/utils/microsam.py | 102 +++ pyproject.toml | 17 + settings/example_segmentation_settings.yml | 10 +- tests/conftest.py | 88 +++ tests/test_cli/test_segment_microsam_cli.py | 116 +++ tests/test_segment_microsam.py | 272 +++++++ uv.lock | 730 +++++++++++++++--- 11 files changed, 1392 insertions(+), 146 deletions(-) create mode 100644 biahub/utils/microsam.py create mode 100644 tests/test_cli/test_segment_microsam_cli.py create mode 100644 tests/test_segment_microsam.py diff --git a/.claude/skills/reconstruct-with-nextflow/references/caveats.md b/.claude/skills/reconstruct-with-nextflow/references/caveats.md index ea2065da2..a5c580076 100644 --- a/.claude/skills/reconstruct-with-nextflow/references/caveats.md +++ b/.claude/skills/reconstruct-with-nextflow/references/caveats.md @@ -157,6 +157,12 @@ biahub's `cpdino` extra installs (not on PyPI; DINOv3 License, not open source). Install it with `uv sync --extra cpdino` (or `pip install git+https://github.com/facebookresearch/dinov3`); without it, `biahub segment --init` stops with those commands. +A model with `backend: microsam` uses micro-sam 2 instead of cellpose (`pretrained_model` +`hvit_{t,s,b,l}_cells` or a checkpoint path, `engine: ais|apg|amg`, `downsample`; 2D, one +channel). It needs `uv sync --extra microsam`, and `--init` stops if `micro_sam` is missing. +On A549 VS nuclei, `hvit_b_cells` + `apg` + `downsample: 4` matched native cpsam_v2 on +04_28 and found more mitotic nuclei on mantis-v1 data; at `downsample: 1` it outlines +whole cell clusters. **`track.yml` — schema.** `TrackingSettings` forbids extra keys. Current fields: `output_mode`, `fov`, `blank_frames_path`, `segmentation_method` diff --git a/README.md b/README.md index 90d043bbd..889aefe02 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Heavier or task-specific dependencies live in extras. Add them with `--extra`: | Extra | Installs | Needed for | | --- | --- | --- | | `segment` | `cellpose` | `biahub segment` | +| `microsam` | `micro_sam` 2, Meta's SAM2 (opt-in, not in `all`) | `biahub segment` with `backend: microsam` | | `track` | `ultrack` | `biahub track` | | `stain` | `cytoland` (VisCy) | `biahub virtual-stain` | | `gui` | `napari`, `PyQt6` | interactive/visual commands | @@ -70,6 +71,11 @@ uv sync --extra all uv run --extra stain biahub virtual-stain --help ``` +Install `microsam` with uv (`uv sync --extra microsam`), not pip. `micro_sam` 2.0.1 depends on the PyPI +`sam2` package, which is a third-party upload of a SAM2 fork rather than Meta's release. uv replaces it with +Meta's SAM2 pinned in `pyproject.toml`; pip would install both. The extra also pulls in `napari`/`PyQt6` +and caps `pydantic<2.14`. + ### Development install ```sh diff --git a/biahub/segment.py b/biahub/segment.py index 0a7bc780f..9860317bc 100644 --- a/biahub/segment.py +++ b/biahub/segment.py @@ -37,6 +37,12 @@ local_executor_parameters, ) from biahub.utils.config import settings_fingerprint, yaml_to_model +from biahub.utils.microsam import ( + check_microsam_model, + load_microsam_model, + segment_plane, + warm_microsam_weights, +) from biahub.utils.ngff import label_layout if TYPE_CHECKING: @@ -57,6 +63,10 @@ class ResolvedModel: is_3d: bool # (function, channel index, kwargs), applied in order preprocessing: list[tuple[Callable, int, dict[str, Any]]] = field(default_factory=list) + backend: str = "cellpose" + # micro-sam only: segmentation mode and in-plane downsampling factor + engine: str | None = None + downsample: int = 1 def resolve_models( @@ -86,6 +96,12 @@ def index(name: str, what: str) -> int: "stitch_threshold); remove those arguments to segment in 2D." ) if not settings.is_3d and z_size > 1: + if any(m.backend == "microsam" for m in settings.models.values()): + raise ValueError( + f"The input is 3D (Z={z_size}) but micro-sam models segment 2D planes only. " + "Project the plate with `biahub project` and segment the projected (Z=1) " + "plate." + ) raise ValueError( f"The input is 3D (Z={z_size}) but the models segment in 2D. Project the plate " "with `biahub project` and segment the projected (Z=1) plate, or set " @@ -115,38 +131,64 @@ def index(name: str, what: str) -> int: ) for p in model.preprocessing ], + backend=model.backend, + engine=getattr(model, "engine", None), + downsample=getattr(model, "downsample", 1), ) ) return resolved -# Loaded cellpose models of this process, keyed by (pretrained_model, device). A position -# runs one _segment_czyx call per timepoint; without the cache every frame reloaded the -# ~1.2 GB checkpoint. -_MODEL_CACHE: dict[tuple[str, str], Any] = {} +# Loaded models of this process, keyed by (backend, pretrained_model, engine, device). A +# position runs one _segment_czyx call per timepoint; without the cache every frame +# reloaded the checkpoint (~1.2 GB for cellpose). +_MODEL_CACHE: dict[tuple[str, str, str | None, str], Any] = {} -def _cached_model(pretrained_model: str, device: "torch.device") -> Any: - key = (pretrained_model, str(device)) +def _cached_model(model: ResolvedModel, device: "torch.device") -> Any: + key = (model.backend, model.pretrained_model, model.engine, str(device)) if key not in _MODEL_CACHE: - _MODEL_CACHE[key] = load_cellpose_model(pretrained_model, device) + if model.backend == "microsam": + _MODEL_CACHE[key] = load_microsam_model( + model.pretrained_model, model.engine, device + ) + else: + _MODEL_CACHE[key] = load_cellpose_model(model.pretrained_model, device) return _MODEL_CACHE[key] +def _check_model(model) -> None: + """Raise if a configured model cannot run (unknown name, missing extra).""" + if model.backend == "microsam": + check_microsam_model(model.pretrained_model, model.engine) + else: + check_cellpose_model_name(model.pretrained_model) + + +def _warm_model(model) -> None: + """Fetch a configured model's weights into its shared cache (head node, --init).""" + if model.backend == "microsam": + warm_microsam_weights(model.pretrained_model) + else: + warm_cellpose_weights(model.pretrained_model) + + def _segment_czyx( czyx_data: np.ndarray, models: list[ResolvedModel], gpu: bool = True, ) -> np.ndarray: - """Segment a CZYX image with each resolved cellpose model. + """Segment a CZYX image with each resolved model (cellpose 4 or micro-sam 2). Returns an array of shape (n_models, Z, Y, X); Z is 1 for 2D models. """ # Every job this step submits asks SLURM for a GPU, so an unusable one is a # broken allocation, not a reason to fall back to a ~130x slower CPU run. device = cellpose_device(gpu) - # Stage weights on node-local scratch before cellpose is first imported (no-op after). - stage_cellpose_weights() + if any(m.backend == "cellpose" for m in models): + # Stage weights on node-local scratch before cellpose is first imported (no-op + # after). + stage_cellpose_weights() czyx_segmentation = [] for model in models: @@ -157,11 +199,21 @@ def _segment_czyx( ) czyx_data[c_idx] = func(czyx_data[c_idx], **kwargs) + if model.backend == "microsam": + # One channel, one Z=1 plane: micro-sam segments the (Y, X) plane. + predictor, segmenter = _cached_model(model, device) + plane = czyx_data[model.channel_indices[0], 0] + labels = segment_plane( + plane, predictor, segmenter, model.downsample, **model.eval_args + ) + czyx_segmentation.append(labels[np.newaxis]) + continue + # Cellpose 4 refuses a z axis for 2D processing, so a 2D model gets the (C, Y, X) # plane of the Z=1 input and a 3D model the (C, Z, Y, X) stack. It also ignores # `channels` and keeps the first 3 channels it is given, so pass only the # configured ones. - cellpose_model = _cached_model(model.pretrained_model, device) + cellpose_model = _cached_model(model, device) if model.is_3d: image, z_axis = czyx_data[model.channel_indices], 1 else: @@ -269,8 +321,7 @@ def _segment_position( """Segment one position into its own label images, one per model. Each model gets one ``process_single_position`` call writing the label image named - after it (iohub's ``output_label``); the cellpose model cache makes the repeated - calls free. + after it (iohub's ``output_label``); the model cache makes the repeated calls free. """ for model in models: process_single_position( @@ -297,7 +348,7 @@ def segment( init_only: bool = False, resume: bool = False, ): - """Segment positions with cellpose 4 models (one GPU job per position). + """Segment positions with cellpose 4 or micro-sam 2 models (one GPU job per position). Parameters ---------- @@ -339,9 +390,9 @@ def segment( stage_cellpose_weights() settings = yaml_to_model(config_filepath, SegmentationSettings) if init_only: - # Fail on a bad model name before scaffolding anything. - for name in dict.fromkeys(m.pretrained_model for m in settings.models.values()): - check_cellpose_model_name(name) + # Fail on a bad model name (or a missing extra) before scaffolding anything. + for model in settings.models.values(): + _check_model(model) (T, C, Z, Y, X), models = _init_label_images(input_position_dirpaths, settings) # Calibrated on a real 2D run (2026_04_28 SEC61B, 67 x 1664 x 1193, 6 input channels, @@ -365,8 +416,11 @@ def segment( if init_only: # --init runs once on the head node: populate the shared weights cache once, rather # than N workers racing for it. Workers must not (staging needs cellpose unimported). - for name in dict.fromkeys(m.pretrained_model for m in models): - warm_cellpose_weights(name) + warmed = set() + for model in models: + if (model.backend, model.pretrained_model) not in warmed: + _warm_model(model) + warmed.add((model.backend, model.pretrained_model)) click.echo( f"Created labels/{{{', '.join(m.name for m in models)}}} in " f"{Path(input_position_dirpaths[0]).parents[2]} " @@ -447,7 +501,7 @@ def segment_cli( init_only: bool = False, resume: bool = False, ): - """Segment positions with cellpose 4 models configured in a YAML file. + """Segment positions with cellpose 4 or micro-sam 2 models configured in a YAML file. Writes one label image per model into each -i position (labels/), where `biahub track` reads them. Strategies accumulate as differently named models; a diff --git a/biahub/settings.py b/biahub/settings.py index 06f924e92..20f850efe 100644 --- a/biahub/settings.py +++ b/biahub/settings.py @@ -13,12 +13,14 @@ BaseModel, BeforeValidator, ConfigDict, + Discriminator, Field, ImportString, NonNegativeFloat, NonNegativeInt, PositiveFloat, PositiveInt, + Tag, field_validator, model_validator, ) @@ -1122,7 +1124,7 @@ class PreprocessingFunctions(BaseModel): class SegmentationModel(BaseModel): - """One cellpose 4 model and how to apply it. + """One cellpose 4 model and how to apply it (``backend: cellpose``, the default). ``channels`` are dataset channel names (1-3, any order: cellpose 4 takes up to 3 channels). The model segments in 2D unless ``eval_args.do_3D`` (or a @@ -1131,6 +1133,10 @@ class SegmentationModel(BaseModel): arguments. """ + # Excluded from dumps: label images written before the field existed record no + # backend, and the recorded settings (and resume tokens) of cellpose models must not + # change. A dumped model without `backend` reads back as cellpose. + backend: Literal["cellpose"] = Field("cellpose", exclude=True) pretrained_model: str channels: list[str] = Field(min_length=1) eval_args: dict[str, Any] = {} @@ -1155,6 +1161,12 @@ def reject_old_keys(cls, data): "`biahub project` and segment the 2D (Z=1) plate. A model without " "eval_args.do_3D segments in 2D." ) + microsam_only = [k for k in ("engine", "downsample") if k in data] + if microsam_only: + raise ValueError( + f"{microsam_only} are micro-sam options: set `backend: microsam` to " + "segment with micro-sam 2." + ) return data @field_validator("channels") @@ -1191,10 +1203,91 @@ def is_3d(self) -> bool: ) +# Arguments biahub sets itself when calling micro-sam's automatic_instance_segmentation. +_BIAHUB_MICROSAM_ARGS = ( + "predictor", + "segmenter", + "input_path", + "output_path", + "embedding_path", + "ndim", + "verbose", + "model_type", + "checkpoint", + "device", +) + + +class MicroSamModel(BaseModel): + """One micro-sam 2 model and how to apply it (``backend: microsam``). + + Automatic instance segmentation of each 2D plane (a Z=1 plate, see `biahub + project`) of one channel. ``pretrained_model`` is a micro-sam 2 model name (the + fine-tuned ``hvit_{t,s,b,l}_cells`` for cells and nuclei in light microscopy; the + plain SAM2 backbones ``hvit_{t,s,b,l}`` work with ``engine: amg`` only) or the path + to a checkpoint, e.g. one trained with ``micro_sam train``. ``engine`` is micro-sam's + segmentation mode: ``ais`` (decoder + seeded watershed), ``apg`` (decoder prompts for + SAM2's mask decoder) or ``amg`` (grid prompts, no decoder). + + ``downsample`` keeps every n-th pixel in Y and X before segmenting and scales the + labels back (nearest) to the input grid. The models were trained on cells tens of + pixels across: on mantis-v2 A549 data (0.113 um/px) 3-4 works, 1 outlines whole cell + clusters. ``eval_args`` override micro-sam's post-processing defaults (see + ``micro_sam.v2.postprocessing.default_postprocessing`` and + ``micro_sam.v2.automatic_prompt_generation.default_prompt_generation``). + Needs ``biahub[microsam]``. + """ + + backend: Literal["microsam"] + pretrained_model: str + channels: list[str] = Field(min_length=1) + engine: Literal["ais", "apg", "amg"] = "ais" + downsample: PositiveInt = 1 + eval_args: dict[str, Any] = {} + preprocessing: list[PreprocessingFunctions] = [] + model_config = ConfigDict(extra="forbid", protected_namespaces=()) + + @field_validator("channels") + @classmethod + def check_one_channel(cls, channels): + if len(channels) != 1: + raise ValueError(f"micro-sam segments one channel, got {channels}.") + return channels + + @field_validator("eval_args") + @classmethod + def validate_eval_args(cls, value): + for key in _BIAHUB_MICROSAM_ARGS: + if key in value: + raise ValueError(f"{key} is set by biahub; remove it from eval_args.") + return value + + @property + def is_3d(self) -> bool: + """micro-sam models segment 2D planes only (for now).""" + return False + + +def _segmentation_backend(value: Any) -> str: + if isinstance(value, dict): + return value.get("backend", "cellpose") + return getattr(value, "backend", "cellpose") + + +SegmentationModelConfig = Annotated[ + Annotated[SegmentationModel, Tag("cellpose")] | Annotated[MicroSamModel, Tag("microsam")], + Discriminator( + _segmentation_backend, + custom_error_type="invalid_backend", + custom_error_message="backend must be 'cellpose' (the default) or 'microsam'", + ), +] + + class SegmentationSettings(BaseModel): # One label image per model, `labels/`, written into the plate segment reads. # The name is the strategy's: strategies accumulate as differently named models. - models: dict[str, SegmentationModel] = Field(min_length=1) + models: dict[str, SegmentationModelConfig] = Field(min_length=1) model_config = {"extra": "forbid", "protected_namespaces": ()} @model_validator(mode="before") diff --git a/biahub/utils/microsam.py b/biahub/utils/microsam.py new file mode 100644 index 000000000..db68ec72e --- /dev/null +++ b/biahub/utils/microsam.py @@ -0,0 +1,102 @@ +"""micro-sam 2 (Segment Anything for Microscopy 2) for `biahub segment` (``backend: microsam``). + +micro_sam is an opt-in extra (``biahub[microsam]``): it pulls napari / PyQt6 and caps +pydantic. Every import of it is local, so biahub imports without it. + +Weights are downloaded by micro-sam (pooch) to its cache, ``$MICROSAM_CACHEDIR`` or +``~/.cache/micro_sam``; `biahub segment --init` fetches them once on the head node. +""" + +from pathlib import Path +from typing import Any + +import numpy as np + +_INSTALL_HINT = ( + "micro-sam models need the micro_sam package. Install biahub's opt-in extra: " + "`uv sync --extra microsam` (or `pip install 'biahub[microsam]'`)." +) + + +def _import_microsam(): + try: + from micro_sam.v2 import automatic_segmentation, util + except ImportError as error: + raise ImportError(_INSTALL_HINT) from error + return automatic_segmentation, util + + +def check_microsam_model(pretrained_model: str, engine: str) -> None: + """Raise if micro-sam cannot run ``pretrained_model`` with ``engine``. + + A checkpoint file is accepted as is (micro-sam reads the model size from it). A name + must be a fine-tuned micro-sam 2 model, or a plain SAM2 backbone with ``engine: amg`` + (the backbones have no decoder, which AIS and APG need). + """ + _, util = _import_microsam() + if Path(pretrained_model).is_file(): + return + finetuned, backbones = list(util.get_model_names()), list(util.SUPPORTED_MODELS) + if pretrained_model in backbones: + if engine != "amg": + raise ValueError( + f"micro-sam model {pretrained_model!r} is a plain SAM2 backbone without a " + f"decoder: it supports engine 'amg' only, not {engine!r}. Use a fine-tuned " + f"model ({finetuned}) for 'ais' / 'apg'." + ) + return + if pretrained_model not in finetuned: + raise ValueError( + f"Unknown micro-sam model {pretrained_model!r}: not a file and not one of " + f"{finetuned + backbones}. The micro-sam 1 models (vit_b_lm, ...) are not " + "supported." + ) + + +def warm_microsam_weights(pretrained_model: str) -> None: + """Download a micro-sam model (and its decoder) into micro-sam's cache, once. + + Called on the head node (`--init`) so that N workers do not race for the download. + Checkpoint files and plain SAM2 backbones (downloaded when first built) are skipped. + """ + if Path(pretrained_model).is_file(): + return + _, util = _import_microsam() + registry = util.models() + if pretrained_model not in registry.registry: + return + for name in (pretrained_model, f"{pretrained_model}_decoder"): + if name in registry.registry: + registry.fetch(name, progressbar=False) + + +def load_microsam_model(pretrained_model: str, engine: str, device) -> tuple[Any, Any]: + """Build micro-sam's (predictor, segmenter) for 2D automatic segmentation.""" + automatic_segmentation, _ = _import_microsam() + if Path(pretrained_model).is_file(): + kwargs = {"checkpoint": pretrained_model} + else: + kwargs = {"model_type": pretrained_model} + return automatic_segmentation.get_predictor_and_segmenter( + device=device, segmentation_mode=engine, **kwargs + ) + + +def segment_plane( + plane: np.ndarray, + predictor: Any, + segmenter: Any, + downsample: int = 1, + **generate_kwargs, +) -> np.ndarray: + """Segment one (Y, X) plane, downsampled by striding, and return labels on its grid.""" + automatic_segmentation, _ = _import_microsam() + small = np.ascontiguousarray(plane[::downsample, ::downsample]) + labels = automatic_segmentation.automatic_instance_segmentation( + predictor, segmenter, input_path=small, ndim=2, verbose=False, **generate_kwargs + ) + labels = np.asarray(labels) + if downsample > 1: + # Nearest upsampling: each label pixel covers a downsample x downsample block. + labels = np.repeat(np.repeat(labels, downsample, axis=0), downsample, axis=1) + return labels[: plane.shape[0], : plane.shape[1]].astype(np.uint32) diff --git a/pyproject.toml b/pyproject.toml index 957e84b42..fe7205d82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,20 @@ cpdino = [ "dinov3 @ git+https://github.com/facebookresearch/dinov3@6876159a11b4df116f30f667f8c9888617df0751", ] +# micro-sam 2 (Segment Anything for Microscopy 2, on SAM2) as a `biahub segment` backend +# (`backend: microsam`). Opt-in, not in `all`: micro_sam hard-requires napari and PyQt6 +# and caps pydantic<2.14. micro_sam 2.0.1 pins `sam2==1.1.0` from PyPI, which is not +# Meta's SAM2 but a third-party upload of a fork (JinsuaFeito-dev/segment-anything-2); +# Meta's repo builds the distribution `SAM-2` (import name `sam2`) and is not on PyPI. +# So the extra installs Meta's SAM2 from git at a fixed commit, and the [tool.uv] +# override below drops the PyPI `sam2`. Plain pip honours no override and would install +# both (whichever lands last provides `sam2`): use uv. +microsam = [ + "biahub[segment]", + "micro_sam==2.0.1", + "sam-2 @ git+https://github.com/facebookresearch/sam2@2b90b9f5ceec907a1c18123530e92e794ad901a4", +] + # The trackers `biahub track` can select with `tracker:`: ultrack (default), # tracksdata (ILP on fixed labels), HOCT (learned edge scores + ILP) and Trackastra # (transformer links; greedy, or ILP via motile). ultrack is deliberately CPU-only: its @@ -130,6 +144,9 @@ biahub = "biahub.cli.main:cli" # when resolving build-system requirements such as iohub's hatchling / # uv-dynamic-versioning chain, which pulls in packaging>=24.2. index-strategy = "unsafe-best-match" +# micro_sam 2.0.1 depends on the PyPI `sam2`, a third-party fork (see the `microsam` +# extra); a never-true marker drops it, so only Meta's SAM-2 provides `sam2`. +override-dependencies = ["sam2; sys_platform == 'never'"] [tool.uv.sources] # Private repo, no PyPI release. HTTPS rather than ssh so that installing the diff --git a/settings/example_segmentation_settings.yml b/settings/example_segmentation_settings.yml index 0e4f56e2d..95b9a77cd 100644 --- a/settings/example_segmentation_settings.yml +++ b/settings/example_segmentation_settings.yml @@ -1,4 +1,5 @@ -# Segmentation settings for cellpose 4 (`biahub segment`). +# Segmentation settings for `biahub segment`: cellpose 4 (the default backend) or +# micro-sam 2 (`backend: microsam`, see the last model; needs `uv sync --extra microsam`). # Model names become the label image names in each -i position (e.g. membrane -> # labels/membrane), which `biahub track` reads. Strategies accumulate as differently # named models; a name is only rewritten by the model that made it. @@ -33,3 +34,10 @@ models: cellprob_threshold: 0.0 do_3D: false min_size: 8000 + nucleus_microsam: + backend: microsam # micro-sam 2 (SAM2); 2D (Z=1) plates, one channel + pretrained_model: hvit_b_cells # hvit_{t,s,b,l}_cells, a SAM2 backbone (engine amg only), or a checkpoint path + channels: ['nuc'] + engine: apg # ais (default), apg or amg + downsample: 4 # every 4th pixel in Y and X; labels are scaled back to the input grid + eval_args: {} # micro-sam post-processing overrides, e.g. {min_size: 100} diff --git a/tests/conftest.py b/tests/conftest.py index fe807bf7c..9ff364063 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -282,3 +282,91 @@ def fake_cellpose(monkeypatch, tmp_path): segment._MODEL_CACHE.clear() # models are cached per process return RecordingModel + + +# --- micro-sam 2 stand-in for segment tests (the test extra does not install micro_sam) + + +class RecordingMicroSam: + """Stand-in for micro_sam.v2: records the models built and the images segmented.""" + + MODEL_NAMES = ["hvit_t_cells", "hvit_s_cells", "hvit_b_cells", "hvit_l_cells"] + BACKBONES = ["hvit_t", "hvit_s", "hvit_b", "hvit_l"] + built = [] # (model_type, checkpoint, segmentation_mode) + segmented = [] # (image, generate_kwargs) + fetched = [] # registry names downloaded + + @classmethod + def get_predictor_and_segmenter( + cls, + model_type="hvit_t_cells", + checkpoint=None, + device=None, + segmentation_mode=None, + **_, + ): + cls.built.append((model_type, checkpoint, segmentation_mode)) + return object(), object() + + @classmethod + def automatic_instance_segmentation( + cls, predictor, segmenter, input_path, ndim=None, verbose=True, **generate_kwargs + ): + assert ndim == 2 + cls.segmented.append((np.array(input_path), generate_kwargs)) + return np.ones(input_path.shape, dtype=np.uint32) + + class _Registry: + registry = { + **{ + n: "xxh128:0" + for n in ["hvit_t_cells", "hvit_s_cells", "hvit_b_cells", "hvit_l_cells"] + }, + **{f"{n}_decoder": "xxh128:0" for n in ["hvit_t_cells", "hvit_b_cells"]}, + } + + def fetch(self, name, progressbar=True): + RecordingMicroSam.fetched.append(name) + return f"/cache/{name}" + + +@pytest.fixture() +def fake_microsam(monkeypatch): + automatic = types.ModuleType("micro_sam.v2.automatic_segmentation") + automatic.get_predictor_and_segmenter = RecordingMicroSam.get_predictor_and_segmenter + automatic.automatic_instance_segmentation = ( + RecordingMicroSam.automatic_instance_segmentation + ) + util = types.ModuleType("micro_sam.v2.util") + util.get_model_names = lambda: list(RecordingMicroSam.MODEL_NAMES) + util.SUPPORTED_MODELS = list(RecordingMicroSam.BACKBONES) + util.models = RecordingMicroSam._Registry + v2 = types.ModuleType("micro_sam.v2") + v2.automatic_segmentation, v2.util = automatic, util + package = types.ModuleType("micro_sam") + package.v2 = v2 + for name, module in { + "micro_sam": package, + "micro_sam.v2": v2, + "micro_sam.v2.automatic_segmentation": automatic, + "micro_sam.v2.util": util, + }.items(): + monkeypatch.setitem(sys.modules, name, module) + RecordingMicroSam.built, RecordingMicroSam.segmented, RecordingMicroSam.fetched = ( + [], + [], + [], + ) + from biahub import segment + + segment._MODEL_CACHE.clear() + return RecordingMicroSam + + +@pytest.fixture() +def no_microsam(monkeypatch): + """micro_sam is not installed: importing it fails as it would without the extra.""" + monkeypatch.setitem(sys.modules, "micro_sam", None) + from biahub import segment + + segment._MODEL_CACHE.clear() diff --git a/tests/test_cli/test_segment_microsam_cli.py b/tests/test_cli/test_segment_microsam_cli.py new file mode 100644 index 000000000..1c9e1b834 --- /dev/null +++ b/tests/test_cli/test_segment_microsam_cli.py @@ -0,0 +1,116 @@ +"""biahub segment with a micro-sam 2 model: --init checks and a debug (in-process) run.""" + +import numpy as np +import pytest +import torch +import yaml + +from click.testing import CliRunner +from iohub.ngff import open_ome_zarr + +from biahub.cli.main import cli + + +@pytest.fixture(autouse=True) +def run_in_tmp_path(monkeypatch, tmp_path): + """The submitit folder is ./slurm_output: keep it out of the repo.""" + monkeypatch.chdir(tmp_path) + + +@pytest.fixture +def plate_2d(create_custom_plate, tmp_path): + """A projected (Z=1) plate: (T=3, C=3, Z=1, Y=5, X=6).""" + return create_custom_plate(tmp_path, z_size=1) + + +@pytest.fixture +def cpu_device(monkeypatch): + """Workers ask for the GPU; run the (fake) model on the CPU instead.""" + monkeypatch.setattr("biahub.segment.cellpose_device", lambda gpu: torch.device("cpu")) + + +@pytest.fixture +def microsam_config(tmp_path): + def _write(pretrained_model="hvit_b_cells", engine="apg", downsample=2): + path = tmp_path / f"segment_{pretrained_model.replace('/', '_')}_{engine}.yml" + config = { + "models": { + "nuc": { + "backend": "microsam", + "pretrained_model": pretrained_model, + "channels": ["GFP"], + "engine": engine, + "downsample": downsample, + } + } + } + path.write_text(yaml.safe_dump(config)) + return path + + return _write + + +def _run(*args): + return CliRunner().invoke(cli, ["segment", *map(str, args)]) + + +def test_init_creates_the_label_image_and_fetches_the_weights( + fake_microsam, plate_2d, microsam_config +): + plate_path, _ = plate_2d + position = plate_path / "A" / "1" / "0" + + result = _run("--init", "-i", position, "-c", microsam_config()) + + assert result.exit_code == 0, result.output + assert "Created labels/{nuc}" in result.output + with open_ome_zarr(position, mode="r") as pos: + assert pos.label_names() == ["nuc"] + assert fake_microsam.fetched == ["hvit_b_cells", "hvit_b_cells_decoder"] + assert fake_microsam.segmented == [] # --init segments nothing + + +def test_init_without_micro_sam_says_which_extra_to_install( + no_microsam, plate_2d, microsam_config +): + plate_path, _ = plate_2d + position = plate_path / "A" / "1" / "0" + + result = _run("--init", "-i", position, "-c", microsam_config()) + + assert result.exit_code != 0 + assert "biahub[microsam]" in str(result.exception) + result.output + assert not (position / "labels").exists() + + +def test_init_rejects_an_unknown_microsam_model_before_creating_labels( + fake_microsam, plate_2d, microsam_config +): + plate_path, _ = plate_2d + position = plate_path / "A" / "1" / "0" + + result = _run("--init", "-i", position, "-c", microsam_config(pretrained_model="vit_b_lm")) + + assert result.exit_code != 0 + assert "Unknown micro-sam model 'vit_b_lm'" in str(result.exception) + result.output + assert not (position / "labels").exists() + + +def test_debug_run_fills_the_label_image(fake_microsam, cpu_device, plate_2d, microsam_config): + plate_path, _ = plate_2d + config = microsam_config() + position = plate_path / "B" / "1" / "0" + assert _run("--init", "-i", position, "-c", config).exit_code == 0 + + result = _run("--cluster", "debug", "-i", position, "-c", config) + + assert result.exit_code == 0, result.output + with open_ome_zarr(position, mode="r") as pos: + label = pos.get_label("nuc")["0"][:] + assert label.shape == (3, 1, 1, 5, 6) + assert np.all(label == 1) # the stand-in labels every pixel 1, upsampled back + attrs = dict(pos.get_label("nuc").zattrs) + assert attrs["biahub-segment"]["models"]["nuc"]["backend"] == "microsam" + assert len(fake_microsam.built) == 1 # one model load for the whole position + assert len(fake_microsam.segmented) == 3 # one per timepoint + assert fake_microsam.segmented[0][0].shape == (3, 3) # 5 x 6 downsampled by 2 diff --git a/tests/test_segment_microsam.py b/tests/test_segment_microsam.py new file mode 100644 index 000000000..d9d2073f2 --- /dev/null +++ b/tests/test_segment_microsam.py @@ -0,0 +1,272 @@ +"""micro-sam 2 as a `biahub segment` backend: config schema and what segment hands to it. + +The test extra does not install micro_sam; ``fake_microsam`` (conftest) records the +models built and the images segmented. +""" + +import numpy as np +import pytest + +from pydantic import ValidationError + + +def _settings(**model): + from biahub.settings import SegmentationSettings + + base = {"backend": "microsam", "pretrained_model": "hvit_b_cells", "channels": ["nuc"]} + return SegmentationSettings(models={"nucleus": {**base, **model}}) + + +def _segment(czyx, channels, **model): + """Run _segment_czyx on ``czyx`` whose channels are named c0, c1, ...""" + from biahub.segment import _segment_czyx, resolve_models + from biahub.settings import SegmentationSettings + + names = [f"c{i}" for i in range(czyx.shape[0])] + settings = SegmentationSettings( + models={"nuc": {"channels": [names[c] for c in channels], **model}} + ) + models = resolve_models(settings, names, scale=(1,) * 5, z_size=czyx.shape[1]) + return _segment_czyx(czyx, models, gpu=False) + + +# --- config + + +def test_microsam_model_defaults(): + m = _settings().models["nucleus"] + assert m.backend == "microsam" + assert m.engine == "ais" # micro-sam's own default + assert m.downsample == 1 + assert m.eval_args == {} + assert not m.is_3d + + +def test_a_config_without_backend_is_still_cellpose(fake_cellpose): + from biahub.settings import SegmentationSettings + + s = SegmentationSettings( + models={"nuc": {"pretrained_model": "cpsam_v2", "channels": ["n"]}} + ) + assert s.models["nuc"].backend == "cellpose" + + +def test_cellpose_provenance_does_not_record_the_backend(fake_cellpose): + # Label images written before the backend field existed record no `backend`; the + # recorded settings (and the resume token) of a cellpose model must not change. + from biahub.settings import SegmentationSettings + + s = SegmentationSettings( + models={"nuc": {"pretrained_model": "cpsam_v2", "channels": ["n"]}} + ) + assert "backend" not in s.model_dump(mode="json")["models"]["nuc"] + + +def test_microsam_provenance_records_the_backend(): + assert _settings().model_dump(mode="json")["models"]["nucleus"]["backend"] == "microsam" + + +def test_microsam_takes_one_channel(): + with pytest.raises(ValidationError, match="one channel"): + _settings(channels=["nuc", "mem"]) + + +@pytest.mark.parametrize("downsample", [0, -2]) +def test_downsample_must_be_positive(downsample): + with pytest.raises(ValidationError): + _settings(downsample=downsample) + + +def test_unknown_engine_is_refused(): + with pytest.raises(ValidationError): + _settings(engine="cellpose") + + +def test_microsam_options_are_refused_on_a_cellpose_model(fake_cellpose): + from biahub.settings import SegmentationSettings + + with pytest.raises(ValidationError, match="engine"): + SegmentationSettings( + models={ + "nuc": {"pretrained_model": "cpsam_v2", "channels": ["n"], "engine": "apg"} + } + ) + + +def test_unknown_backend_is_refused(): + with pytest.raises(ValidationError, match="backend"): + _settings(backend="stardist") + + +def test_cellpose_and_microsam_models_can_share_a_config(fake_cellpose): + from biahub.settings import SegmentationSettings + + s = SegmentationSettings( + models={ + "cp": {"pretrained_model": "cpsam_v2", "channels": ["n"]}, + "msam": { + "backend": "microsam", + "pretrained_model": "hvit_b_cells", + "channels": ["n"], + }, + } + ) + assert [m.backend for m in s.models.values()] == ["cellpose", "microsam"] + assert not s.is_3d + + +def test_microsam_models_are_2d_only(): + from biahub.segment import resolve_models + + with pytest.raises(ValueError, match="2D"): + resolve_models(_settings(), ["nuc"], scale=(1,) * 5, z_size=4) + + +# --- what segment hands to micro-sam + + +def test_segment_builds_the_configured_model_and_engine(fake_microsam): + _segment( + np.zeros((1, 1, 8, 8), np.float32), + channels=[0], + backend="microsam", + pretrained_model="hvit_b_cells", + engine="apg", + ) + assert fake_microsam.built == [("hvit_b_cells", None, "apg")] + + +def test_a_checkpoint_path_is_passed_as_the_checkpoint(fake_microsam, tmp_path): + ckpt = tmp_path / "best.pt" + ckpt.write_bytes(b"") + _segment( + np.zeros((1, 1, 8, 8), np.float32), + channels=[0], + backend="microsam", + pretrained_model=str(ckpt), + ) + ((model_type, checkpoint, _),) = fake_microsam.built + assert checkpoint == str(ckpt) + + +def test_segment_passes_the_configured_plane_downsampled(fake_microsam): + czyx = np.stack([np.full((1, 9, 12), c, np.float32) for c in (10, 20)]) + czyx[1, 0, ::3, ::3] = 99 # only the strided samples carry 99 + + _segment( + czyx, channels=[1], backend="microsam", pretrained_model="hvit_b_cells", downsample=3 + ) + + ((image, _),) = fake_microsam.segmented + assert image.shape == (3, 4) # 2D plane, every 3rd pixel + assert np.all(image == 99) + + +def test_segment_returns_labels_on_the_input_grid(fake_microsam): + czyx = np.zeros((1, 1, 10, 13), np.float32) # not a multiple of the factor + labels = _segment( + czyx, channels=[0], backend="microsam", pretrained_model="hvit_b_cells", downsample=4 + ) + assert labels.shape == (1, 1, 10, 13) # (models, Z=1, Y, X) + assert np.all(labels == 1) + + +def test_eval_args_are_forwarded_to_the_postprocessing(fake_microsam): + _segment( + np.zeros((1, 1, 8, 8), np.float32), + channels=[0], + backend="microsam", + pretrained_model="hvit_b_cells", + eval_args={"min_size": 100}, + ) + ((_, kwargs),) = fake_microsam.segmented + assert kwargs == {"min_size": 100} + + +def test_segment_loads_a_microsam_model_once_across_timepoints(fake_microsam): + from biahub.segment import _segment_czyx, resolve_models + from biahub.settings import SegmentationSettings + + settings = SegmentationSettings( + models={ + "nuc": { + "backend": "microsam", + "pretrained_model": "hvit_b_cells", + "channels": ["c0"], + } + } + ) + models = resolve_models(settings, ["c0"], scale=(1,) * 5, z_size=1) + for _ in range(3): + _segment_czyx(np.zeros((1, 1, 8, 8), np.float32), models, gpu=False) + assert len(fake_microsam.built) == 1 + assert len(fake_microsam.segmented) == 3 + + +def test_a_mixed_config_runs_each_backend(fake_cellpose, fake_microsam): + from biahub.segment import _segment_czyx, resolve_models + from biahub.settings import SegmentationSettings + + settings = SegmentationSettings( + models={ + "cp": {"pretrained_model": "cpsam_v2", "channels": ["c0"]}, + "msam": { + "backend": "microsam", + "pretrained_model": "hvit_b_cells", + "channels": ["c0"], + }, + } + ) + models = resolve_models(settings, ["c0"], scale=(1,) * 5, z_size=1) + labels = _segment_czyx(np.zeros((1, 1, 8, 8), np.float32), models, gpu=False) + assert labels.shape == (2, 1, 8, 8) + assert fake_cellpose.built == ["cpsam_v2"] + assert [b[0] for b in fake_microsam.built] == ["hvit_b_cells"] + + +# --- model checks (`--init`) + + +def test_check_accepts_a_finetuned_model(fake_microsam): + from biahub.utils.microsam import check_microsam_model + + check_microsam_model("hvit_b_cells", "apg") + + +def test_check_refuses_an_unknown_name(fake_microsam): + from biahub.utils.microsam import check_microsam_model + + with pytest.raises(ValueError, match="Unknown micro-sam model 'vit_b_lm'"): + check_microsam_model("vit_b_lm", "ais") + + +def test_check_refuses_a_backbone_without_decoder_for_ais(fake_microsam): + # The plain SAM2 backbones have no decoder: only AMG can use them. + from biahub.utils.microsam import check_microsam_model + + with pytest.raises(ValueError, match="amg"): + check_microsam_model("hvit_b", "ais") + check_microsam_model("hvit_b", "amg") + + +def test_check_says_how_to_install_micro_sam(no_microsam): + from biahub.utils.microsam import check_microsam_model + + with pytest.raises(ImportError, match=r"biahub\[microsam\]"): + check_microsam_model("hvit_b_cells", "ais") + + +def test_warm_fetches_the_model_and_its_decoder(fake_microsam): + from biahub.utils.microsam import warm_microsam_weights + + warm_microsam_weights("hvit_b_cells") + assert fake_microsam.fetched == ["hvit_b_cells", "hvit_b_cells_decoder"] + + +def test_warm_skips_a_checkpoint_file(fake_microsam, tmp_path): + from biahub.utils.microsam import warm_microsam_weights + + ckpt = tmp_path / "best.pt" + ckpt.write_bytes(b"") + warm_microsam_weights(str(ckpt)) + assert fake_microsam.fetched == [] diff --git a/uv.lock b/uv.lock index f44901529..208bae377 100644 --- a/uv.lock +++ b/uv.lock @@ -4,18 +4,29 @@ requires-python = ">=3.12" resolution-markers = [ "python_full_version >= '3.15' and sys_platform == 'win32'", "python_full_version >= '3.15' and sys_platform == 'emscripten'", - "python_full_version >= '3.15' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version >= '3.15' and sys_platform == 'linux'", + "python_full_version >= '3.15' and sys_platform == 'darwin'", + "python_full_version >= '3.15' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version == '3.14.*' and sys_platform == 'win32'", "python_full_version == '3.14.*' and sys_platform == 'emscripten'", - "python_full_version == '3.14.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version == '3.14.*' and sys_platform == 'linux'", + "python_full_version == '3.14.*' and sys_platform == 'darwin'", + "python_full_version == '3.14.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version == '3.13.*' and sys_platform == 'win32'", "python_full_version == '3.13.*' and sys_platform == 'emscripten'", - "python_full_version == '3.13.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version == '3.13.*' and sys_platform == 'linux'", + "python_full_version == '3.13.*' and sys_platform == 'darwin'", + "python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version < '3.13' and sys_platform == 'win32'", "python_full_version < '3.13' and sys_platform == 'emscripten'", - "python_full_version < '3.13' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version < '3.13' and sys_platform == 'linux'", + "python_full_version < '3.13' and sys_platform == 'darwin'", + "python_full_version < '3.13' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", ] +[manifest] +overrides = [{ name = "sam2", marker = "sys_platform == 'never'" }] + [[package]] name = "absl-py" version = "2.5.1" @@ -394,6 +405,11 @@ gui = [ { name = "napari-animation" }, { name = "pyqt6" }, ] +microsam = [ + { name = "cellpose" }, + { name = "micro-sam" }, + { name = "sam-2" }, +] qc = [ { name = "imaging-qc-pipeline", extra = ["interactive"] }, ] @@ -428,6 +444,7 @@ requires-dist = [ { name = "build", marker = "extra == 'build'" }, { name = "cellpose", marker = "extra == 'all'", specifier = ">=4.0.1" }, { name = "cellpose", marker = "extra == 'cpdino'", specifier = ">=4.0.1" }, + { name = "cellpose", marker = "extra == 'microsam'", specifier = ">=4.0.1" }, { name = "cellpose", marker = "extra == 'segment'", specifier = ">=4.0.1" }, { name = "click" }, { name = "cytoland", marker = "extra == 'all'" }, @@ -452,6 +469,7 @@ requires-dist = [ { name = "llvmlite", specifier = ">=0.41.0" }, { name = "markdown" }, { name = "matplotlib" }, + { name = "micro-sam", marker = "extra == 'microsam'", specifier = "==2.0.1" }, { name = "mkdocs-click", marker = "extra == 'doc'", specifier = ">=0.8" }, { name = "napari", extras = ["pyqt6"], marker = "extra == 'all'" }, { name = "napari", extras = ["pyqt6"], marker = "extra == 'gui'" }, @@ -465,6 +483,7 @@ requires-dist = [ { name = "pyqt6", marker = "extra == 'all'", specifier = "<6.10" }, { name = "pyqt6", marker = "extra == 'gui'", specifier = "<6.10" }, { name = "pystackreg" }, + { name = "sam-2", marker = "extra == 'microsam'", git = "https://github.com/facebookresearch/sam2?rev=2b90b9f5ceec907a1c18123530e92e794ad901a4" }, { name = "scikit-learn" }, { name = "scipy" }, { name = "submitit" }, @@ -481,7 +500,7 @@ requires-dist = [ { name = "waveorder", git = "https://github.com/mehta-lab/waveorder?rev=0e25b9bbe760e5278fde867ef24bdf28979f0bca" }, { name = "zensical", marker = "extra == 'doc'", specifier = ">=0.0.32" }, ] -provides-extras = ["all", "build", "cpdino", "doc", "gui", "qc", "segment", "stain", "track"] +provides-extras = ["all", "build", "cpdino", "doc", "gui", "microsam", "qc", "segment", "stain", "track"] [package.metadata.requires-dev] dev = [ @@ -500,6 +519,104 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/97/53/2a3c7d562271ec6b6e38e7216b3104899f8aa4180c0713cb8aaf69e29cd5/bidict-0.24.1-py3-none-any.whl", hash = "sha256:fd3eaa737917d8a14f4baa391670c433c4e3f6f5fd2cd99d4bf436437f432364", size = 36175, upload-time = "2026-08-25T23:45:51.096Z" }, ] +[[package]] +name = "bioimage-cpp" +version = "0.10.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/2e/99/c320754380e7130a01d584dbc27cb074275e008472644a2bae7e16275a3e/bioimage_cpp-0.10.0.tar.gz", hash = "sha256:a709d972d1fb5f65c780fc4b19678ba3fd229037a06ddb906b0ea6655ce32973", size = 763911, upload-time = "2026-11-05T09:15:54.176Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d4/a2/eebded41330153d019845282beb78deffcdcf5884e09c196c60553c0c41a/bioimage_cpp-0.10.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:71d915a06ba61cadd402893c481b6f854fabe2fa08f337862b9427df7b3628ae", size = 1779032, upload-time = "2026-11-05T09:15:35.656Z" }, + { url = "https://files.pythonhosted.org/packages/ca/5a/643bcdafcc89e8d7ae3465197560b6691c8ea6077995867cc96140698456/bioimage_cpp-0.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6e8fe96eb3da191f5d525e5d3386ab45eff19905e6401cc3cd6fe7fa7edfe33c", size = 1405994, upload-time = "2026-11-05T09:15:37.153Z" }, + { url = "https://files.pythonhosted.org/packages/62/5f/00d8559324b6b76cfb470f7d8c651cd6bb1a374507ca1600fc611d2abc34/bioimage_cpp-0.10.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b7aad4097047f15a56cd9233e81ea1481ecac44a449f0d8c500f807d53134aa3", size = 2304456, upload-time = "2026-11-05T09:15:39.067Z" }, + { url = "https://files.pythonhosted.org/packages/09/ac/6779f592f5dc998406dc8fa0efade2599a477dbf45f0628d22d396638e2d/bioimage_cpp-0.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:89bc54fe7fb0ebdb72be9c43ebff3f0d758b153e40d74a6cc7559cfbff0d589f", size = 875202, upload-time = "2026-11-05T09:15:40.857Z" }, + { url = "https://files.pythonhosted.org/packages/3e/0a/5fec6b1d9c508f59af90c4ab538ba7fd7de70a4d34884c2fc305b4c1fd9e/bioimage_cpp-0.10.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:9cbb62c15439e47567e00ae54aba8ab9cafe4a9ecd1ea3f3cfdc8d1fe5a157ad", size = 1779145, upload-time = "2026-11-05T09:15:42.339Z" }, + { url = "https://files.pythonhosted.org/packages/aa/2a/553ba0d90d657f28ee673c6d377c1fba29802fd44d6a8a5eae0ab1033c86/bioimage_cpp-0.10.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a39a011fb00548b13515f6b8684c9948445d1d9e4ed47c8dc55273991c7eb0bd", size = 1406028, upload-time = "2026-11-05T09:15:43.794Z" }, + { url = "https://files.pythonhosted.org/packages/cb/71/3a006c27591a51ed2f85bb44bd7d5e237cde837dfa36b13d7b081343cab4/bioimage_cpp-0.10.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7cd3bf1922fc6c2b0da963789a6a11bf461e72db7035e9451ca35b515beb7958", size = 2304380, upload-time = "2026-11-05T09:15:45.386Z" }, + { url = "https://files.pythonhosted.org/packages/67/ed/bcc4bc8ff78a53dd02057da0cda73b4ec9e3ec67e04213cc061f87b6d10d/bioimage_cpp-0.10.0-cp313-cp313-win_amd64.whl", hash = "sha256:b8071607caf3a9f530a85e39029c01d2ad9fe1e26040b6448d27897b19626b48", size = 875188, upload-time = "2026-11-05T09:15:46.902Z" }, + { url = "https://files.pythonhosted.org/packages/24/62/e86e464f6cb6a0142420b4f6edbf5262cdfa18e2da8f711e9db27e9e60e4/bioimage_cpp-0.10.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:7ca3a9b8367ec787dd40168ad89c0baaf50d3d110e5167511e17538069f9a1c1", size = 1778814, upload-time = "2026-11-05T09:15:48.37Z" }, + { url = "https://files.pythonhosted.org/packages/83/6a/582612eb2533232fe878ef9d51a5aa6f102b96b7c5fcb883e64cb2fc002f/bioimage_cpp-0.10.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:56a27d262daf6f302cfeb8f5bfba064c0450f3a64ee08fc4014f1d816ebf1b60", size = 1406216, upload-time = "2026-11-05T09:15:49.814Z" }, + { url = "https://files.pythonhosted.org/packages/88/67/9fcd3553b773d77f57a2d512ad2245528fe6c98af605a2e55ae6869233c6/bioimage_cpp-0.10.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:763f13dda3169e240b31f717532b22d9fb273d22ee014c2130fd5e6a10d8b4a3", size = 2304696, upload-time = "2026-11-05T09:15:51.288Z" }, + { url = "https://files.pythonhosted.org/packages/85/a5/c61590b4afcde6c4b98932bf9466addb74f95756864fc82f4fead6a75dbd/bioimage_cpp-0.10.0-cp314-cp314-win_amd64.whl", hash = "sha256:d50ffea79d08d05483519b3b2bf589d184840400a81e9054456b7e9c67074de4", size = 898296, upload-time = "2026-11-05T09:15:52.757Z" }, +] + +[[package]] +name = "bioimage-py" +version = "0.2.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "bioimage-cpp" }, + { name = "cloudpickle" }, + { name = "numpy" }, + { name = "pandas" }, + { name = "scikit-image" }, + { name = "scipy" }, + { name = "threadpoolctl" }, + { name = "tomli-w" }, + { name = "tqdm" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/17/f5/17c41174c1b3753b19ee1c552039ca30fdd64d065cbe347628c939f6656f/bioimage_py-0.2.2.tar.gz", hash = "sha256:e25853cf8d36129d09f038a4bcbc2a11983db36dea5dbe8dac92d54608cac69e", size = 170273, upload-time = "2026-10-15T20:33:36.079Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0a/24/a558890a0a32b4d333bcb3b17f7542fe92193c4935f2b009d5f3d302bfdb/bioimage_py-0.2.2-py3-none-any.whl", hash = "sha256:c9aee39ec35e73425ed989f8468523e293b4e9a01fe2abf7ef1fbc12984c7a71", size = 168071, upload-time = "2026-10-15T20:33:34.651Z" }, +] + +[[package]] +name = "bioimageio-core" +version = "0.11.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "bioimageio-spec" }, + { name = "imagecodecs" }, + { name = "imageio" }, + { name = "loguru" }, + { name = "numpy" }, + { name = "pydantic" }, + { name = "pydantic-settings" }, + { name = "ruyaml" }, + { name = "scipy" }, + { name = "tqdm" }, + { name = "typing-extensions" }, + { name = "xarray" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7b/3a/f0c17c651ed7a0edd9e22e1e7476699aaccace74895c4fff86147a99280e/bioimageio_core-0.11.0.tar.gz", hash = "sha256:050041c58cef248e51490f8feef9d406c0a734f4c7d6adf67d80086191dc22c7", size = 124680, upload-time = "2026-07-28T13:13:36.564Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b4/f3/44ac651f90b5182f4368fb85a696e715d984d41733337de88ddab4486ffe/bioimageio_core-0.11.0-py3-none-any.whl", hash = "sha256:293144067ab11a6bf6501e5af06ff20a4f09d86190cf423e8d0fc7030ac3c57a", size = 127667, upload-time = "2026-07-28T13:13:34.963Z" }, +] + +[[package]] +name = "bioimageio-spec" +version = "0.5.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "email-validator" }, + { name = "exceptiongroup" }, + { name = "genericache" }, + { name = "httpx" }, + { name = "imageio" }, + { name = "loguru" }, + { name = "markdown" }, + { name = "numpy" }, + { name = "packaging" }, + { name = "platformdirs" }, + { name = "pydantic" }, + { name = "pydantic-core" }, + { name = "pydantic-settings" }, + { name = "python-dateutil" }, + { name = "rich" }, + { name = "ruyaml" }, + { name = "tifffile" }, + { name = "tqdm" }, + { name = "typing-extensions" }, + { name = "zipp" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a9/80/6ef63a4d45e6a158833a6fca10f19bb6b3ffafada09a7c1af0624ecb0841/bioimageio_spec-0.5.12.0.tar.gz", hash = "sha256:37059a3174e31bd36298a41c062fb3ad9ddb6993462124b9703aef3635b14007", size = 232772, upload-time = "2026-07-08T12:14:21.54Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3c/93/154f2af18cfe185992725c9fb9a2eb9c1b935f53eb19b78f1b95aa00e7ab/bioimageio_spec-0.5.12.0-py3-none-any.whl", hash = "sha256:251c7cbb8208dd8017378c9a3840b5773ed667765d5f44a59eca17df7166f536", size = 253086, upload-time = "2026-07-08T12:14:19.768Z" }, +] + [[package]] name = "blosc2" version = "4.15.0" @@ -1332,6 +1449,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" }, ] +[[package]] +name = "dnspython" +version = "2.9.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/76/49/900383b471c645a3c397f47b3211d1fcecb3a540c98f683494cdf86b33de/dnspython-2.9.2.tar.gz", hash = "sha256:8d4d39a513e649d634004ce4d39ade2352efcea472a0247535a5c2d18a9d7ba9", size = 455484, upload-time = "2026-11-03T23:56:53.601Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/0c/5346358b3a20275d256978c35203ddc2c8617f78c1b23795b79ba22ced6d/dnspython-2.9.2-py3-none-any.whl", hash = "sha256:af15f7d385a6ae2fb35a796fde2138004c8c42c7389090e2addc83e3b3340fd8", size = 360455, upload-time = "2026-11-03T23:56:52.088Z" }, +] + [[package]] name = "docstring-parser" version = "0.18.0" @@ -1397,6 +1523,40 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/6d/88/43021f1ca8bbb5922c1013db1d401d3844c6eabb849f50a00ede6232f35c/edt-3.1.2-cp314-cp314t-win_amd64.whl", hash = "sha256:65b8618675e20a715b276a72a13e8210295e783591118cc9f087c7c05a4dd851", size = 220580, upload-time = "2026-07-02T20:54:05.263Z" }, ] +[[package]] +name = "email-validator" +version = "2.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "dnspython" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c0/4d/f5e9d9de19f4b8f9e33d802fe3efb0ef96e88d4d6d45d604f335bef2f1ef/email_validator-2.4.0.tar.gz", hash = "sha256:be487bc50bc3bd832a98515a55a15649d9bec06d954fa178663190714b6c4ee1", size = 55168, upload-time = "2026-11-14T20:21:28.125Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b8/8b/99e715c59560afa0bf68f21ed16eec794d94293945f57934b70c5255d741/email_validator-2.4.0-py3-none-any.whl", hash = "sha256:4454e41c4e1c6b6caee34a1dc71d5e736791562be8fd179b02e298f796522684", size = 36810, upload-time = "2026-11-14T20:21:27.14Z" }, +] + +[[package]] +name = "et-xmlfile" +version = "2.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d3/38/af70d7ab1ae9d4da450eeec1fa3918940a5fafb9055e934af8d6eb0c2313/et_xmlfile-2.0.0.tar.gz", hash = "sha256:dab3f4764309081ce75662649be815c4c9081e88f0837825f90fd28317d4da54", size = 17234, upload-time = "2024-10-25T17:25:40.039Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c1/8b/5fe2cc11fee489817272089c4203e679c63b570a5aaeb18d852ae3cbba6a/et_xmlfile-2.0.0-py3-none-any.whl", hash = "sha256:7a91720bc756843502c3b7504c77b8fe44217c85c537d85037f0f536151b2caa", size = 18059, upload-time = "2024-10-25T17:25:39.051Z" }, +] + +[[package]] +name = "exceptiongroup" +version = "1.3.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/85/ac/f882fe3234606340c8729372da0fb98c634b97a560c9d375d9afea21496b/exceptiongroup-1.3.2.tar.gz", hash = "sha256:ca82e69f0cb535fbde934885744b67669a3efddd50fe7bc00d3398839fcaddec", size = 34687, upload-time = "2026-11-19T22:10:16.815Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a0/7d/0fb19ccdf794c448141461180d5992c50402f69f8515a801bfac7ad65f45/exceptiongroup-1.3.2-py3-none-any.whl", hash = "sha256:41c6a70dfec22050d3d8b43386b059a4dc0bca3f3d40a40971cb206fff1785af", size = 16854, upload-time = "2026-11-19T22:10:15.746Z" }, +] + [[package]] name = "executing" version = "2.3.0" @@ -1806,6 +1966,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a7/dd/d926171f122cd1a0cc504b1debd1bb76000c73907451144c7d5384133e8c/geff_spec-1.3.1-py3-none-any.whl", hash = "sha256:9cd16ac83d458dc099cec95967602ff40de9ce79490c273eec6d5105311ca3dd", size = 16552, upload-time = "2026-11-03T16:48:21.896Z" }, ] +[[package]] +name = "genericache" +version = "0.5.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "filelock" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/01/8b/9773e74ece19b9fbf1d0f6d78f659091dfb8c4549107e9d95b15b6e8ff5d/genericache-0.5.2.tar.gz", hash = "sha256:1bdc21b0471ffd3092c78dbbee2c757ad444baa746073c68068f0f41509d826f", size = 8278, upload-time = "2025-08-12T10:27:24.776Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/a1/3f982f9a8f082760b6970ad6c25573bb2526dc180b695f0f50fa3f392d60/genericache-0.5.2-py3-none-any.whl", hash = "sha256:5c922cf07df74280911d79068f43583f86b4d6caee1704d79c779d9fd6547a72", size = 10165, upload-time = "2025-08-12T10:27:23.465Z" }, +] + [[package]] name = "google-crc32c" version = "1.9.0" @@ -1971,10 +2143,14 @@ source = { registry = "https://pypi.org/simple" } resolution-markers = [ "python_full_version == '3.13.*' and sys_platform == 'win32'", "python_full_version == '3.13.*' and sys_platform == 'emscripten'", - "python_full_version == '3.13.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version == '3.13.*' and sys_platform == 'linux'", + "python_full_version == '3.13.*' and sys_platform == 'darwin'", + "python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version < '3.13' and sys_platform == 'win32'", "python_full_version < '3.13' and sys_platform == 'emscripten'", - "python_full_version < '3.13' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version < '3.13' and sys_platform == 'linux'", + "python_full_version < '3.13' and sys_platform == 'darwin'", + "python_full_version < '3.13' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", ] wheels = [ { url = "https://files.pythonhosted.org/packages/6f/bb/b3784497115c64c2bd122cc9d411f167026d4ec42a26b1ff3c43a779275d/gurobipy-12.0.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:020f23277f630e079eac114385eabd1bd9fb4ac22f8796ed5ba6d915ce4f141b", size = 12222234, upload-time = "2025-07-15T07:19:24.64Z" }, @@ -1994,10 +2170,14 @@ source = { registry = "https://pypi.org/simple" } resolution-markers = [ "python_full_version >= '3.15' and sys_platform == 'win32'", "python_full_version >= '3.15' and sys_platform == 'emscripten'", - "python_full_version >= '3.15' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version >= '3.15' and sys_platform == 'linux'", + "python_full_version >= '3.15' and sys_platform == 'darwin'", + "python_full_version >= '3.15' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version == '3.14.*' and sys_platform == 'win32'", "python_full_version == '3.14.*' and sys_platform == 'emscripten'", - "python_full_version == '3.14.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version == '3.14.*' and sys_platform == 'linux'", + "python_full_version == '3.14.*' and sys_platform == 'darwin'", + "python_full_version == '3.14.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", ] wheels = [ { url = "https://files.pythonhosted.org/packages/8c/87/ada84ac49ccc8478ad50b4938ef61122719d64f224a2c5312ad4bccbdb20/gurobipy-13.0.3-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:ee439774ed56dca173cddf0017f1cb854d7f79dfcc12abc4fe5d83a7f22bb9b3", size = 15987021, upload-time = "2026-08-25T06:33:48.381Z" }, @@ -2524,6 +2704,17 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7e/62/2a0a2e17f265bf8646cfe11ede5ac7a89039142f6e5f37b8cfe512b14e18/iohub-0.4.1-py3-none-any.whl", hash = "sha256:b8088af0077dc6b8b31bf8dbd0dd4780eed4330d970f455bab7553debfbab194", size = 136114, upload-time = "2026-11-02T19:32:11.785Z" }, ] +[[package]] +name = "iopath" +version = "0.1.10" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "portalocker" }, + { name = "tqdm" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/72/73/b3d451dfc523756cf177d3ebb0af76dc7751b341c60e2a21871be400ae29/iopath-0.1.10.tar.gz", hash = "sha256:3311c16a4d9137223e20f141655759933e1eda24f8bff166af834af3c645ef01", size = 42226, upload-time = "2022-07-09T19:00:50.866Z" } + [[package]] name = "ipykernel" version = "7.4.0" @@ -3107,6 +3298,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/db/bc/83e112abc66cd466c6b83f99118035867cecd41802f8d044638aa78a106e/locket-1.0.0-py2.py3-none-any.whl", hash = "sha256:b6c819a722f7b6bd955b80781788e4a66a55628b858d347536b7e81325a3a5e3", size = 4398, upload-time = "2022-04-20T22:04:42.23Z" }, ] +[[package]] +name = "loguru" +version = "0.8.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "win32-setctime", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/61/ce/b5bb93d4d9fc7a067f69140b3bb3782f6ad6360bc76e99b6e3d386cb1320/loguru-0.8.0.tar.gz", hash = "sha256:fb3e4623288e37700a0577f6e0ce776cc1860b5d95c657d67f07a2476b304867", size = 71232, upload-time = "2026-11-11T18:50:26.248Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c8/00/9ee7c8da7342b1a5524bca9d036f89e7d1d1e5a6345c9623763eeeac941f/loguru-0.8.0-py3-none-any.whl", hash = "sha256:e0fba09d6f76ba2d2f4bd1757122942f5a670c702e988b5efaeab99dacba0069", size = 69409, upload-time = "2026-11-11T18:50:24.148Z" }, +] + [[package]] name = "lxml" version = "6.1.3" @@ -3489,6 +3693,55 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" }, ] +[[package]] +name = "micro-sam" +version = "2.0.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "bioimage-cpp" }, + { name = "bioimage-py" }, + { name = "bioimageio-core" }, + { name = "click" }, + { name = "h5py" }, + { name = "huggingface-hub" }, + { name = "imagecodecs" }, + { name = "imageio" }, + { name = "joblib" }, + { name = "kornia" }, + { name = "magicgui" }, + { name = "matplotlib" }, + { name = "napari" }, + { name = "natsort" }, + { name = "networkx" }, + { name = "numpy" }, + { name = "pandas" }, + { name = "pooch" }, + { name = "pydantic" }, + { name = "pyqt6" }, + { name = "python-elf" }, + { name = "sam2", marker = "sys_platform == 'never'" }, + { name = "scikit-image" }, + { name = "scikit-learn" }, + { name = "segment-anything-py" }, + { name = "superqt" }, + { name = "tensordict" }, + { name = "timm" }, + { name = "torch" }, + { name = "torch-em" }, + { name = "torchvision" }, + { name = "tqdm" }, + { name = "trackastra" }, + { name = "transformers" }, + { name = "xarray" }, + { name = "xxhash" }, + { name = "z5py" }, + { name = "zarr" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/52/eb/6477a18a73f99623ee933ddc79a26b42425fe408736e9835f82b240a0caf/micro_sam-2.0.1.tar.gz", hash = "sha256:d521a878b28b73df2cc4df5a59be870fb8d5c9260fb170e89dfd7b70fd21accf", size = 734430, upload-time = "2026-11-19T10:04:07.688Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/dc/ab66a0672db7a0c7a408ffd12bc1a41885fac67d6b5889fd00c8776d3c6d/micro_sam-2.0.1-py3-none-any.whl", hash = "sha256:106f928d572032690b4b9dbeae95878633e0db5c3a2fc0d95afb6474969bbcf4", size = 675522, upload-time = "2026-11-19T10:04:05.617Z" }, +] + [[package]] name = "mip" version = "2.0.2" @@ -3607,6 +3860,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl", hash = "sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c", size = 536198, upload-time = "2023-03-07T16:47:09.197Z" }, ] +[[package]] +name = "mrcfile" +version = "1.5.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/56/22/8834f44c2455291e241fb2543c2d5d4f0fe58fd63ad0f42e86570f0b1161/mrcfile-1.5.4.tar.gz", hash = "sha256:8fa9eb2e237d87d99b301c61bf02854dd85a451db25eefcbe142c09b36d8d601", size = 52052606, upload-time = "2025-01-22T12:36:10.924Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6f/cb/3f4ee8233f30c7926f1ed4885ff32b79ec7ce3210370f43e1cb2b385bed6/mrcfile-1.5.4-py2.py3-none-any.whl", hash = "sha256:195370a13db5ce19600499f9bdf90fd9888979bf39de19a17c19024436c6f4c2", size = 45012, upload-time = "2025-01-22T12:02:38.502Z" }, +] + [[package]] name = "msgpack" version = "1.2.4" @@ -4049,7 +4314,8 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "dask", extra = ["array"] }, { name = "numpy" }, - { name = "ome-types" }, + { name = "ome-types", version = "0.6.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.15'" }, + { name = "ome-types", version = "0.7.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.15'" }, { name = "pydantic-core", marker = "python_full_version >= '3.13'" }, { name = "resource-backed-dask-array" }, { name = "typing-extensions" }, @@ -4500,13 +4766,52 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/52/5f/74e2d29240de30a971d59ca20f4a3c4f2720cd49752809eeb4177d385c2c/nvidia_nvtx-13.2.86-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1c6ae1be92fba569dd271f7b9b3056f99f5642726dc6c53d1b93ae4110c398fb", size = 154292, upload-time = "2026-07-16T09:40:53.791Z" }, ] +[[package]] +name = "ome-types" +version = "0.6.3" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.15' and sys_platform == 'win32'", + "python_full_version >= '3.15' and sys_platform == 'emscripten'", + "python_full_version >= '3.15' and sys_platform == 'linux'", + "python_full_version >= '3.15' and sys_platform == 'darwin'", + "python_full_version >= '3.15' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", +] +dependencies = [ + { name = "pydantic" }, + { name = "pydantic-core" }, + { name = "pydantic-extra-types" }, + { name = "xsdata" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/48/4c/d252c1619c733eec9b4d2d21fe369fd21a2594954b396bf4352edea1e272/ome_types-0.6.3.tar.gz", hash = "sha256:eef4138cda5edfdcb2a44cfb90b714a59ead1b69e4c5ce5f9892ad397ccaaa68", size = 121784, upload-time = "2025-11-26T00:28:24.34Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fc/6a/1000cad1700ab0af4d1b1d0a9c23c34badddb4f547c008bde2a6c61968f1/ome_types-0.6.3-py3-none-any.whl", hash = "sha256:ce9753ff351bbc534ee5c5038d3cf60b1e4c13d69ad2e6b5a5b75de2a52521a5", size = 245802, upload-time = "2025-11-26T00:28:22.853Z" }, +] + [[package]] name = "ome-types" version = "0.7.0" source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version == '3.14.*' and sys_platform == 'win32'", + "python_full_version == '3.14.*' and sys_platform == 'emscripten'", + "python_full_version == '3.14.*' and sys_platform == 'linux'", + "python_full_version == '3.14.*' and sys_platform == 'darwin'", + "python_full_version == '3.14.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", + "python_full_version == '3.13.*' and sys_platform == 'win32'", + "python_full_version == '3.13.*' and sys_platform == 'emscripten'", + "python_full_version == '3.13.*' and sys_platform == 'linux'", + "python_full_version == '3.13.*' and sys_platform == 'darwin'", + "python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", + "python_full_version < '3.13' and sys_platform == 'win32'", + "python_full_version < '3.13' and sys_platform == 'emscripten'", + "python_full_version < '3.13' and sys_platform == 'linux'", + "python_full_version < '3.13' and sys_platform == 'darwin'", + "python_full_version < '3.13' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", +] dependencies = [ { name = "pydantic" }, - { name = "pydantic-core", marker = "python_full_version >= '3.13'" }, + { name = "pydantic-core", marker = "python_full_version >= '3.13' and python_full_version < '3.15'" }, { name = "pydantic-extra-types" }, { name = "xsdata" }, ] @@ -4645,6 +4950,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b8/88/763b967f7efd7226b82c9fae16d560cba049b1f0c036647e65c610fd636e/opencv_python_headless-5.0.0.93-cp37-abi3-win_amd64.whl", hash = "sha256:829717b6a95554f273e49e357cee3b3a2a26b6f4842fbc1bed2b45bdd8f87e0e", size = 43825962, upload-time = "2026-07-02T05:50:09.627Z" }, ] +[[package]] +name = "openpyxl" +version = "3.1.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "et-xmlfile" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3d/f9/88d94a75de065ea32619465d2f77b29a0469500e99012523b91cc4141cd1/openpyxl-3.1.5.tar.gz", hash = "sha256:cf0e3cf56142039133628b5acffe8ef0c12bc902d2aadd3e0fe5878dc08d1050", size = 186464, upload-time = "2024-06-28T14:03:44.161Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c0/da/977ded879c29cbd04de313843e76868e6e13408a94ed6b987245dc7c8506/openpyxl-3.1.5-py2.py3-none-any.whl", hash = "sha256:5282c12b107bffeef825f4617dc029afaf41d0ea60823bbb665ef3079dc79de2", size = 250910, upload-time = "2024-06-28T14:03:41.161Z" }, +] + [[package]] name = "opentelemetry-api" version = "1.45.2" @@ -5013,10 +5330,14 @@ source = { registry = "https://pypi.org/simple" } resolution-markers = [ "python_full_version == '3.13.*' and sys_platform == 'win32'", "python_full_version == '3.13.*' and sys_platform == 'emscripten'", - "python_full_version == '3.13.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version == '3.13.*' and sys_platform == 'linux'", + "python_full_version == '3.13.*' and sys_platform == 'darwin'", + "python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version < '3.13' and sys_platform == 'win32'", "python_full_version < '3.13' and sys_platform == 'emscripten'", - "python_full_version < '3.13' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version < '3.13' and sys_platform == 'linux'", + "python_full_version < '3.13' and sys_platform == 'darwin'", + "python_full_version < '3.13' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", ] dependencies = [ { name = "polars-runtime-32", version = "1.44.2", source = { registry = "https://pypi.org/simple" } }, @@ -5033,10 +5354,14 @@ source = { registry = "https://pypi.org/simple" } resolution-markers = [ "python_full_version >= '3.15' and sys_platform == 'win32'", "python_full_version >= '3.15' and sys_platform == 'emscripten'", - "python_full_version >= '3.15' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version >= '3.15' and sys_platform == 'linux'", + "python_full_version >= '3.15' and sys_platform == 'darwin'", + "python_full_version >= '3.15' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version == '3.14.*' and sys_platform == 'win32'", "python_full_version == '3.14.*' and sys_platform == 'emscripten'", - "python_full_version == '3.14.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version == '3.14.*' and sys_platform == 'linux'", + "python_full_version == '3.14.*' and sys_platform == 'darwin'", + "python_full_version == '3.14.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", ] dependencies = [ { name = "polars-runtime-32", version = "2.1.0", source = { registry = "https://pypi.org/simple" } }, @@ -5053,10 +5378,14 @@ source = { registry = "https://pypi.org/simple" } resolution-markers = [ "python_full_version == '3.13.*' and sys_platform == 'win32'", "python_full_version == '3.13.*' and sys_platform == 'emscripten'", - "python_full_version == '3.13.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version == '3.13.*' and sys_platform == 'linux'", + "python_full_version == '3.13.*' and sys_platform == 'darwin'", + "python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version < '3.13' and sys_platform == 'win32'", "python_full_version < '3.13' and sys_platform == 'emscripten'", - "python_full_version < '3.13' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version < '3.13' and sys_platform == 'linux'", + "python_full_version < '3.13' and sys_platform == 'darwin'", + "python_full_version < '3.13' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", ] sdist = { url = "https://files.pythonhosted.org/packages/d4/a1/a7eace6587b56f22cf2a21ab4d5e695db372dc23fd96accb68b1ec12660b/polars_runtime_32-1.44.2.tar.gz", hash = "sha256:b84842f7d621aaca7a52e165e19a24f89db45f8aa13744941430218419a14a67", size = 3172205, upload-time = "2026-09-09T07:42:10.851Z" } wheels = [ @@ -5077,10 +5406,14 @@ source = { registry = "https://pypi.org/simple" } resolution-markers = [ "python_full_version >= '3.15' and sys_platform == 'win32'", "python_full_version >= '3.15' and sys_platform == 'emscripten'", - "python_full_version >= '3.15' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version >= '3.15' and sys_platform == 'linux'", + "python_full_version >= '3.15' and sys_platform == 'darwin'", + "python_full_version >= '3.15' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", "python_full_version == '3.14.*' and sys_platform == 'win32'", "python_full_version == '3.14.*' and sys_platform == 'emscripten'", - "python_full_version == '3.14.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version == '3.14.*' and sys_platform == 'linux'", + "python_full_version == '3.14.*' and sys_platform == 'darwin'", + "python_full_version == '3.14.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'linux' and sys_platform != 'win32'", ] sdist = { url = "https://files.pythonhosted.org/packages/e0/a6/46e09af693326735b1fba3a8bf5a725b57136fb1342e707e75d3113c826b/polars_runtime_32-2.1.0.tar.gz", hash = "sha256:c575f5f3cdb8a5f9be65477b9b4202b062593687fe62a0082add87fbd4571067", size = 3878004, upload-time = "2026-10-25T18:00:34.932Z" } wheels = [ @@ -5108,6 +5441,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2a/2d/d4bf65e47cea8ff2c794a600c4fd1273a7902f268757c531e0ee9f18aa58/pooch-1.9.0-py3-none-any.whl", hash = "sha256:f265597baa9f760d25ceb29d0beb8186c243d6607b0f60b83ecf14078dbc703b", size = 67175, upload-time = "2026-01-30T19:15:08.36Z" }, ] +[[package]] +name = "portalocker" +version = "4.4.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7f/d9/586fb0510fdfbd95a86f9d5c5046463aca41a55f6573d1a5a082a62e0acb/portalocker-4.4.2.tar.gz", hash = "sha256:7ac85bb2aa3c7873bf2ac72586fc6154afa4671ac786994a16617a6b7ccb3e5e", size = 310698, upload-time = "2026-10-28T00:24:58.214Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e8/43/bca094221a0f9f592fe1e982d090a92075aa302ecaa92c94cc6268a39b2c/portalocker-4.4.2-py3-none-any.whl", hash = "sha256:e661b91af34fc1806740f8e0e42990fe55cd85cbae55675ac48a400a9656a51b", size = 129702, upload-time = "2026-10-28T00:24:56.625Z" }, +] + [[package]] name = "pre-commit" version = "4.7.0" @@ -5462,7 +5804,7 @@ wheels = [ [[package]] name = "pydantic" -version = "2.14.3" +version = "2.13.5" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "annotated-types" }, @@ -5470,118 +5812,84 @@ dependencies = [ { name = "typing-extensions" }, { name = "typing-inspection" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/b4/fc/1203d011145c98ddce3cd2f505bb54375ef8d43223053df6bfcf3c746f46/pydantic-2.14.3.tar.gz", hash = "sha256:1054f237f4d4733e5a30e1e2333bd33a2004ab9ab1510bd053a9a31bb48e232d", size = 925636, upload-time = "2026-11-05T09:17:04.686Z" } +sdist = { url = "https://files.pythonhosted.org/packages/53/ef/fc4f868f4e2cee79f863883abffceff107875f569b848507319842d2a681/pydantic-2.13.5.tar.gz", hash = "sha256:51a9c5f7b2f8e636f04c6cada605d9b6a3bf1348fdf945a3d8869b19bba0ee08", size = 845750, upload-time = "2026-08-28T14:04:00.916Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/72/b8/b864503789ef5c58597d2a7b4adbee62c26440ab1e682581fc6838df8947/pydantic-2.14.3-py3-none-any.whl", hash = "sha256:3f7b347782ab7e4cf4c798496ae3a82787d9f21ec12676a9c564355eeef8daa8", size = 494071, upload-time = "2026-11-05T09:17:02.426Z" }, + { url = "https://files.pythonhosted.org/packages/eb/47/c95ffc2009878c7aac0c5e08528022dcb885933252a88b5f170058014464/pydantic-2.13.5-py3-none-any.whl", hash = "sha256:346a034f080da3755d8e9cb5e00e8b07de1d39e4f6e2c87d8ab7cafa0b269a73", size = 472589, upload-time = "2026-08-28T14:03:59.136Z" }, ] [[package]] name = "pydantic-core" -version = "2.50.4" +version = "2.46.5" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/9c/0f/34f9ce4ba701dd0b815033ef94d99b56f66200e578ee6052aa3ac26f064e/pydantic_core-2.50.4.tar.gz", hash = "sha256:aead3b74b68396bf0feab5d57e050b730ded7df55853c1e048a87e00aaf033c6", size = 522249, upload-time = "2026-11-05T09:15:26.774Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/10/bf/d1f6b81709538f831ebe1c42f50fb89db3dfda06f9e9b1ea24e90fc69209/pydantic_core-2.50.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:32a991aebd165f227b7c7c60bb9d66c2c7de9c24308552da264c9938fde0f8d6", size = 2231444, upload-time = "2026-11-05T09:12:06.969Z" }, - { url = "https://files.pythonhosted.org/packages/c1/39/6618e541658d5a687a8d4962fc304350073a8f322bc4c62e8ed4c2d514d6/pydantic_core-2.50.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1e20cbde2b6deb33a51d08cd168454dd9044ec7d4474056f4d98d63f51578783", size = 2108048, upload-time = "2026-11-05T09:12:08.85Z" }, - { url = "https://files.pythonhosted.org/packages/d9/54/1c941fffa4e14bfc9ab0cd4977075f0e03201447856130d08a33cd45e47b/pydantic_core-2.50.4-cp312-cp312-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:8cceae48ae7f94990c2f4e36291e9ec9868735e8b0f19e4489a17b0422338466", size = 2256866, upload-time = "2026-11-05T09:12:10.495Z" }, - { url = "https://files.pythonhosted.org/packages/61/a0/8028ef3e014be522ce43060aeac82a5be2288215e660866f5e6260acc123/pydantic_core-2.50.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:16902a147b3da4840612164a5e67947104d63e978f7a57c395877a5e26690b9c", size = 2125682, upload-time = "2026-11-05T09:12:12.278Z" }, - { url = "https://files.pythonhosted.org/packages/c3/f2/b98bb73b1734ec4e42e786a766abc24f3c89620a0ddbaf8aa14e4b4c628c/pydantic_core-2.50.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d6e3485a5e5c01fb5339c1ee3d4b9e21e2135a2a9d44caafb71acd994487ee7c", size = 2197108, upload-time = "2026-11-05T09:12:13.873Z" }, - { url = "https://files.pythonhosted.org/packages/f1/d1/7a7142786781400143e8806633fe5b65e2d407c311041fc9494490f05b18/pydantic_core-2.50.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:629eae995185540406e3635df5d5cf1d44f19ea240840b835d3f44541ff694d8", size = 2380521, upload-time = "2026-11-05T09:12:15.539Z" }, - { url = "https://files.pythonhosted.org/packages/b5/34/cf710ca48d4498b04a3ea605d45892675dc2b14a94a25121a8d03f56d3e9/pydantic_core-2.50.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:41b2cd8b29dbb5a4c9828a70f50d1abfc92011115c813213d3a91205c6f731b3", size = 2457436, upload-time = "2026-11-05T09:12:17.447Z" }, - { url = "https://files.pythonhosted.org/packages/91/23/e0c6e3cd09a0ac809953fea698c816b9f03bf0b35b6820c9553e4f5d85a8/pydantic_core-2.50.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c81d98e27d9d9261909dcccab1ba5d6ea1c98b0bb9470e368604614fd1d36ddd", size = 2261727, upload-time = "2026-11-05T09:12:19.097Z" }, - { url = "https://files.pythonhosted.org/packages/f9/00/292a0ed96d5d2d6edb49468ef481336e5b7e54f13435d73b7c912c891c23/pydantic_core-2.50.4-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:ca83a32b2b41653d89f09a3d22b770bca96da72273bef8f7a68136bdd1e8b823", size = 2262071, upload-time = "2026-11-05T09:12:20.78Z" }, - { url = "https://files.pythonhosted.org/packages/f8/36/d4690faf8c082eacf7754e52ab6bebe1bc73b167272e28699c00480ee908/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:817953730e4a73a09008b010c4a42396cefe799616a22df2ac21d3927b3080cf", size = 2298931, upload-time = "2026-11-05T09:12:22.614Z" }, - { url = "https://files.pythonhosted.org/packages/21/17/b180af6d17cf6c8e0d3d2661fc501a4a40959744ca4947d6ad0db81b1416/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:664e74848c2f5fc27db8505fe24e1ecd3ac669412913bf73d176916f86cc08e2", size = 2474285, upload-time = "2026-11-05T09:12:24.842Z" }, - { url = "https://files.pythonhosted.org/packages/6e/bb/7e44d4ac6e1292f1859384c688713045bdf5448e0635c49c003d2be3bb6c/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:219114f8dcdcbe4720d82ef016b1287ce5a0a67d7c69ca61524eb72e82aac344", size = 2498172, upload-time = "2026-11-05T09:12:26.434Z" }, - { url = "https://files.pythonhosted.org/packages/d8/84/5101f35294579c4bef7dc32fd4f097d91eedac2e195894266bdabc1e6dfd/pydantic_core-2.50.4-cp312-cp312-win32.whl", hash = "sha256:67f7cc397e1d5556a801d1cba74de0d27d827eb242e6c036c0ca273c745414f1", size = 2119592, upload-time = "2026-11-05T09:12:27.971Z" }, - { url = "https://files.pythonhosted.org/packages/82/88/d438a8fcf3738e9ff2670f724047ca3893ec899bcd5cdfc077a2aab133c6/pydantic_core-2.50.4-cp312-cp312-win_amd64.whl", hash = "sha256:ea2f61b0bc12f3592288503961b764579dea0658852d96a0b3d823614d808821", size = 2264064, upload-time = "2026-11-05T09:12:29.538Z" }, - { url = "https://files.pythonhosted.org/packages/77/d4/4a0c73dc3ef9e50b122b8c3527afcded15a44838f1c9668d2d4b72cc09f0/pydantic_core-2.50.4-cp312-cp312-win_arm64.whl", hash = "sha256:32d6dda86383645ec428ea64dfc277036f5cbc60a72238eab28b91a3fdb9a113", size = 2167792, upload-time = "2026-11-05T09:12:31.103Z" }, - { url = "https://files.pythonhosted.org/packages/1b/21/39f8d97e7ea8e3083606ee9bb1d7f3ec70ded780bb6a872aad76c7eb08b2/pydantic_core-2.50.4-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0f87ae9db5ba8d8de40dcb93982cf8dd544e6552a80d3345af51941cc2146b80", size = 2232841, upload-time = "2026-11-05T09:12:32.617Z" }, - { url = "https://files.pythonhosted.org/packages/90/a9/fc89a632331882c4cb91b949003418e6f5085ddcf2c9b875d499682bca91/pydantic_core-2.50.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1239daaf063e62213ca1f34d96663900bd7510c42a786e843fd328af70e46445", size = 2108326, upload-time = "2026-11-05T09:12:34.419Z" }, - { url = "https://files.pythonhosted.org/packages/5d/6d/4f6d00e9e4ba2a7bfb206ae49cb32a3ea90c4d658e62f8775277d75e8291/pydantic_core-2.50.4-cp313-cp313-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:1afefe44ec042fbabfb4483ea258c04cf75ff4ff328d754f09b321fdaa232aca", size = 2256276, upload-time = "2026-11-05T09:12:36.212Z" }, - { url = "https://files.pythonhosted.org/packages/b3/b8/936cb0d85a4082e902c7397db0f05c4372eac08372c8bd2d0b43088fcf17/pydantic_core-2.50.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:a9ee990bf2cfbd81574c5d4f9f6c9d480a14b5b43d2c4f2ca13f4c6f48089394", size = 2125469, upload-time = "2026-11-05T09:12:37.913Z" }, - { url = "https://files.pythonhosted.org/packages/66/a1/f3b551ce233dcac73286b8b2ae45c23232a9f41c68663e2dcce4bb2dbcfa/pydantic_core-2.50.4-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:ab2822bcdcefb54d1e8ca29f5e3ec3afe160fb794bb3a3a73b09d11ed2671104", size = 2196397, upload-time = "2026-11-05T09:12:39.725Z" }, - { url = "https://files.pythonhosted.org/packages/3d/93/a8a6e7e20826567a73e6f52416667698aa3de704804d7a49d25272246af4/pydantic_core-2.50.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:0001d6920e3a5d92758cda460d6dc9f918a78ad6d5d092f1c8b5395e6b775356", size = 2380442, upload-time = "2026-11-05T09:12:41.196Z" }, - { url = "https://files.pythonhosted.org/packages/aa/ba/921d90c9d8ddfa653a35a92f2bbdcd650a9493f5c43f39cdfe4c56659cfa/pydantic_core-2.50.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:ad92d255a165cde5f9882ff69699eaf5495e0a1f32e97566bbbb80f11e46781f", size = 2457747, upload-time = "2026-11-05T09:12:42.723Z" }, - { url = "https://files.pythonhosted.org/packages/2b/c0/1c8f2c8f1b03d3fe2fdd7962df8f5a744fe48c90b4c49615e4eb77d04141/pydantic_core-2.50.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:fb2bb5b557080da398b866408117d98fe9731a12334afd0cdff221b458cdc5dc", size = 2260946, upload-time = "2026-11-05T09:12:44.185Z" }, - { url = "https://files.pythonhosted.org/packages/07/ab/5b78a78f0c0f11c8b54fac214ed49cbb4795c34881aa5e5a15715917936f/pydantic_core-2.50.4-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:92f8f63df729061bb14558ed740e7a222f6e2aa6c2e6a5bcfb4e706676562049", size = 2261921, upload-time = "2026-11-05T09:12:45.706Z" }, - { url = "https://files.pythonhosted.org/packages/b3/e8/dd5d154cf3401f836d8754fdc1b82ecadd37944e4355d855e5b54c7d8ae5/pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:2a60ec2a57ac3ef3767e526e9bf706ec75aa3d79c4ea134d9d4fcf7c62a297a7", size = 2298475, upload-time = "2026-11-05T09:12:47.183Z" }, - { url = "https://files.pythonhosted.org/packages/b7/49/af059d9c4483cba168b17e5f84f1090a3e4547a02fc7698ebc231d48298a/pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:a2f8716344bbbd10443391be0b1f2003b34949e3c4e6883005c2bc498ab6b64b", size = 2473226, upload-time = "2026-11-05T09:12:48.785Z" }, - { url = "https://files.pythonhosted.org/packages/71/ba/4e8cc3064e8bc2ea272cf80dfc57fa4e455f6835c1def21609a9b4f94135/pydantic_core-2.50.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:b300a30304c4c6aeab03ed06809819d9eceacdd58441d3c7dffe41edfd006091", size = 2498764, upload-time = "2026-11-05T09:12:50.316Z" }, - { url = "https://files.pythonhosted.org/packages/bf/96/0878499cfa88eb0b07762b488d3cc1b64cb156a4905db99a0d12096b2e17/pydantic_core-2.50.4-cp313-cp313-win32.whl", hash = "sha256:ef8a9ddb2e2a4eae4abb72dc0710eca6c2726779b0664bd10c3ce9fcfaed8c4e", size = 2119158, upload-time = "2026-11-05T09:12:51.834Z" }, - { url = "https://files.pythonhosted.org/packages/e7/e0/95b651213e79ffe0cbee855590bf5cfdf8e3a0d90a7fc73a080e63f7cc38/pydantic_core-2.50.4-cp313-cp313-win_amd64.whl", hash = "sha256:4c29b8f2d6417069bb1f257e6b9113f5d64dc2f554cc200ea90b4fe2c5cdb733", size = 2262887, upload-time = "2026-11-05T09:12:53.282Z" }, - { url = "https://files.pythonhosted.org/packages/08/d3/c3801dc75844a0b13d000bd575bf1b3b3a8aca9f63d19e1809f69c9c5121/pydantic_core-2.50.4-cp313-cp313-win_arm64.whl", hash = "sha256:a0c5210d038418a115e7cf8706bfa611bd14add2f5787274dba45aadca3155e0", size = 2167878, upload-time = "2026-11-05T09:12:54.677Z" }, - { url = "https://files.pythonhosted.org/packages/ee/ed/c9a4982ac3bbc78f27498d9efb85b3dabd739a1724db53c35cc4c018e1de/pydantic_core-2.50.4-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:5c074454dc6d4f6f4ba6561a56bf33a14db7651d882a5a5321ba3ae8868e082d", size = 2236841, upload-time = "2026-11-05T09:12:56.111Z" }, - { url = "https://files.pythonhosted.org/packages/56/32/92c174c17bfc5fc52d0c064e6a7969a727731e25829ede752fba8bacce0f/pydantic_core-2.50.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a4bb174bd65f795c39ad6642d9d5bdc43351b306b7d0a654ab0d0abb38be245f", size = 2108348, upload-time = "2026-11-05T09:12:57.638Z" }, - { url = "https://files.pythonhosted.org/packages/cb/cb/9f637d424a04d3edce7dd527da941950cce05a74b025eef3d54427b86c8e/pydantic_core-2.50.4-cp314-cp314-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:0ec20aca2b067369913716847f7dfe5f4dddf16a46965b7a70bbad5defaaba86", size = 2261331, upload-time = "2026-11-05T09:12:59.154Z" }, - { url = "https://files.pythonhosted.org/packages/91/ff/1117a3cccabb67305bd98d992a84eaf275939a9a043b4f14126ed7252e4f/pydantic_core-2.50.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:70dbc9f83c41f37a4faa62dae5203853847223a891da446f48ef2efcfd5df806", size = 2128667, upload-time = "2026-11-05T09:13:00.614Z" }, - { url = "https://files.pythonhosted.org/packages/93/45/6de1b4a6e8c415cd547f90d1408a711e7975116423e3eb3046061c62d7c7/pydantic_core-2.50.4-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:3de6c2a4df2af0ac9ab4dc1488746fe8b1a90e27955d870d9edda3187d20092b", size = 2198183, upload-time = "2026-11-05T09:13:02.259Z" }, - { url = "https://files.pythonhosted.org/packages/d0/bd/c6e64c315d35cc0783a0ea033a3dca062bc368905d0217eab6f6f63007de/pydantic_core-2.50.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:3a48a5254d15a0ad050318bfc7a9566d4ec740118187e8f303e47a6840287eb7", size = 2386279, upload-time = "2026-11-05T09:13:03.988Z" }, - { url = "https://files.pythonhosted.org/packages/33/ab/0d56280c89d3841381e9c699c3fa80e3dd3288edf5e7fe4d149136835dca/pydantic_core-2.50.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:0af56dbf8822ba9f4efcbbfdc15478f8b6fb08f1609860cb50aa2cc8476b3c34", size = 2464343, upload-time = "2026-11-05T09:13:05.98Z" }, - { url = "https://files.pythonhosted.org/packages/56/9c/621ad8f88590a92a086b1168dce09369d9c5e079e2e635e6646d248af55b/pydantic_core-2.50.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f1d62fb172db35c6478c9323da34ff37d1f3d37d7d44337a9d94ba8c583e5730", size = 2265388, upload-time = "2026-11-05T09:13:07.808Z" }, - { url = "https://files.pythonhosted.org/packages/f3/7b/cef68a667bf29b86e293a80a601d488a84c8f45508915ad6201fcfe1a798/pydantic_core-2.50.4-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:5c1013647be741647895c102831dcf79c34209662dbb683df9efb864417ed7d5", size = 2267012, upload-time = "2026-11-05T09:13:09.273Z" }, - { url = "https://files.pythonhosted.org/packages/4b/9f/3ae4d163d8feda2b52de88b5cd96b1c40f79d11503003b061136d2ece6ab/pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:aeb2e123cbf978a905e9f55155c1b8316fbbfa7cf64d04521fe174bab302d100", size = 2300478, upload-time = "2026-11-05T09:13:10.758Z" }, - { url = "https://files.pythonhosted.org/packages/e8/72/41881d31f6452430ed6792679c5391795910f0a27a6aebd424683e504ed6/pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:523466eba8ee10f7480f3c2057563145978011c583130d2cc01fb1e7af808e25", size = 2474874, upload-time = "2026-11-05T09:13:12.188Z" }, - { url = "https://files.pythonhosted.org/packages/05/ef/099874dd6d5ca1e49987dea87eecc05610183249450b1fff883d87f1e8eb/pydantic_core-2.50.4-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:c9e70012926e97069cdd09221861aff412aa94e4cac2e019055cdb79485b150c", size = 2502771, upload-time = "2026-11-05T09:13:13.981Z" }, - { url = "https://files.pythonhosted.org/packages/c6/07/a7d8615b8677bf69e24666bbce431299850c95a7b084649342582a1c3210/pydantic_core-2.50.4-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:e6da138a1ecc1341c8b788a5ee822670b03788e1f5decf7af9d461de6e508b8e", size = 1496509, upload-time = "2026-11-05T09:13:15.704Z" }, - { url = "https://files.pythonhosted.org/packages/ab/71/fdf2c25c3a4f89968263c1d896c933809ca8d2fb13443626648a17b2e296/pydantic_core-2.50.4-cp314-cp314-win32.whl", hash = "sha256:13b6dd62b5279f5b9d72f3bf918a35443ee8bd549241d9dc52d79a2c3b6d7016", size = 2122015, upload-time = "2026-11-05T09:13:17.09Z" }, - { url = "https://files.pythonhosted.org/packages/3a/9f/3554f0148b01ddaa5e678bf5fbce4679873534e5c0985cdf6c59c41dc9a9/pydantic_core-2.50.4-cp314-cp314-win_amd64.whl", hash = "sha256:b0cdb655fbd1562c2dfc9986f9103a106f7058cd0915afc6e656d4b1d73f3387", size = 2265109, upload-time = "2026-11-05T09:13:18.702Z" }, - { url = "https://files.pythonhosted.org/packages/ed/3c/196ef237d9ec5cca5ea9b773911dee1a387b9b1d4bfea05625b3e191a338/pydantic_core-2.50.4-cp314-cp314-win_arm64.whl", hash = "sha256:df1c174796cd63eb6b139f7daf783affe1f3ed659605850e843b24764c21bfc5", size = 2165745, upload-time = "2026-11-05T09:13:20.245Z" }, - { url = "https://files.pythonhosted.org/packages/36/12/0ee82a41a3995f0b531cf14e0b823dc2365ba4a22330670fccaa72753f12/pydantic_core-2.50.4-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:edbca8789fd10f0de534b660a6b4c71f1fd18039679c918dad392ab044bb37e4", size = 2223917, upload-time = "2026-11-05T09:13:21.623Z" }, - { url = "https://files.pythonhosted.org/packages/90/2c/592f8404abbcc65a70e6a802d1dc8f11412af44913e5146cf5c345370074/pydantic_core-2.50.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:33b21f69540a12c2053cd1d95766d8bd9667a3897f7c712a642de8aa37eb0865", size = 2087372, upload-time = "2026-11-05T09:13:23.16Z" }, - { url = "https://files.pythonhosted.org/packages/ea/1d/c7111757c84b5b8c19b1e39ceb5e131e6e48e14169ec6004e0f8f28f43f3/pydantic_core-2.50.4-cp314-cp314t-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:ffb616d8d55965839670301dc3bae3abacff560a7e137a89056058a8a9da4d96", size = 2275190, upload-time = "2026-11-05T09:13:24.634Z" }, - { url = "https://files.pythonhosted.org/packages/3d/ae/6c49cc9b8e66e61adee782d1763894bf64a357cddae82f725059b85bdc98/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6c5687b59b6ba0f663c4f2f15470f68507d6b45ccd3a19ee6d224f95cbee70d8", size = 2110343, upload-time = "2026-11-05T09:13:26.168Z" }, - { url = "https://files.pythonhosted.org/packages/ed/39/0ee5261d1daa9ad526371181c13696add0565251b2823f6e00a9a9af397d/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:c733087ecf7dde06b1d071679bfd5f3ba03266ba77814c1c7253bc48c9adedd9", size = 2207887, upload-time = "2026-11-05T09:13:27.681Z" }, - { url = "https://files.pythonhosted.org/packages/ac/b5/a0652c0e99590107e111088b6d059044380a787da9ffdd0b458ab4cd9453/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:94733cb447c37b0ce6f71b39ca1288d5f966a084023a5617b4cc35a852586859", size = 2404171, upload-time = "2026-11-05T09:13:29.864Z" }, - { url = "https://files.pythonhosted.org/packages/a3/85/d49f0b8e09a0ffc40dcefb604f9e6020e0d61b51a5f64a504f382fa84c39/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b26f39a5be3cd91a2035818be3d0ffdf5282c3e1f5f53d3b80b7024021acee52", size = 2466049, upload-time = "2026-11-05T09:13:31.658Z" }, - { url = "https://files.pythonhosted.org/packages/e6/76/f2b04d7c53edfd8136053c812ea49914fbf4091196cb7baf9ea326fa2ff8/pydantic_core-2.50.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c856e439a9d54d514e81a7131229ba151cdf81df7c408e0f6c89340e5003dfe2", size = 2262062, upload-time = "2026-11-05T09:13:33.806Z" }, - { url = "https://files.pythonhosted.org/packages/24/60/016f14cea883adc33df90b8df220df934de49ded9640f45c8e92bb298494/pydantic_core-2.50.4-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:cbf0777d54672990b10cb8ca9b0523499e182d7e2ea39f86b138519a902aa601", size = 2263713, upload-time = "2026-11-05T09:13:35.337Z" }, - { url = "https://files.pythonhosted.org/packages/f1/3f/b05828e978512973e7e215bab69e65e70d223d6309a17bf48084a50692f4/pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:edc17549ab592e33cfcaf285f047bb75fcd98f608aa9309af1187fd736ce9641", size = 2305044, upload-time = "2026-11-05T09:13:37.043Z" }, - { url = "https://files.pythonhosted.org/packages/91/c1/fca6c5f623ac45ba284713c614b30173aa0794899a0a457f866fa6f5e886/pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:23a9ba564b2db709ff16eca990992ba95a19069972b34bff87c81d4b473cd755", size = 2483506, upload-time = "2026-11-05T09:13:40.524Z" }, - { url = "https://files.pythonhosted.org/packages/94/c2/ec41f68d1208e53e1a73ead940c050c4316bbb555ba42676a5e949fd529e/pydantic_core-2.50.4-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:41f4f8ae714e4fea1d635880f8a1af715ecf080eed4d13c5b04a0f3210f9c61a", size = 2512832, upload-time = "2026-11-05T09:13:43.361Z" }, - { url = "https://files.pythonhosted.org/packages/43/22/58583b86309f70cce854e0e77c412839a56ac6c682d6060f5794afeff315/pydantic_core-2.50.4-cp314-cp314t-win32.whl", hash = "sha256:601fce6cea9ddeaa85329e12e7f351def38d233075f42a3012b9c48071b02941", size = 2101977, upload-time = "2026-11-05T09:13:45.735Z" }, - { url = "https://files.pythonhosted.org/packages/6b/28/193bc0994f7fe15f2874c1dfe2f3bc7872aed8283ffda2cf05fb9a5a06b4/pydantic_core-2.50.4-cp314-cp314t-win_amd64.whl", hash = "sha256:22e874666bdbd96d6bf629d32cd8ab376fedf1fd62585b52a42b9fa9fa6c20b6", size = 2240461, upload-time = "2026-11-05T09:13:48.38Z" }, - { url = "https://files.pythonhosted.org/packages/00/ed/5615cfdd5620a4926440eb1a2b73db0dc895824ba565ccaa8d9eb3a8e974/pydantic_core-2.50.4-cp314-cp314t-win_arm64.whl", hash = "sha256:71395a43da5584bb70556f380387e15f845c0dcf76373c1afbfa0025737576ac", size = 2168505, upload-time = "2026-11-05T09:13:50.762Z" }, - { url = "https://files.pythonhosted.org/packages/6d/9f/e6673535165d965a11c1d5339f53995f90234019827eaecb41a57e6e463d/pydantic_core-2.50.4-cp315-cp315-macosx_10_12_x86_64.whl", hash = "sha256:7ac2769a7ddd661e07e26c12220adc31b17014c48234b2a5a88993b8d4109e09", size = 2241950, upload-time = "2026-11-05T09:13:53.055Z" }, - { url = "https://files.pythonhosted.org/packages/6f/02/65951efadbf7826e6a270843f97e3da2ef726de2b6d9cd7c5dfa4c48807e/pydantic_core-2.50.4-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:930ad463d3fb7a340d323bcc496ec32dae469ec9974c29ff569f19806b6b03b4", size = 2112412, upload-time = "2026-11-05T09:13:55.309Z" }, - { url = "https://files.pythonhosted.org/packages/c9/d3/4fb6e2e4a9e4951f1e05b198366ed5330e0874e83d52077e8b985350fe0e/pydantic_core-2.50.4-cp315-cp315-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:b867f9fd183d76977f810c626d539265183c25b2284762893a31e8d6cacc81c0", size = 2263220, upload-time = "2026-11-05T09:13:57.555Z" }, - { url = "https://files.pythonhosted.org/packages/63/83/42e70436c523357b49393b73f161f2741acf36003c8efd2f941d2be56bae/pydantic_core-2.50.4-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:49eb1241a969a5994db6880c18c012b6cbe2340343d8f529721571806583e500", size = 2134716, upload-time = "2026-11-05T09:13:59.413Z" }, - { url = "https://files.pythonhosted.org/packages/36/66/ed9b87f4751fd07e472c62cfe151f575abdf4c452fab943d35ba8efdc6c4/pydantic_core-2.50.4-cp315-cp315-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:477af785d1846e4e96bf56983b92ea7553aaeccdeb8acdaa55c7cee9eda0ae32", size = 2201901, upload-time = "2026-11-05T09:14:01.472Z" }, - { url = "https://files.pythonhosted.org/packages/2b/21/ff2e6ac7202b6d326e9f007c6082f6e6f3aaa063790ea2a355bdc985addc/pydantic_core-2.50.4-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:29358a8ca74e7d81158d14e2b10c904bd18773293ae3788716c0626fe0342347", size = 2389670, upload-time = "2026-11-05T09:14:03.431Z" }, - { url = "https://files.pythonhosted.org/packages/b9/34/e9348bc13d549641791a51843ed140fbb311d9066628e27477343412d5ad/pydantic_core-2.50.4-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:300753f71c73302e218124baf995f00058e085cd01869bd9610bcbd0bd4500c1", size = 2468951, upload-time = "2026-11-05T09:14:05.028Z" }, - { url = "https://files.pythonhosted.org/packages/ac/5e/145a02bf2b9f66981108caf6cc9e78917e31e4caca14d1e3ccd3ff2c7293/pydantic_core-2.50.4-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:26cb012c4b8ca9f847bd0ac15978bd3d0f55b050bfbe6c47355edfc7e945029b", size = 2272957, upload-time = "2026-11-05T09:14:06.587Z" }, - { url = "https://files.pythonhosted.org/packages/fd/38/b71c5b245e923f6cf144e948ed2a9d6b7fb97d8905784db8d860f5176b8b/pydantic_core-2.50.4-cp315-cp315-manylinux_2_31_riscv64.whl", hash = "sha256:9be1cfe715ecaa060ffd5d599ef410b94ef2697a0eed4cee562f788a2aa2175b", size = 2275028, upload-time = "2026-11-05T09:14:08.219Z" }, - { url = "https://files.pythonhosted.org/packages/ba/71/2504dacdc5cd3ea3ec5e68c9b6e097c979500bcff220b97046cc8ea3c1ad/pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_aarch64.whl", hash = "sha256:c81e35862aced259177a537ce1a6264c3a97bae1ced184ca9dc10ea754563688", size = 2305447, upload-time = "2026-11-05T09:14:09.795Z" }, - { url = "https://files.pythonhosted.org/packages/2c/90/904233a6c148bcac9f30bb96a2761e5fb52682d0d6de31a40c74a3714ceb/pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_armv7l.whl", hash = "sha256:b2f2d13239487cecaae98c9f4d5904ad0737643cdf8873c88ec6a78b12214f20", size = 2477852, upload-time = "2026-11-05T09:14:11.443Z" }, - { url = "https://files.pythonhosted.org/packages/72/33/1cbdcbf343ca23b507e967b21dddc4c8bf17a74c8b5cad59228c85ba4efc/pydantic_core-2.50.4-cp315-cp315-musllinux_1_1_x86_64.whl", hash = "sha256:e6b4b08d09054310a4dc389fa61ee22a7a5a292cb23ab8a985136ca8828bf924", size = 2506352, upload-time = "2026-11-05T09:14:13.165Z" }, - { url = "https://files.pythonhosted.org/packages/91/24/3ad9ea0876e6624c90967e5f1446e751b275cfdfaaf798a0d8e0b30025bc/pydantic_core-2.50.4-cp315-cp315-win32.whl", hash = "sha256:6619d49a89a15cd04334f76fec530c155923bfc60da74ff5d815a52629e1aa6c", size = 2127780, upload-time = "2026-11-05T09:14:17.52Z" }, - { url = "https://files.pythonhosted.org/packages/c0/3c/0582532b90a12492471977bdbca1317eca5144f6342ea581d2cee73ccd35/pydantic_core-2.50.4-cp315-cp315-win_amd64.whl", hash = "sha256:e5bd109d095aaae989a0463d5ef0fcc43e9ddd5de125e656d3c119a79e466380", size = 2270596, upload-time = "2026-11-05T09:14:20.955Z" }, - { url = "https://files.pythonhosted.org/packages/6c/50/967cfe4f7043a993c0c80cd3563c598b5281d2276aa775d0f6ff7f714271/pydantic_core-2.50.4-cp315-cp315-win_arm64.whl", hash = "sha256:6118e5a5550e36582e19bac1a403711a748f9f18251b054c326d3db02aaa7a18", size = 2170880, upload-time = "2026-11-05T09:14:24.822Z" }, - { url = "https://files.pythonhosted.org/packages/9e/71/3ec5bd8a82f792482f16d79fdbe8ce85aa71bf7147e556c5fc5f8546818d/pydantic_core-2.50.4-cp315-cp315t-macosx_10_12_x86_64.whl", hash = "sha256:d8201c9f9035520cdcc7dcad383b039ec8123969b87e01cf27c3dd883c02313b", size = 2233053, upload-time = "2026-11-05T09:14:27.942Z" }, - { url = "https://files.pythonhosted.org/packages/6e/2e/614dc37aedf8e9f811c1f2eedaf8eb09a7c196e2d137fe82bcc9d5662ca2/pydantic_core-2.50.4-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:1de7be9a66fc8536770481ab64a05aae5067c725f2b29a09543af00e6a417b97", size = 2090776, upload-time = "2026-11-05T09:14:30.281Z" }, - { url = "https://files.pythonhosted.org/packages/f9/14/aefc14e3e05013070ee959fc0b8703f6860a2776ed6e75b9c748f61aced0/pydantic_core-2.50.4-cp315-cp315t-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:789a6453e5ffd18a7ab6b8c3a0dd8403053829197ec258ecb90c604c21ffcc99", size = 2272481, upload-time = "2026-11-05T09:14:32.578Z" }, - { url = "https://files.pythonhosted.org/packages/13/c9/d56999aa7236dc9303091db2b1ef7303f0b022baf25ebf33cd200c0cb933/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6348ad12fa741bcc9c2f173e99fbf27cbc038826d8c31a4a7d836eca27878ba2", size = 2113069, upload-time = "2026-11-05T09:14:34.69Z" }, - { url = "https://files.pythonhosted.org/packages/b7/d5/a62da9e72f272f198f6118c5457332bbd4b9fdc4b77858448120569756de/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d49127f137f871cde3c5650af33bbbdcee02679dae76e020902fa106f522b8ae", size = 2202754, upload-time = "2026-11-05T09:14:36.49Z" }, - { url = "https://files.pythonhosted.org/packages/37/4a/e7f21577f96e42ac3082cd014df398c1c913d482afac1c8ef17b9e039198/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:2f5cc5bcb94063fbbdfd285a2b302da34af07491337c10bb35de1d5220fa1583", size = 2411472, upload-time = "2026-11-05T09:14:38.63Z" }, - { url = "https://files.pythonhosted.org/packages/38/ad/c57c5e13bbfd3404ec1af519764aadbc52ee01e39f9f9ae9d28317f982f2/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b99bed995ed7c41515c11fe2beb86f8a6cc298e5537cae2f736de2f982f74ef0", size = 2475330, upload-time = "2026-11-05T09:14:40.519Z" }, - { url = "https://files.pythonhosted.org/packages/6e/63/65cf0e1f1fd8cfaafee3c005712b8020e063b0f3e3571493ea68db5ec44f/pydantic_core-2.50.4-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:faa4e96385c820ce9d7f7a623486e23d4134ae3c9ba2071e44e0ab5a5a5002c4", size = 2265718, upload-time = "2026-11-05T09:14:42.379Z" }, - { url = "https://files.pythonhosted.org/packages/72/5d/fd9fdec9b25e2ef1f788970a84f749f0e28f166573c87654fd5387d8e5ce/pydantic_core-2.50.4-cp315-cp315t-manylinux_2_31_riscv64.whl", hash = "sha256:d6a166978f22f10cb91413f70519861605219346decf65bc79008f9257c94afe", size = 2273454, upload-time = "2026-11-05T09:14:44.286Z" }, - { url = "https://files.pythonhosted.org/packages/34/8c/19705c6d5eb72ff8c25006df8a375da7466176a5968781789e5415384f65/pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_aarch64.whl", hash = "sha256:a70d5effebd81ebd8e15a8aabdc7980832367b2b00c36543bac378977004cc80", size = 2314862, upload-time = "2026-11-05T09:14:45.97Z" }, - { url = "https://files.pythonhosted.org/packages/b8/fb/acefa27031aba2646b0d3026c4a1602e526489d39395ab17bc47f03234e3/pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_armv7l.whl", hash = "sha256:f8fd23653a252cefabea11cd041efd7b80bdf403e43a36dea53f9cb0aaa21f0f", size = 2479073, upload-time = "2026-11-05T09:14:47.526Z" }, - { url = "https://files.pythonhosted.org/packages/ef/e1/db08fa1e5edf1779fa0612f8d09f9030bdc513f593687c883cb781b86caa/pydantic_core-2.50.4-cp315-cp315t-musllinux_1_1_x86_64.whl", hash = "sha256:7646353a5a7c553c04167aca628e2550b538f492765b03ccf34321a560acc43c", size = 2521328, upload-time = "2026-11-05T09:14:49.042Z" }, - { url = "https://files.pythonhosted.org/packages/0d/51/bf1ec5b96c076d8d514b08f3bcffb3397df7a0fcc729eb960838a8bbe27f/pydantic_core-2.50.4-cp315-cp315t-win32.whl", hash = "sha256:65376dbe1ab4dbc768ca2b72b7c13993562c035f5925fd3bc7ff9c8c585c515d", size = 2107629, upload-time = "2026-11-05T09:14:50.891Z" }, - { url = "https://files.pythonhosted.org/packages/18/32/43d5db1824ec2314f737ff8d9962ff59954a74616d8656a8cc78790e45f1/pydantic_core-2.50.4-cp315-cp315t-win_amd64.whl", hash = "sha256:f08ee8248aad2d054e5bc4c73554d4505464698f6d754f16198dbc5764e9821d", size = 2244906, upload-time = "2026-11-05T09:14:53.056Z" }, - { url = "https://files.pythonhosted.org/packages/3a/c0/38c505004969c4641c3a077a8e72e354f02d5c06d8f51d7a103699704772/pydantic_core-2.50.4-cp315-cp315t-win_arm64.whl", hash = "sha256:da779ae50b46f3f7d1e1b5f362fdc0ad376a49fd55f6f3122dc2b6149936cdf7", size = 2179018, upload-time = "2026-11-05T09:14:54.448Z" }, - { url = "https://files.pythonhosted.org/packages/9a/18/2f6a25e9104d5af713d16671711927601da1f0db74e785be67bd590385c9/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:c04e9d920e2674f54651fd260a15c5d2843526c73d5242ee4311325ddc9573b3", size = 2212591, upload-time = "2026-11-05T09:14:56.262Z" }, - { url = "https://files.pythonhosted.org/packages/4c/1b/ba8b721af10a7659e7fbbef320ff8eb55462557a72607858af5a9bd22cb1/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:5bc1811ef2b4d4ba63e8e452f6e332b6374bd1d2cbbfdf66826c8cb1f71dd10d", size = 2048167, upload-time = "2026-11-05T09:14:57.681Z" }, - { url = "https://files.pythonhosted.org/packages/48/42/3f8638e7d90bdd9a7c7f3e5084723af59e7f43f15a292e242d35624073ce/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0b059a7968b1911be5a2d9a8234827ab0bef9d1e465d4b42da525894143550e8", size = 2119548, upload-time = "2026-11-05T09:14:59.317Z" }, - { url = "https://files.pythonhosted.org/packages/e0/8d/4bfbacaf191f7939893d165e18eb301731fa3366c59a6e57336c4f168fbd/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bee28aab5a580eec673f7b68dfa8dece3dd37bd207ef8d22fafe23a8e9837296", size = 2279952, upload-time = "2026-11-05T09:15:00.907Z" }, - { url = "https://files.pythonhosted.org/packages/9e/3a/d405a50e02ea81cd95e93fc97f43d351eeaa1707c28aa6fb58a9f1c1efa9/pydantic_core-2.50.4-graalpy313-graalpy253_313_native-macosx_11_0_arm64.whl", hash = "sha256:71e03d2ea1a221d020cfc5b6cc8bbbedef23a06704c70fcf4d0afb42965b22d1", size = 2049324, upload-time = "2026-11-05T09:15:02.379Z" }, - { url = "https://files.pythonhosted.org/packages/8f/3b/03e7992115e17cae4131ecd71aadb8fd5e4a04cc2aead72c3c27e9b453d1/pydantic_core-2.50.4-graalpy313-graalpy253_313_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:09450778e3ab58d3f565899fcfbf6c82926e31af29e28e799d1d50941316e0cb", size = 2119802, upload-time = "2026-11-05T09:15:03.901Z" }, - { url = "https://files.pythonhosted.org/packages/e3/d5/b76fc647e473377ca6e693c21549ee3a4a7677e4962c28ae4659337c5114/pydantic_core-2.50.4-graalpy313-graalpy253_313_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4eb15be588407148ef5937dc8d9256a71f6b115e6cddadb7aa20b6ee384680dc", size = 2280639, upload-time = "2026-11-05T09:15:05.374Z" }, +sdist = { url = "https://files.pythonhosted.org/packages/af/f9/8a06bea35ef8daf588f707784c973a7046e0034c8d8cfb08828eeffb8b75/pydantic_core-2.46.5.tar.gz", hash = "sha256:10416c15b8839ecc4ef4d0885da76da6fd0f67333a0eb8aff6d93c4b8f2910fc", size = 472262, upload-time = "2026-08-28T10:01:31.677Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/82/3f/76358795aa7a8c6d4f36e2cb828ad1c90ee118e1393a9281664f5aade9d4/pydantic_core-2.46.5-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:b9fe6fb92520e3fd61f2e49000b6911b188824f089b75973ea06d6267f0b476d", size = 2076516, upload-time = "2026-08-28T09:58:21.576Z" }, + { url = "https://files.pythonhosted.org/packages/db/50/26b091836076ce4cb2fac264186936acc069e0595772cfd02a563bc4761a/pydantic_core-2.46.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a39ac25a9a2fa4072efdb429833c4a4c8009a51ff9eea3eeae131713cd27991e", size = 1922874, upload-time = "2026-08-28T09:58:23.766Z" }, + { url = "https://files.pythonhosted.org/packages/09/f0/2a8ce3849e299d44e2d2c196b6082643a3235565a735cb51db7a6261f614/pydantic_core-2.46.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4fdc8b93a41521988916eeaa271173fcca7fa0803d62f87675aac8dcec1c8e29", size = 1951772, upload-time = "2026-08-28T09:58:25.435Z" }, + { url = "https://files.pythonhosted.org/packages/87/46/ac0dc8bdd9e6048183a14eb127764e7ad9240021c17513074a4711b0e31e/pydantic_core-2.46.5-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b98134087d9de723658d17a42c7d0da8d6e2ef08015dee7dc93889047315f5e4", size = 2031832, upload-time = "2026-08-28T09:58:27.102Z" }, + { url = "https://files.pythonhosted.org/packages/c4/c2/339de5bef7be36301a2231eaa52e62163742c2281f11b5f4892bc79785cd/pydantic_core-2.46.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e652ab17569c94bff5475520f907b7148b8c24036a8ebbe5cf7cf7493d28579a", size = 2208645, upload-time = "2026-08-28T09:58:28.948Z" }, + { url = "https://files.pythonhosted.org/packages/7b/a0/9ff22b797724262da14427abaed4dd1d864a139693fc5e7809114376a716/pydantic_core-2.46.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d925f3d9afd05a8c0fb3a1031463a8d59ebe5e2afad297e29c78be19e13b4e62", size = 2265935, upload-time = "2026-08-28T09:58:30.625Z" }, + { url = "https://files.pythonhosted.org/packages/c0/a4/eb9409ec0736e50aa70a412f16c204ed149516846912f7e6724d4c73ee53/pydantic_core-2.46.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fc5be0abd4a407e200d844b404e33639a554e7bd0d448e7b9ae181be4789ac2", size = 2066284, upload-time = "2026-08-28T09:58:32.289Z" }, + { url = "https://files.pythonhosted.org/packages/c0/02/7f6156ffc926857f1c37c07d9a388682865a81830ab6a1b637082c25e399/pydantic_core-2.46.5-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:816ff0a6550ffc06c098ccd2e0698600f9aa7da192a79eaa6f9af504a35db869", size = 2105889, upload-time = "2026-08-28T09:58:33.986Z" }, + { url = "https://files.pythonhosted.org/packages/92/b1/e781d357ebe09fc929f995700f1b3503e8897f1cece183ecb1300d4d67e9/pydantic_core-2.46.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c7ea57fc63aa7da93a1bd2d644e6577befae10c52c4e36377635eea1056a74f5", size = 2158006, upload-time = "2026-08-28T09:58:35.647Z" }, + { url = "https://files.pythonhosted.org/packages/70/0a/644597d84ab400e50609c192120b85c9681c22d3a20461b9060a79be0a7a/pydantic_core-2.46.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:efd62a42486f1bda5d24cb4f63d15a3c7768375fe83d36f9417b4ad7a2fb20b3", size = 2158408, upload-time = "2026-08-28T09:58:37.38Z" }, + { url = "https://files.pythonhosted.org/packages/1e/ee/ca3b7b3a4b3769ffe9ce9432a7c9be755de9593a46d3b0d54d0409323e44/pydantic_core-2.46.5-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:2bc9419666990c06d7397831f2126a1ecc3594aaa3ff7de5bf2d066802f4e07b", size = 2309609, upload-time = "2026-08-28T09:58:39.22Z" }, + { url = "https://files.pythonhosted.org/packages/ce/52/39fa1f451486019524ca685020390e7ca351832fd874530ba30c8628e6dc/pydantic_core-2.46.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:18a09e1e1011b462f2e32774f25859ef1223d5c2b0546a633cf56654710721e0", size = 2342618, upload-time = "2026-08-28T09:58:40.89Z" }, + { url = "https://files.pythonhosted.org/packages/81/5e/468fc630568c61dcef3cd47ad32ffbeed9af643f49208d1ea86ab4f890c4/pydantic_core-2.46.5-cp312-cp312-win32.whl", hash = "sha256:5cb482e9e84c851f4e623fe4acc1ced89168cf1fe18f7089db4548c8f5bbb65b", size = 1939475, upload-time = "2026-08-28T09:58:42.591Z" }, + { url = "https://files.pythonhosted.org/packages/cf/c9/4c19f41b84cf6b622a72fbeed7665b25d47a187d68d47d0d430c07f23268/pydantic_core-2.46.5-cp312-cp312-win_amd64.whl", hash = "sha256:5e81740c09e310f5aa5cbd3e434a01c154d4bef93241c7877b39f211d2b78ba8", size = 2043140, upload-time = "2026-08-28T09:58:44.272Z" }, + { url = "https://files.pythonhosted.org/packages/af/dd/0c1a050299147c746e5256db16d645ab5efd4f78c59937d581a0524e74a2/pydantic_core-2.46.5-cp312-cp312-win_arm64.whl", hash = "sha256:f7b0ec93a2893de856652154d73b7ba622f26fa97726487dcac373de5f4c6084", size = 1997729, upload-time = "2026-08-28T09:58:46.13Z" }, + { url = "https://files.pythonhosted.org/packages/f5/37/5abe39a8372a61d3dc3c1338fc504281c01b32fdb3169cd7187153b56d3e/pydantic_core-2.46.5-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:b7ca9034437b6022f941f4857459562ee00a560b97e7cce8a0ec5a74fc6766e0", size = 2075885, upload-time = "2026-08-28T09:58:47.856Z" }, + { url = "https://files.pythonhosted.org/packages/21/43/6323b1f8b217780454c61304bcd2b38ae4762f50754414124603ccc90bb2/pydantic_core-2.46.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f332f0e72a5a0400141f830744e141bf9f97917878dbe968669e8a7fefea78ff", size = 1922768, upload-time = "2026-08-28T09:58:49.58Z" }, + { url = "https://files.pythonhosted.org/packages/0f/a3/c05ca796e1197618a774b01e596aeedfefc2f7d8c01ae3054e910b120e8a/pydantic_core-2.46.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:193375f3548919d3f0b60936ca113ada3e38f264f91b9b8e0508efaad57be931", size = 1951241, upload-time = "2026-08-28T09:58:51.511Z" }, + { url = "https://files.pythonhosted.org/packages/68/32/33bc39ac705c52cffc908e8389f9754fdb208aea5c69cceddf4eb3ce99af/pydantic_core-2.46.5-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:79bdfa52f843137045b2d081cc05c120ba6665d29b7559c2c47690906f39279f", size = 2031975, upload-time = "2026-08-28T09:58:53.166Z" }, + { url = "https://files.pythonhosted.org/packages/b0/70/2333e885c0f6a67bc105c5916965dac9b57f2718ee20d81d1a06a4ebdc13/pydantic_core-2.46.5-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:24922243639cbdac66c75fcb6fd6495a9cb52b213d62f9a0d16f0310b1ff8038", size = 2208542, upload-time = "2026-08-28T09:58:55.017Z" }, + { url = "https://files.pythonhosted.org/packages/f7/ea/296debfb4264207bbda5936133892e027c0a58875ad53ebd512fba8ec3a2/pydantic_core-2.46.5-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c76fe65e607be28c7fd4d56fc3c42b1583aa058ce3408b7ad0fd540171d31f9f", size = 2264692, upload-time = "2026-08-28T09:58:56.767Z" }, + { url = "https://files.pythonhosted.org/packages/d3/f2/9e4de77a6271e07a76d2d58b11c091a979c191ed2939bf80067568b369d2/pydantic_core-2.46.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f7b393a8b3da82f5c1fc0751e6d01ac6c55b93c18226a60bdfba4a724efafd1", size = 2066633, upload-time = "2026-08-28T09:58:58.531Z" }, + { url = "https://files.pythonhosted.org/packages/8d/db/f9e9d0c97445987b2084823d5c240de88087338f04fc2cfaa2df186b8049/pydantic_core-2.46.5-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:7ac031912d54f3d83ef3b3eb98dfabc1608802e2202263d25957eeed40b94761", size = 2105235, upload-time = "2026-08-28T09:59:00.421Z" }, + { url = "https://files.pythonhosted.org/packages/07/c5/79169b047b3b2c3e99e04bc76372af9637e0bf6db638274fa927df96369e/pydantic_core-2.46.5-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:837b396ca3d7b74091ca623f6cbd8351bd42d670a79c2683e79fb089f06a2de5", size = 2157367, upload-time = "2026-08-28T09:59:02.442Z" }, + { url = "https://files.pythonhosted.org/packages/26/b5/ba6057afb7c291bd449f51b867f95aef2072941c4ce4e5c31d6ffd132d3b/pydantic_core-2.46.5-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:5ee239d575f80b08eca11f6e20f90c4c695de7825c67eefe6091fbf20dda648e", size = 2158420, upload-time = "2026-08-28T09:59:04.2Z" }, + { url = "https://files.pythonhosted.org/packages/6e/28/2057abecaafdc22912afa819603a51f0a62d40643b7c4871c51721fea9be/pydantic_core-2.46.5-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:e80675d75ae2cd14372cb65cad5400d9347a3d3f6c13000183f22dfd027283ed", size = 2309588, upload-time = "2026-08-28T09:59:06.048Z" }, + { url = "https://files.pythonhosted.org/packages/71/9d/881156dc404e27479c4246128d73538464cab4a239bec61995e227644c30/pydantic_core-2.46.5-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:9c4b71f10dd532fb7a5cbc8f58707779e64f03a258c2bf8bfbaecfcd9970b519", size = 2341866, upload-time = "2026-08-28T09:59:08.539Z" }, + { url = "https://files.pythonhosted.org/packages/5a/38/d66f443a259f84d13babdceae568e572b0ed26da17ca5d0a649ebb110a67/pydantic_core-2.46.5-cp313-cp313-win32.whl", hash = "sha256:97bf8de4d541598c94a59344eeb988a94c08ff76b5723c41f6567ec18c7892ea", size = 1938580, upload-time = "2026-08-28T09:59:10.402Z" }, + { url = "https://files.pythonhosted.org/packages/2c/1e/1d5371213f4cc9a7ed70c0bfcc7911de22311ee99a662a56077d7292d2ac/pydantic_core-2.46.5-cp313-cp313-win_amd64.whl", hash = "sha256:15f4a94963c95accac15b7b657bb177d3ad82bb90b0d0526d9a9b85079925db5", size = 2041980, upload-time = "2026-08-28T09:59:12.396Z" }, + { url = "https://files.pythonhosted.org/packages/5a/48/4222d90b1c67568bace4dec6dca6271449c66de3595d72b6d098f5fde597/pydantic_core-2.46.5-cp313-cp313-win_arm64.whl", hash = "sha256:d22a945598fb91236b4dd793a6e42e4f3dd7740bb5aace5ebd7d4c08d13bb575", size = 1997213, upload-time = "2026-08-28T09:59:14.245Z" }, + { url = "https://files.pythonhosted.org/packages/8e/8a/14596f2a8367da50cf7cbac48169ee5d9c8e11d486a3b527082384630c72/pydantic_core-2.46.5-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:c1c43ad4339643d70ebb8124e1305a7dab423001eff58bb41a0f731adbc98355", size = 2074081, upload-time = "2026-08-28T09:59:16.141Z" }, + { url = "https://files.pythonhosted.org/packages/ae/d5/d8a4eb6d6c7f66b91dd37c576d76e9e60fba900caf5372c17bcf949febc2/pydantic_core-2.46.5-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1a353f84de772f423b5ffb11d7ae352fbbef0f446f3c0b0af0f8236d7233606e", size = 1920497, upload-time = "2026-08-28T09:59:18.065Z" }, + { url = "https://files.pythonhosted.org/packages/8e/26/092079428f86e927e030b2c0ced87df69dbb1c875cdeaa67bf42ea2be746/pydantic_core-2.46.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5086029a57366b8cf81b130a43908738095c270c21a8d7f0e8bdfdb89718e2f3", size = 1952130, upload-time = "2026-08-28T09:59:20.476Z" }, + { url = "https://files.pythonhosted.org/packages/08/c3/8ec0e290a9ebaebd64047bf5fda94be835c6b1551b02437e4b76778fbcd7/pydantic_core-2.46.5-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:46c25dda9d092a06c08db76ffe0a197107904d0dfac653f7d5306bbcd6d6119c", size = 2026371, upload-time = "2026-08-28T09:59:22.227Z" }, + { url = "https://files.pythonhosted.org/packages/01/72/4fd20ad520fb8da0157f95b27a7eb05a72790ef08138e7701ac972c342ea/pydantic_core-2.46.5-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:37ea7b83c935e5b0d68c9449b82651accf78a10828b2c02b2f2d9e9496446c21", size = 2202822, upload-time = "2026-08-28T09:59:24.277Z" }, + { url = "https://files.pythonhosted.org/packages/31/b0/d16e0771206b29314f0d52198b720be21e8a99ab2bf11e3bc0d7c9cebdff/pydantic_core-2.46.5-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e64e88d5585bea9ce95861079de72006c7fa6d3df4e3a3b65ba31eb979c15c9f", size = 2262756, upload-time = "2026-08-28T09:59:26.608Z" }, + { url = "https://files.pythonhosted.org/packages/2c/9b/59634b7ac631c63b2a37760eb6943af3e29573d6b59a4abc5e7f019d4cee/pydantic_core-2.46.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:54d510bac3ee52247af28ed4bb18a1e799f040ac60fd2bf5ccd4c92f1fbe786f", size = 2068352, upload-time = "2026-08-28T09:59:29.044Z" }, + { url = "https://files.pythonhosted.org/packages/08/7c/570abb1ad2155348dc754ea91be22e5aaa18eb6d69a6068f7c6f2679a6ed/pydantic_core-2.46.5-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:a2a5e1d0ff29adddc9f6d6821a66302e4493f8ca898b715b6b1182c2c201ea0a", size = 2104777, upload-time = "2026-08-28T09:59:30.95Z" }, + { url = "https://files.pythonhosted.org/packages/8e/25/5bf74adc65a1ac5b7be3f6cb0bcb5433615c1598a801c19d830d84c98ded/pydantic_core-2.46.5-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:03b9666e41e35d8909852ba191a0607520f81b74eaf12ccf8737005dbb313821", size = 2156312, upload-time = "2026-08-28T09:59:32.604Z" }, + { url = "https://files.pythonhosted.org/packages/90/6a/2ef38830675e050121040618135564ed56b860b45433b02d9b4ebece46f3/pydantic_core-2.46.5-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:a91c17edf6eea2402cb5457b4c89e99bc5ed1004aa34c4adf1d4258c1a5c22c2", size = 2150067, upload-time = "2026-08-28T09:59:34.453Z" }, + { url = "https://files.pythonhosted.org/packages/90/ef/a7dbb03a14a64c2a4621f989c615ed9a892535a6cad938fc27079f919d80/pydantic_core-2.46.5-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:b49924c73a235e969511bf2aabdff3beebf9820931f646c80274d5d780010c47", size = 2304516, upload-time = "2026-08-28T09:59:36.194Z" }, + { url = "https://files.pythonhosted.org/packages/68/f8/6bb4c4b80e8a6fde1904c64a51c62a1d04fcdfa3ea521a66b2ddefa1d885/pydantic_core-2.46.5-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:2cbd9a5eff05e51c447c34dfa4632145b26b09120cf04bd0c871e44c1a5e1c9a", size = 2335223, upload-time = "2026-08-28T09:59:37.931Z" }, + { url = "https://files.pythonhosted.org/packages/2a/80/f46b8c681195190b2c1f1c7c0a81abce60663e987613e09ef64d433dd96b/pydantic_core-2.46.5-cp314-cp314-win32.whl", hash = "sha256:2d5d76654becf5efd62c9e51c3756c67b49498b0c9a40884934c40807adbd074", size = 1934827, upload-time = "2026-08-28T09:59:39.836Z" }, + { url = "https://files.pythonhosted.org/packages/f7/3c/60674207246bc0a4009d2391b7c7251c7159f279c8d2ab8aae8ef46f3dee/pydantic_core-2.46.5-cp314-cp314-win_amd64.whl", hash = "sha256:fa10ef4112775900e7a0661068635eb67b2ab824fbde764de6e0e21982a93db0", size = 2042648, upload-time = "2026-08-28T09:59:41.792Z" }, + { url = "https://files.pythonhosted.org/packages/69/0c/117c562c7c1babdf44576b72a5e496906506c93690387ecfbca7c729ae2e/pydantic_core-2.46.5-cp314-cp314-win_arm64.whl", hash = "sha256:045ab3b6d308439e32b81cc173bba5b9018bc6ed896afd0c65b3b009b1699af5", size = 1989652, upload-time = "2026-08-28T09:59:43.702Z" }, + { url = "https://files.pythonhosted.org/packages/e8/66/9336ae58f9eb68c41d121894e52c4c89eccb07eb8f602a04ee9c3f37736a/pydantic_core-2.46.5-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:8816f3d218beb4b787de5c9759c259b8fa61f9dec42dc7811f320a33771778b7", size = 2065829, upload-time = "2026-08-28T09:59:45.364Z" }, + { url = "https://files.pythonhosted.org/packages/c5/02/bc19b47a96c2d3109760711acf22369e56bd7e405ca52f7ade164d2ead57/pydantic_core-2.46.5-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:bce57638e08ac148e5778cce7feb968307a727d66f8e2274a543d0cf0c9ad6a3", size = 1905716, upload-time = "2026-08-28T09:59:47.18Z" }, + { url = "https://files.pythonhosted.org/packages/52/a4/70b47c0509923dd98ccfed04fb3e32ea3849c82a0ff2205bb41009b43c00/pydantic_core-2.46.5-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:976e1128455aa595ea04c79ccfedff1aaeab96ee013fcc916bed120c4f0ad94f", size = 1934216, upload-time = "2026-08-28T09:59:49.241Z" }, + { url = "https://files.pythonhosted.org/packages/52/ab/aa03b65f7bb198585edf806b906c3223ecf1795543e39e23aec4cce27ad2/pydantic_core-2.46.5-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e7b891faeedeafba41b2983e5001a81b6a915b69544c7e7570d1989ce1c36ac7", size = 2010635, upload-time = "2026-08-28T09:59:51.692Z" }, + { url = "https://files.pythonhosted.org/packages/3c/8b/0da06343f30b84ec549aafd309c6456223d5dc8bd36af504c573faad561d/pydantic_core-2.46.5-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5f194189415698233dd1114a093a9b56e61e2c57e11b469be3b0506f46f0771c", size = 2209369, upload-time = "2026-08-28T09:59:53.582Z" }, + { url = "https://files.pythonhosted.org/packages/d6/5b/844c4defaa34a3df66eb9257087d121d70c201298b96abdf9f492fc2f1bf/pydantic_core-2.46.5-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:82a36973cf8a2ef5406f4fe2edbf8ed0c99629535d959e0b100c76a32535a111", size = 2253238, upload-time = "2026-08-28T09:59:55.484Z" }, + { url = "https://files.pythonhosted.org/packages/f4/64/a4e536cb16d7f61a7fd3120b46c577fc7fa7325992f69c4f52bc786d77d8/pydantic_core-2.46.5-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdbb78909f52b981d3b2d56b97328d71eb0b974c36bd77c920123a7ebb192829", size = 2065740, upload-time = "2026-08-28T09:59:58.038Z" }, + { url = "https://files.pythonhosted.org/packages/5f/75/aaa38c6bc2d085f6605b34eabdc6a8a4e0b2e61fc9c8e6e52b28e97b3125/pydantic_core-2.46.5-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:52e24eacdb536cade636aa90fb851835222becff8484b7001fdc78cb0290f2aa", size = 2087425, upload-time = "2026-08-28T09:59:59.898Z" }, + { url = "https://files.pythonhosted.org/packages/55/ae/fcab4cfc39aba3689e1d20c8b5250ad280957022c09af2ed9cd585602a5e/pydantic_core-2.46.5-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:37ae34309d7bd8c0d61ab839668058f2a7962ea1fc51d105d2db228fe0618034", size = 2139306, upload-time = "2026-08-28T10:00:03.057Z" }, + { url = "https://files.pythonhosted.org/packages/2d/f4/f1d03a4bc9d9acbc62f4d742b8a319af52f71885079868b2ff8e48a651ee/pydantic_core-2.46.5-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:0cdbada856a1c69a7624a64d3d9aefe79300bd6ef827b43a4f265010b9b55184", size = 2144589, upload-time = "2026-08-28T10:00:05.645Z" }, + { url = "https://files.pythonhosted.org/packages/83/f3/7a53bb1356de514a4cd295f25b6ac39237895620c0462d2592b76c16e114/pydantic_core-2.46.5-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:545f26c504b27c3758439a5e6d9349931f0a04f855668d5fe323c89e82300a38", size = 2288882, upload-time = "2026-08-28T10:00:07.931Z" }, + { url = "https://files.pythonhosted.org/packages/cd/94/5a81583660c175c59d49ffb09f4b3a44debeaf86a19fca664ae1cdd9ee32/pydantic_core-2.46.5-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:ff218293c9c806138dca139765e3b067621be52bcd93cdc14c7711be7ddc90a9", size = 2335210, upload-time = "2026-08-28T10:00:10.177Z" }, + { url = "https://files.pythonhosted.org/packages/5a/9f/5d685c2693b972d1a59c998586e8823712b66603aeff47ee60a4bdaafd37/pydantic_core-2.46.5-cp314-cp314t-win32.whl", hash = "sha256:97cf3eb53a8cccacf9d46686a0926186c9bfb5574f2ed66d3639d5fe117cd3a9", size = 1921180, upload-time = "2026-08-28T10:00:12.35Z" }, + { url = "https://files.pythonhosted.org/packages/70/12/5c94ee16d65a37a15f9e869f5e6256df111154491173801a4c5e800ab548/pydantic_core-2.46.5-cp314-cp314t-win_amd64.whl", hash = "sha256:d2f9fc07a8042a8f95925b35c4f04f469707c981fc33245b6ca187cf5d2dd290", size = 2020515, upload-time = "2026-08-28T10:00:14.774Z" }, + { url = "https://files.pythonhosted.org/packages/63/19/67830dda664e6bdf9285ee2e40f355d0d7d6b92aa0c42e8d217bb8d33d36/pydantic_core-2.46.5-cp314-cp314t-win_arm64.whl", hash = "sha256:acf8a67ba51f4ca9ddbd0e6b3000a65ac51ab734661778b3e7ba64d99a710f2f", size = 1989276, upload-time = "2026-08-28T10:00:16.984Z" }, + { url = "https://files.pythonhosted.org/packages/df/dd/053c2e4303f791f3b8f8a14ab0b22008e8eb21d868c0c90b4f9be705b76a/pydantic_core-2.46.5-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:013d6f3483d81e02e7c328831808f336c8596ee33b4bd4026b9ffb1e960b8942", size = 2062540, upload-time = "2026-08-28T10:01:00.318Z" }, + { url = "https://files.pythonhosted.org/packages/d7/dd/a18df751a5e37dd51bfad7f68e766999125bebe68c9e1d10a493ad01bd63/pydantic_core-2.46.5-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:e9c134bb666dd54b778b9fc0d2b50cbb7f979b9e3716f26a88c9ab3b6fc1dd0f", size = 1902040, upload-time = "2026-08-28T10:01:02.529Z" }, + { url = "https://files.pythonhosted.org/packages/b7/13/01d40f9d07ce8a779fd6e0bd8ad4fba91309500dd67b869e2e219d261a6d/pydantic_core-2.46.5-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:347ec774390c87326a2e4929d58d3f7e8763a104d5d35f4cd595a4c952366433", size = 1967479, upload-time = "2026-08-28T10:01:05.004Z" }, + { url = "https://files.pythonhosted.org/packages/fa/04/c81d4841331c2178b6fb09ae225425e110ed72d990c9fe556c4ec03d1013/pydantic_core-2.46.5-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8e24d8f05fa2d28513d94e877e9c75ad66175376209b3977f916e240e623193c", size = 2111034, upload-time = "2026-08-28T10:01:07.345Z" }, ] [[package]] @@ -5875,6 +6183,27 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/60/d1/38f3a3405989a89ac18390803e70c6ad7c7760da4f9b83cbeca0c44a0c72/python_dotenv-1.2.4-py3-none-any.whl", hash = "sha256:42269a8a5b3fd54ffa6f3d84b18abed50064717576b4ecf03dc4a55d8aa04fdc", size = 23266, upload-time = "2026-10-01T05:36:08.633Z" }, ] +[[package]] +name = "python-elf" +version = "0.9.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "bioimage-cpp" }, + { name = "h5py" }, + { name = "imageio" }, + { name = "numpy" }, + { name = "pooch" }, + { name = "requests" }, + { name = "scikit-image" }, + { name = "scikit-learn" }, + { name = "skan" }, + { name = "zarr" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7a/86/b40f324e6f7b8d4b8ac1a960a3ae7481287d13e2a9449ba598ee66b4a868/python_elf-0.9.3.tar.gz", hash = "sha256:2c614e47d1713e3dadf41bcb8ff170036ce149c44ecef4da02c3b9ed6691080e", size = 189597, upload-time = "2026-11-17T13:29:03.176Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f4/49/e76dbf907aabe62948818b4001f7a705de5077d2d7b30513c4535d7a62f1/python_elf-0.9.3-py3-none-any.whl", hash = "sha256:863e9936d5c3e76ad3e09f9c02fc4cb2a5e8d9406c765686078d215aff458ce5", size = 187740, upload-time = "2026-11-17T13:29:01.681Z" }, +] + [[package]] name = "pytorch-lightning" version = "2.6.6" @@ -5909,6 +6238,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/46/7d/73ef5052f57b7720cad00e16598db3592a5ef4826745ffca67a2f085d4dc/pytorch_metric_learning-2.9.0-py3-none-any.whl", hash = "sha256:d51646006dc87168f00cf954785db133a4c5aac81253877248737aa42ef6432a", size = 127801, upload-time = "2025-08-17T17:11:18.185Z" }, ] +[[package]] +name = "pyvers" +version = "0.2.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/62/21/9daf8da2793d112a04b46ac33ab9046c91b0af8292cd93b3cfdd07ff7169/pyvers-0.2.3.tar.gz", hash = "sha256:c4b81c3a033963245e124cdecb052783c9c4cea3bb08c051833af1c44faa6283", size = 12347, upload-time = "2026-07-09T13:58:07.046Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2d/8d/63787e8feda59d981ebc953b6581ccab3c97cf7bfe0a6a407c07b50fc86c/pyvers-0.2.3-py3-none-any.whl", hash = "sha256:6f5b5612f2f4bd08caa49baa70fc5f875fc7da701a5385c13e244eea6b8114dd", size = 11757, upload-time = "2026-07-09T13:58:06.078Z" }, +] + [[package]] name = "pywavelets" version = "1.10.0" @@ -6551,6 +6889,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/37/0b/05bd31d19d0d74658f30c5bd584906c741a2e4d1fb8f5c08a0168c042553/rustworkx-0.18.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:aedc1b30330927810588b3dcf5e3032c5379cd19580fd01ec8e13f1cec55c30d", size = 2392538, upload-time = "2026-07-30T00:18:21.141Z" }, ] +[[package]] +name = "ruyaml" +version = "0.91.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "distro" }, + { name = "setuptools" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/4b/75/abbc7eab08bad7f47887a0555d3ac9e3947f89d2416678c08e025e449fdc/ruyaml-0.91.0.tar.gz", hash = "sha256:6ce9de9f4d082d696d3bde264664d1bcdca8f5a9dff9d1a1f1a127969ab871ab", size = 239075, upload-time = "2021-12-07T16:19:58.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/9a/16ca152a04b231c179c626de40af1d5d0bc2bc57bc875c397706016ddb2b/ruyaml-0.91.0-py3-none-any.whl", hash = "sha256:50e0ee3389c77ad340e209472e0effd41ae0275246df00cdad0a067532171755", size = 108906, upload-time = "2021-12-07T16:19:56.798Z" }, +] + [[package]] name = "s3fs" version = "2026.9.0" @@ -6589,6 +6940,35 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8d/fc/7eedc3510d97878876e32774eebbeb61c43f148a96e915c84229a3e967aa/safetensors-0.8.0-cp310-abi3-win_arm64.whl", hash = "sha256:f7838e5135a406ad3e02efdcb8cf2e5397d368b0154537c4fec682dbc544d452", size = 340500, upload-time = "2026-06-09T07:52:26.745Z" }, ] +[[package]] +name = "sam-2" +version = "1.0" +source = { git = "https://github.com/facebookresearch/sam2?rev=2b90b9f5ceec907a1c18123530e92e794ad901a4#2b90b9f5ceec907a1c18123530e92e794ad901a4" } +dependencies = [ + { name = "hydra-core" }, + { name = "iopath" }, + { name = "numpy" }, + { name = "pillow" }, + { name = "torch" }, + { name = "torchvision" }, + { name = "tqdm" }, +] + +[[package]] +name = "sam2" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "hydra-core" }, + { name = "iopath" }, + { name = "numpy" }, + { name = "pillow" }, + { name = "torch" }, + { name = "torchvision" }, + { name = "tqdm" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ce/11/d07fc96688f731a85de6d5260e98b709051eded2b7b5667ae292530bcf90/sam2-1.1.0.tar.gz", hash = "sha256:7e0ea252d43c10d853e3acfce0b5770ac683c30481bd6de311300e9d44f45b74", size = 152836, upload-time = "2024-12-21T09:55:17.154Z" } + [[package]] name = "scikit-image" version = "0.26.0" @@ -6777,6 +7157,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/75/77/8e0c16abf151a1dd076b562febc0da2ecf1132b0b41826087af96f101f42/segment_anything-1.0-py3-none-any.whl", hash = "sha256:86f67d417a915823c3302098effe9008b688945772517310956bb49de0e7f02e", size = 36560, upload-time = "2023-04-06T18:04:38.834Z" }, ] +[[package]] +name = "segment-anything-py" +version = "1.0.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "torch" }, + { name = "torchvision" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9b/2a/c29459219e4760315298301d65ec8bf902e75d2827e22212835cbbdd4052/segment_anything_py-1.0.1.tar.gz", hash = "sha256:91d7d65804dd3a9030e26cd269991c4d24099008fb82e5ae98c9f6d9163b4b75", size = 36469, upload-time = "2024-07-20T01:08:03.595Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/80/c6/ce82fea654a390f33ac4650619c97c705fca2aaef18722328813b7a30a06/segment_anything_py-1.0.1-py3-none-any.whl", hash = "sha256:708fdaddecd4f2d1e4d6f27ac21763497026bb938df50f993caeaf1f5c3c99b8", size = 40461, upload-time = "2024-07-20T01:08:02.046Z" }, +] + [[package]] name = "setuptools" version = "84.2.1" @@ -6804,6 +7197,28 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, ] +[[package]] +name = "skan" +version = "0.13.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "imageio" }, + { name = "matplotlib" }, + { name = "networkx" }, + { name = "numba" }, + { name = "numpy" }, + { name = "openpyxl" }, + { name = "pandas" }, + { name = "scikit-image" }, + { name = "scipy" }, + { name = "toolz" }, + { name = "tqdm" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/aa/4f/f50a606fdfba856fee46640e35c5f00307374e63cf6f9253db997017fec4/skan-0.13.1.tar.gz", hash = "sha256:d5a0f4eb30e88b3113ad419f87577e7b6412bcf14f61393b7968947b3ab60db0", size = 6743398, upload-time = "2026-02-06T05:33:32.064Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fd/2a/42e3621fc00b3f058b8602a4665030eed6ccb1a586f5c3f477ea46fa1242/skan-0.13.1-py3-none-any.whl", hash = "sha256:174c8ae26d098638b3869e812f809614c63b9e318861f7d5a36257f118d5aaca", size = 1557412, upload-time = "2026-02-06T05:33:30.252Z" }, +] + [[package]] name = "sniffio" version = "1.3.1" @@ -7094,6 +7509,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/73/c6/825dab04195756cf8ff2e12698f22513b3db2f64925bdd41671bfb33aaa5/tensorboard_data_server-0.7.2-py3-none-manylinux_2_31_x86_64.whl", hash = "sha256:ef687163c24185ae9754ed5650eb5bc4d84ff257aabdc33f0cc6f74d8ba54530", size = 6590363, upload-time = "2023-10-23T21:23:35.583Z" }, ] +[[package]] +name = "tensordict" +version = "0.15.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cloudpickle" }, + { name = "numpy" }, + { name = "pyvers" }, + { name = "torch" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/78/6a/afc9e529c87fc47d6b9d869d7d4906334b4153f75764338158da1f32a1cd/tensordict-0.15.6-py3-none-any.whl", hash = "sha256:fd4dc096ad5f98d9418a90ed572fdb1d1f1f3286c82b7dc138e9a4130a6ba5c3", size = 876045, upload-time = "2026-11-11T21:18:33.021Z" }, +] + [[package]] name = "tensorstore" version = "0.1.86" @@ -7342,6 +7771,32 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7b/64/1ad0107cec15706e4d972fcbfaa6b3da26734959109861a60902c922b50c/torch-2.15.0-cp315-cp315t-win_amd64.whl", hash = "sha256:c521a00891e92aba2f34717671c268acd0bde26444623efcceaeaf51c87b3b36", size = 127024483, upload-time = "2026-10-28T15:20:23.183Z" }, ] +[[package]] +name = "torch-em" +version = "0.10.11" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "bioimage-cpp" }, + { name = "bioimageio-core" }, + { name = "h5py" }, + { name = "imageio" }, + { name = "kornia" }, + { name = "mrcfile" }, + { name = "natsort" }, + { name = "python-elf" }, + { name = "requests" }, + { name = "scikit-image" }, + { name = "tensorboard" }, + { name = "tifffile" }, + { name = "torch" }, + { name = "torchvision" }, + { name = "tqdm" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/4e/68/5f33b9829c2db6f23a42c3ae5a61155ebe2433047d03ebd5f7639fe84f35/torch_em-0.10.11.tar.gz", hash = "sha256:7e032629bac4a8c8d510fbed137e1d36af1225e953894e9a95e11fbaa77a883a", size = 1329933, upload-time = "2026-11-14T11:13:17.729Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bc/be/75060d248d7758408ba8faef71646c0659af7b36f1aa4f66183b6d3e74da/torch_em-0.10.11-py3-none-any.whl", hash = "sha256:af6c76f0d6c04abc8fdaca79a96eda837df160f8a401c169beed6f8eea7a982d", size = 2108137, upload-time = "2026-11-14T11:13:15.571Z" }, +] + [[package]] name = "torchmetrics" version = "1.9.0" @@ -8131,6 +8586,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/34/95/40e17e20046b7bc820d29d09ae84ec157ec8dd6e6f6cd722626292c31b2e/widgetsnbextension-4.0.16-py3-none-any.whl", hash = "sha256:a31a8774885b96fe825462f5d6496166f0c7cae111195b6465c801d230eb5a4e", size = 2225148, upload-time = "2026-08-18T08:52:53.736Z" }, ] +[[package]] +name = "win32-setctime" +version = "1.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1a/e4/f0f252c65f9bf7c4042b1f707ef338d49f799da582234e1d3e6e2cfca291/win32_setctime-1.2.1.tar.gz", hash = "sha256:077b35471bf1ff1d71e165c919ddc0cecf51b8e1802f5d820d33a96e2f6717dd", size = 4983, upload-time = "2026-10-25T18:21:32.318Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bd/df/5593480bc1e932eeae28e4fa182ab68174edd0d77409ced3b6491d02d1d5/win32_setctime-1.2.1-py3-none-any.whl", hash = "sha256:a9edc685b35414bec69392c866ed82456ad125ac4a6a4b703ec1d8b462d4f477", size = 4215, upload-time = "2026-10-25T18:21:30.939Z" }, +] + [[package]] name = "witty" version = "0.3.4" @@ -8519,6 +8983,26 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/54/22/318c7980066769c6bcd9221ed2248294f5698811da099013098c670565ed/yarl-1.25.1-py3-none-any.whl", hash = "sha256:681c758b0490f9e96b78e5fa8e8dc6e648e9185bb6eaebe73183c33ea0c445f3", size = 63617, upload-time = "2026-09-15T19:34:59.616Z" }, ] +[[package]] +name = "z5py" +version = "3.0.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ba/84/99a3091146541781c4f2072d7dff1e62b6b8a5793ebd7bf9da1e597f2343/z5py-3.0.2.tar.gz", hash = "sha256:8a5872c5113321441397cf81ec44234257fe8b94a8e0c8f48f1c997718af3aae", size = 390199, upload-time = "2026-07-02T17:01:28.2Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cd/05/5b1618ef06577913fbbda9c1a951c881de1f42ccf3b3be8c6c5dc850f93e/z5py-3.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:45035a3c0c4c97b214fd773d66fd8e77d724994e30eaa75510205e242957391f", size = 1053845, upload-time = "2026-07-02T17:01:13.209Z" }, + { url = "https://files.pythonhosted.org/packages/b1/5d/d889339a038661d6bcf28590d500f0b18b767a27aec60596fb91de968112/z5py-3.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d14d66e328c5951750599a4486a00486397ddc3c27cdd33a57f20708ecfced4d", size = 1669538, upload-time = "2026-07-02T17:01:15.083Z" }, + { url = "https://files.pythonhosted.org/packages/67/59/0fd4d8e5bd4e6ef895c397d4d5f817016d2426031e9123643172475cf16c/z5py-3.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:f44d2da0a6afdc3b9a6f16bc01b46fcf10f248389c51d9ef67284a488cff5e66", size = 890423, upload-time = "2026-07-02T17:01:16.893Z" }, + { url = "https://files.pythonhosted.org/packages/b3/0a/dc0ec179ab997d8e0bb3246f4d7e11933e0de34f65b1eaf3b91e79ac6eec/z5py-3.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:54f50eb829c2cabdcc83afa708d6d8c102747c704d67909233502b0bff2a2a67", size = 1053656, upload-time = "2026-07-02T17:01:18.7Z" }, + { url = "https://files.pythonhosted.org/packages/96/e8/82105eb4d63f2f71d09a8104fd0de493fcd43b4f6d61861d496da2897ff9/z5py-3.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:269a78740e862a71743ee36c060205fcece34fc268bf9a40f6db445ec3fa8ef0", size = 1669397, upload-time = "2026-07-02T17:01:20.443Z" }, + { url = "https://files.pythonhosted.org/packages/5a/e5/66e540425d4b130a4ba455cd9ade93fe1d3b7a0995848cce540fb8f8e517/z5py-3.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:2ec022f4be918d9a1e6ee0eb05a50978b06bc58a8aa7a7052b22a13190d3cf7e", size = 890197, upload-time = "2026-07-02T17:01:21.829Z" }, + { url = "https://files.pythonhosted.org/packages/bd/24/66529fc35fc876b6ef6c96e66003e833395e040e8341e32d692a504e6452/z5py-3.0.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:95fcff57468cd4856945f2f167955788e945cfe2c6322d7f3f7bd604ed9a7222", size = 1054165, upload-time = "2026-07-02T17:01:23.293Z" }, + { url = "https://files.pythonhosted.org/packages/37/d3/0afc8ad90e4b0cee452529fbe83570938071d70aef591ed0f27a391ea1e2/z5py-3.0.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:43c3fa6a89e58138035c9d9471caf58290bbdb006c3623677ee28da36768ea25", size = 1669571, upload-time = "2026-07-02T17:01:24.991Z" }, + { url = "https://files.pythonhosted.org/packages/d1/44/0ac7e6dad86aeaaa766319b06ee8bdd5d69b680f2c54fcb77aaf0bebc5c5/z5py-3.0.2-cp314-cp314-win_amd64.whl", hash = "sha256:cc61a30b4ab7f99aa5b719c5fd8d330b7fe28a93d58c5908083ab355f679dac0", size = 913262, upload-time = "2026-07-02T17:01:26.704Z" }, +] + [[package]] name = "zarr" version = "3.4.0" From 4d6bf63a3c5edec00328c8f8dff056773ff3f015 Mon Sep 17 00:00:00 2001 From: Taylla Theodoro Date: Fri, 20 Nov 2026 11:13:02 -0800 Subject: [PATCH 2/7] docs(deps): the PyPI sam2 1.1.0 is Meta's SAM2 code, not a fork Diffed the sam2 1.1.0 sdist against facebookresearch/sam2 at 2b90b9f: the sam2 package is identical; only setup.py's name, version, URL and author differ (micro_sam's setup.cfg says the same). Keep installing SAM2 from Meta's repo with the uv override, but describe it as installing from the original source, and say that pip (which installs both) gets the same code. --- README.md | 8 ++++---- pyproject.toml | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 889aefe02..fc1698eab 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,10 @@ uv sync --extra all uv run --extra stain biahub virtual-stain --help ``` -Install `microsam` with uv (`uv sync --extra microsam`), not pip. `micro_sam` 2.0.1 depends on the PyPI -`sam2` package, which is a third-party upload of a SAM2 fork rather than Meta's release. uv replaces it with -Meta's SAM2 pinned in `pyproject.toml`; pip would install both. The extra also pulls in `napari`/`PyQt6` -and caps `pydantic<2.14`. +The `microsam` extra installs SAM2 from Meta's repository at a fixed commit. `micro_sam` 2.0.1 depends on +the PyPI `sam2` package instead, a third-party upload of the same code, because Meta does not publish SAM2 on +PyPI. With uv (`uv sync --extra microsam`) an override drops that package. pip ignores the override and +installs both, which is the same code. The extra also pulls in `napari`/`PyQt6` and caps `pydantic<2.14`. ### Development install diff --git a/pyproject.toml b/pyproject.toml index fe7205d82..bfadccbdb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,12 +65,14 @@ cpdino = [ # micro-sam 2 (Segment Anything for Microscopy 2, on SAM2) as a `biahub segment` backend # (`backend: microsam`). Opt-in, not in `all`: micro_sam hard-requires napari and PyQt6 -# and caps pydantic<2.14. micro_sam 2.0.1 pins `sam2==1.1.0` from PyPI, which is not -# Meta's SAM2 but a third-party upload of a fork (JinsuaFeito-dev/segment-anything-2); -# Meta's repo builds the distribution `SAM-2` (import name `sam2`) and is not on PyPI. -# So the extra installs Meta's SAM2 from git at a fixed commit, and the [tool.uv] -# override below drops the PyPI `sam2`. Plain pip honours no override and would install -# both (whichever lands last provides `sam2`): use uv. +# and caps pydantic<2.14. Meta does not publish SAM2 on PyPI (its repo builds the +# distribution `SAM-2`, import name `sam2`). micro_sam 2.0.1 pins `sam2==1.1.0`, a +# third-party PyPI upload whose `sam2` code is identical to facebookresearch/sam2 at +# 2b90b9f (only the setup.py name/author/URL differ; checked, and noted in micro_sam's +# setup.cfg). We install SAM2 from Meta's repo at that same commit instead, so the +# source is the original one and does not depend on who controls the PyPI name; the +# [tool.uv] override below drops the PyPI `sam2`. Plain pip ignores the override and +# installs both, which is the same code. microsam = [ "biahub[segment]", "micro_sam==2.0.1", @@ -144,8 +146,8 @@ biahub = "biahub.cli.main:cli" # when resolving build-system requirements such as iohub's hatchling / # uv-dynamic-versioning chain, which pulls in packaging>=24.2. index-strategy = "unsafe-best-match" -# micro_sam 2.0.1 depends on the PyPI `sam2`, a third-party fork (see the `microsam` -# extra); a never-true marker drops it, so only Meta's SAM-2 provides `sam2`. +# micro_sam 2.0.1 depends on the PyPI `sam2`, a third-party upload of Meta's SAM2 (see +# the `microsam` extra); a never-true marker drops it, so Meta's SAM-2 provides `sam2`. override-dependencies = ["sam2; sys_platform == 'never'"] [tool.uv.sources] From 84a57dcd19419115837a93e1a7534ea3fe90b2e3 Mon Sep 17 00:00:00 2001 From: Taylla Theodoro Date: Wed, 25 Nov 2026 13:43:11 -0800 Subject: [PATCH 3/7] fix(segment): check micro-sam eval_args up front, stage its cache on scratch Review fixes for the micro-sam backend: - eval_args are checked against the engine micro-sam will run, read from the signatures of the callables that receive them (AIS flow / multicut by mode, APG and AMG generate). A typo, a cellpose argument or min_size with amg (which calls it min_object_size) used to pass --init and then fail with a TypeError in every GPU job. micro-sam models are now checked on every head-node path (--init, SLURM, local, debug), before labels are created. - stage_microsam_weights copies the model and decoder to node-local scratch ($TMPDIR/micro_sam-) and points MICROSAM_CACHEDIR there, like stage_cellpose_weights: jobs no longer all read the weights over NFS, and the temporary embeddings micro-sam writes for tiled AIS go to scratch. - --init refuses a downsample that leaves fewer than 2 pixels along Y or X (micro-sam squeezed the axis and failed in the job). - warm_microsam_weights also prefetches plain SAM2 backbones. - Docs: eval_args keys depend on the engine and sizes are in downsampled pixels; the pydantic<2.14 cap applies to every install from uv.lock. - Tests: the micro-sam stand-in returns one id per pixel, so the upsampling test checks where each label lands, and carries micro-sam's real post-processing signatures. --- README.md | 3 +- biahub/segment.py | 36 +++- biahub/settings.py | 5 +- biahub/utils/microsam.py | 183 +++++++++++++++++--- settings/example_segmentation_settings.yml | 4 +- tests/conftest.py | 121 ++++++++++++- tests/test_cli/test_segment_microsam_cli.py | 48 ++++- tests/test_segment_microsam.py | 156 ++++++++++++++++- 8 files changed, 511 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index fc1698eab..8d0b58270 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,8 @@ uv run --extra stain biahub virtual-stain --help The `microsam` extra installs SAM2 from Meta's repository at a fixed commit. `micro_sam` 2.0.1 depends on the PyPI `sam2` package instead, a third-party upload of the same code, because Meta does not publish SAM2 on PyPI. With uv (`uv sync --extra microsam`) an override drops that package. pip ignores the override and -installs both, which is the same code. The extra also pulls in `napari`/`PyQt6` and caps `pydantic<2.14`. +installs both, which is the same code. The extra also pulls in `napari`/`PyQt6`. Its `pydantic<2.14` cap +applies to every install from `uv.lock`, because the lock resolves one version for all extras. ### Development install diff --git a/biahub/segment.py b/biahub/segment.py index 9860317bc..3d5e2eb51 100644 --- a/biahub/segment.py +++ b/biahub/segment.py @@ -41,6 +41,7 @@ check_microsam_model, load_microsam_model, segment_plane, + stage_microsam_weights, warm_microsam_weights, ) from biahub.utils.ngff import label_layout @@ -158,13 +159,30 @@ def _cached_model(model: ResolvedModel, device: "torch.device") -> Any: def _check_model(model) -> None: - """Raise if a configured model cannot run (unknown name, missing extra).""" + """Raise if a configured model cannot run (unknown name, missing extra, bad eval_args).""" if model.backend == "microsam": - check_microsam_model(model.pretrained_model, model.engine) + check_microsam_model(model.pretrained_model, model.engine, model.eval_args) else: check_cellpose_model_name(model.pretrained_model) +def check_plane_size(models: list[ResolvedModel], y_size: int, x_size: int) -> None: + """Refuse a micro-sam ``downsample`` that leaves fewer than 2 pixels along Y or X. + + micro-sam squeezes a singleton axis and then cannot read the plane as 2D. + """ + for model in models: + if model.backend != "microsam": + continue + small = (-(-y_size // model.downsample), -(-x_size // model.downsample)) + if min(small) < 2: + raise ValueError( + f"Model {model.name}: downsample {model.downsample} turns the " + f"{y_size} x {x_size} plane into {small[0]} x {small[1]} pixels; micro-sam " + "needs at least 2 along each axis. Lower downsample." + ) + + def _warm_model(model) -> None: """Fetch a configured model's weights into its shared cache (head node, --init).""" if model.backend == "microsam": @@ -189,6 +207,11 @@ def _segment_czyx( # Stage weights on node-local scratch before cellpose is first imported (no-op # after). stage_cellpose_weights() + microsam_models = [m.pretrained_model for m in models if m.backend == "microsam"] + if microsam_models: + # Same for micro-sam: its weights and temporary embeddings go to node-local + # scratch (no-op after the first timepoint). + stage_microsam_weights(microsam_models) czyx_segmentation = [] for model in models: @@ -281,6 +304,7 @@ def _init_label_images( channel_names = input_dataset.channel_names models = resolve_models(settings, channel_names, scale, Z) + check_plane_size(models, Y, X) label_names = [m.name for m in models] recorded = settings.model_dump(mode="json") @@ -389,9 +413,11 @@ def segment( # own copy inside the job (_segment_czyx). stage_cellpose_weights() settings = yaml_to_model(config_filepath, SegmentationSettings) - if init_only: - # Fail on a bad model name (or a missing extra) before scaffolding anything. - for model in settings.models.values(): + # Fail on a bad model (unknown name, missing extra, bad eval_args) before scaffolding + # anything or submitting jobs. micro-sam models are checked on every path: their + # eval_args are only checked here, so a bad key would otherwise fail in every GPU job. + for model in settings.models.values(): + if init_only or model.backend == "microsam": _check_model(model) (T, C, Z, Y, X), models = _init_label_images(input_position_dirpaths, settings) diff --git a/biahub/settings.py b/biahub/settings.py index 20f850efe..90ab64dfe 100644 --- a/biahub/settings.py +++ b/biahub/settings.py @@ -1234,7 +1234,10 @@ class MicroSamModel(BaseModel): pixels across: on mantis-v2 A549 data (0.113 um/px) 3-4 works, 1 outlines whole cell clusters. ``eval_args`` override micro-sam's post-processing defaults (see ``micro_sam.v2.postprocessing.default_postprocessing`` and - ``micro_sam.v2.automatic_prompt_generation.default_prompt_generation``). + ``micro_sam.v2.automatic_prompt_generation.default_prompt_generation``); the keys + depend on the engine (AIS ``min_size``, AMG ``min_object_size``, ...) and are checked + before any job runs. They apply to the downsampled plane: sizes are in downsampled + pixels (``min_size: 100`` with ``downsample: 4`` is 1600 input pixels). Needs ``biahub[microsam]``. """ diff --git a/biahub/utils/microsam.py b/biahub/utils/microsam.py index db68ec72e..38a1976a3 100644 --- a/biahub/utils/microsam.py +++ b/biahub/utils/microsam.py @@ -4,19 +4,35 @@ pydantic. Every import of it is local, so biahub imports without it. Weights are downloaded by micro-sam (pooch) to its cache, ``$MICROSAM_CACHEDIR`` or -``~/.cache/micro_sam``; `biahub segment --init` fetches them once on the head node. +``~/.cache/micro_sam``; `biahub segment --init` fetches them once on the head node. A +worker copies them to node-local scratch and points micro-sam's cache there +(:func:`stage_microsam_weights`), so the jobs do not all read the weights over NFS and +the temporary embeddings micro-sam writes for tiled images stay on the node. """ +import getpass +import inspect +import logging +import os + from pathlib import Path from typing import Any +import click import numpy as np +from biahub.utils.cellpose import _copy_weight + +logger = logging.getLogger(__name__) + _INSTALL_HINT = ( "micro-sam models need the micro_sam package. Install biahub's opt-in extra: " "`uv sync --extra microsam` (or `pip install 'biahub[microsam]'`)." ) +# AIS post-processing modes (micro-sam's UniSAM2 `generate(mode=...)`). +_AIS_MODES = ("sparse", "dense") + def _import_microsam(): try: @@ -26,48 +42,161 @@ def _import_microsam(): return automatic_segmentation, util -def check_microsam_model(pretrained_model: str, engine: str) -> None: - """Raise if micro-sam cannot run ``pretrained_model`` with ``engine``. +def _keyword_parameters(function, skip: tuple[str, ...] = ()) -> set[str]: + """Return the parameters of ``function`` that have a default (tunable keywords).""" + return { + name + for name, p in inspect.signature(function).parameters.items() + if p.default is not inspect.Parameter.empty and name not in skip + } + + +def engine_eval_args(engine: str, mode: str = "sparse") -> set[str]: + """Return the ``eval_args`` keys micro-sam's ``engine`` accepts. + + Read from the callables that receive them, so they follow the installed micro_sam: + AIS forwards them to ``flow_instance_segmentation`` (``mode: sparse``, the default) + or ``run_multicut`` (``mode: dense``), APG to ``AutomaticPromptGenerator.generate``, + AMG to ``AutomaticMaskGenerationSegmenter.generate``. Arguments micro-sam or biahub + set themselves are excluded. + """ + _import_microsam() + if engine == "ais": + from micro_sam.v2 import postprocessing + + function = ( + postprocessing.run_multicut + if mode == "dense" + else postprocessing.flow_instance_segmentation + ) + # `boundary` is a prediction array micro-sam passes itself, not a setting. + return {"mode"} | _keyword_parameters(function, skip=("model_type", "boundary")) + if engine == "apg": + from micro_sam.v2.automatic_prompt_generation import AutomaticPromptGenerator + + return _keyword_parameters( + AutomaticPromptGenerator.generate, skip=("verbose", "pbar_init", "pbar_update") + ) + from micro_sam.v2.instance_segmentation import AutomaticMaskGenerationSegmenter + + return _keyword_parameters( + AutomaticMaskGenerationSegmenter.generate, skip=("output_mode",) + ) + + +def check_microsam_model( + pretrained_model: str, engine: str, eval_args: dict[str, Any] | None = None +) -> None: + """Raise if micro-sam cannot run ``pretrained_model`` with ``engine`` and ``eval_args``. A checkpoint file is accepted as is (micro-sam reads the model size from it). A name must be a fine-tuned micro-sam 2 model, or a plain SAM2 backbone with ``engine: amg`` - (the backbones have no decoder, which AIS and APG need). + (the backbones have no decoder, which AIS and APG need). ``eval_args`` keys must be + parameters of the engine's post-processing (:func:`engine_eval_args`); otherwise + every job would fail with a TypeError in micro-sam. """ _, util = _import_microsam() - if Path(pretrained_model).is_file(): - return - finetuned, backbones = list(util.get_model_names()), list(util.SUPPORTED_MODELS) - if pretrained_model in backbones: - if engine != "amg": + if not Path(pretrained_model).is_file(): + finetuned, backbones = list(util.get_model_names()), list(util.SUPPORTED_MODELS) + if pretrained_model in backbones: + if engine != "amg": + raise ValueError( + f"micro-sam model {pretrained_model!r} is a plain SAM2 backbone without " + f"a decoder: it supports engine 'amg' only, not {engine!r}. Use a " + f"fine-tuned model ({finetuned}) for 'ais' / 'apg'." + ) + elif pretrained_model not in finetuned: raise ValueError( - f"micro-sam model {pretrained_model!r} is a plain SAM2 backbone without a " - f"decoder: it supports engine 'amg' only, not {engine!r}. Use a fine-tuned " - f"model ({finetuned}) for 'ais' / 'apg'." + f"Unknown micro-sam model {pretrained_model!r}: not a file and not one of " + f"{finetuned + backbones}. The micro-sam 1 models (vit_b_lm, ...) are not " + "supported." ) - return - if pretrained_model not in finetuned: + + eval_args = eval_args or {} + mode = eval_args.get("mode", "sparse") + if engine == "ais" and mode not in _AIS_MODES: + raise ValueError( + f"eval_args.mode must be one of {_AIS_MODES} for engine 'ais', got {mode!r}." + ) + valid = engine_eval_args(engine, mode) + unknown = sorted(set(eval_args) - valid) + if unknown: + what = f"engine {engine!r}" + (f" (mode {mode!r})" if engine == "ais" else "") raise ValueError( - f"Unknown micro-sam model {pretrained_model!r}: not a file and not one of " - f"{finetuned + backbones}. The micro-sam 1 models (vit_b_lm, ...) are not " - "supported." + f"eval_args {unknown} are not parameters of micro-sam's {what}. " + f"Allowed: {sorted(valid)}." ) def warm_microsam_weights(pretrained_model: str) -> None: - """Download a micro-sam model (and its decoder) into micro-sam's cache, once. + """Download a micro-sam model (and its decoder) into micro-sam's shared cache, once. Called on the head node (`--init`) so that N workers do not race for the download. - Checkpoint files and plain SAM2 backbones (downloaded when first built) are skipped. + Checkpoint files are skipped. """ if Path(pretrained_model).is_file(): return _, util = _import_microsam() registry = util.models() - if pretrained_model not in registry.registry: - return - for name in (pretrained_model, f"{pretrained_model}_decoder"): - if name in registry.registry: - registry.fetch(name, progressbar=False) + if pretrained_model in registry.registry: + for name in (pretrained_model, f"{pretrained_model}_decoder"): + if name in registry.registry: + registry.fetch(name, progressbar=False) + elif pretrained_model in util.SUPPORTED_MODELS: + # Plain SAM2 backbones are not in the registry; micro-sam fetches them with its + # own (private) helper when a model is built. + get_checkpoint = getattr(util, "_get_checkpoint", None) + if get_checkpoint is None: + logger.warning( + "Cannot prefetch SAM2 backbone %s with this micro_sam.", pretrained_model + ) + return + get_checkpoint(pretrained_model) + + +def _weight_files(pretrained_model: str) -> list[str]: + """Return a model's cache file names: its weights and, if fine-tuned, its decoder.""" + if Path(pretrained_model).is_file(): + return [] + return [pretrained_model, f"{pretrained_model}_decoder"] + + +def stage_microsam_weights(pretrained_models) -> Path | None: + """Copy micro-sam weights to node-local scratch and point micro-sam's cache there. + + Mirrors ``stage_cellpose_weights``: every job reading the shared cache over NFS at + once is the access pattern that made cellpose loads fail with stale file handles. + The weights (``models/`` and ``models/_decoder``) are copied to + ``$TMPDIR/micro_sam-`` once per node and ``MICROSAM_CACHEDIR`` is set to it, + which micro-sam reads on every call. Its temporary embeddings for tiled images + (``tmp_embeddings/``) then go to scratch too. Weights that are not in the shared + cache yet are downloaded by micro-sam into scratch; checkpoint files are read where + they are. + + Returns the scratch cache directory, or ``None`` if staging failed (micro-sam then + keeps its shared cache, as before). + """ + from micro_sam.util import get_cache_directory + + dest = Path(os.environ.get("TMPDIR", "/tmp")) / f"micro_sam-{getpass.getuser()}" + source = Path(get_cache_directory()) + if source == dest: + return dest # already staged in this process, e.g. a second position on one worker + try: + (dest / "models").mkdir(parents=True, exist_ok=True) + copied = [] + for model in dict.fromkeys(pretrained_models): + for name in _weight_files(model): + shared = source / "models" / name + if shared.is_file(): + _copy_weight(shared, dest / "models" / name) + copied.append(name) + except OSError as exc: + logger.warning("Not staging micro-sam weights from %s: %r", source, exc) + return None + os.environ["MICROSAM_CACHEDIR"] = os.fspath(dest) + click.echo(f"micro-sam cache on node-local scratch: {dest} (staged {copied or 'nothing'})") + return dest def load_microsam_model(pretrained_model: str, engine: str, device) -> tuple[Any, Any]: @@ -89,7 +218,11 @@ def segment_plane( downsample: int = 1, **generate_kwargs, ) -> np.ndarray: - """Segment one (Y, X) plane, downsampled by striding, and return labels on its grid.""" + """Segment one (Y, X) plane, downsampled by striding, and return labels on its grid. + + ``generate_kwargs`` (the model's ``eval_args``) apply to the downsampled plane, so + sizes such as ``min_size`` are in downsampled pixels. + """ automatic_segmentation, _ = _import_microsam() small = np.ascontiguousarray(plane[::downsample, ::downsample]) labels = automatic_segmentation.automatic_instance_segmentation( diff --git a/settings/example_segmentation_settings.yml b/settings/example_segmentation_settings.yml index 95b9a77cd..1b86da161 100644 --- a/settings/example_segmentation_settings.yml +++ b/settings/example_segmentation_settings.yml @@ -40,4 +40,6 @@ models: channels: ['nuc'] engine: apg # ais (default), apg or amg downsample: 4 # every 4th pixel in Y and X; labels are scaled back to the input grid - eval_args: {} # micro-sam post-processing overrides, e.g. {min_size: 100} + # micro-sam post-processing overrides; keys depend on the engine (ais / apg: min_size, + # amg: min_object_size), sizes in downsampled pixels (100 here = 1600 input pixels) + eval_args: {min_size: 100} diff --git a/tests/conftest.py b/tests/conftest.py index 9ff364063..91f42cab9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,8 @@ import sys import types +from pathlib import Path + import numpy as np import pytest import yaml @@ -288,13 +290,18 @@ def fake_cellpose(monkeypatch, tmp_path): class RecordingMicroSam: - """Stand-in for micro_sam.v2: records the models built and the images segmented.""" + """Stand-in for micro_sam (2.0.1 API): records models built, planes segmented, fetches. + + The post-processing callables carry the real parameter names (biahub reads their + signatures to check ``eval_args``), and the cache directory honours + MICROSAM_CACHEDIR like micro_sam.util.get_cache_directory. + """ MODEL_NAMES = ["hvit_t_cells", "hvit_s_cells", "hvit_b_cells", "hvit_l_cells"] BACKBONES = ["hvit_t", "hvit_s", "hvit_b", "hvit_l"] - built = [] # (model_type, checkpoint, segmentation_mode) + built = [] # (model_type, checkpoint, segmentation_mode, MICROSAM_CACHEDIR) segmented = [] # (image, generate_kwargs) - fetched = [] # registry names downloaded + fetched = [] # names downloaded (registry fetch or backbone checkpoint) @classmethod def get_predictor_and_segmenter( @@ -305,7 +312,9 @@ def get_predictor_and_segmenter( segmentation_mode=None, **_, ): - cls.built.append((model_type, checkpoint, segmentation_mode)) + cls.built.append( + (model_type, checkpoint, segmentation_mode, os.environ.get("MICROSAM_CACHEDIR")) + ) return object(), object() @classmethod @@ -314,7 +323,8 @@ def automatic_instance_segmentation( ): assert ndim == 2 cls.segmented.append((np.array(input_path), generate_kwargs)) - return np.ones(input_path.shape, dtype=np.uint32) + # One distinct id per pixel, so the tests can check where each label lands. + return np.arange(1, input_path.size + 1, dtype=np.uint32).reshape(input_path.shape) class _Registry: registry = { @@ -329,9 +339,90 @@ def fetch(self, name, progressbar=True): RecordingMicroSam.fetched.append(name) return f"/cache/{name}" + @staticmethod + def get_checkpoint(model_type="hvit_t"): + RecordingMicroSam.fetched.append(model_type) + return f"/cache/{model_type}" + + +# micro_sam 2.0.1's post-processing signatures (data arguments first). +def _flow_instance_segmentation( + foreground, + directed_distances, + model_type=None, + foreground_threshold=None, + n_iter=None, + dt=None, + sigma=None, + spacing=None, + density_threshold=None, + min_size=None, + foreground_weight=None, + n_threads=8, + boundary=None, + boundary_weight=None, + boundary_mask_threshold=None, +): + pass + + +def _run_multicut( + boundary_map, + distances, + model_type=None, + beta=None, + density_threshold=None, + n_iter=None, + dt=None, + sigma=None, + n_threads=8, +): + pass + + +class _AutomaticPromptGenerator: + def generate( + self, + candidate_threshold=None, + foreground_threshold=None, + n_iter=None, + dt=None, + sigma=None, + spacing=None, + min_candidate_size=None, + score_threshold=None, + max_overlap=None, + min_size=None, + max_size_factor=None, + refinement=None, + refinement_kwargs=None, + multimasking=False, + n_objects_per_pass=1, + early_stop_patience=None, + propagation_waves=1, + batch_size=1, + n_threads=1, + verbose=False, + pbar_init=None, + pbar_update=None, + ): + pass + + +class _AutomaticMaskGenerationSegmenter: + def generate( + self, + min_object_size=0, + max_object_size=None, + with_background=True, + output_mode="instance_segmentation", + ): + pass + @pytest.fixture() -def fake_microsam(monkeypatch): +def fake_microsam(monkeypatch, tmp_path): + """micro_sam stand-in; its shared cache is tmp_path/microsam-shared (no weights in it).""" automatic = types.ModuleType("micro_sam.v2.automatic_segmentation") automatic.get_predictor_and_segmenter = RecordingMicroSam.get_predictor_and_segmenter automatic.automatic_instance_segmentation = ( @@ -341,17 +432,33 @@ def fake_microsam(monkeypatch): util.get_model_names = lambda: list(RecordingMicroSam.MODEL_NAMES) util.SUPPORTED_MODELS = list(RecordingMicroSam.BACKBONES) util.models = RecordingMicroSam._Registry + util._get_checkpoint = RecordingMicroSam.get_checkpoint + postprocessing = types.ModuleType("micro_sam.v2.postprocessing") + postprocessing.flow_instance_segmentation = _flow_instance_segmentation + postprocessing.run_multicut = _run_multicut + apg = types.ModuleType("micro_sam.v2.automatic_prompt_generation") + apg.AutomaticPromptGenerator = _AutomaticPromptGenerator + instance = types.ModuleType("micro_sam.v2.instance_segmentation") + instance.AutomaticMaskGenerationSegmenter = _AutomaticMaskGenerationSegmenter + top_util = types.ModuleType("micro_sam.util") + top_util.get_cache_directory = lambda: Path(os.environ["MICROSAM_CACHEDIR"]) v2 = types.ModuleType("micro_sam.v2") v2.automatic_segmentation, v2.util = automatic, util package = types.ModuleType("micro_sam") - package.v2 = v2 + package.v2, package.util = v2, top_util for name, module in { "micro_sam": package, + "micro_sam.util": top_util, "micro_sam.v2": v2, "micro_sam.v2.automatic_segmentation": automatic, "micro_sam.v2.util": util, + "micro_sam.v2.postprocessing": postprocessing, + "micro_sam.v2.automatic_prompt_generation": apg, + "micro_sam.v2.instance_segmentation": instance, }.items(): monkeypatch.setitem(sys.modules, name, module) + monkeypatch.setenv("MICROSAM_CACHEDIR", str(tmp_path / "microsam-shared")) + monkeypatch.setenv("TMPDIR", str(tmp_path / "scratch")) RecordingMicroSam.built, RecordingMicroSam.segmented, RecordingMicroSam.fetched = ( [], [], diff --git a/tests/test_cli/test_segment_microsam_cli.py b/tests/test_cli/test_segment_microsam_cli.py index 1c9e1b834..b34ebb899 100644 --- a/tests/test_cli/test_segment_microsam_cli.py +++ b/tests/test_cli/test_segment_microsam_cli.py @@ -1,6 +1,5 @@ """biahub segment with a micro-sam 2 model: --init checks and a debug (in-process) run.""" -import numpy as np import pytest import torch import yaml @@ -108,9 +107,54 @@ def test_debug_run_fills_the_label_image(fake_microsam, cpu_device, plate_2d, mi with open_ome_zarr(position, mode="r") as pos: label = pos.get_label("nuc")["0"][:] assert label.shape == (3, 1, 1, 5, 6) - assert np.all(label == 1) # the stand-in labels every pixel 1, upsampled back + assert label.min() >= 1 # every pixel got a label from the stand-in, upsampled back attrs = dict(pos.get_label("nuc").zattrs) assert attrs["biahub-segment"]["models"]["nuc"]["backend"] == "microsam" assert len(fake_microsam.built) == 1 # one model load for the whole position assert len(fake_microsam.segmented) == 3 # one per timepoint assert fake_microsam.segmented[0][0].shape == (3, 3) # 5 x 6 downsampled by 2 + + +def test_bad_eval_args_stop_before_any_label_image_is_written( + fake_microsam, cpu_device, plate_2d, tmp_path +): + # Without --init (SLURM fan-out or a direct debug run), a bad key must still fail on + # the head node, not in every GPU job. + plate_path, _ = plate_2d + position = plate_path / "A" / "1" / "0" + config = tmp_path / "bad.yml" + config.write_text( + yaml.safe_dump( + { + "models": { + "nuc": { + "backend": "microsam", + "pretrained_model": "hvit_b_cells", + "channels": ["GFP"], + "engine": "amg", + "eval_args": {"min_size": 100}, + } + } + } + ) + ) + + result = _run("--cluster", "debug", "-i", position, "-c", config) + + assert result.exit_code != 0 + assert "min_size" in str(result.exception) + result.output + assert not (position / "labels").exists() + assert fake_microsam.segmented == [] + + +def test_init_refuses_a_downsample_larger_than_the_plane( + fake_microsam, plate_2d, microsam_config +): + plate_path, _ = plate_2d # Y=5, X=6 + position = plate_path / "A" / "1" / "0" + + result = _run("--init", "-i", position, "-c", microsam_config(downsample=6)) + + assert result.exit_code != 0 + assert "downsample" in str(result.exception) + result.output + assert not (position / "labels").exists() diff --git a/tests/test_segment_microsam.py b/tests/test_segment_microsam.py index d9d2073f2..68771d23c 100644 --- a/tests/test_segment_microsam.py +++ b/tests/test_segment_microsam.py @@ -133,7 +133,7 @@ def test_segment_builds_the_configured_model_and_engine(fake_microsam): pretrained_model="hvit_b_cells", engine="apg", ) - assert fake_microsam.built == [("hvit_b_cells", None, "apg")] + assert [b[:3] for b in fake_microsam.built] == [("hvit_b_cells", None, "apg")] def test_a_checkpoint_path_is_passed_as_the_checkpoint(fake_microsam, tmp_path): @@ -145,7 +145,7 @@ def test_a_checkpoint_path_is_passed_as_the_checkpoint(fake_microsam, tmp_path): backend="microsam", pretrained_model=str(ckpt), ) - ((model_type, checkpoint, _),) = fake_microsam.built + ((model_type, checkpoint, _, _),) = fake_microsam.built assert checkpoint == str(ckpt) @@ -168,7 +168,11 @@ def test_segment_returns_labels_on_the_input_grid(fake_microsam): czyx, channels=[0], backend="microsam", pretrained_model="hvit_b_cells", downsample=4 ) assert labels.shape == (1, 1, 10, 13) # (models, Z=1, Y, X) - assert np.all(labels == 1) + # The stand-in gives each downsampled pixel its own id: every full-resolution pixel + # must carry the id of the block it was sampled into (nearest upsampling). + small = np.arange(1, 3 * 4 + 1).reshape(3, 4) # ceil(10 / 4) x ceil(13 / 4) + y, x = np.indices((10, 13)) + np.testing.assert_array_equal(labels[0, 0], small[y // 4, x // 4]) def test_eval_args_are_forwarded_to_the_postprocessing(fake_microsam): @@ -270,3 +274,149 @@ def test_warm_skips_a_checkpoint_file(fake_microsam, tmp_path): ckpt.write_bytes(b"") warm_microsam_weights(str(ckpt)) assert fake_microsam.fetched == [] + + +# --- eval_args are checked against the engine micro-sam will run (review of #494) + + +@pytest.mark.parametrize( + "engine, eval_args", + [ + ("ais", {"min_size": 100, "foreground_threshold": 0.5}), + ("ais", {"mode": "dense", "beta": 0.6}), + ("apg", {"min_size": 100, "candidate_threshold": 0.5}), + ("amg", {"min_object_size": 100}), + ], +) +def test_check_accepts_the_engines_own_eval_args(fake_microsam, engine, eval_args): + from biahub.utils.microsam import check_microsam_model + + check_microsam_model("hvit_b_cells", engine, eval_args) + + +@pytest.mark.parametrize( + "engine, eval_args, bad", + [ + ("amg", {"min_size": 100}, "min_size"), # AMG calls it min_object_size + ("ais", {"min_sze": 100}, "min_sze"), # a typo + ("ais", {"do_3D": True}, "do_3D"), # a cellpose argument + ("ais", {"mode": "dense", "min_size": 100}, "min_size"), # multicut has no min_size + ("apg", {"pbar_init": None}, "pbar_init"), # set by micro-sam, not a parameter + ], +) +def test_check_refuses_eval_args_the_engine_does_not_take( + fake_microsam, engine, eval_args, bad +): + from biahub.utils.microsam import check_microsam_model + + with pytest.raises(ValueError, match=rf"{bad}.*{engine}"): + check_microsam_model("hvit_b_cells", engine, eval_args) + + +def test_check_refuses_an_unknown_ais_mode(fake_microsam): + from biahub.utils.microsam import check_microsam_model + + with pytest.raises(ValueError, match="mode"): + check_microsam_model("hvit_b_cells", "ais", {"mode": "watershed"}) + + +# --- weights and temporary files go to node-local scratch (review of #494) + + +def _shared_weights(names): + """Put fake weight files into the stand-in's shared micro-sam cache.""" + import os + + from pathlib import Path + + models = Path(os.environ["MICROSAM_CACHEDIR"]) / "models" + models.mkdir(parents=True, exist_ok=True) + for name in names: + (models / name).write_bytes(name.encode()) + return models + + +def test_stage_copies_the_model_and_decoder_to_scratch(fake_microsam): + import os + + from pathlib import Path + + from biahub.utils.microsam import stage_microsam_weights + + shared = _shared_weights(["hvit_b_cells", "hvit_b_cells_decoder", "hvit_t_cells"]) + dest = stage_microsam_weights(["hvit_b_cells"]) + + assert dest.is_relative_to(Path(os.environ["TMPDIR"])) + assert os.environ["MICROSAM_CACHEDIR"] == os.fspath(dest) # temp embeddings go here too + assert sorted(p.name for p in (dest / "models").iterdir()) == [ + "hvit_b_cells", + "hvit_b_cells_decoder", + ] + assert (dest / "models" / "hvit_b_cells").read_bytes() == b"hvit_b_cells" + assert shared.parent != dest + + +def test_stage_twice_is_a_no_op(fake_microsam): + from biahub.utils.microsam import stage_microsam_weights + + _shared_weights(["hvit_b_cells", "hvit_b_cells_decoder"]) + first = stage_microsam_weights(["hvit_b_cells"]) + assert stage_microsam_weights(["hvit_b_cells"]) == first + + +def test_stage_without_shared_weights_still_moves_the_cache_to_scratch(fake_microsam): + # Nothing was downloaded yet (or the model is a checkpoint file): no copy, but the + # temporary embeddings must still not be written to the shared cache. + import os + + from biahub.utils.microsam import stage_microsam_weights + + dest = stage_microsam_weights(["hvit_b_cells"]) + assert os.environ["MICROSAM_CACHEDIR"] == os.fspath(dest) + + +def test_segment_stages_before_building_the_model(fake_microsam): + import os + + _shared_weights(["hvit_b_cells", "hvit_b_cells_decoder"]) + shared = os.environ["MICROSAM_CACHEDIR"] + _segment( + np.zeros((1, 1, 8, 8), np.float32), + channels=[0], + backend="microsam", + pretrained_model="hvit_b_cells", + ) + ((*_, cache_dir),) = fake_microsam.built + assert cache_dir != shared + assert cache_dir.startswith(os.environ["TMPDIR"]) + + +def test_warm_fetches_a_plain_backbone(fake_microsam): + from biahub.utils.microsam import warm_microsam_weights + + warm_microsam_weights("hvit_b") + assert fake_microsam.fetched == ["hvit_b"] + + +# --- planes too small for the downsampling factor (review of #494) + + +@pytest.mark.parametrize("shape, downsample", [((4, 300), 4), ((300, 3), 4), ((5, 6), 6)]) +def test_a_plane_smaller_than_two_downsampled_pixels_is_refused(shape, downsample): + from biahub.segment import check_plane_size + + models = _resolved(downsample) + with pytest.raises(ValueError, match="downsample"): + check_plane_size(models, *shape) + + +def test_a_plane_of_two_downsampled_pixels_is_accepted(): + from biahub.segment import check_plane_size + + check_plane_size(_resolved(4), 5, 300) # ceil(5 / 4) = 2 + + +def _resolved(downsample): + from biahub.segment import resolve_models + + return resolve_models(_settings(downsample=downsample), ["nuc"], scale=(1,) * 5, z_size=1) From 7dbf30232e4ffdf8f740e46e2c4c764d0de55ded Mon Sep 17 00:00:00 2001 From: Taylla Theodoro Date: Mon, 30 Nov 2026 14:45:29 -0800 Subject: [PATCH 4/7] docs(segment): name the micro-sam example model nuclei_microsam biahub's nuclei label image is labels/nuclei (a549 segment.yml model name, track.yml labels: nuclei, tracks_nuclei in QC, the VS channel nuclei_prediction). The micro-sam example and its tests used nucleus. --- settings/example_segmentation_settings.yml | 2 +- tests/test_segment_microsam.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/settings/example_segmentation_settings.yml b/settings/example_segmentation_settings.yml index 1b86da161..46671fe02 100644 --- a/settings/example_segmentation_settings.yml +++ b/settings/example_segmentation_settings.yml @@ -34,7 +34,7 @@ models: cellprob_threshold: 0.0 do_3D: false min_size: 8000 - nucleus_microsam: + nuclei_microsam: backend: microsam # micro-sam 2 (SAM2); 2D (Z=1) plates, one channel pretrained_model: hvit_b_cells # hvit_{t,s,b,l}_cells, a SAM2 backbone (engine amg only), or a checkpoint path channels: ['nuc'] diff --git a/tests/test_segment_microsam.py b/tests/test_segment_microsam.py index 68771d23c..61c4742a8 100644 --- a/tests/test_segment_microsam.py +++ b/tests/test_segment_microsam.py @@ -14,7 +14,7 @@ def _settings(**model): from biahub.settings import SegmentationSettings base = {"backend": "microsam", "pretrained_model": "hvit_b_cells", "channels": ["nuc"]} - return SegmentationSettings(models={"nucleus": {**base, **model}}) + return SegmentationSettings(models={"nuclei": {**base, **model}}) def _segment(czyx, channels, **model): @@ -34,7 +34,7 @@ def _segment(czyx, channels, **model): def test_microsam_model_defaults(): - m = _settings().models["nucleus"] + m = _settings().models["nuclei"] assert m.backend == "microsam" assert m.engine == "ais" # micro-sam's own default assert m.downsample == 1 @@ -63,7 +63,7 @@ def test_cellpose_provenance_does_not_record_the_backend(fake_cellpose): def test_microsam_provenance_records_the_backend(): - assert _settings().model_dump(mode="json")["models"]["nucleus"]["backend"] == "microsam" + assert _settings().model_dump(mode="json")["models"]["nuclei"]["backend"] == "microsam" def test_microsam_takes_one_channel(): From cf9dd00185d632eb580ff4f3587c14b8375e17fe Mon Sep 17 00:00:00 2001 From: Taylla Theodoro Date: Mon, 30 Nov 2026 14:47:13 -0800 Subject: [PATCH 5/7] docs(segment): name the example cellpose nuclei model nuclei The example segmentation config called it nucleus, while the example track config (and the a549 configs) read labels: nuclei. --- settings/example_segmentation_settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/example_segmentation_settings.yml b/settings/example_segmentation_settings.yml index 46671fe02..49e303776 100644 --- a/settings/example_segmentation_settings.yml +++ b/settings/example_segmentation_settings.yml @@ -26,7 +26,7 @@ models: - function: skimage.exposure.equalize_adapthist kwargs: {"clip_limit": 0.01, "kernel_size": [5, 32, 32]} channel: 'mem' - nucleus: + nuclei: pretrained_model: cpsam_v2 channels: ['nuc'] eval_args: From bd093e6de2f09d4ea15c09cc46c6698c70983aab Mon Sep 17 00:00:00 2001 From: Taylla Theodoro Date: Mon, 30 Nov 2026 11:04:16 -0800 Subject: [PATCH 6/7] refactor(segment): move the segmentation library code into biahub/segmentation Implements #504, step 1 (no behaviour change). Stacked on #494. - biahub/segmentation/methods/cellpose.py and methods/microsam.py: the former biahub/utils/cellpose.py and utils/microsam.py, plus each backend's `segment` (the per-backend branches of _segment_czyx) and micro-sam's `check_plane` (the body of check_plane_size). - biahub/segmentation/staging.py (_copy_weight, shared by both backends) and devices.py (cellpose_device, used by both). - biahub/segmentation/backends.py: BACKENDS registry with the hooks check, warm, stage, load, segment and check_plane; segment.py looks backends up instead of branching on model.backend. segment.py keeps the CLI, the label images, resume, resources and the model cache. - All 22 moved definitions are AST-identical to their old versions. - biahub/utils/cellpose.py is removed without a re-export: nothing outside biahub imports it (GitHub code search over Biohub / czbiohub-sf). - Tests: import paths only (patches of _dinov3_installed now target the new module), plus tests/test_segmentation_package.py (every backend a config can name is registered). --- biahub/segment.py | 97 +++-------------- biahub/segmentation/__init__.py | 6 ++ biahub/segmentation/backends.py | 69 ++++++++++++ biahub/segmentation/devices.py | 50 +++++++++ biahub/segmentation/methods/__init__.py | 1 + .../methods}/cellpose.py | 102 +++++------------- .../methods}/microsam.py | 25 ++++- biahub/segmentation/staging.py | 41 +++++++ biahub/utils/__init__.py | 1 - tests/test_segment_microsam.py | 26 ++--- tests/test_segmentation_package.py | 14 +++ tests/test_utils/test_cellpose.py | 6 +- 12 files changed, 262 insertions(+), 176 deletions(-) create mode 100644 biahub/segmentation/__init__.py create mode 100644 biahub/segmentation/backends.py create mode 100644 biahub/segmentation/devices.py create mode 100644 biahub/segmentation/methods/__init__.py rename biahub/{utils => segmentation/methods}/cellpose.py (75%) rename biahub/{utils => segmentation/methods}/microsam.py (90%) create mode 100644 biahub/segmentation/staging.py create mode 100644 tests/test_segmentation_package.py diff --git a/biahub/segment.py b/biahub/segment.py index 3d5e2eb51..4bfad58d8 100644 --- a/biahub/segment.py +++ b/biahub/segment.py @@ -21,14 +21,10 @@ sbatch_filepath, sbatch_to_submitit, ) +from biahub.segmentation.backends import BACKENDS +from biahub.segmentation.devices import cellpose_device +from biahub.segmentation.methods.cellpose import stage_cellpose_weights from biahub.settings import SegmentationSettings -from biahub.utils.cellpose import ( - cellpose_device, - check_cellpose_model_name, - load_cellpose_model, - stage_cellpose_weights, - warm_cellpose_weights, -) from biahub.utils.cluster import ( apply_sbatch_overrides, echo_resources, @@ -37,13 +33,6 @@ local_executor_parameters, ) from biahub.utils.config import settings_fingerprint, yaml_to_model -from biahub.utils.microsam import ( - check_microsam_model, - load_microsam_model, - segment_plane, - stage_microsam_weights, - warm_microsam_weights, -) from biahub.utils.ngff import label_layout if TYPE_CHECKING: @@ -149,46 +138,24 @@ def index(name: str, what: str) -> int: def _cached_model(model: ResolvedModel, device: "torch.device") -> Any: key = (model.backend, model.pretrained_model, model.engine, str(device)) if key not in _MODEL_CACHE: - if model.backend == "microsam": - _MODEL_CACHE[key] = load_microsam_model( - model.pretrained_model, model.engine, device - ) - else: - _MODEL_CACHE[key] = load_cellpose_model(model.pretrained_model, device) + _MODEL_CACHE[key] = BACKENDS[model.backend].load(model, device) return _MODEL_CACHE[key] def _check_model(model) -> None: """Raise if a configured model cannot run (unknown name, missing extra, bad eval_args).""" - if model.backend == "microsam": - check_microsam_model(model.pretrained_model, model.engine, model.eval_args) - else: - check_cellpose_model_name(model.pretrained_model) + BACKENDS[model.backend].check(model) def check_plane_size(models: list[ResolvedModel], y_size: int, x_size: int) -> None: - """Refuse a micro-sam ``downsample`` that leaves fewer than 2 pixels along Y or X. - - micro-sam squeezes a singleton axis and then cannot read the plane as 2D. - """ + """Refuse a plane a model cannot segment (a micro-sam ``downsample`` too large for it).""" for model in models: - if model.backend != "microsam": - continue - small = (-(-y_size // model.downsample), -(-x_size // model.downsample)) - if min(small) < 2: - raise ValueError( - f"Model {model.name}: downsample {model.downsample} turns the " - f"{y_size} x {x_size} plane into {small[0]} x {small[1]} pixels; micro-sam " - "needs at least 2 along each axis. Lower downsample." - ) + BACKENDS[model.backend].check_plane(model, y_size, x_size) def _warm_model(model) -> None: """Fetch a configured model's weights into its shared cache (head node, --init).""" - if model.backend == "microsam": - warm_microsam_weights(model.pretrained_model) - else: - warm_cellpose_weights(model.pretrained_model) + BACKENDS[model.backend].warm(model.pretrained_model) def _segment_czyx( @@ -196,22 +163,19 @@ def _segment_czyx( models: list[ResolvedModel], gpu: bool = True, ) -> np.ndarray: - """Segment a CZYX image with each resolved model (cellpose 4 or micro-sam 2). + """Segment a CZYX image with each resolved model. Returns an array of shape (n_models, Z, Y, X); Z is 1 for 2D models. """ # Every job this step submits asks SLURM for a GPU, so an unusable one is a # broken allocation, not a reason to fall back to a ~130x slower CPU run. device = cellpose_device(gpu) - if any(m.backend == "cellpose" for m in models): - # Stage weights on node-local scratch before cellpose is first imported (no-op - # after). - stage_cellpose_weights() - microsam_models = [m.pretrained_model for m in models if m.backend == "microsam"] - if microsam_models: - # Same for micro-sam: its weights and temporary embeddings go to node-local - # scratch (no-op after the first timepoint). - stage_microsam_weights(microsam_models) + # Stage each backend's weights on node-local scratch before it is first imported + # (no-op after the first timepoint). + for name, backend in BACKENDS.items(): + pretrained_models = [m.pretrained_model for m in models if m.backend == name] + if pretrained_models: + backend.stage(pretrained_models) czyx_segmentation = [] for model in models: @@ -221,35 +185,8 @@ def _segment_czyx( f"Processing with {func.__name__} with kwargs {kwargs} to channel {c_idx}" ) czyx_data[c_idx] = func(czyx_data[c_idx], **kwargs) - - if model.backend == "microsam": - # One channel, one Z=1 plane: micro-sam segments the (Y, X) plane. - predictor, segmenter = _cached_model(model, device) - plane = czyx_data[model.channel_indices[0], 0] - labels = segment_plane( - plane, predictor, segmenter, model.downsample, **model.eval_args - ) - czyx_segmentation.append(labels[np.newaxis]) - continue - - # Cellpose 4 refuses a z axis for 2D processing, so a 2D model gets the (C, Y, X) - # plane of the Z=1 input and a 3D model the (C, Z, Y, X) stack. It also ignores - # `channels` and keeps the first 3 channels it is given, so pass only the - # configured ones. - cellpose_model = _cached_model(model, device) - if model.is_3d: - image, z_axis = czyx_data[model.channel_indices], 1 - else: - image, z_axis = czyx_data[model.channel_indices, 0], None - segmentation, _, _ = cellpose_model.eval( - image, channel_axis=0, z_axis=z_axis, **model.eval_args - ) - # Cellpose squeezes singleton axes; restore the (Z, Y, X) shape the output - # plate expects (Z is 1 for a 2D model). - segmentation = np.reshape( - segmentation, image.shape[1:] if model.is_3d else (1, *image.shape[-2:]) - ) - czyx_segmentation.append(segmentation) + loaded = _cached_model(model, device) + czyx_segmentation.append(BACKENDS[model.backend].segment(czyx_data, model, loaded)) return np.stack(czyx_segmentation, axis=0) diff --git a/biahub/segmentation/__init__.py b/biahub/segmentation/__init__.py new file mode 100644 index 000000000..b77cb1db2 --- /dev/null +++ b/biahub/segmentation/__init__.py @@ -0,0 +1,6 @@ +"""Segmentation library code: one module per backend (``methods/``) and what they share. + +``biahub segment`` (the CLI, the label images in the plate, resume, resources, SLURM fan-out) +stays in ``biahub/segment.py``, which looks backends up in :mod:`biahub.segmentation.backends`. +The modules here do no plate (OME-Zarr) I/O, like ``biahub/tracking``. +""" diff --git a/biahub/segmentation/backends.py b/biahub/segmentation/backends.py new file mode 100644 index 000000000..e00838377 --- /dev/null +++ b/biahub/segmentation/backends.py @@ -0,0 +1,69 @@ +"""The segmentation backends ``biahub segment`` can run, keyed by a model's ``backend``. + +Each backend provides the same hooks, so ``biahub/segment.py`` looks them up instead of +branching on the backend: + +================= =========================== ============================================= +hook runs on does +================= =========================== ============================================= +``check`` head node refuse a model that cannot run (name, extra, + arguments) before anything is scaffolded +``warm`` head node, ``--init`` fetch the weights into the shared cache once +``stage`` worker, before the import copy the weights to node-local scratch +``load`` worker, cached per process build the model on a device +``segment`` worker, per timepoint CZYX image -> (Z, Y, X) labels +``check_plane`` head node refuse a plane the model cannot segment +================= =========================== ============================================= + +``check`` takes the configured model (``biahub.settings``); ``load``, ``segment`` and +``check_plane`` the model resolved against the input plate (``biahub.segment.ResolvedModel``); +``warm`` a ``pretrained_model``; ``stage`` the ``pretrained_model`` of every model of the +backend in the job. +""" + +from collections.abc import Callable +from dataclasses import dataclass +from typing import Any + +from biahub.segmentation.methods import cellpose, microsam + + +@dataclass(frozen=True) +class Backend: + check: Callable[[Any], None] + warm: Callable[[str], Any] + stage: Callable[[list[str]], Any] + load: Callable[[Any, Any], Any] + segment: Callable[[Any, Any, Any], Any] + check_plane: Callable[[Any, int, int], None] + + +def _no_plane_check(model, y_size: int, x_size: int) -> None: + return None + + +BACKENDS: dict[str, Backend] = { + "cellpose": Backend( + check=lambda model: cellpose.check_cellpose_model_name(model.pretrained_model), + warm=cellpose.warm_cellpose_weights, + # cellpose stages its whole weights directory, whatever the model names. + stage=lambda pretrained_models: cellpose.stage_cellpose_weights(), + load=lambda model, device: cellpose.load_cellpose_model( + model.pretrained_model, device + ), + segment=cellpose.segment, + check_plane=_no_plane_check, + ), + "microsam": Backend( + check=lambda model: microsam.check_microsam_model( + model.pretrained_model, model.engine, model.eval_args + ), + warm=microsam.warm_microsam_weights, + stage=microsam.stage_microsam_weights, + load=lambda model, device: microsam.load_microsam_model( + model.pretrained_model, model.engine, device + ), + segment=microsam.segment, + check_plane=microsam.check_plane, + ), +} diff --git a/biahub/segmentation/devices.py b/biahub/segmentation/devices.py new file mode 100644 index 000000000..5f692d8c9 --- /dev/null +++ b/biahub/segmentation/devices.py @@ -0,0 +1,50 @@ +"""The torch device a segmentation job runs on (used by every backend).""" + +import os + +import torch + + +def cellpose_device(gpu: bool) -> torch.device: + """Resolve the torch device for cellpose, refusing a silent CPU fallback. + + Left to itself, cellpose picks its device in ``cellpose.core.assign_device``, + which probes CUDA inside a bare ``except: pass`` and quietly returns the CPU + whenever the probe fails — a transient CUDA init error on a busy node included. + Nothing in the logs distinguishes the two devices, and on an A6000 against a + 1664x1193 frame the CPU is 130x slower (2.0 s vs 264 s per frame), so a + three-minute task silently runs for hours. Probing here surfaces the real CUDA + error and fails the task in seconds instead, which lets the caller (or the + workflow) retry on a fresh allocation. + + Parameters + ---------- + gpu : bool + Whether GPU segmentation was requested. + + Returns + ------- + torch.device + ``cuda:0`` — the GPU SLURM allocated, via CUDA_VISIBLE_DEVICES — when + ``gpu`` is set, ``cpu`` otherwise. + + Raises + ------ + RuntimeError + If ``gpu`` is set but CUDA cannot be used on this host. + """ + if not gpu: + return torch.device("cpu") + + device = torch.device("cuda:0") + try: + torch.zeros(1).to(device) + except Exception as exc: + raise RuntimeError( + "GPU segmentation was requested but CUDA is unusable on this host " + f"(CUDA_VISIBLE_DEVICES={os.environ.get('CUDA_VISIBLE_DEVICES')!r}): {exc}. " + "Refusing to fall back to the CPU, which is ~130x slower for cellpose. " + "Ask for the CPU explicitly to segment on it deliberately " + "(tracking: cellpose_config.gpu: false)." + ) from exc + return device diff --git a/biahub/segmentation/methods/__init__.py b/biahub/segmentation/methods/__init__.py new file mode 100644 index 000000000..ca8e17e8a --- /dev/null +++ b/biahub/segmentation/methods/__init__.py @@ -0,0 +1 @@ +"""One module per segmentation backend.""" diff --git a/biahub/utils/cellpose.py b/biahub/segmentation/methods/cellpose.py similarity index 75% rename from biahub/utils/cellpose.py rename to biahub/segmentation/methods/cellpose.py index ad874c757..245489ea1 100644 --- a/biahub/utils/cellpose.py +++ b/biahub/segmentation/methods/cellpose.py @@ -20,72 +20,26 @@ ``cpdino`` extra installs (it is not on PyPI and has its own licence). Without it cellpose only logs "Could not import CPDINO" and fails when the model is built. ``check_cellpose_model_name`` stops at ``--init`` with the install command instead. + +``cellpose_device`` now lives in :mod:`biahub.segmentation.devices` and the weight copy in +:mod:`biahub.segmentation.staging`; they are shared with the other backends. """ import getpass import importlib.util import logging import os -import shutil import sys -import time from pathlib import Path import click +import numpy as np import torch -logger = logging.getLogger(__name__) - -# Attempts for each node-local cellpose weight copy. ESTALE on the NFS home export -# is transient and is the very thing staging exists to avoid, so retry the copy -# before giving up and reading the weights over NFS. See stage_cellpose_weights. -_STAGE_ATTEMPTS = 3 - - -def cellpose_device(gpu: bool) -> torch.device: - """Resolve the torch device for cellpose, refusing a silent CPU fallback. - - Left to itself, cellpose picks its device in ``cellpose.core.assign_device``, - which probes CUDA inside a bare ``except: pass`` and quietly returns the CPU - whenever the probe fails — a transient CUDA init error on a busy node included. - Nothing in the logs distinguishes the two devices, and on an A6000 against a - 1664x1193 frame the CPU is 130x slower (2.0 s vs 264 s per frame), so a - three-minute task silently runs for hours. Probing here surfaces the real CUDA - error and fails the task in seconds instead, which lets the caller (or the - workflow) retry on a fresh allocation. +from biahub.segmentation.staging import _copy_weight - Parameters - ---------- - gpu : bool - Whether GPU segmentation was requested. - - Returns - ------- - torch.device - ``cuda:0`` — the GPU SLURM allocated, via CUDA_VISIBLE_DEVICES — when - ``gpu`` is set, ``cpu`` otherwise. - - Raises - ------ - RuntimeError - If ``gpu`` is set but CUDA cannot be used on this host. - """ - if not gpu: - return torch.device("cpu") - - device = torch.device("cuda:0") - try: - torch.zeros(1).to(device) - except Exception as exc: - raise RuntimeError( - "GPU segmentation was requested but CUDA is unusable on this host " - f"(CUDA_VISIBLE_DEVICES={os.environ.get('CUDA_VISIBLE_DEVICES')!r}): {exc}. " - "Refusing to fall back to the CPU, which is ~130x slower for cellpose. " - "Ask for the CPU explicitly to segment on it deliberately " - "(tracking: cellpose_config.gpu: false)." - ) from exc - return device +logger = logging.getLogger(__name__) def _cellpose_models_dir() -> Path: @@ -94,32 +48,6 @@ def _cellpose_models_dir() -> Path: return Path(env_dir) if env_dir else Path.home() / ".cellpose" / "models" -def _copy_weight(source: Path, dest: Path) -> None: - """Copy ``source`` to ``dest``, skipping a copy that is already there. - - The bytes land on a private temporary name and are renamed into place, so tasks - staging concurrently on the same node never read a half-written file and the - loser of the race just overwrites with identical content. Weights are matched - on size alone: they are ~1.2 GB and immutable once downloaded, so hashing them - on every task would cost more than the read this function avoids. - """ - if dest.is_file() and dest.stat().st_size == source.stat().st_size: - return - - partial = dest.with_name(f".{dest.name}.{os.getpid()}.partial") - for attempt in range(1, _STAGE_ATTEMPTS + 1): - try: - shutil.copyfile(source, partial) - break - except OSError as exc: - partial.unlink(missing_ok=True) - if attempt == _STAGE_ATTEMPTS: - raise - logger.warning("Retrying copy of %s to node-local scratch: %r", source, exc) - time.sleep(attempt) - os.replace(partial, dest) - - def stage_cellpose_weights() -> Path | None: """Cache the cellpose weights on node-local scratch and point cellpose at them. @@ -295,3 +223,21 @@ def warm_cellpose_weights(pretrained_model: str = "cpsam_v2") -> Path | None: click.echo(f"Cellpose weights ready: {weights}") return weights + + +def segment(czyx_data: np.ndarray, model, cellpose_model) -> np.ndarray: + """Segment a CZYX image with a loaded cellpose model; returns (Z, Y, X) labels.""" + # Cellpose 4 refuses a z axis for 2D processing, so a 2D model gets the (C, Y, X) + # plane of the Z=1 input and a 3D model the (C, Z, Y, X) stack. It also ignores + # `channels` and keeps the first 3 channels it is given, so pass only the + # configured ones. + if model.is_3d: + image, z_axis = czyx_data[model.channel_indices], 1 + else: + image, z_axis = czyx_data[model.channel_indices, 0], None + segmentation, _, _ = cellpose_model.eval( + image, channel_axis=0, z_axis=z_axis, **model.eval_args + ) + # Cellpose squeezes singleton axes; restore the (Z, Y, X) shape the output + # plate expects (Z is 1 for a 2D model). + return np.reshape(segmentation, image.shape[1:] if model.is_3d else (1, *image.shape[-2:])) diff --git a/biahub/utils/microsam.py b/biahub/segmentation/methods/microsam.py similarity index 90% rename from biahub/utils/microsam.py rename to biahub/segmentation/methods/microsam.py index 38a1976a3..f5f90bca4 100644 --- a/biahub/utils/microsam.py +++ b/biahub/segmentation/methods/microsam.py @@ -21,7 +21,7 @@ import click import numpy as np -from biahub.utils.cellpose import _copy_weight +from biahub.segmentation.staging import _copy_weight logger = logging.getLogger(__name__) @@ -233,3 +233,26 @@ def segment_plane( # Nearest upsampling: each label pixel covers a downsample x downsample block. labels = np.repeat(np.repeat(labels, downsample, axis=0), downsample, axis=1) return labels[: plane.shape[0], : plane.shape[1]].astype(np.uint32) + + +def segment(czyx_data: np.ndarray, model, loaded) -> np.ndarray: + """Segment the model's channel of a Z=1 CZYX image; returns (1, Y, X) labels.""" + # One channel, one Z=1 plane: micro-sam segments the (Y, X) plane. + predictor, segmenter = loaded + plane = czyx_data[model.channel_indices[0], 0] + labels = segment_plane(plane, predictor, segmenter, model.downsample, **model.eval_args) + return labels[np.newaxis] + + +def check_plane(model, y_size: int, x_size: int) -> None: + """Refuse a ``downsample`` that leaves fewer than 2 pixels along Y or X. + + micro-sam squeezes a singleton axis and then cannot read the plane as 2D. + """ + small = (-(-y_size // model.downsample), -(-x_size // model.downsample)) + if min(small) < 2: + raise ValueError( + f"Model {model.name}: downsample {model.downsample} turns the " + f"{y_size} x {x_size} plane into {small[0]} x {small[1]} pixels; micro-sam " + "needs at least 2 along each axis. Lower downsample." + ) diff --git a/biahub/segmentation/staging.py b/biahub/segmentation/staging.py new file mode 100644 index 000000000..9866fe36b --- /dev/null +++ b/biahub/segmentation/staging.py @@ -0,0 +1,41 @@ +"""Copying model weights to node-local scratch, shared by the segmentation backends.""" + +import logging +import os +import shutil +import time + +from pathlib import Path + +logger = logging.getLogger(__name__) + +# Attempts for each node-local cellpose weight copy. ESTALE on the NFS home export +# is transient and is the very thing staging exists to avoid, so retry the copy +# before giving up and reading the weights over NFS. See stage_cellpose_weights. +_STAGE_ATTEMPTS = 3 + + +def _copy_weight(source: Path, dest: Path) -> None: + """Copy ``source`` to ``dest``, skipping a copy that is already there. + + The bytes land on a private temporary name and are renamed into place, so tasks + staging concurrently on the same node never read a half-written file and the + loser of the race just overwrites with identical content. Weights are matched + on size alone: they are ~1.2 GB and immutable once downloaded, so hashing them + on every task would cost more than the read this function avoids. + """ + if dest.is_file() and dest.stat().st_size == source.stat().st_size: + return + + partial = dest.with_name(f".{dest.name}.{os.getpid()}.partial") + for attempt in range(1, _STAGE_ATTEMPTS + 1): + try: + shutil.copyfile(source, partial) + break + except OSError as exc: + partial.unlink(missing_ok=True) + if attempt == _STAGE_ATTEMPTS: + raise + logger.warning("Retrying copy of %s to node-local scratch: %r", source, exc) + time.sleep(attempt) + os.replace(partial, dest) diff --git a/biahub/utils/__init__.py b/biahub/utils/__init__.py index e7cdfc990..72f4b1067 100644 --- a/biahub/utils/__init__.py +++ b/biahub/utils/__init__.py @@ -1,7 +1,6 @@ """Helpers shared across the step CLIs, grouped by concern. * :mod:`biahub.utils.array_ops` -- NumPy cropping and empty-frame detection. -* :mod:`biahub.utils.cellpose` -- cellpose device policy and weight caching. * :mod:`biahub.utils.cluster` -- per-position resource sizing, executor choice. * :mod:`biahub.utils.config` -- YAML configs <-> pydantic settings models. * :mod:`biahub.utils.ngff` -- OME-Zarr store paths, versions, and provenance. diff --git a/tests/test_segment_microsam.py b/tests/test_segment_microsam.py index 61c4742a8..a9aab6e99 100644 --- a/tests/test_segment_microsam.py +++ b/tests/test_segment_microsam.py @@ -232,13 +232,13 @@ def test_a_mixed_config_runs_each_backend(fake_cellpose, fake_microsam): def test_check_accepts_a_finetuned_model(fake_microsam): - from biahub.utils.microsam import check_microsam_model + from biahub.segmentation.methods.microsam import check_microsam_model check_microsam_model("hvit_b_cells", "apg") def test_check_refuses_an_unknown_name(fake_microsam): - from biahub.utils.microsam import check_microsam_model + from biahub.segmentation.methods.microsam import check_microsam_model with pytest.raises(ValueError, match="Unknown micro-sam model 'vit_b_lm'"): check_microsam_model("vit_b_lm", "ais") @@ -246,7 +246,7 @@ def test_check_refuses_an_unknown_name(fake_microsam): def test_check_refuses_a_backbone_without_decoder_for_ais(fake_microsam): # The plain SAM2 backbones have no decoder: only AMG can use them. - from biahub.utils.microsam import check_microsam_model + from biahub.segmentation.methods.microsam import check_microsam_model with pytest.raises(ValueError, match="amg"): check_microsam_model("hvit_b", "ais") @@ -254,21 +254,21 @@ def test_check_refuses_a_backbone_without_decoder_for_ais(fake_microsam): def test_check_says_how_to_install_micro_sam(no_microsam): - from biahub.utils.microsam import check_microsam_model + from biahub.segmentation.methods.microsam import check_microsam_model with pytest.raises(ImportError, match=r"biahub\[microsam\]"): check_microsam_model("hvit_b_cells", "ais") def test_warm_fetches_the_model_and_its_decoder(fake_microsam): - from biahub.utils.microsam import warm_microsam_weights + from biahub.segmentation.methods.microsam import warm_microsam_weights warm_microsam_weights("hvit_b_cells") assert fake_microsam.fetched == ["hvit_b_cells", "hvit_b_cells_decoder"] def test_warm_skips_a_checkpoint_file(fake_microsam, tmp_path): - from biahub.utils.microsam import warm_microsam_weights + from biahub.segmentation.methods.microsam import warm_microsam_weights ckpt = tmp_path / "best.pt" ckpt.write_bytes(b"") @@ -289,7 +289,7 @@ def test_warm_skips_a_checkpoint_file(fake_microsam, tmp_path): ], ) def test_check_accepts_the_engines_own_eval_args(fake_microsam, engine, eval_args): - from biahub.utils.microsam import check_microsam_model + from biahub.segmentation.methods.microsam import check_microsam_model check_microsam_model("hvit_b_cells", engine, eval_args) @@ -307,14 +307,14 @@ def test_check_accepts_the_engines_own_eval_args(fake_microsam, engine, eval_arg def test_check_refuses_eval_args_the_engine_does_not_take( fake_microsam, engine, eval_args, bad ): - from biahub.utils.microsam import check_microsam_model + from biahub.segmentation.methods.microsam import check_microsam_model with pytest.raises(ValueError, match=rf"{bad}.*{engine}"): check_microsam_model("hvit_b_cells", engine, eval_args) def test_check_refuses_an_unknown_ais_mode(fake_microsam): - from biahub.utils.microsam import check_microsam_model + from biahub.segmentation.methods.microsam import check_microsam_model with pytest.raises(ValueError, match="mode"): check_microsam_model("hvit_b_cells", "ais", {"mode": "watershed"}) @@ -341,7 +341,7 @@ def test_stage_copies_the_model_and_decoder_to_scratch(fake_microsam): from pathlib import Path - from biahub.utils.microsam import stage_microsam_weights + from biahub.segmentation.methods.microsam import stage_microsam_weights shared = _shared_weights(["hvit_b_cells", "hvit_b_cells_decoder", "hvit_t_cells"]) dest = stage_microsam_weights(["hvit_b_cells"]) @@ -357,7 +357,7 @@ def test_stage_copies_the_model_and_decoder_to_scratch(fake_microsam): def test_stage_twice_is_a_no_op(fake_microsam): - from biahub.utils.microsam import stage_microsam_weights + from biahub.segmentation.methods.microsam import stage_microsam_weights _shared_weights(["hvit_b_cells", "hvit_b_cells_decoder"]) first = stage_microsam_weights(["hvit_b_cells"]) @@ -369,7 +369,7 @@ def test_stage_without_shared_weights_still_moves_the_cache_to_scratch(fake_micr # temporary embeddings must still not be written to the shared cache. import os - from biahub.utils.microsam import stage_microsam_weights + from biahub.segmentation.methods.microsam import stage_microsam_weights dest = stage_microsam_weights(["hvit_b_cells"]) assert os.environ["MICROSAM_CACHEDIR"] == os.fspath(dest) @@ -392,7 +392,7 @@ def test_segment_stages_before_building_the_model(fake_microsam): def test_warm_fetches_a_plain_backbone(fake_microsam): - from biahub.utils.microsam import warm_microsam_weights + from biahub.segmentation.methods.microsam import warm_microsam_weights warm_microsam_weights("hvit_b") assert fake_microsam.fetched == ["hvit_b"] diff --git a/tests/test_segmentation_package.py b/tests/test_segmentation_package.py new file mode 100644 index 000000000..9165b08f9 --- /dev/null +++ b/tests/test_segmentation_package.py @@ -0,0 +1,14 @@ +"""biahub/segmentation: the backend registry.""" + + +def test_every_backend_a_config_can_name_is_registered(): + import typing + + from biahub.segmentation.backends import BACKENDS + from biahub.settings import MicroSamModel, SegmentationModel + + names = { + typing.get_args(cls.model_fields["backend"].annotation)[0] + for cls in (SegmentationModel, MicroSamModel) + } + assert names == set(BACKENDS) diff --git a/tests/test_utils/test_cellpose.py b/tests/test_utils/test_cellpose.py index 27f3cb4f4..f648ce64b 100644 --- a/tests/test_utils/test_cellpose.py +++ b/tests/test_utils/test_cellpose.py @@ -6,10 +6,10 @@ import pytest import torch -import biahub.utils.cellpose as cellpose_utils +import biahub.segmentation.methods.cellpose as cellpose_utils -from biahub.utils.cellpose import ( - cellpose_device, +from biahub.segmentation.devices import cellpose_device +from biahub.segmentation.methods.cellpose import ( check_cellpose_model_name, load_cellpose_model, stage_cellpose_weights, From aacea1e3ad1302063c9779c45ba5576cb9058ec3 Mon Sep 17 00:00:00 2001 From: Taylla Theodoro Date: Mon, 30 Nov 2026 15:37:36 -0800 Subject: [PATCH 7/7] refactor(segment): review fixes for the segmentation package From three independent reviews of #511 (no behaviour change): - Test that _segment_czyx stages cellpose weights before loading the model. Disabling the cellpose stage hook left every test green; the old test only reached the head-node staging call. The micro-sam equivalent existed. - The registry test reads the backend classes from SegmentationModelConfig instead of listing them, so a third backend cannot be missed. - Hooks take models: warm(model), stage(models) like load, segment and check_plane; named functions instead of lambdas, typed; check_plane defaults to accepting every plane. - cellpose_device -> segmentation_device (it serves every backend); its docstring and error text no longer assume cellpose, and drop the stale tracking: cellpose_config.gpu hint. - Docstrings and comments that still described the old layout: the cellpose and micro-sam module docstrings, the staging comment, segment.py's GPU comments. - tests/test_utils/test_cellpose.py -> tests/test_segmentation/test_cellpose.py (device tests split into test_devices.py), test_segmentation_package.py -> tests/test_segmentation/test_backends.py. Logger names follow the modules (biahub.segmentation.*); nothing filters on the old ones. --- biahub/segment.py | 16 +-- biahub/segmentation/backends.py | 97 +++++++++++++------ biahub/segmentation/devices.py | 14 +-- biahub/segmentation/methods/cellpose.py | 12 +-- biahub/segmentation/methods/microsam.py | 4 + biahub/segmentation/staging.py | 6 +- biahub/utils/cluster.py | 2 +- tests/test_cli/test_segment_cli.py | 4 +- tests/test_cli/test_segment_microsam_cli.py | 2 +- tests/test_segmentation/test_backends.py | 56 +++++++++++ .../test_cellpose.py | 32 +----- tests/test_segmentation/test_devices.py | 27 ++++++ tests/test_segmentation_package.py | 14 --- 13 files changed, 189 insertions(+), 97 deletions(-) create mode 100644 tests/test_segmentation/test_backends.py rename tests/{test_utils => test_segmentation}/test_cellpose.py (86%) create mode 100644 tests/test_segmentation/test_devices.py delete mode 100644 tests/test_segmentation_package.py diff --git a/biahub/segment.py b/biahub/segment.py index 4bfad58d8..c09f33b38 100644 --- a/biahub/segment.py +++ b/biahub/segment.py @@ -22,7 +22,7 @@ sbatch_to_submitit, ) from biahub.segmentation.backends import BACKENDS -from biahub.segmentation.devices import cellpose_device +from biahub.segmentation.devices import segmentation_device from biahub.segmentation.methods.cellpose import stage_cellpose_weights from biahub.settings import SegmentationSettings from biahub.utils.cluster import ( @@ -155,7 +155,7 @@ def check_plane_size(models: list[ResolvedModel], y_size: int, x_size: int) -> N def _warm_model(model) -> None: """Fetch a configured model's weights into its shared cache (head node, --init).""" - BACKENDS[model.backend].warm(model.pretrained_model) + BACKENDS[model.backend].warm(model) def _segment_czyx( @@ -168,14 +168,14 @@ def _segment_czyx( Returns an array of shape (n_models, Z, Y, X); Z is 1 for 2D models. """ # Every job this step submits asks SLURM for a GPU, so an unusable one is a - # broken allocation, not a reason to fall back to a ~130x slower CPU run. - device = cellpose_device(gpu) + # broken allocation, not a reason to fall back to a far slower CPU run. + device = segmentation_device(gpu) # Stage each backend's weights on node-local scratch before it is first imported # (no-op after the first timepoint). for name, backend in BACKENDS.items(): - pretrained_models = [m.pretrained_model for m in models if m.backend == name] - if pretrained_models: - backend.stage(pretrained_models) + backend_models = [m for m in models if m.backend == name] + if backend_models: + backend.stage(backend_models) czyx_segmentation = [] for model in models: @@ -397,7 +397,7 @@ def segment( "slurm_cpus_per_task": num_cpus, "slurm_array_parallelism": 100, # process up to 100 positions at a time "slurm_time": time_minutes, - # cellpose runs on the GPU; the non-preemptible `gpu` partition keeps long + # the models run on the GPU; the non-preemptible `gpu` partition keeps long # per-position jobs from being evicted. Override via --sbatch-filepath. "slurm_partition": "gpu", "slurm_gpus_per_node": 1, diff --git a/biahub/segmentation/backends.py b/biahub/segmentation/backends.py index e00838377..96f18ceb8 100644 --- a/biahub/segmentation/backends.py +++ b/biahub/segmentation/backends.py @@ -15,54 +15,95 @@ ``check_plane`` head node refuse a plane the model cannot segment ================= =========================== ============================================= -``check`` takes the configured model (``biahub.settings``); ``load``, ``segment`` and -``check_plane`` the model resolved against the input plate (``biahub.segment.ResolvedModel``); -``warm`` a ``pretrained_model``; ``stage`` the ``pretrained_model`` of every model of the -backend in the job. +``check`` takes the model as configured (a ``biahub.settings`` model: it runs before the +config is resolved against a plate); the other hooks take models resolved against the +input plate (``biahub.segment.ResolvedModel``), ``stage`` all of the backend's models in +the job. ``check_plane`` defaults to accepting every plane. + +To add a backend: a module in ``methods/`` with these functions, its settings class in +``biahub/settings.py`` (with a ``backend`` literal and a ``Tag`` in +``SegmentationModelConfig``), and an entry in :data:`BACKENDS`. """ from collections.abc import Callable from dataclasses import dataclass -from typing import Any +from typing import TYPE_CHECKING, Any from biahub.segmentation.methods import cellpose, microsam +if TYPE_CHECKING: + import numpy as np + import torch + + from biahub.segment import ResolvedModel + + +def _accept_every_plane(model: "ResolvedModel", y_size: int, x_size: int) -> None: + return None + @dataclass(frozen=True) class Backend: check: Callable[[Any], None] - warm: Callable[[str], Any] - stage: Callable[[list[str]], Any] - load: Callable[[Any, Any], Any] - segment: Callable[[Any, Any, Any], Any] - check_plane: Callable[[Any, int, int], None] + warm: Callable[["ResolvedModel"], Any] + stage: Callable[[list["ResolvedModel"]], Any] + load: Callable[["ResolvedModel", "torch.device"], Any] + segment: Callable[["np.ndarray", "ResolvedModel", Any], "np.ndarray"] + check_plane: Callable[["ResolvedModel", int, int], None] = _accept_every_plane -def _no_plane_check(model, y_size: int, x_size: int) -> None: - return None +# --- cellpose 4 + + +def _cellpose_check(model) -> None: + cellpose.check_cellpose_model_name(model.pretrained_model) + + +def _cellpose_warm(model: "ResolvedModel"): + return cellpose.warm_cellpose_weights(model.pretrained_model) + + +def _cellpose_stage(models: list["ResolvedModel"]): + # cellpose stages its whole weights directory, whatever the models. + return cellpose.stage_cellpose_weights() + + +def _cellpose_load(model: "ResolvedModel", device: "torch.device"): + return cellpose.load_cellpose_model(model.pretrained_model, device) + + +# --- micro-sam 2 + + +def _microsam_check(model) -> None: + microsam.check_microsam_model(model.pretrained_model, model.engine, model.eval_args) + + +def _microsam_warm(model: "ResolvedModel"): + return microsam.warm_microsam_weights(model.pretrained_model) + + +def _microsam_stage(models: list["ResolvedModel"]): + return microsam.stage_microsam_weights([m.pretrained_model for m in models]) + + +def _microsam_load(model: "ResolvedModel", device: "torch.device"): + return microsam.load_microsam_model(model.pretrained_model, model.engine, device) BACKENDS: dict[str, Backend] = { "cellpose": Backend( - check=lambda model: cellpose.check_cellpose_model_name(model.pretrained_model), - warm=cellpose.warm_cellpose_weights, - # cellpose stages its whole weights directory, whatever the model names. - stage=lambda pretrained_models: cellpose.stage_cellpose_weights(), - load=lambda model, device: cellpose.load_cellpose_model( - model.pretrained_model, device - ), + check=_cellpose_check, + warm=_cellpose_warm, + stage=_cellpose_stage, + load=_cellpose_load, segment=cellpose.segment, - check_plane=_no_plane_check, ), "microsam": Backend( - check=lambda model: microsam.check_microsam_model( - model.pretrained_model, model.engine, model.eval_args - ), - warm=microsam.warm_microsam_weights, - stage=microsam.stage_microsam_weights, - load=lambda model, device: microsam.load_microsam_model( - model.pretrained_model, model.engine, device - ), + check=_microsam_check, + warm=_microsam_warm, + stage=_microsam_stage, + load=_microsam_load, segment=microsam.segment, check_plane=microsam.check_plane, ), diff --git a/biahub/segmentation/devices.py b/biahub/segmentation/devices.py index 5f692d8c9..79daee2c7 100644 --- a/biahub/segmentation/devices.py +++ b/biahub/segmentation/devices.py @@ -1,14 +1,15 @@ -"""The torch device a segmentation job runs on (used by every backend).""" +"""The torch device a segmentation job runs on, for every backend.""" import os import torch -def cellpose_device(gpu: bool) -> torch.device: - """Resolve the torch device for cellpose, refusing a silent CPU fallback. +def segmentation_device(gpu: bool) -> torch.device: + """Resolve the torch device for segmentation, refusing a silent CPU fallback. - Left to itself, cellpose picks its device in ``cellpose.core.assign_device``, + The backends then run on this device instead of choosing their own. Left to itself, + cellpose (for example) picks its device in ``cellpose.core.assign_device``, which probes CUDA inside a bare ``except: pass`` and quietly returns the CPU whenever the probe fails — a transient CUDA init error on a busy node included. Nothing in the logs distinguishes the two devices, and on an A6000 against a @@ -43,8 +44,7 @@ def cellpose_device(gpu: bool) -> torch.device: raise RuntimeError( "GPU segmentation was requested but CUDA is unusable on this host " f"(CUDA_VISIBLE_DEVICES={os.environ.get('CUDA_VISIBLE_DEVICES')!r}): {exc}. " - "Refusing to fall back to the CPU, which is ~130x slower for cellpose. " - "Ask for the CPU explicitly to segment on it deliberately " - "(tracking: cellpose_config.gpu: false)." + "Refusing to fall back to the CPU, which is far slower (~130x for cellpose). " + "Rerun on a node with a working GPU." ) from exc return device diff --git a/biahub/segmentation/methods/cellpose.py b/biahub/segmentation/methods/cellpose.py index 245489ea1..b1bbb5eb2 100644 --- a/biahub/segmentation/methods/cellpose.py +++ b/biahub/segmentation/methods/cellpose.py @@ -1,6 +1,6 @@ -"""Helpers for running cellpose on the cluster. +"""The cellpose 4 backend of ``biahub segment``, and the problems it works around. -Two problems this module exists to solve, both observed in one overnight run: +Two problems, both observed in one overnight run: * cellpose resolves its own device in ``cellpose.core.assign_device``, which probes CUDA inside a bare ``except: pass`` and quietly returns the CPU whenever the probe @@ -9,8 +9,9 @@ is an NFS export on Bruno. A per-position fan-out reads that one file from dozens of nodes at once. -``cellpose_device`` addresses the first, ``warm_cellpose_weights`` (once, on the -head node) and ``stage_cellpose_weights`` (per worker) the second. +The first is solved for every backend by :func:`biahub.segmentation.devices.segmentation_device`, +the second by ``warm_cellpose_weights`` (once, on the head node) and +``stage_cellpose_weights`` (per worker; the copy itself is :mod:`biahub.segmentation.staging`). A third: cellpose 4 ignores ``model_type`` and falls back to ``cpsam_v2`` with only a log warning when ``pretrained_model`` names a model it does not know. @@ -21,8 +22,7 @@ only logs "Could not import CPDINO" and fails when the model is built. ``check_cellpose_model_name`` stops at ``--init`` with the install command instead. -``cellpose_device`` now lives in :mod:`biahub.segmentation.devices` and the weight copy in -:mod:`biahub.segmentation.staging`; they are shared with the other backends. +:func:`segment` runs a loaded model on one CZYX image (the backend's ``segment`` hook). """ import getpass diff --git a/biahub/segmentation/methods/microsam.py b/biahub/segmentation/methods/microsam.py index f5f90bca4..16c6173db 100644 --- a/biahub/segmentation/methods/microsam.py +++ b/biahub/segmentation/methods/microsam.py @@ -8,6 +8,10 @@ worker copies them to node-local scratch and points micro-sam's cache there (:func:`stage_microsam_weights`), so the jobs do not all read the weights over NFS and the temporary embeddings micro-sam writes for tiled images stay on the node. + +:func:`segment` runs a loaded model on the Z=1 plane of one CZYX image and :func:`check_plane` +refuses a ``downsample`` too large for the plane (the backend's ``segment`` and +``check_plane`` hooks). """ import getpass diff --git a/biahub/segmentation/staging.py b/biahub/segmentation/staging.py index 9866fe36b..26e5bbcc6 100644 --- a/biahub/segmentation/staging.py +++ b/biahub/segmentation/staging.py @@ -9,9 +9,9 @@ logger = logging.getLogger(__name__) -# Attempts for each node-local cellpose weight copy. ESTALE on the NFS home export -# is transient and is the very thing staging exists to avoid, so retry the copy -# before giving up and reading the weights over NFS. See stage_cellpose_weights. +# Attempts for each node-local weight copy. ESTALE on the NFS home export is transient +# and is the very thing staging exists to avoid, so retry the copy before giving up and +# reading the weights over NFS. Used by every backend's stage hook. _STAGE_ATTEMPTS = 3 diff --git a/biahub/utils/cluster.py b/biahub/utils/cluster.py index 6ecf46a56..792c57f19 100644 --- a/biahub/utils/cluster.py +++ b/biahub/utils/cluster.py @@ -49,7 +49,7 @@ def local_executor_parameters(timeout_min: float, gpu: bool = True) -> dict: SLURM jobs get their GPU from ``slurm_gpus_per_node``/gres and their limit from ``slurm_time``, and ``debug`` runs in-process with the caller's GPU. submitit's local executor ignores both: it sets ``CUDA_VISIBLE_DEVICES`` only from the generic - ``gpus_per_node`` (otherwise every GPU is hidden and ``cellpose_device`` refuses), and + ``gpus_per_node`` (otherwise every GPU is hidden and ``segmentation_device`` refuses), and kills jobs after the generic ``timeout_min`` (default 2 minutes). Note that local jobs all run at once on the same GPU, so keep local runs to a few positions. diff --git a/tests/test_cli/test_segment_cli.py b/tests/test_cli/test_segment_cli.py index fd194750b..4ed212cf0 100644 --- a/tests/test_cli/test_segment_cli.py +++ b/tests/test_cli/test_segment_cli.py @@ -45,7 +45,7 @@ def plate_2d(create_custom_plate, tmp_path): @pytest.fixture def cpu_cellpose(monkeypatch): """Workers ask for the GPU; run the (fake) model on the CPU instead.""" - monkeypatch.setattr("biahub.segment.cellpose_device", lambda gpu: torch.device("cpu")) + monkeypatch.setattr("biahub.segment.segmentation_device", lambda gpu: torch.device("cpu")) @pytest.fixture(autouse=True) @@ -327,7 +327,7 @@ def test_segment_gives_local_jobs_a_gpu( fake_cellpose, plate_2d, segment_config, tmp_path, monkeypatch, cluster, expected ): """submitit's local executor only exposes GPUs through gpus_per_node; without it the - local subprocess runs with CUDA_VISIBLE_DEVICES='' and cellpose_device refuses.""" + local subprocess runs with CUDA_VISIBLE_DEVICES='' and segmentation_device refuses.""" monkeypatch.setattr("biahub.segment.submitit.AutoExecutor", _RecordingExecutor) monkeypatch.delenv("CI", raising=False) # CI forces cluster=debug plate_path, _ = plate_2d diff --git a/tests/test_cli/test_segment_microsam_cli.py b/tests/test_cli/test_segment_microsam_cli.py index b34ebb899..9c1882ab8 100644 --- a/tests/test_cli/test_segment_microsam_cli.py +++ b/tests/test_cli/test_segment_microsam_cli.py @@ -25,7 +25,7 @@ def plate_2d(create_custom_plate, tmp_path): @pytest.fixture def cpu_device(monkeypatch): """Workers ask for the GPU; run the (fake) model on the CPU instead.""" - monkeypatch.setattr("biahub.segment.cellpose_device", lambda gpu: torch.device("cpu")) + monkeypatch.setattr("biahub.segment.segmentation_device", lambda gpu: torch.device("cpu")) @pytest.fixture diff --git a/tests/test_segmentation/test_backends.py b/tests/test_segmentation/test_backends.py new file mode 100644 index 000000000..40dce29e7 --- /dev/null +++ b/tests/test_segmentation/test_backends.py @@ -0,0 +1,56 @@ +"""biahub/segmentation: the backend registry and the hooks segment calls.""" + +import typing + +import numpy as np + + +def test_every_backend_a_config_can_name_is_registered(): + from biahub.segmentation.backends import BACKENDS + from biahub.settings import SegmentationModelConfig + + # SegmentationModelConfig = Annotated[Annotated[A, Tag] | Annotated[B, Tag] | ..., Discriminator] + union = typing.get_args(SegmentationModelConfig)[0] + classes = [typing.get_args(member)[0] for member in typing.get_args(union)] + names = {typing.get_args(cls.model_fields["backend"].annotation)[0] for cls in classes} + assert len(classes) >= 2 + assert names == set(BACKENDS) + + +def test_segment_stages_cellpose_weights_before_loading_the_model(fake_cellpose, monkeypatch): + """Workers must copy the weights to scratch before cellpose is imported and loaded.""" + import biahub.segmentation.methods.cellpose as cellpose_method + + from biahub.segment import _segment_czyx, resolve_models + from biahub.settings import SegmentationSettings + + calls = [] + real_load = cellpose_method.load_cellpose_model + monkeypatch.setattr( + cellpose_method, "stage_cellpose_weights", lambda: calls.append("stage") + ) + monkeypatch.setattr( + cellpose_method, + "load_cellpose_model", + lambda name, device: calls.append("load") or real_load(name, device), + ) + settings = SegmentationSettings( + models={"nuclei": {"pretrained_model": "cpsam_v2", "channels": ["c0"]}} + ) + models = resolve_models(settings, ["c0"], scale=(1,) * 5, z_size=1) + + _segment_czyx(np.zeros((1, 1, 8, 8), np.float32), models, gpu=False) + + assert calls == ["stage", "load"] + + +def test_backend_hooks_take_models(): + """warm and stage take resolved models, like load / segment / check_plane.""" + import inspect + + from biahub.segmentation.backends import BACKENDS + + for name, backend in BACKENDS.items(): + for hook in ("warm", "stage", "load", "segment", "check_plane"): + first = next(iter(inspect.signature(getattr(backend, hook)).parameters)) + assert first in ("model", "models", "czyx_data"), (name, hook, first) diff --git a/tests/test_utils/test_cellpose.py b/tests/test_segmentation/test_cellpose.py similarity index 86% rename from tests/test_utils/test_cellpose.py rename to tests/test_segmentation/test_cellpose.py index f648ce64b..ac427adc4 100644 --- a/tests/test_utils/test_cellpose.py +++ b/tests/test_segmentation/test_cellpose.py @@ -6,9 +6,8 @@ import pytest import torch -import biahub.segmentation.methods.cellpose as cellpose_utils +import biahub.segmentation.methods.cellpose as cellpose_method -from biahub.segmentation.devices import cellpose_device from biahub.segmentation.methods.cellpose import ( check_cellpose_model_name, load_cellpose_model, @@ -17,27 +16,6 @@ ) -def test_cellpose_device_cpu_when_not_requested(): - assert cellpose_device(gpu=False) == torch.device("cpu") - - -def test_cellpose_device_raises_instead_of_falling_back(monkeypatch): - """An unusable GPU must fail loudly, not silently segment on the CPU.""" - - def unavailable(*args, **kwargs): - raise RuntimeError("CUDA error: all CUDA-capable devices are busy or unavailable") - - monkeypatch.setattr(torch, "zeros", unavailable) - monkeypatch.setenv("CUDA_VISIBLE_DEVICES", "3") - - with pytest.raises(RuntimeError, match="Refusing to fall back to the CPU") as excinfo: - cellpose_device(gpu=True) - - # The message has to carry enough to debug the node it happened on. - assert "CUDA_VISIBLE_DEVICES='3'" in str(excinfo.value) - assert "busy or unavailable" in str(excinfo.value) - - @pytest.fixture() def cellpose_cache(tmp_path, monkeypatch): """A shared weights directory and an empty node-local scratch to stage into.""" @@ -180,7 +158,7 @@ def __init__(self, pretrained_model, gpu, device): _fake_cellpose(monkeypatch, FakeModel) sys.modules["cellpose.models"].MODEL_NAMES = ["cpsam_v2", "cpdino"] sys.modules["cellpose.models"].get_user_models = lambda: [] - monkeypatch.setattr(cellpose_utils, "_dinov3_installed", lambda: True) + monkeypatch.setattr(cellpose_method, "_dinov3_installed", lambda: True) load_cellpose_model("cpdino", torch.device("cpu")) assert built == {"pretrained_model": "cpdino", "gpu": False} @@ -196,7 +174,7 @@ def _known_models(monkeypatch): def test_cpdino_without_dinov3_says_how_to_install(monkeypatch, name): """cellpose only warns 'Could not import CPDINO' and fails later; stop at init instead.""" _known_models(monkeypatch) - monkeypatch.setattr(cellpose_utils, "_dinov3_installed", lambda: False) + monkeypatch.setattr(cellpose_method, "_dinov3_installed", lambda: False) with pytest.raises(ValueError, match="dinov3") as excinfo: check_cellpose_model_name(name) @@ -228,13 +206,13 @@ def test_cpdino_extra_is_opt_in_and_pinned(): def test_cpdino_with_dinov3_passes(monkeypatch): _known_models(monkeypatch) - monkeypatch.setattr(cellpose_utils, "_dinov3_installed", lambda: True) + monkeypatch.setattr(cellpose_method, "_dinov3_installed", lambda: True) check_cellpose_model_name("cpdino") def test_cpsam_does_not_need_dinov3(monkeypatch): _known_models(monkeypatch) - monkeypatch.setattr(cellpose_utils, "_dinov3_installed", lambda: False) + monkeypatch.setattr(cellpose_method, "_dinov3_installed", lambda: False) check_cellpose_model_name("cpsam_v2") diff --git a/tests/test_segmentation/test_devices.py b/tests/test_segmentation/test_devices.py new file mode 100644 index 000000000..88c01685a --- /dev/null +++ b/tests/test_segmentation/test_devices.py @@ -0,0 +1,27 @@ +"""The device every segmentation job runs on: a GPU, or a loud failure, never a silent CPU.""" + +import pytest +import torch + +from biahub.segmentation.devices import segmentation_device + + +def test_segmentation_device_cpu_when_not_requested(): + assert segmentation_device(gpu=False) == torch.device("cpu") + + +def test_segmentation_device_raises_instead_of_falling_back(monkeypatch): + """An unusable GPU must fail loudly, not silently segment on the CPU.""" + + def unavailable(*args, **kwargs): + raise RuntimeError("CUDA error: all CUDA-capable devices are busy or unavailable") + + monkeypatch.setattr(torch, "zeros", unavailable) + monkeypatch.setenv("CUDA_VISIBLE_DEVICES", "3") + + with pytest.raises(RuntimeError, match="Refusing to fall back to the CPU") as excinfo: + segmentation_device(gpu=True) + + # The message has to carry enough to debug the node it happened on. + assert "CUDA_VISIBLE_DEVICES='3'" in str(excinfo.value) + assert "busy or unavailable" in str(excinfo.value) diff --git a/tests/test_segmentation_package.py b/tests/test_segmentation_package.py deleted file mode 100644 index 9165b08f9..000000000 --- a/tests/test_segmentation_package.py +++ /dev/null @@ -1,14 +0,0 @@ -"""biahub/segmentation: the backend registry.""" - - -def test_every_backend_a_config_can_name_is_registered(): - import typing - - from biahub.segmentation.backends import BACKENDS - from biahub.settings import MicroSamModel, SegmentationModel - - names = { - typing.get_args(cls.model_fields["backend"].annotation)[0] - for cls in (SegmentationModel, MicroSamModel) - } - assert names == set(BACKENDS)