c# 调用DeepAI
2021/7/27 17:05:45
本文主要是介绍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:\Users\gwang\Pictures\1469162215-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:\Users\gwang\Pictures\1469162215-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 (); } } }
这篇关于c# 调用DeepAI的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#
- 2024-01-24Advanced .Net Debugging 1:你必须知道的调试工具
- 2024-01-24.NET集成IdGenerator生成分布式全局唯一ID