cellmap_flow.ai_annotate.backends.base
What every provider takes and gives back, so the pipeline does not know which one ran.
A provider turns one RGB EM plane and a prompt into a mask of the same size.
How it gets there is its own business: an image model asked to paint the
structure (Vertex Gemini), a local stand-in (fake), or later a model that
takes the click itself as a point prompt (click_px).
Classes
One plane to segment. |
|
A provider's answer. |
|
Base class for protocol classes. |
Module Contents
- class cellmap_flow.ai_annotate.backends.base.SegmentRequest
One plane to segment.
imageis exactly what is sent: the RGB EM plane at the resolution the prompt states.target_rgbis the colour the prompt asks for, andclick_pxthe (row, col) the user pointed at inimage, or None.- image: PIL.Image.Image
- prompt: str
- target_rgb: tuple
- click_px: tuple | None = None
- class cellmap_flow.ai_annotate.backends.base.SegmentResult
A provider’s answer.
maskis bool withimage’s (height, width).model_imageis what the model drew, resized toimage’s size, for the review preview (None for a provider that draws nothing).usageholds whatever token counts the provider reports, possibly none.- mask: numpy.ndarray
- model_image: PIL.Image.Image | None
- model: str
- usage: dict
- class cellmap_flow.ai_annotate.backends.base.Backend
Base class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto(Protocol[T]): def meth(self) -> T: ...
- segment(request: SegmentRequest, model: str) SegmentResult
Segment
requestwithmodel, raisingAIAnnotateErroron failure.