예제 #1
0
        static void Main(string[] args)
        {
            ClarifaiClient c          = new ClarifaiClient("Wads5t98mMepkTuQFLbQvdYBPH0xIBz_7KqdhMIp", "Igqe-qov2dbcS8EQDHoI8DxRR0PiEN3y3Tj4Vu2m");
            var            task_r_ntf = c.GenerateToken();

            task_r_ntf.ConfigureAwait(true)
            .GetAwaiter()
            .OnCompleted(() =>
            {
                try
                {
                    if (task_r_ntf.IsCompleted)
                    {
                        if (task_r_ntf.Status == TaskStatus.RanToCompletion)
                        {
                            Task.Run(async() =>
                            {
                                var p = await c.PredictByFolderPath(@"C:\My Files\work\Ashraf\LogoDetection\test-positive");
                                Console.WriteLine(p.Status.Code);
                                Console.WriteLine(p.Status.Description);
                                if (p.Status.Code == 10000)
                                {
                                    foreach (var d in p.Outputs)
                                    {
                                        Console.WriteLine(d.Data.Concepts[0].ImageName);
                                        Console.WriteLine(d.Data.Concepts[0].Prediction);
                                    }
                                }
                            });
                        }
                        else
                        {
                            Console.WriteLine("completed with errors " + task_r_ntf.Status);
                            if (task_r_ntf.Exception != null)
                            {
                                if (task_r_ntf.Exception.InnerException != null)
                                {
                                    Console.WriteLine("Excepion : " + task_r_ntf.Exception.Message + " - Details : " + task_r_ntf.Exception.InnerException.Message);
                                }
                                else
                                {
                                    Console.WriteLine("Excepion : " + task_r_ntf.Exception.Message);
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("serving notifications failed");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Excepion : " + e.Message);
                }
            });
            Console.ReadLine();
        }
예제 #2
0
        static void Main2(string[] args)
        {
            ClarifaiClient c          = new ClarifaiClient("JU5zeSv_YJQG5THfAHwUvuD_oDFI13PqFKTXjKoS", "GQynbkt8D5mQcXUlZhcPqw7SAyQbTjj3WC1SYpkM");
            var            task_r_ntf = c.GenerateToken();

            task_r_ntf.ConfigureAwait(true)
            .GetAwaiter()
            .OnCompleted(() =>
            {
                try
                {
                    if (task_r_ntf.IsCompleted)
                    {
                        if (task_r_ntf.Status == TaskStatus.RanToCompletion)
                        {
                            Task.Run(async() =>
                            {
                                var p = await c.PredictByImgURL(new List <string> {
                                    "https://samples.clarifai.com/metro-north.jpg"
                                });
                                Console.WriteLine(p.Status.Code);
                                Console.WriteLine(p.Status.Description);
                            });
                        }
                        else
                        {
                            Console.WriteLine("completed with errors " + task_r_ntf.Status);
                            if (task_r_ntf.Exception != null)
                            {
                                if (task_r_ntf.Exception.InnerException != null)
                                {
                                    Console.WriteLine("Excepion : " + task_r_ntf.Exception.Message + " - Details : " + task_r_ntf.Exception.InnerException.Message);
                                }
                                else
                                {
                                    Console.WriteLine("Excepion : " + task_r_ntf.Exception.Message);
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("serving notifications failed");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Excepion : " + e.Message);
                }
            });
            Console.ReadLine();
        }