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的更多相关文章
- 黑马毕向东Java基础知识总结
Java基础知识总结(超级经典) 转自:百度文库 黑马毕向东JAVA基础总结笔记 侵删! 写代码: 1,明确需求.我要做什么? 2,分析思路.我要怎么做?1,2,3. 3,确定步骤.每一个思路部 ...
- 《果壳中的C# C# 5.0 权威指南》 - 学习笔记
<果壳中的C# C# 5.0 权威指南> ========== ========== ==========[作者] (美) Joseph Albahari (美) Ben Albahari ...
- JS调用Android、Ios原生控件
在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...
- 【原创分享·支付宝支付】HBuilder打包APP调用支付宝客户端支付
前言 最近有点空余时间,所以,就研究了一下APP支付.前面很早就搞完APP的微信支付了,但是由于时间上和应用上的情况,支付宝一直没空去研究.然后等我空了的时候,发现支付宝居然升级了支付逻辑,虽然目前还 ...
- 操作系统篇-调用门与特权级(CPL、DPL和RPL)
|| 版权声明:本文为博主原创文章,未经博主允许不得转载. 一.前言 在前两篇文章(<操作系统篇-浅谈实模式与保护模式>和<操作系统篇-分段机制与GDT|LDT>)中,我们提到 ...
- 架构设计:远程调用服务架构设计及zookeeper技术详解(下篇)
一.下篇开头的废话 终于开写下篇了,这也是我写远程调用框架的第三篇文章,前两篇都被博客园作为[编辑推荐]的文章,很兴奋哦,嘿嘿~~~~,本人是个很臭美的人,一定得要截图为证: 今天是2014年的第一天 ...
- django server之间通过remote user 相互调用
首先,场景是这样的:存在两个django web应用,并且两个应用存在一定的联系.某些情况下彼此需要获取对方的数据. 但是我们的应用肯经都会有对应的鉴权机制.不会让人家随随便便就访问的对吧.好比上车要 ...
- 调用AJAX做登陆和注册
先建立一个页面来检测一下我们建立的用户名能不能用,看一下有没有已经存在的用户名吗 可以通过ajax提示一下 $("#uid").blur(function(){ //取用户名 va ...
- nodejs进阶(2)—函数模块调用
函数调用 1. 文件内普通函数调用 创建一个js文件命名为2_callFunction.js,其中定义一个函数fun1,向返回对象输出了一段字符串“你好,我是fun1”. //------------ ...
- 【初学python】使用python调用monkey测试
目前公司主要开发安卓平台的APP,平时测试经常需要使用monkey测试,所以尝试了下用python调用monkey,代码如下: import os apk = {'j': 'com.***.test1 ...
随机推荐
- 2024御网线上Pwn方向题解
ASM Checksec检查保护 基本上保护都关闭了 64位ida逆向 程序只有一段,并且返回地址就是输入的数据,看起来就是srop了,找一下可以用的gadget 通过异或清空rax值,然后通过异或e ...
- 🎈Fluent Editor 富文本开源2个月的总结:增加格式刷、截屏、TypeScript 类型声明等新特性
你好,我是 Kagol,个人公众号:前端开源星球. Fluent Editor 是一个基于 Quill 2.0 的富文本编辑器,在 Quill 基础上扩展了丰富的模块和格式,框架无关. 功能强大.开箱 ...
- Pcb-Merging:无需训练的多任务模型合并方案 | NeurIPS'24
来源:晓飞的算法工程笔记 公众号,转载请注明出处 论文: Parameter Competition Balancing for Model Merging 论文地址:https://arxiv.or ...
- MySQL原理简介—1.SQL的执行流程
大纲(2426字) 1.MySQL驱动的作用 2.Java系统中的数据库连接池的作用 3.MySQL中的数据库连接池的作用 4.网络连接必须让线程来处理 5.SQL接口会负责处理接收到的SQL语句 6 ...
- Vulhub WebLogic漏洞复现
目录 前言 任意文件上传漏洞(CVE-2018-2894) 管理控制台未授权RCE漏洞(CVE-2020-14882 & CVE-2020-14883) 未授权RCE漏洞(CVE-2023-2 ...
- 在 ASP.NET Core 中创建 gRPC 客户端和服务器
前言 gRPC 是一种高性能.开源的远程过程调用(RPC)框架,它基于 Protocol Buffers(protobuf)定义服务,并使用 HTTP/2 协议进行通信. 新建项目 新建解决方案Grp ...
- linux 查看进程的bin文件所在路径
1.获取进程pid ps aux |grep nginx|grep master|grep -v grep|awk '{print $2}' 2.根据进程pid 获取 bin路径 方法a pwdx p ...
- Java网络爬虫的实现
记得在刚找工作时,隔壁的一位同学在面试时豪言壮语曾实现过网络爬虫,当时的景仰之情犹如滔滔江水连绵不绝.后来,在做图片搜索时,需要大量的测试图片,因此萌生了从Amazon中爬取图书封面图片的想法,从网上 ...
- 基于Docker搭建PHP开发环境
Docker 是这几年非常火的一项技术,作为一名软件开发人员,应该及时的接触和掌握. 镜像加速: 可以在阿里云上免费的获取,然后进行配置即可使用.阿里云 Docker 加速器,没有阿里云账号注册一个即 ...
- 本地环境搭建Virtualbox+Vagrant
环境准备 virtualbox是免费,不必要费劲去找破解,下载就可以用. 使用virtualbox每次安装虚拟机,需要你去下载iso,然后设置虚拟机硬件配置,使用iso创建虚拟器.一系列的手工操作,如 ...