VertexAIImageCaptioner
Generate captions for images using Google Vertex AI imagetext model.
Key Features
- Generates descriptive captions for images using the Vertex AI imagetext model
- Accepts images as
ByteStreaminput - Authenticates using Google Cloud Application Default Credentials (ADCs)
Configuration
- Drag the
VertexAIImageCaptionercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Enter your GCP project ID. Create a secret with the key
GCP_PROJECT_ID. For detailed instructions, see Create Secrets. - Optionally, enter the location. If not set, uses
us-central1. - The default model is
imagetext.
- Enter your GCP project ID. Create a secret with the key
- Go to the Advanced tab to configure additional model keyword arguments.
Connections
VertexAIImageCaptioner accepts an image as a ByteStream object through its image input. It outputs generated captions as captions (a list of strings).
Connect an image source to the image input. Connect the captions output to AnswerBuilder.
Source Code
To check this component's source code, open captioner.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
VertexAIImageCaptioner:
type: haystack_integrations.components.generators.google_vertex.captioner.VertexAIImageCaptioner
init_parameters:
model: imagetext
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
Inputs
| Parameter | Type | Description |
|---|---|---|
image | ByteStream | The image to generate captions for. |
Outputs
| Parameter | Type | Description |
|---|---|---|
captions | List[str] | A list of captions generated by the model. |
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 component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Description |
|---|---|---|
image | ByteStream | The image to generate captions for. |
Related Information
Was this page helpful?