lazyslide.tl.text_embedding#
- text_embedding(texts, model='plip', device=None)#
Embed the text into a vector in the text-vision co-embedding using
- Parameters:
- textsList[str]
The list of texts.
- modelLiteral[“plip”, “conch”, “omiclip”], default: “plip”
The text embedding model
- devicestr, optional
The device to use for computation (e.g., ‘cpu’, ‘cuda’, ‘mps’). If None, will use CUDA if available, otherwise CPU.
- 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")