コード例 #1
0
        public static async Task <ImagePrediction> PredictImageURL(Guid projectID, string modelName, string url)
        {
            ImageUrl imageUrl = new ImageUrl(url);

            ImagePrediction result = null;

            try
            {
                result = await endpoint.ClassifyImageUrlAsync(projectID, modelName, imageUrl);

                Console.WriteLine($"\nSuccessfully retrieved predictions for image '{url}'.");
            }
            catch (Exception e)
            {
                Console.WriteLine($"\n{e.GetType().Name}: {e.Message} \nCould not get prediction for image '{url}'.");
            }

            // Loop over each prediction and write out the results
            if (result != null)
            {
                foreach (var c in result.Predictions)
                {
                    Console.WriteLine($"\t{c.TagName}: {c.Probability:P1}");
                }
            }

            return(result);
        }