Hi, I was able to find the code for SDK code and create a dummy aaplication . However I am getting an Error, and so I am unable to predict the object.
Referring to the code in this
https://video2.skills-academy.com/en-us/azure/cognitive-services/custom-vision-service/quickstarts/image-classification?tabs=visual-studio&pivots=programming-language-csharp
I am getting an error on this line of Code :
var result = predictionApi.DetectImage(project.Id, project.Name, stream);
Error: Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.Models.CustomVisionErrorException
HResult=0x80131500
Message=Operation returned an invalid status code 'NotFound'
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Since my model is already , I just used the test iteration part .
CustomVisionTrainingClient TrainingApi = AuthenticateTraining(ENDPOINT, trainingKey);
CustomVisionPredictionClient predictionApi = AuthenticatePrediction(ENDPOINT, predictionKey);
//// Find the object detection domain
//var domains = TrainingApi.GetDomains();
//var objDetectionDomain = domains.FirstOrDefault(d => d.Type == "ObjectDetection");
var projects = TrainingApi.GetProjects();
var project = TrainingApi.GetProject(Guid.Parse(projects[0].Id));
TestIteration(predictionApi, project);
private void TestIteration(CustomVisionPredictionClient predictionApi, Project project)
{
var imageFile = Server.MapPath("~/" + imgPath);
using (var stream = File.OpenRead(imageFile))
{
***var result = predictionApi.DetectImage(project.Id, project.Name, stream);***
lblResponse.Text = result.Predictions;
}
}