VertexAIImageCaptioner
Generate captions for images using Google Vertex AI imagetext model.
Basic Information
- Type:
haystack_integrations.components.generators.google_vertex.captioner.VertexAIImageCaptioner - Components it can connect with:
Input: Receives an image asByteStreaminput.AnswerBuilder: Sends generated captions toAnswerBuilder.
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| image | ByteStream | The image to generate captions for. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| captions | List[str] | A list of captions generated by the model. |
Overview
VertexAIImageCaptioner generates captions for images using Google Vertex AI imagetext generative model. It takes an image and returns descriptive captions.
Authorization
This component authenticates using Google Cloud Application Default Credentials (ADCs). For more information, see the official Google documentation.
Create secrets for GCP_PROJECT_ID and optionally GCP_DEFAULT_REGION. For detailed instructions on creating secrets, see Create Secrets.
Usage Example
This pipeline uses VertexAIImageCaptioner to generate captions for images:
components:
VertexAIImageCaptioner:
type: haystack_integrations.components.generators.google_vertex.captioner.VertexAIImageCaptioner
init_parameters:
project_id:
model: imagetext
location:
AnswerBuilder:
type: haystack.components.builders.answer_builder.AnswerBuilder
init_parameters:
pattern:
reference_pattern:
connections:
- sender: VertexAIImageCaptioner.captions
receiver: AnswerBuilder.replies
inputs:
image:
- VertexAIImageCaptioner.image
query:
- AnswerBuilder.query
outputs:
answers: AnswerBuilder.answers
max_runs_per_component: 100
metadata: {}
Parameters
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| project_id | Optional[str] | None | ID of the GCP project to use. By default, it is set during Google Cloud authentication. |
| model | str | imagetext | Name of the model to use. |
| location | Optional[str] | None | The default location to use when making API calls. If not set, uses us-central-1. |
| kwargs | Any | Additional keyword arguments to pass to the model. See the ImageTextModel.get_captions() documentation. |
Run Method Parameters
These are the parameters you can configure for the run() method. You can pass these parameters at query time through the API, in Playground, or when running a job.
| Parameter | Type | Default | Description |
|---|---|---|---|
| image | ByteStream | The image to generate captions for. |
Was this page helpful?