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 ...
随机推荐
- 批处理-- 查询进程,杀进程,启动pythond程序,任务计划程序
@echo off wmic process where caption="python.exe" get processid,commandline | findstr &quo ...
- spring下 -spring整体架构,JdbcTemplate笔记
2,搭建Java Maven项目 我的idea是2024.1.1版本,创建普通Maven项目如下图: 用的jdk8,项目名可以自己改,Archetype选图中的第一个就行,之后点 create. 创建 ...
- [Flink/FlinkCDC] 实践总结:Flink 1.12.6 升级 Flink 1.15.4
Flink DataStream/API 依赖模块的变化 版本变化 flink.version : 1.12.6 => 1.15.4 flink.connector.version : 1.12 ...
- Python请求接口传Null
Python中没有Null,与之对应的是None. {"dog": "keji", "cat": None}
- Lattice、Xilinx FPGA reg初始化赋值问题
一.起因 最近在开发Lattice的一款低功耗FPGA时,遇到了reg初始化复位问题,经过在网上搜寻相关资料整理如下: 二.FPGA中reg的初始化方式 在定义时初始化,例如: reg r_test ...
- 题解:CF1551D1 Domino (easy version)
题解:CF1551D1 Domino (easy version) 分析 题目中保证 \(n\times m\) 为偶数,下面进行分类讨论. 情况一 如果 \(n\) 和 \(m\) 都是偶数,那么可 ...
- C# 开发的环境监测上位机应用
前言 在工业和科研领域,环境监测系统的重要性日益凸显.上位机软件作为环境监测系统的关键组成部分,负责数据采集.处理和显示,对提高监测效率和准确性起着至关重要的作用. 本文将向大家介绍一款用 C# 开发 ...
- Halo 正式开源: 使用可穿戴设备进行开源健康追踪
在飞速发展的可穿戴技术领域,我们正处于一个十字路口.市场上充斥着各式时尚.功能丰富的设备,声称能够彻底改变我们对健康和健身的方式.然而,在这些光鲜的外观和营销宣传背后,隐藏着一个令人担忧的现实:大多数 ...
- 2025年前端面试准备css篇
1.css 盒子模型 css包含了内容(content) ,内边距(padding),边框(border),外边距(margin) 等因素. css 标准盒子模型宽包括:margin+border+p ...
- ECharts 引入中国地图和区域地图
一,引入中国地图 <div id="chinaMap"></div> import china from 'echarts/map/js/china. ...