MIT虚拟人AI-generated Characters
一、项目简介
麻省理工学院媒体实验室(MIT Media Lab)的研究人员开源了一个虚拟角色生成工具。该工具结合了面部、手势、语音和动作领域的人工智能模型,可用于创建各种音频和视频输出,一举登上《Nature Machine Intelligence》。
该项目主要用于音频或视频驱动的视频,但不支持文本驱动的视频。主要用于医学视频或其他视频通话,保护个人隐私,视频驱动的视频,让历史或现代名人活起来。
[En]
The project is mainly used for audio or video-driven video, but does not support text-driven video. Mainly used for medical video or other video calls to protect personal privacy video-driven video, to make famous historical or modern people alive.
项目地址:https://github.com/mitmedialab/AI-generated-characters
二、原理简介
- Character :可选择给定模板人物,也可自定义上传人物照片(单张图片)。
- Inputs:可录音,上传音频,以及上传视频。
首先使用 first-order-model 生成动态视频,然后通过 Wav2Lip 生成嘴型。
- 若 Inputs 为音频,则调用案例视频驱动 Character 生成相应的动态视频,然后使用 inference.py 生成嘴型。
- 若 Inputs 为视频,则使用该视频作为驱动生成动态视频,取出视频音轨再合并音视频。
三、代码实现
1. 数据准备
下载 first-order-model & Wav2Lip 以及人物图片。
; 2. 函数定义
- 定义一些通用函数,如选择/上传人的照片,录制/上传音频,上传视频,以及定义相关函数。
[En]
define some general functions, such as selecting / uploading photos of people, recording / uploading audio, uploading videos, and defining related functions.*
- 函数 animate_video 定义了,从first-order-model 项目的 demo.py 文件里导入功能
make_animation,将人物照片和驱动视频缩放至256×256,最后保存动态视频
/content/vidvid.mp4(256×256,30fps)
def animate_video(img_filename, vid_filename): from demo import make_animation from demo import load_checkpoints source_image=resize(source_image, (256, 256))[..., :3] driving_video=[resize(frame, (256, 256))[..., :3] for frame in driving_video] predictions=make_animation(source_image, driving_video, generator, kp_detector, relative=True,adapt_movement_scale=False) imageio.mimsave('/content/vidvid.mp4', [img_as_ubyte(frame) for frame in predictions], fps=30)
3. 人物选择/上传
- 选择模板人物或自定义上传某人的照片(单张图像)。
[En]
Select a template character or customize to upload a photo of a person (a single image).*
- 模板人物:[“Van Gogh”, “Mona Lisa”, “Einstein”, “Lincoln”, “Nietzsche”, “Sokrates”]。
- 自定义上传的字符图像的宽度和高度必须相等。
[En]
Custom uploaded character images must be equal in width and height.*
; 4. 输入驱动选择/上传
有三种方式可以输入驱动:录制、上传音频、上传视频。
[En]
There are three ways to input drivers: * recording * , * uploading audio * , and * uploading video * .
5. 视频生成
首先使用 animate_video 生成动态视频。
- 若前一步骤为音频输入,animate_video 所用的表情驱动为默认案例视频;
- 若前一步骤为视频输入,animate_video 所用的表情驱动则为该视频。
video_driver = "/content/driving_video.mp4"
然后通过 Wav2Lip 生成嘴型。
- 若前一步骤为音频输入,则用 inference.py 生成嘴型。
- 如果上一步是视频输入,请先移除视频轨道,然后再合并音视频。
[En]
if the previous step is video input, remove the video track first and then merge the audio and video.*
参考资料
https://news.mit.edu/2021/ai-generated-characters-for-good-1216
https://www.nature.com/articles/s42256-021-00417-9
https://www.media.mit.edu/articles/characters-for-good-created-by-artificial-intelligence/
Original: https://blog.csdn.net/vivisl/article/details/123483651
Author: vivisl
Title: MIT开源最强虚拟人生成器
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/527089/
转载文章受原作者版权保护。转载请注明原作者出处!