• c# 调用DeepAI


    包括画卡通画,找出2张图片的相似度,电脑做梦的图片生成,利用GTP-2的文本续写。

    using System;
    using System.Collections.Concurrent;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using DeepAI;
    namespace WpfApp7
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
                
            }
    
            void TestCartoon() {
    
                // Ensure your DeepAI.Client NuGet package is up to date: https://www.nuget.org/packages/DeepAI.Client
                // Example posting a image URL:
    
               // using DeepAI; // Add this line to the top of your file
    
                //DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                //StandardApiResponse resp = api.callStandardApi("toonify", new
                //{
                //    image = "YOUR_IMAGE_URL",
                //});
                //Console.Write(api.objectAsJsonString(resp));
    
    
                // Example posting a local image file:
    
              //  using DeepAI; // Add this line to the top of your file
    
                DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                StandardApiResponse resp = api.callStandardApi("toonify", new
                {
                    image = File.OpenRead(@"C:UsersgwangPictures1469162215-how-to-read-faces.jpg"),
                });
    
    
                Console.Write(api.objectAsJsonString(resp));
    
    
    
    
    
    
            }
    
    
            void TestSearchSimil2Image() {
    
    
                //DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                //StandardApiResponse resp = api.callStandardApi("image-similarity", new
                //{
                //    image1 = "YOUR_IMAGE_URL",
                //    image2 = "YOUR_IMAGE_URL",
                //});
                //Console.Write(api.objectAsJsonString(resp));
    
    
                // Example posting a local image file:
    
    
                DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                StandardApiResponse resp = api.callStandardApi("image-similarity", new
                {
                    image1 = File.OpenRead("C:\path\to\your\file.jpg"),
                    image2 = File.OpenRead("C:\path\to\your\file.jpg"),
                });
                Console.Write(api.objectAsJsonString(resp));
    
    
    
            }
    
            void TestDeepDream() {
    
                // Ensure your DeepAI.Client NuGet package is up to date: https://www.nuget.org/packages/DeepAI.Client
                // Example posting a image URL:
    
                //using DeepAI; // Add this line to the top of your file
    
                //DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                //StandardApiResponse resp = api.callStandardApi("deepdream", new
                //{
                //    image = "YOUR_IMAGE_URL",
                //});
                //Console.Write(api.objectAsJsonString(resp));
    
    
                // Example posting a local image file:
    
              //  using DeepAI; // Add this line to the top of your file
    
                DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                StandardApiResponse resp = api.callStandardApi("deepdream", new
                {
                    image = File.OpenRead(@"C:UsersgwangPictures1469162215-how-to-read-faces.jpg"),
                });
                Console.Write(api.objectAsJsonString(resp));
    
    
    
    
    
    
            }
    
    
    
            void TestTextGeneration() {
    
                //https://deepai.org/machine-learning-model/text-generator
                // Text Generation Csharp Examples
                // Ensure your DeepAI.Client NuGet package is up to date: https://www.nuget.org/packages/DeepAI.Client
                // Example posting a text URL:
    
                //  using DeepAI; // Add this line to the top of your file
    
                //DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                //StandardApiResponse resp = api.callStandardApi("text-generator", new
                //{
                //    text = "YOUR_TEXT_URL",
                //});
                //Console.Write(api.objectAsJsonString(resp));
    
    
                // Example posting a local text file:
    
                //using DeepAI; // Add this line to the top of your file
    
                //DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                //StandardApiResponse resp = api.callStandardApi("text-generator", new
                //{
                //    text = File.OpenRead("C:\path\to\your\file.txt"),
                //});
                //Console.Write(api.objectAsJsonString(resp));
    
    
                //// Example directly sending a text string:
    
                //using DeepAI; // Add this line to the top of your file
    
                DeepAI_API api = new DeepAI_API(apiKey: "quickstart-QUdJIGlzIGNvbWluZy4uLi4K");
    
                StandardApiResponse resp = api.callStandardApi("text-generator", new
                {
                    text = "Three days into the Tokyo 2020 Games, 20 sports will be contested today",
                });
                Console.Write(api.objectAsJsonString(resp));
    
    
    
    
    
    
    
    
    
            }
    
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                TestTextGeneration();
               // TestDeepDream ();
            }
    
    
    
    
    
    
    
    
    
        }
    
    
    
    }
    

      

    fffffffffffffffff
    test red font.
  • 相关阅读:
    golang中使用selenium进行爬虫
    SAS关于宏、宏函数、宏变量、data步、proc步和call execute的理解
    golang基础--slice和array
    MySQL基础操作——转
    wamp的手动安装
    SQL索引一步到位
    C语言的随机发牌程序(红桃、黑桃、梅花、方块)
    mysql数据库的导入导出
    比Android更深远的改变世界——谷歌开源人工智能系统TensorFlow文档中文版
    TensorFlow博客翻译——用TensorFlow在云端进行机器学习
  • 原文地址:https://www.cnblogs.com/wgscd/p/15066825.html
Copyright © 2020-2023  润新知