ImageCaptionLoader#

class langchain_community.document_loaders.image_captions.ImageCaptionLoader(images: str | Path | bytes | List[str | bytes | Path], blip_processor: str = 'Salesforce/blip-image-captioning-base', blip_model: str = 'Salesforce/blip-image-captioning-base')[source]#

Load image captions.

By default, the loader utilizes the pre-trained Salesforce BLIP image captioning model. https://huggingface.co/Salesforce/blip-image-captioning-base

Initialize with a list of image data (bytes) or file paths

Parameters:
  • images (str | Path | bytes | List[str | bytes | Path]) – Either a single image or a list of images. Accepts image data (bytes) or file paths to images.

  • blip_processor (str) – The name of the pre-trained BLIP processor.

  • blip_model (str) – The name of the pre-trained BLIP model.

Methods

__init__(images[,Β blip_processor,Β blip_model])

Initialize with a list of image data (bytes) or file paths

alazy_load()

A lazy loader for Documents.

aload()

Load data into Document objects.

lazy_load()

A lazy loader for Documents.

load()

Load from a list of image data or file paths

load_and_split([text_splitter])

Load Documents and split into chunks.

__init__(images: str | Path | bytes | List[str | bytes | Path], blip_processor: str = 'Salesforce/blip-image-captioning-base', blip_model: str = 'Salesforce/blip-image-captioning-base')[source]#

Initialize with a list of image data (bytes) or file paths

Parameters:
  • images (str | Path | bytes | List[str | bytes | Path]) – Either a single image or a list of images. Accepts image data (bytes) or file paths to images.

  • blip_processor (str) – The name of the pre-trained BLIP processor.

  • blip_model (str) – The name of the pre-trained BLIP model.

async alazy_load() β†’ AsyncIterator[Document]#

A lazy loader for Documents.

Return type:

AsyncIterator[Document]

async aload() β†’ List[Document]#

Load data into Document objects.

Return type:

List[Document]

lazy_load() β†’ Iterator[Document]#

A lazy loader for Documents.

Return type:

Iterator[Document]

load() β†’ List[Document][source]#

Load from a list of image data or file paths

Return type:

List[Document]

load_and_split(text_splitter: TextSplitter | None = None) β†’ List[Document]#

Load Documents and split into chunks. Chunks are returned as Documents.

Do not override this method. It should be considered to be deprecated!

Parameters:

text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns:

List of Documents.

Return type:

List[Document]

Examples using ImageCaptionLoader