public static void ProcessImages(List <string> files) { HttpResponseMessage response = null; foreach (var file in files) { Console.WriteLine($"Processing {file} "); Thread.Sleep(1000); response = ImagePrediction.MakePredictionRequestAsync(file.ToString()).Result; if (!(response.IsSuccessStatusCode)) { GenericUtilities.MessageBox(IntPtr.Zero, $"{response.Content.ReadAsStringAsync().Result.ToString()}: {file}", "Bad File Error", 0); Console.WriteLine($"Response:{response.Content.ReadAsStringAsync().Result.ToString()}"); } else { Root predictionResults = GenericUtilities.Deserialize <Root>(response.Content.ReadAsStringAsync().Result.ToString()); Console.WriteLine($"Response:{response.Content.ReadAsStringAsync().Result.ToString()}"); predictionResults.predictions.ForEach(item => Predict(item.probability, item.tagName, file)); Console.WriteLine($"Please View the Output folder for Results."); } } }
static void Main(string[] args) { /*Clear Results From Ouput Folder*/ FileHelpers.ClearResults(); /*Warning Message*/ GenericUtilities.MessageBox(IntPtr.Zero, UserMessage.FileFormatMessage, "File Format", 0); /*Read Image From Input Folder*/ Console.WriteLine("Retrieving Images from the Input Folder......."); /*Get All Image from Input Folder*/ List <string> files = FileHelpers.GetImages(); if (files.Count == 0) { Console.WriteLine("No Images Found. Please upload images in 'Input' Folder:"); } ; /*Process Image*/ ImagePrediction.ProcessImages(files); /*Completion Notification*/ GenericUtilities.MessageBox(IntPtr.Zero, UserMessage.CompletionMessage, "Execution Status", 0); }