lazyslide.tl.text_embedding#
- text_embedding(texts, model='plip', amp=None, autocast_dtype=None, device='cpu')#
Embed the text into a vector in the text-vision co-embedding using
- Parameters:
- textsList[str]
The list of texts.
- model{“plip”, “conch”, “omiclip”}, default: “plip”
The text embedding multimodal model
- ampbool, default: False
Whether to use automatic mixed precision (AMP) for inference.
- autocast_dtypetorch.dtype, default: torch.float16
The dtype for automatic mixed precision.
- devicestr, default: “cpu”
The device to use for computation (e.g., ‘cpu’, ‘cuda’, ‘mps’).
- Returns:
DataFrameThe embeddings of the texts, with texts as index.
Examples
>>> import lazyslide as zs >>> wsi = zs.datasets.sample() >>> zs.pp.find_tissues(wsi) >>> zs.pp.tile_tissues(wsi, 256, mpp=0.5, key_added="text_tiles") >>> zs.tl.feature_extraction(wsi, "plip", tile_key="text_tiles") >>> terms = ["mucosa", "submucosa", "musclaris", "lymphocyte"] >>> zs.tl.text_embedding(terms, model="plip")