Abstract class for ImageToText.
Module base
BaseImageToText
class BaseImageToText(BaseComponent)
Abstract class for ImageToText.
BaseImageToText.generate_captions
@abstractmethod
def generate_captions(image_file_paths: List[str],
generation_kwargs: Optional[dict] = None,
batch_size: Optional[int] = None) -> List[Document]
Abstract method for generating captions.
Arguments:
image_file_paths
: Paths to the images for which you want to generate captions.generation_kwargs
: Dictionary containing arguments for thegenerate()
method of the Hugging Face model. See generate() on Hugging Face.batch_size
: Number of images to process at a time.
Returns:
List of Documents. Document.content
is the caption. Document.meta["image_file_path"]
contains the path to the image file.
BaseImageToText.run
def run(file_paths: Optional[List[str]] = None,
documents: Optional[List[Document]] = None)
Arguments:
file_paths
: Paths to the images for which you want to generate captions.documents
: List of image Documents to process into text.
BaseImageToText.run_batch
def run_batch(file_paths: Optional[List[str]] = None,
documents: Optional[List[Document]] = None)
Arguments:
file_paths
: Paths to the images for which you want to generate captions.documents
: List of image Documents to process into text.