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
platformIPlatformAdapterhttpClientHttpClientloggerILogger
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
requestImageCaptioningRequestThe ImageCaptioningRequest containing the image and parameters.
cancellationTokenCancellationTokenThe 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
imageUristringThe Google Cloud Storage URI of the image to be processed.
parametersImageCaptioningParametersOptional parameters for image captioning customization.
cancellationTokenCancellationTokenThe 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
imagePathstringThe file path of the local image to be processed.
parametersImageCaptioningParametersOptional parameters to configure the image captioning request.
cancellationTokenCancellationTokenThe 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
requestVqaRequestThe VqaRequest containing the image and question.
cancellationTokenCancellationTokenThe 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
promptstringThe question or prompt to be applied to the image.
imageUristringThe Google Cloud Storage URI of the image to be analyzed.
parametersVqaParametersOptional parameters for visual question answering customization.
cancellationTokenCancellationTokenThe 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
promptstringThe question or query to be answered based on the image content.
imagePathstringThe file path of the local image to be analyzed.
parametersVqaParametersOptional parameters to configure the visual question answering request.
cancellationTokenCancellationTokenThe CancellationToken to cancel the operation.
Returns
- Task<VqaResponse>
The VqaResponse containing the answer to the specified question.
- See Also