10

太强了,头发丝完整保留!华盛顿大学研究员开源的实时视频抠图工具

 3 years ago
source link: https://zhuanlan.zhihu.com/p/343118376
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

【导语】:一种实时、高分辨率的背景替换技术,保留头发细节,效果惊人。

简介

BackgroundMattingV2 是华盛顿大学几位研究员提出的一种实时、高分辨率的背景替换技术,是基于 Python 实现的。在 4K 分辨率下,该技术的运行速度为 30fps,在现代 GPU 上,高清的运行速度为 60fps。该技术是基于背景抠图,其中一帧额外的背景被捕获并用于恢复前景蒙版和前景层。

6VZbmmf.gif!mobile

简单使用

项目源码地址

https:// github.com/PeterL1n/Bac kgroundMattingV2

项目依赖库

jeAZbiR.jpg!mobile

开发者提供的一些文件资源(国内需木弟子):

1、下载模型/权重文件 https:// drive.google.com/drive/ folders/1cbetlrKREitIgjnIikG1HdM4x72FtgBh?usp=sharing

2、用于练习的视频和图片文件

HD视频: https:// drive.google.com/drive/ folders/1j3BMrRFhFpfzJAe6P2WDtfanoeSCLPiq

4K视频和图片:

https:// drive.google.com/drive/ folders/16H6Vz3294J-DEzauw06j4IUARRqYGgRD?usp=sharing

项目demo脚本介绍

  • inference_images.py:用于图片中的背景替换,用法如下:
python inference_images.py

--model-type mattingrefine

--model-backbone resnet50

--model-backbone-scale 0.25

--model-refine-mode sampling

--model-refine-sample-pixels 80000

--model-checkpoint "PATH_TO_CHECKPOINT"

--images-src "PATH_TO_IMAGES_SRC_DIR"

--images-bgr "PATH_TO_IMAGES_BGR_DIR"

--output-dir "PATH_TO_OUTPUT_DIR"

--output-type com fgr pha
  • inference_video.py: 用于视频中的背景替换,用法如下:
python inference_video.py 

--model-type mattingrefine 

--model-backbone resnet50 

--model-backbone-scale 0.25 

--model-refine-mode sampling 

--model-refine-sample-pixels 80000 

--model-checkpoint "PATH_TO_CHECKPOINT" 

--video-src "PATH_TO_VIDEO_SRC" 

--video-bgr "PATH_TO_VIDEO_BGR" 

--video-resize 1920 1080 

--output-dir "PATH_TO_OUTPUT_DIR" 

--output-type com fgr pha err ref
  • inference_webcam.py:用于使用网络摄像头下的交互式背景替换,用法如下:
python inference_webcam.py 

--model-type mattingrefine 

--model-backbone resnet50 

--model-checkpoint "PATH_TO_CHECKPOINT" 

--resolution 1280 720

虚拟摄像机

开发者提供了一个应用插件,通过他们的模型将网络摄像头视频输送到一个虚拟摄像头。该插件仅适用于Linux系统,可以在Zoom视频会议软件中使用。更多详情请查看:

https:// github.com/andreyryabts ev/BGMv2-webcam-plugin-linux

在Google Colab上体验

另外,开发者还提供了Google Colab的体验地址(国内需要木弟子),可以体验替换图片和视频中的背景。

1、图片背景替换体验地址: https:// colab.research.google.com /drive/1cTxFq1YuoJ5QPqaTcnskwlHDolnjBkB9?usp=sharing

图片背景替换效果:

QjmaIjE.jpg!mobile

2、视频背景替换体验地址:

ttps:// http:// colab.research.google.com /drive/1Y9zWfULc8-DDTSsCH-pX6Utw8skiJG5s?usp=sharing

视频背景替换效果:

6VZbmmf.gif!mobile

附上开发者提供的项目演示视频给大家观看:

知乎视频 www.zhihu.com feYriu.png!mobile

感兴趣的朋友赶紧上手体验一下吧!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK