C# OnnxRuntime部署LivePortrait实现快速、高质量的人像驱动视频生成

目录
效果
说明
项目
模型信息
代码
下载
效果
LivePortrait实现快速、高质量的人像驱动视频生成
说明
官网地址:https://github.com/KwaiVGI/LivePortrait
代码实现参考:https://github.com/hpc203/liveportrait-onnxrun
模型下载:onnx文件在百度云盘,链接: https://pan.baidu.com/s/13wjBFRHIIyCyBsgnBOKqsw 提取码: si95
项目

模型信息
appearance_feature_extractor.onnx
Model Properties
-------------------------
---------------------------------------------------------------
Inputs
-------------------------
name:img
tensor:Float[1, 3, 256, 256]
---------------------------------------------------------------
Outputs
-------------------------
name:output
tensor:Float[1, 32, 16, 64, 64]
---------------------------------------------------------------
face_2dpose_106_static.onnx
Model Properties
-------------------------
---------------------------------------------------------------
Inputs
-------------------------
name:data
tensor:Float[1, 3, 192, 192]
---------------------------------------------------------------
Outputs
-------------------------
name:fc1
tensor:Float[1, 212]
---------------------------------------------------------------
landmark.onnx
Model Properties
-------------------------
---------------------------------------------------------------
Inputs
-------------------------
name:input
tensor:Float[1, 3, 224, 224]
---------------------------------------------------------------
Outputs
-------------------------
name:output
tensor:Float[1, 214]
name:853
tensor:Float[1, 262]
name:856
tensor:Float[1, 406]
---------------------------------------------------------------
motion_extractor.onnx
Model Properties
-------------------------
---------------------------------------------------------------
Inputs
-------------------------
name:img
tensor:Float[1, 3, 256, 256]
---------------------------------------------------------------
Outputs
-------------------------
name:pitch
tensor:Float[1, 66]
name:yaw
tensor:Float[1, 66]
name:roll
tensor:Float[1, 66]
name:t
tensor:Float[1, 3]
name:exp
tensor:Float[1, 63]
name:scale
tensor:Float[1, 1]
name:kp
tensor:Float[1, 63]
---------------------------------------------------------------
retinaface_det_static.onnx
Model Properties
-------------------------
---------------------------------------------------------------
Inputs
-------------------------
name:input.1
tensor:Float[1, 3, 512, 512]
---------------------------------------------------------------
Outputs
-------------------------
name:448
tensor:Float[8192, 1]
name:471
tensor:Float[2048, 1]
name:494
tensor:Float[512, 1]
name:451
tensor:Float[8192, 4]
name:474
tensor:Float[2048, 4]
name:497
tensor:Float[512, 4]
name:454
tensor:Float[8192, 10]
name:477
tensor:Float[2048, 10]
name:500
tensor:Float[512, 10]
---------------------------------------------------------------
stitching.onnx
Model Properties
-------------------------
---------------------------------------------------------------
Inputs
-------------------------
name:input
tensor:Float[1, 126]
---------------------------------------------------------------
Outputs
-------------------------
name:output
tensor:Float[1, 65]
---------------------------------------------------------------
warping_spade.onnx
Inputs
feature_3d
name: feature_3d
tensor: float32[1,32,16,64,64]
kp_driving
name: kp_driving
tensor: float32[1,21,3]
kp_source
name: kp_source
tensor: float32[1,21,3]
Outputs
name: out
tensor: float32[1,3,512,512]
代码
using LivePortraitSharp;
using OpenCvSharp;
using System;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FaceFusionSharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string fileFilter = "图片|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
string startupPath = "";
string source_path = "";
string video_path = "";
string videoFilter = "视频|*.mp4;*.avi;";
LivePortraitPipeline livePortraitPipeline;
/// <summary>
/// 选择静态图像
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = fileFilter;
ofd.InitialDirectory = Application.StartupPath + "\\test";
if (ofd.ShowDialog() != DialogResult.OK) return;
pictureBox1.Image = null;
source_path = ofd.FileName;
pictureBox1.Image = new Bitmap(source_path);
}
/// <summary>
/// 驱动视频
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = videoFilter;
ofd.InitialDirectory = Application.StartupPath + "\\test\\driving";
if (ofd.ShowDialog() != DialogResult.OK) return;
video_path = ofd.FileName;
textBox1.Text = video_path;
//读取第一帧显示
VideoCapture vcapture = new VideoCapture(video_path);
if (!vcapture.IsOpened())
{
MessageBox.Show("打开视频文件失败");
video_path = "";
return;
}
Mat frame = new Mat();
if (vcapture.Read(frame))
{
pictureBox2.Image = new Bitmap(frame.ToMemoryStream());
frame.Dispose();
}
else
{
MessageBox.Show("读取视频文件失败");
video_path = "";
}
}
private void button1_Click(object sender, EventArgs e)
{
if (source_path == "")
{
MessageBox.Show("请选择静态图");
return;
}
if (video_path == "")
{
MessageBox.Show("请选择驱动视频");
return;
}
bool saveDetVideo = false;
if (checkBox1.Checked)
{
saveDetVideo = true;
}
else
{
saveDetVideo = false;
}
button1.Enabled = false;
textBox1.Text = "";
Application.DoEvents();
Task.Factory.StartNew(() =>
{
string msg;
if (!livePortraitPipeline.execute(source_path, video_path, saveDetVideo, out msg))
{
this.Invoke(new Action(() =>
{
button1.Enabled = true;
textBox1.Text = msg;
}));
}
else
{
this.Invoke(new Action(() =>
{
button1.Enabled = true;
textBox1.Text = "执行完成!";
}));
}
}, TaskCreationOptions.LongRunning);
}
private void Form1_Load(object sender, EventArgs e)
{
livePortraitPipeline = new LivePortraitPipeline();
source_path = "test\\0.jpg";
pictureBox1.Image = new Bitmap(source_path);
video_path = "test\\driving\\d0.mp4";
//读取第一帧显示
VideoCapture vcapture = new VideoCapture(video_path);
if (!vcapture.IsOpened())
{
video_path = "";
return;
}
Mat frame = new Mat();
if (vcapture.Read(frame))
{
pictureBox2.Image = new Bitmap(frame.ToMemoryStream());
frame.Dispose();
}
else
{
video_path = "";
}
}
}
}
using LivePortraitSharp;
using OpenCvSharp;
using System;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;namespace FaceFusionSharp
{public partial class Form1 : Form{public Form1(){InitializeComponent();}string fileFilter = "图片|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";string startupPath = "";string source_path = "";string video_path = "";string videoFilter = "视频|*.mp4;*.avi;";LivePortraitPipeline livePortraitPipeline;/// <summary>/// 选择静态图像/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button2_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;ofd.InitialDirectory = Application.StartupPath + "\\test";if (ofd.ShowDialog() != DialogResult.OK) return;pictureBox1.Image = null;source_path = ofd.FileName;pictureBox1.Image = new Bitmap(source_path);}/// <summary>/// 驱动视频/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button3_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = videoFilter;ofd.InitialDirectory = Application.StartupPath + "\\test\\driving";if (ofd.ShowDialog() != DialogResult.OK) return;video_path = ofd.FileName;textBox1.Text = video_path;//读取第一帧显示VideoCapture vcapture = new VideoCapture(video_path);if (!vcapture.IsOpened()){MessageBox.Show("打开视频文件失败");video_path = "";return;}Mat frame = new Mat();if (vcapture.Read(frame)){pictureBox2.Image = new Bitmap(frame.ToMemoryStream());frame.Dispose();}else{MessageBox.Show("读取视频文件失败");video_path = "";}}private void button1_Click(object sender, EventArgs e){if (source_path == ""){MessageBox.Show("请选择静态图");return;}if (video_path == ""){MessageBox.Show("请选择驱动视频");return;}bool saveDetVideo = false;if (checkBox1.Checked){saveDetVideo = true;}else{saveDetVideo = false;}button1.Enabled = false;textBox1.Text = "";Application.DoEvents();Task.Factory.StartNew(() =>{string msg;if (!livePortraitPipeline.execute(source_path, video_path, saveDetVideo, out msg)){this.Invoke(new Action(() =>{button1.Enabled = true;textBox1.Text = msg;}));}else{this.Invoke(new Action(() =>{button1.Enabled = true;textBox1.Text = "执行完成!";}));}}, TaskCreationOptions.LongRunning);}private void Form1_Load(object sender, EventArgs e){livePortraitPipeline = new LivePortraitPipeline();source_path = "test\\0.jpg";pictureBox1.Image = new Bitmap(source_path);video_path = "test\\driving\\d0.mp4";//读取第一帧显示VideoCapture vcapture = new VideoCapture(video_path);if (!vcapture.IsOpened()){video_path = "";return;}Mat frame = new Mat();if (vcapture.Read(frame)){pictureBox2.Image = new Bitmap(frame.ToMemoryStream());frame.Dispose();}else{video_path = "";}}}
}
下载
源码下载
相关文章:
C# OnnxRuntime部署LivePortrait实现快速、高质量的人像驱动视频生成
目录 效果 说明 项目 模型信息 代码 下载 效果 LivePortrait实现快速、高质量的人像驱动视频生成 说明 官网地址:https://github.com/KwaiVGI/LivePortrait 代码实现参考:https://github.com/hpc203/liveportrait-onnxrun 模型下载:…...
Spring boot框架指南
1. Spring Boot 概述 1.1 定义与起源 Spring Boot是一种基于Spring框架的开源框架,旨在简化Spring应用程序的创建和开发过程。它通过提供一系列默认配置和自动配置功能,减少了开发者在配置上的工作量,使得快速搭建生产级别的Spring应用程序…...
数据结构--树与二叉树
数据结构分类 集合 线性结构(一对一) 树形结构(一对多) 图结构(多对多) 数据结构三要素 1、逻辑结构 2、数据的运算 3、存储结构(物理结构) 树的概念 树的分类 满二叉树和完全二叉树 二叉排序树 平衡二叉树 二叉树分类总结 二叉树的存储结构 …...
C#项目实战经验——计时方法总结
前言 我们在开发C#程序的过程中经常需要计算某段程序执行的时间,比如调用的某个算法的时间,这时候我们就需要利用计时工具,本文就是详细介绍在C#中我们常用哪些计时工具。 1、计时方法—StopWatch 在C#中我们可以利用Stopwatch这个类来实现…...
电子盖章软件哪个好|盖章软件
在选择电子盖章软件时,需要考虑多个因素,包括软件的功能、安全性、易用性、兼容性以及成本等。以下是根据当前市场情况推荐的一些优秀的电子盖章软件: e章宝: 功能丰富:e章宝是国内领先的电子盖章系统,功能…...
ThreejsWebGPU运动残影demo
功能点 实例化SkinnedMesh 修改NodeMaterial着色器 节点材质系统 shader 语言 使用uniform和attribute 中合其他几篇博客中的内容 代码仓库 克隆后需要放到three源码同级别目录下 运行 three源码部分不在git仓库中(太大了) 使用vscode的live-server启动后访问 http://127.0.0.…...
HttpSession常用方法
1.HttpSession常用方法 是在Java Servlet中用来管理会话状态的重要接口,它提供了一种在多个请求或页面之间存储用户特定信息的方式。以下是一些 HttpSession 常用的方法和用法: 获取会话对象: HttpSession session request.getSession();…...
【JavaEE初阶】文件操作和IO
目录 🌴认识文件 🚩树型结构组织和目录 🚩文件路径(Path) 🚩 文件分类 🎍Java 中操作文件 🚩 File 概述: 📌属性 📌构造方法 Ὄ…...
存储器芯片的基本原理
目录 1.存储元 1.1栅极电容 1.2双稳态触发器 2.存储单元 3.存储体 4.存储器 5.容量计算 6.寻址 1.存储元 1.1栅极电容 给MOS管一个阈值电压(5v)就能够导电,若是不给那么就是一个绝缘体不会导电。 读出二进制原理: 通常…...
前端实习手记(7):立秋快乐
这周相比上周感觉挺好的哈哈哈,可能只有自己感觉蛮好的,旁边师父忙的飞起了要,不仅赶工作还要回答我乱七八糟的问题(心疼一秒)。这周也是立秋&七夕咯,立秋快乐哇家人们(虽然还是很热嘛&…...
感恩放下,笑对人生,在人生的长河中,每一天都是独特的篇章,或顺心如意,或充满挑战
在人生的长河中,每一天都是独特的篇章,或顺心如意,或充满挑战。然而,无论今日的经历如何,我们都应怀着感恩与放下的心态,因为人生的旅程远不止这短暂的一天,明天依然充满希望,等待我们继续努力前行。 生活,犹如一场变幻莫测的舞台剧,顺心之时,我们仿佛置身于温暖的…...
URLSession之初窥门径
NSURLSession 于 2013 年随 iOS 7 的发布一起面世,苹果将其定位为 NSURLConnection 的替代者。我们使用最广泛的第三方框架如 AFNetworking 和 SDWebImage 的最新版也都已经全面切换至 NSURLSession。 NSURLSession 不仅仅指代同名类 NSURLSession,它还…...
ios创建控制器的3种方法实现页面跳转
ios遵守mvc设计模式,下面介绍创建控制器viewcontroller的几种方法,来实现页面的跳转 1.纯代码创建 // // AppDelegate.m // study2024 // // Created by zhifei zhu on 2024/8/7. //#import "AppDelegate.h" #import "MyViewContro…...
Android逆向题解-boomshakalaka-3-难度5
这个app 是一个cocos游戏,没有用脚本实现,纯c实现。 题目描述:play the game, get the highest score 题目要求是玩游戏得到最高分就可以得到flag,是写到配置文件的,初始flag值看着是base编码的。 核心代码在so里面的ControlLay…...
Linux(Ubuntu 22.04)系统中固定串口
Linux(Ubuntu 22.04)系统中固定串口 文章目录 前言正文查看linux串口信息修改udev固化串口校验是否修改完成 注意 前言 在Linux系统中固定串口(通常指的是串行通信接口,如/dev/ttyS0或/dev/ttyUSB0)的原因有几个方面&…...
LeetCode - 209 - 长度最小的子数组
力扣209题 题目描述:长度最小的子数组 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 子数组 [numsl, numsl1, ..., numsr-1, numsr] ,并返回其长度**。**如果不存在符合条件的子数组&…...
探索空间计算与VR中的手势跟踪新纪元:XHand框架详解
在虚拟现实(VR)和扩展现实(XR)技术日新月异的今天,手势跟踪作为实现沉浸式体验的关键技术之一,正逐步从概念走向成熟。今天,我们将深入探索一个创新的框架——XHand,它以其卓越的性能和先进的技术亮点,为空间计算与VR领域的手势跟踪带来了全新的解决方案。 XHand框架…...
leetcode + 项目复习
上午 Leetcode算法 参考文章——代码随想录 1. KMP 概念 主要应用 字符串匹配 主要思想 根据之前匹配的信息,当发现字符串不匹配时,避免从头开始匹配。 什么是前缀表(next数组、prefix) 是用来回退的,当文本串和…...
树莓派4/5:设置apt、pip、conda首选清华镜像源
一、教程简介 在中国大陆地区,使用清华镜像源可以显著缩短资源下载时间。 本教程介绍如何将清华镜像源设置为树莓派的apt、pip、conda下载的首选项(默认项)。其中,apt和pip为树莓派系统自带,conda则需要安装miniforg…...
NoSQL 之Redis集群模式
目录 案例概述 redis工作模式 主从模式 哨兵模式 redis cluster模式 Redis集群介绍 Redis集群的优势 Redis集群的实现方法 Redis-Cluster数据分片 Redis-Cluster的主从复制模型 Redis集群部署 案例部署 安装redis 检查redis的状态 修改配置文件 重启启动redis服…...
损失2万块买来的教训:出海独立站如何从“裸奔”走向云原生高可用架构?
上个月,我帮一位做跨境宠物用品的老板做了一次紧急的架构救火。起因是他发现网站在正常投放 Google Ads 的情况下,突然大面积访问超时。我介入排查后发现,服务器 CPU 已经飙升到 100%,Nginx 日志里密密麻麻全是针对 /api/checkout…...
ESP8266对接GLPi的轻量级IoT工单库
1. 项目概述 glpi_esp8266 是一款专为 ESP8266 系列 Wi-Fi 微控制器设计的轻量级 C 库,其核心使命是构建物联网终端设备与企业级 IT 服务管理(ITSM)平台 GLPi 之间的标准化通信桥梁。该库并非直接对接 GLPi 的 REST API,而是通过…...
OpenClaw长期运行方案:Phi-3-mini-128k-instruct服务的稳定性保障
OpenClaw长期运行方案:Phi-3-mini-128k-instruct服务的稳定性保障 1. 为什么需要长期运行方案? 去年冬天的一个深夜,我被手机警报惊醒——部署在家庭服务器的OpenClaw服务崩溃了。当时正在运行的自动化周报生成任务因此中断,导致…...
拯救眼瞎程序员:用Vim同时高亮10+关键词的骚操作(含配色方案)
拯救眼瞎程序员:Vim多关键词高亮实战指南 深夜两点,你盯着满屏的分布式系统错误日志,十几个微服务模块的报错信息交织在一起,像一团乱麻。关键词搜索只能一个个来,眼睛都快看瞎了——这场景是不是很熟悉?今…...
OpenClaw内存优化:Qwen3-32B在24G显存下的高效利用技巧
OpenClaw内存优化:Qwen3-32B在24G显存下的高效利用技巧 1. 为什么需要关注显存优化? 当我第一次在RTX 4090D上部署Qwen3-32B模型时,本以为24GB显存足够应对各种任务。但实际运行OpenClaw后,很快就遇到了显存溢出的问题——一个简…...
OpenClaw模型切换指南:Kimi-VL-A3B-Thinking与其他多模态模型对比测试
OpenClaw模型切换指南:Kimi-VL-A3B-Thinking与其他多模态模型对比测试 1. 为什么需要模型对比测试 在OpenClaw的实际使用中,我发现多模态模型的选择直接影响自动化任务的成败。上个月尝试用AI助手处理一份包含图表和文字的调研报告时,不同模…...
APDS9999传感器驱动开发:寄存器配置、中断与FreeRTOS集成
1. Arduino_APDS9999 库深度解析:面向嵌入式工程师的环境光、色彩与接近度传感器驱动开发指南APDS9999 是 Broadcom(原 Avago)推出的高集成度光学传感器芯片,集环境光感知(ALS)、RGB 色彩识别(C…...
UID生成器终极路线图:未来版本将带来的7大突破性功能
UID生成器终极路线图:未来版本将带来的7大突破性功能 【免费下载链接】uid-generator UniqueID generator 项目地址: https://gitcode.com/gh_mirrors/ui/uid-generator UID生成器是分布式系统中确保数据唯一性的核心组件,GitHub加速计划下的ui/u…...
5步搞定微信聊天记录永久保存:WechatBakTool全面解析
5步搞定微信聊天记录永久保存:WechatBakTool全面解析 【免费下载链接】WechatBakTool 基于C#的微信PC版聊天记录备份工具,提供图形界面,解密微信数据库并导出聊天记录。 项目地址: https://gitcode.com/gh_mirrors/we/WechatBakTool 在…...
Docker 完全指南:从入门到生产级实践
一篇长文,彻底搞懂 Docker、Compose 与 Swarm容器技术已经成为现代软件交付的基石。无论是开发者、运维工程师,还是架构师,掌握 Docker 都是必备技能。本文将系统介绍 Docker 的核心概念、多容器编排、集群管理,以及从开发到生产的…...
