lazyslide.tl.slide_caption#
- slide_caption(wsi, prompt, feature_key, *, agg_key=None, agg_by=None, max_length=100, model='prism', device=None, amp=None, autocast_dtype=None, compile=None, compile_kws=None)#
Generate captions for the slide.
- Parameters:
- wsi
WSIData The WSIData object to work on.
- promptlist of str
The text instruction to generate the caption.
- feature_keystr
The slide features to be used.
- agg_keystr, default: None
The aggregation key.
- agg_bystr or list of str, default: None
The aggregation keys that were used to create the slide features.
- max_lengthint, default: 100
The maximum length of the generated caption.
- modelstr or ModelBaseProtocol, default: “prism”
The caption generation model to use: a model registry key (see Models) or a model instance with a
captionmethod.- devicestr, default: None
The device to use for inference. If None, the default device will be used.
- ampbool, optional
Whether to use automatic mixed precision.
- autocast_dtypetorch.dtype, optional
The dtype for automatic mixed precision.
- compilebool, optional
Whether to compile the model with
torch.compile(). Compilation is best-effort and is silently skipped for models that do not support it.- compile_kwsdict, optional
Keyword arguments passed to
torch.compile().
- wsi
- Returns:
DataFrameThe generated captions. Contains a ‘caption’ column, plus any annotation columns if aggregation groups were used.