Crystal Detector (Cellpose cpsam)

A Cellpose cpsam model fine-tuned to segment individual crystals in microscopy images of crystallization. Given a frame, it produces an instance mask (one label per crystal), from which centroid and pixel-area measurements are derived.

This checkpoint backs the crystal_detector component of the crystalization research project — the deep-learning counterpart to that repo's deterministic (focus/motion) crystal annotator.

Usage

The project downloads and caches this checkpoint automatically:

uv sync --group crystal-detector
uv run crystal-detector-analyze image.png

Or directly with huggingface_hub + Cellpose:

import torch
from huggingface_hub import hf_hub_download
from cellpose import models

ckpt = hf_hub_download("MarekWadinger/crystal-detector-cpsam", "cpsam_20260517_223507")
model = models.CellposeModel(gpu=torch.cuda.is_available(), pretrained_model=ckpt)
masks, flows, _ = model.eval(image, diameter=None, flow_threshold=0.9, cellprob_threshold=-2.0)

The inference defaults used by the project are flow_threshold=0.9 and cellprob_threshold=-2.0, on images preprocessed with flat-field correction + CLAHE (see src/crystal_detector/analyze.py).

Training

Fine-tuned from the base Cellpose cpsam model in the Cellpose GUI on flat-field-corrected microscopy frames, with masks hand-corrected per image. The frame-export and training workflow is documented in the project's component README.

Intended use & limitations

  • Intended for segmenting crystals in microscopy imagery from the same optical setup / preparation as the training data.
  • Limitations: trained on a small, domain-specific frame set; expect degraded performance on different magnifications, illumination, or crystal habits. Treat outputs as assistive measurements, not ground truth. No held-out quantitative benchmark is published with this checkpoint.

License

Released under BSD-3-Clause, matching the upstream Cellpose license.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support