Exemplo n.º 1
0
        public string TransferFromUrl(string contentUrl, string styleUrl)
        {
            DeepAI_API api = new DeepAI_API(_configuration.GetValue <string>("DeepAISettings:ApiKey"));

            StandardApiResponse resp = api.callStandardApi("fast-style-transfer", new
            {
                content = contentUrl,
                style   = styleUrl
            });

            return(api.objectAsJsonString(resp));
        }
Exemplo n.º 2
0
        public string CompararImagen()
        {
            DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");

            StandardApiResponse resp = api.callStandardApi("image-similarity", new
            {
                image1 = File.OpenRead(@"C:\Users\juan.jose.agudelo\source\repos\DesparcheBackend\DesparcheBackend\temp\imagen1.jpeg"),
                image2 = File.OpenRead(@"C:\Users\juan.jose.agudelo\source\repos\DesparcheBackend\DesparcheBackend\temp\imagen2.jpeg"),
            });
            string diferencia = api.objectAsJsonString(resp.output);

            return(diferencia);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            DeepAI_API          api  = new DeepAI_API(apiKey: "c374d52f-84ce-46a6-8a4f-598ba5b9e988");
            StandardApiResponse resp = api.callStandardApi("nsfw-detector", new
            {
                image = File.OpenRead(@"C:\Users\www\Desktop\1\sasha2.jpg"),
            });

            //  File.WriteAllText("file.txt", api.objectAsJsonString(resp));

            Console.WriteLine(api.objectAsJsonString(resp));
            Console.ReadLine();
        }
Exemplo n.º 4
0
        public string TransferFromFile(string contentPath, string stylePath)
        {
            DeepAI_API api = new DeepAI_API(_configuration.GetValue <string>("DeepAISettings:ApiKey"));

            using var contentStream = File.OpenRead(contentPath);
            using var styleStream   = File.OpenRead(stylePath);

            StandardApiResponse resp = api.callStandardApi("fast-style-transfer", new
            {
                content = contentStream,
                style   = styleStream
            });

            return(api.objectAsJsonString(resp));
        }
Exemplo n.º 5
0
        public static int GetSimilarScore(string localFile, string hostFileUrl)
        {
            api = new DeepAI_API(apiKey: "ed6a1b7c-f7ab-428f-997f-474ea0c1e1dc");
            if (api == null)
            {
                throw new InvalidOperationException("The API Ket did not work");
            }

            // Ensure your DeepAI.Client NuGet package is up to date: https://www.nuget.org/packages/DeepAI.Client
            StandardApiResponse resp = api.callStandardApi("image-similarity", new
            {
                image1 = File.OpenRead(localFile),  // local file
                image2 = hostFileUrl,               // host file
            });

            var re = JsonConvert.DeserializeObject <ImageSimilarityResponse>(api.objectAsJsonString(resp.output));

            return(re.distance);
        }
Exemplo n.º 6
0
        private void btnKarsilastir_Click(object sender, EventArgs e)
        {
            DeepAI_API api = new DeepAI_API(apiKey: "df10d4f7-7797-4030-b0f6-e5243e869c91");
            string     a   = resim1.FileName;
            string     a2  = resim2.FileName;

            StandardApiResponse resp = api.callStandardApi("image-similarity", new
            {
                //image1 = resim1.FileName.ToString(),
                //image2 = resim2.FileName.ToString(),
                image1 = File.OpenRead(a),
                image2 = File.OpenRead(a2),

                //File.OpenRead("C:\\path\\to\\your\\file.jpg"),
            });
            string gelen = api.objectAsJsonString(resp.output);

            lblSonuc.Text = api.objectAsJsonString(resp.output).ToString();
        }
Exemplo n.º 7
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.CheckFileExists && isFileSelected)
            {
                pictureBox1.Visible = false;
                MessageBox.Show("Please wait a few seconds! Your file is being uploaded and upscaled.");
                DeepAI_API api = new DeepAI_API(apiKey: "Enter your DeepAI Licencekey here.");

                StandardApiResponse resp = api.callStandardApi("torch-srgan", new {
                    image = File.OpenRead(openFileDialog1.FileName),
                });
                dynamic d = JObject.Parse(api.objectAsJsonString(resp));
                Console.Write(d.output_url);

                pictureBox1.ImageLocation = d.output_url;
                pictureBox1.Visible       = true;

                MessageBox.Show("Your file has been upscaled and is now available in the output folder.");
            }
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            //args = new string[] { "-k=983cc50b-cd6f-48ad-85c9-b3aae4f7f26f ", "-is=SM-0003.www.ebay.co.uk.311858508219.jpg", "-is=SM-0016.www.ebay.co.uk.123752402471.jpg", "-is=SM-0016_.www.ebay.co.uk.183994826038.jpg"};
            bool   show_help = false;
            string apiKey    = "";

            List <string> images = new List <string>();

            DeepAI_API m_DeepAI_API = null;

            var p = new OptionSet()
            {
                { "k|key=", "DeepAI api key", v => apiKey = v },
                { "r", "Use remote files with url", v => useLocalFiles = v == null },
                { "is|imgsource=", "Images to compare", (string v) => images.Add(v) },
                { "v", "increase debug message verbosity", v => { if (v != null)
                                                                  {
                                                                      ++verbosity;
                                                                  }
                  } },
                { "h|help", "show this message and exit", v => show_help = v != null }
            };

            List <string> extra;

            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("daic: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `daic --help' for more information.");
                return;
            }

            if (show_help)
            {
                ShowHelp(p);
                return;
            }

            if (extra.Count > 0)
            {
            }
            else
            {
            }

            if (images.Count < 2)
            {
                Console.WriteLine("Images count must be lager that 2.");
                Console.WriteLine("Try `daic --help' for more information.");
                return;
            }

            if (string.IsNullOrEmpty(apiKey))
            {
                Console.WriteLine("Deep Api key not specified!");
                Console.WriteLine("Try `daic --help' for more information.");
                return;
            }

            var results = new List <StandardApiResponse>();

            m_DeepAI_API = new DeepAI_API(apiKey: apiKey);

            var comparsionCount = images.Count - 1;
            var firstImage      = images[0];

            for (int i = 1; i <= comparsionCount; i++)
            {
                var opt = BuildInputOptions(firstImage, images[i]);
                StandardApiResponse resp = m_DeepAI_API.callStandardApi("image-similarity", opt);
                results.Add(resp);
            }

            var distances = new List <int>();

            foreach (var result in results)
            {
                Newtonsoft.Json.Linq.JObject distance = (Newtonsoft.Json.Linq.JObject)result.output;
                var value = JObjectToInt(distance);
                distances.Add(value);
            }
            var outputStr = string.Join(";", distances.ToArray());

            Console.Write(outputStr);
            //Console.ReadKey();


            /*
             * // Ensure your DeepAI.Client NuGet package is up to date: https://www.nuget.org/packages/DeepAI.Client
             * DeepAI_API api = new DeepAI_API(apiKey: "983cc50b-cd6f-48ad-85c9-b3aae4f7f26f");
             * StandardApiResponse resp = api.callStandardApi("image-similarity", new
             * {
             *  image1 = "YOUR_IMAGE_URL",
             *  image2 = "YOUR_IMAGE_URL",
             * });
             * Console.Write(api.objectAsJsonString(resp));
             */
        }