Image To Text
Defines a base class for image to text converter used in Gen AI applications.
This module provides the foundation for converting images to text in various formats, including OCR, image captioning, and other image analysis tasks.
BaseImageToText()
Bases: BaseModalityConverter, ABC
An abstract base class for image to text conversion used in Gen AI applications.
This class provides a foundation for building image to text converter components in Gen AI applications. It supports various types of image sources (file paths, URLs, base64 strings) and can be extended to implement different types of image analysis tasks like OCR, captioning, or object detection.
Subclasses must implement the _convert method.
Initialize the base image to text component with logging capabilities.
convert(source, **kwargs)
async
Execute the image to text conversion process.
This method validates the input parameters and delegates to _convert
to perform the actual conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | bytes
|
The source of the image to convert to text. |
required |
**kwargs
|
Any
|
Additional conversion parameters. Implementations may
accept keyword arguments such as |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
TextResult |
TextResult
|
The result of processing the image. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |