Hi Deepankar -
To use the Analyze
method with a custom AI Vision Model in C#, you’ll need to ensure you’re passing the correct parameters, including the model name, feature, and options. Here’s a basic example of how you can achieve this:
Set up your client:
var client = new ComputerVisionClient(new ApiKeyServiceClientCredentials("<Your API Key>"))
{ Endpoint = "<Your Endpoint>"};
Define the parameters:
string imageUri = "<Your Image URI>";
string modelName = "<Your Custom Model Name>";
var features = new List<VisualFeatureTypes?> { VisualFeatureTypes.Objects };
var options = new ImageAnalysisOptions
{
ModelVersion = modelName
};
Call the Analyze method:
var analysisResult = await client.AnalyzeImageAsync(imageUri, features, options);
Extract the confidence score:
foreach (var obj in analysisResult.Objects)
{
Console.WriteLine($"Object: {obj.ObjectProperty}, Confidence: {obj.Confidence}");
}
In this example, replace "<Your API Key>"
, "<Your Endpoint>"
, "<Your Image URI>"
, and "<Your Custom Model Name>"
with your actual values. The AnalyzeImageAsync
method takes the image URI, a list of features to analyze, and options that include your custom model name.