• This repository has been archived on 01/Sep/2021
  • Stars
    star
    770
  • Rank 57,090 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use Unity 3D character and Python deep learning algorithms to stream as a VTuber!

VTuber_Unity

2021/9/1: Due to massive bugs and the fast-moving virtual character technology, I decide to archive this repository (no updates anymore). Nowadays you can basically find many public tools on the internet, even for mobile platforms. This repository doesn't work as well as those tools, but can still serve as a tool if you want to integrate your character in Unity and custom it (e.g. play around with Unity objects).

Use Unity 3D character and Python deep learning algorithms to stream as a VTuber!

This is part of the OpenVTuberProject, which provides many toolkits for becoming a VTuber.

Youtube Playlist (Chinese) (Covers videos 1-4): teaser


Credits

First of all, I'd like to give credits to the following projects that I borrow code from:

Project LICENSE
head-pose-estimation LICENSE
face-alignment LICENSE
GazeTracking LICENSE

And the virtual character unity-chan © UTJ/UCL.

Installation

Hardware

  • OS: Ubuntu 16.04 (18.04 may also work) or Windows 10 64bits or MacOS
  • (Optional but recommended) An NVIDIA GPU (tested with CUDA 9.0, 10.0 and 10.1, but may also work with other versions)

Software

  • Python3.x (installation via Anaconda is recommended; mandatory for Windows users)

    • (Optional) It is recommended to use conda environments. Run conda create -n vtuber python=3.6. Activate it by conda activate vtuber.
  • Python libraries

    • Ubuntu:
      • Install the requirements by pip install -r requirements_(cpu or gpu).txt
      • If you have CUDA 10.1, pip install onnxruntime-gpu to get faster inference speed using onnx model.
    • Windows:
      • CPU:
        • pip install -r requirements_cpu.txt
        • if dlib cannot be properly installed, follow here.
      • GPU:
        • Install pytorch using conda. Example: conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
        • Install other dependencies by pip install -r requirements_gpu.txt.
        • If you have CUDA 10, pip install onnxruntime-gpu to get faster inference speed using onnx model.
  • Optional

Example usage

Here we assume that you have installed the requirements and activated the virtual environment you are using.

0. Model download

You need to download the models here, extract and put into face_alignment/ckpts.

If you don't use onnxruntime, you can omit this step as the script will automatically download them for you.

1. Face detection test

Run python demo.py --debug. (add --cpu if you have CPU only)

You should see the following:


Left: CPU model. Right: GPU model run on a GTX1080Ti.

2. Synchronize with the virtual character

  1. Download and launch the binaries here depending on your OS to launch the unity window featuring the virtual character (unity-chan here). Important: Ensure that only one window is opened at a time!
  2. After the vitual character shows up, run python demo.py --connect to synchronize your face features with the virtual character. (add --debug to see your face and --cpu if you have CPU only as step 1.)

You should see the following:


Left: CPU model. Right: GPU model run on a GTX1080Ti.

Enjoy your VTuber life!

Functionalities details

In this section, I will describe the functionalities implemented and a little about the technology behind.

Head pose estimation

Using head-pose-estimation and face-alignment, deep learning methods are applied to do the following: face detection and facial landmark detection. A face bounding box and the 68-point facial landmark is detected, then a PnP algorithm is used to obtain the head pose (the rotation of the face). Finally, kalman filters are applied to the pose to make it smoother.

The character's head pose is synchronized.

As for the visualization, the white bounding box is the detected face, on top of which 68 green face landmarks are plotted. The head pose is represented by the green frustum and the axes in front of the nose.

Gaze estimation

Using GazeTracking, The eyes are first extracted using the landmarks enclosing the eyes. Then the eye images are converted to grayscale, and a pixel intensity threshold is applied to detect the iris (the black part of the eye). Finally, the center of the iris is computed as the center of the black area.

The character's gaze is not synchronized. (Since I didn't find a way to move unity-chan's eyes)

As for the visualization, the red crosses indicate the iris.

Miscellaneous

  1. Estimate eye aspect ratio: The eye aspect ratio can be used to detect blinking, but currently I just use auto blinking since this estimation is not so accurate.

  2. Estimate mouth aspect ratio: I use this number to synchronize with the character's mouth.

  3. The mouth distance is used to detect smile and synchronize with the character.

Unity Project

If you want to customize the virtual character, you can find the unity project in release.

License

MIT License

More Repositories

1

nerf_pl

NeRF (Neural Radiance Fields) and NeRF in the Wild using pytorch-lightning
Jupyter Notebook
2,642
star
2

ngp_pl

Instant-ngp in pytorch+cuda trained with pytorch-lightning (high quality with high speed, with only few lines of legible code)
Jupyter Notebook
1,220
star
3

gaussian_splatting_notes

A detailed formulae explanation on gaussian splatting
433
star
4

pytorch-cppcuda-tutorial

tutorial for writing custom pytorch cpp+cuda kernel, applied on volume rendering (NeRF)
Cuda
333
star
5

CasMVSNet_pl

Cascade Cost Volume for High-Resolution Multi-View Stereo and Stereo Matching using pytorch-lightning
Jupyter Notebook
268
star
6

OpenVTuberProject

Open Vtuber project containing all sub projects
235
star
7

nsff_pl

Neural Scene Flow Fields using pytorch-lightning, with potential improvements
Jupyter Notebook
220
star
8

nerf_Unity

Unity project for nerf_pl (Neural Radiance Fields)
C#
216
star
9

fish_detection

Fish detection using Open Images Dataset and Tensorflow Object Detection
Jupyter Notebook
123
star
10

Coordinate-MLPs

Experiments of coordinate MLPs
Python
91
star
11

RL

Jupyter Notebook
79
star
12

MVSNet_pl

MVSNet: Depth Inference for Unstructured Multi-view Stereo using pytorch-lightning
Jupyter Notebook
67
star
13

MINER_pl

Unofficial implementation (replicates paper results!) of MINER: Multiscale Implicit Neural Representations in pytorch-lightning
Jupyter Notebook
60
star
14

BlendedMVS_scenes

Quick lookup for BlendedMVS scenes
Python
48
star
15

ROS_notes

Personal notes of ROS usage
Jupyter Notebook
47
star
16

Unity_live_caption

Use Google Speech-to-Text API to do real-time live stream caption on Unity! Best when combined with your virtual character!
Python
36
star
17

pytorch-lightning-tutorial

Pytorch lightning tutorial using MNIST
Python
32
star
18

python-ray-tracing-with-cuda-example

An example of cuda ray tracing in pure python syntax.
Python
30
star
19

pytorch_cppcuda_practice

Practice to write cpp/cuda extension for pytorch
Cuda
26
star
20

hindsight_experience_replay

A tensorflow implementation of hindsight experience replay
Jupyter Notebook
16
star
21

kwea123

7
star
22

dino_pl

Reimplementation of Self-Supervised Vision Transformers with DINO in pytorch-lightning
Python
6
star
23

python-ray-tracing-with-numpy-example

Example of ray tracing with numpy in pure python syntax
4
star
24

bookkeeping

網頁語音記帳程式 - 利用Google Cloud Speech API 實現快速語音記帳
Python
4
star
25

kitti_bev_detection

Jupyter Notebook
3
star
26

facebook-bot

Python
2
star
27

cpp_data_algo

C++
1
star
28

raspberry_pi3

Jupyter Notebook
1
star
29

frustum-pointnets-work

Jupyter Notebook
1
star
30

cifar-10-cnn

Jupyter Notebook
1
star
31

kwea123.github.io

CSS
1
star
32

line-bot

Python
1
star
33

acoustic-indices

Jupyter Notebook
1
star