Table of Contents

Class ImageTextModel

Namespace
GenerativeAI.Clients
Assembly
GenerativeAI.dll

Provides functionality for image-to-text generative AI tasks including image captioning and visual question answering (VQA). Offers methods to interact with both local image files and images hosted on cloud storage.

public class ImageTextModel : BaseClient
Inheritance
ImageTextModel
Inherited Members
Extension Methods

Remarks

This class integrates with the AI platform defined by IPlatformAdapter and provides access to the platform's image text processing capabilities. Inherited from BaseClient, it uses HTTP communication and logging mechanisms defined at a higher level.

Constructors

ImageTextModel(IPlatformAdapter, HttpClient?, ILogger?)

Represents a client for interacting with image-to-text models, including functionality for image captioning and visual question answering.

public ImageTextModel(IPlatformAdapter platform, HttpClient? httpClient = null, ILogger? logger = null)

Parameters

platform IPlatformAdapter
httpClient HttpClient
logger ILogger

Remarks

This class provides various methods to generate captions or answer questions about images from local files or cloud storage.

Methods

GenerateImageCaptionAsync(ImageCaptioningRequest, CancellationToken)

Generate image captions for a given image.

public Task<ImageCaptioningResponse?> GenerateImageCaptionAsync(ImageCaptioningRequest request, CancellationToken cancellationToken = default)

Parameters

request ImageCaptioningRequest

The ImageCaptioningRequest containing the image and parameters.

cancellationToken CancellationToken

The CancellationToken to cancel the operation.

Returns

Task<ImageCaptioningResponse>

The ImageCaptioningResponse containing the predicted captions.

See Also

GenerateImageCaptionFromGcsImageAsync(string, ImageCaptioningParameters?, CancellationToken)

Generates image captions for an image stored in Google Cloud Storage (GCS).

public Task<ImageCaptioningResponse?> GenerateImageCaptionFromGcsImageAsync(string imageUri, ImageCaptioningParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

imageUri string

The Google Cloud Storage URI of the image to be processed.

parameters ImageCaptioningParameters

Optional parameters for image captioning customization.

cancellationToken CancellationToken

The CancellationToken to cancel the operation.

Returns

Task<ImageCaptioningResponse>

The ImageCaptioningResponse containing the predicted captions.

See Also

GenerateImageCaptionFromLocalFileAsync(string, ImageCaptioningParameters?, CancellationToken)

Generates image captions for a local image file.

public Task<ImageCaptioningResponse?> GenerateImageCaptionFromLocalFileAsync(string imagePath, ImageCaptioningParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

imagePath string

The file path of the local image to be processed.

parameters ImageCaptioningParameters

Optional parameters to configure the image captioning request.

cancellationToken CancellationToken

The CancellationToken to cancel the operation.

Returns

Task<ImageCaptioningResponse>

The ImageCaptioningResponse containing the predicted captions.

See Also

VisualQuestionAnsweringAsync(VqaRequest, CancellationToken)

Predicts the answer to a question about an image using the Imagen for Captioning & VQA model.

public Task<VqaResponse?> VisualQuestionAnsweringAsync(VqaRequest request, CancellationToken cancellationToken = default)

Parameters

request VqaRequest

The VqaRequest containing the image and question.

cancellationToken CancellationToken

The CancellationToken to cancel the operation.

Returns

Task<VqaResponse>

The VqaResponse containing the predicted answers.

See Also

VisualQuestionAnsweringFromGcsFileAsync(string, string, VqaParameters?, CancellationToken)

Performs visual question answering for an image stored in Google Cloud Storage (GCS).

public Task<VqaResponse?> VisualQuestionAnsweringFromGcsFileAsync(string prompt, string imageUri, VqaParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

prompt string

The question or prompt to be applied to the image.

imageUri string

The Google Cloud Storage URI of the image to be analyzed.

parameters VqaParameters

Optional parameters for visual question answering customization.

cancellationToken CancellationToken

The CancellationToken to cancel the operation.

Returns

Task<VqaResponse>

The VqaResponse containing the results of the visual question answering process.

See Also

VisualQuestionAnsweringFromLocalFileAsync(string, string, VqaParameters?, CancellationToken)

Processes a visual question answering task on a local image file.

public Task<VqaResponse?> VisualQuestionAnsweringFromLocalFileAsync(string prompt, string imagePath, VqaParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

prompt string

The question or query to be answered based on the image content.

imagePath string

The file path of the local image to be analyzed.

parameters VqaParameters

Optional parameters to configure the visual question answering request.

cancellationToken CancellationToken

The CancellationToken to cancel the operation.

Returns

Task<VqaResponse>

The VqaResponse containing the answer to the specified question.

See Also