Giter Club home page Giter Club logo

vtuber-momosehiyori's Introduction

VTuber-MomoseHiyori

description   stars   forks   contributors

                 


👋 Hello, I am Momose Hiyori, a Live2D VTuber from Japan. My parents are Cubsim and Unity, my teachers are OpenCV and Deep Learning. I am really good at mimicking faces including poses and expressions, it is a pleasure to meet you all and look forward to being good friends~ ❤️🧡💗🥰💕


 

  • Head: 6 degrees of freedom.
  • Eyes: opening, half-opening, glare, closing, blinking, eyeballs rotation.
  • Eyebrows: raising.
  • Mouth: opening and closing, grinning and pouting.

Table of Contents

Development Environment

System Windows 10 x64
Language Python 3.8 (algorithm), C# (Unity script)
IDE Visual Studio Code 1.83.1 (algorithm), Live2D Cubism Editor 4.0 (Live2D model), Unity 2022.3.12f1 LTS (Engine)

Install

  1. Install Python 3.8 (recommend to use Anaconda), Unity (recommend to use UnityHub).

  2. Download the executable file from the latest release.

  3. Environment configuration.

    git clone https://github.com/KennardWang/VTuber-MomoseHiyori.git
    cd VTuber-MomoseHiyori
    conda env create -f environment.yml
    
  4. Activate environment and install dependencies.

    conda activate l2d-vtb
    pip install -r requirements.txt
    
  5. There are 2 types of running environments, please choose the env based on your condition.

    • CPU env

      • Install dlib, my version is v19.24.2.

        conda install -c conda-forge dlib
        
    • GPU env

      • Install scipy with version > 0.16, using conda is faster than pip.

        conda install scipy
        
      • Windows

        • Install CUDA v10.2 & CUDNN v8.3.1.

        • Install Pytorch.

          pip install torch==1.10.2+cu102 torchvision==0.11.3+cu102 torchaudio===0.10.2+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html
          
      • MacOS (X86-64) with Intel

        • Install Pytorch.

          conda install pytorch torchvision torchaudio -c pytorch
          
      • MacOS (ARM64) with Apple M1

        • Install Pytorch.

          conda install pytorch torchvision torchaudio -c pytorch-nightly
          
      • (Optional) Download models in ckpts, unzip and place it at face_alignment/ckpts. If not, it will automatically download from the site.

Usage

Step 1 : Test camera

If it runs normally, you can see your face, and press q to quit.

  • CPU env

    python main.py --debug
    
  • GPU env

    python main.py --debug --gpu
    

CPU env (left) has higher FPS that may perform better in VTuber, but lower robustness that cannot recognize well if some parts of the face are covered.

GPU env (right) has higher robustness, better fluency and consecutiveness but lower FPS because of busier data IO.


Step 2 : Connect Unity

  1. Run the Unity executable file.
  2. Run the command according to your env.
    • CPU env

      python main.py --debug --connect
      
    • GPU env

      python main.py --debug --gpu --connect
      

Optional : Set Parameters

There are some parameters you can change. The default port number is 14514, you could set another port number via --port=PORT_NUMBER, but keep it the same as that in the Unity client. Moreover, you can set the camera via --cam=CAM_INDEX if you have more than one camera, the default camera index is 0. Please check the guidance of all parameters by using python main.py --help.


Tips : Improve Performance

  • Use spotlight: Try to make your face look brighter, the spotlight probably shows a better effect than the natural light.
  • Adjust face position: The debug mode of the camera may help you to know the position of your face. Try to put your face in a central position, and let the frame extend but not reach the boundary.
  • No glasses: Wearing glasses may influence the accuracy of recognition on eyes.
  • Show forehead: If your hair is so long that covers your eyes, it may also cause side effects on the recognition of eyes.

File/Folder Description

File / Folder Description
UnityAssets Unity materials for those who want to make Live2D VTuber by themselves, see tutorial.
face_alignment Module for face detection and landmarks by a powerful face alignment network (FAN), recommend to use under GPU env.
face_pose Module for face pose detection, contains the pose estimator and stabilizer.
tests Test folder for GitHub Actions.
main.py Main program.
sock.py File with Socket class.
utils.py File with utility functions.

Calibration Algorithms

Obviously, the position of landmarks is meaningless. In most cases, we focus on the ratio (or aspect ratio) which could describe the degree, because in Unity, we use a scrolling bar to control actions or events. However, the ratio is mostly not perfect correspondence with the bar value. An interesting question is how to calibrate and map the ratio to the bar value. There are some feasible methods I implement in this project:

# Copyright 2023 © Yuyang (Kennard) Wang.

# For some values with distinct boundaries, e.g., eyeballs, we can use linear transformation.
def calibrate_param1(param1):
    """Calibrate parameter1"""
    return (param1 + a) * b


# For some values with overlapping boundaries but main body has significant differences,
# e.g., eyeOpen, eyebrow, we can set return as discrete values instead of continuous values.
def calibrate_param2(param2, last_state_value):
    """Calibrate parameter2"""
    flag = False  # jump out of current state

    # values of state 1, 2, ..., N are from small to large
    if last_state_value == state1_value:
        if param2 > jump_threshold1:
            flag = True
    elif last_state_value == state2_value:
        if abs(param2 - central_point) > jump_threshold2:
            flag = True
    elif ... :
        if ... :
            flag = True
    else:
        if param2 < jump_thresholdn:
            flag = True

    if flag:
        # state_threshold1 is between state1 and state2, less than jump_threshold1
        if param2 <= state_threshold1:
            current_state_value = state1_value
        # state_threshold2 is between state2 and state3
        elif param2 > state_threshold1 and param2 <= state_threshold2:
            current_state_value = state2_value
        elif ... :
            current_state_value = state..._value
        else:
            current_state_value = stateN_value
    else:
        current_state_value = last_state_value

    return current_state_value


# If you want a smooth effect, you can use a piecewise function to replace discrete states, e.g., mouthWidth
def calibrate_param3(param3):
    """Calibrate parameter3"""
    if param3 <= threshold1:
        bar_value = bar_value_min
    elif param3 > threshold1 and param3 <= threshold2:
        bar_value = k * param3 + b
    elif ... :
        bar_value = ...
    else:
        bar_value = bar_value_max

    return bar_value

References

Releases

badge badge badge

Maintainers

badge @KennardWang

Contributing

Feel free to open an issue or submit PRs. Be careful that the submitted code needs to pass format tests and pytests by GitHub Actions, please self-check before pulling requests.

  • flake8 format test (Windows, MacOS and Linux) 1

    flake8 --exclude=face_alignment,face_pose --ignore=E501 .
    
  • pytest (Windows, MacOS and Linux) 2

    pytest tests/test_win.py
    pytest tests/test_mac.py
    pytest tests/test_linux.py
    

License

license © Kennard Wang ( 2020.6.27 )

vtuber-momosehiyori's People

Contributors

dependabot[bot] avatar kennardwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vtuber-momosehiyori's Issues

The tutorial about the usage of Unity Assets

Description

This is a template for most Cubism Live2D models. If you just want to customize your own Live2D models, probably you can read the following instructions.


Step 0 : Prepare Before You Start

  1. Choose a suitable Unity Engine, recommend Unity 2019.4.1f1 LTS.
  2. Ensure that you have been equipped with basic knowledge of Unity.
  3. You would better download SDK here, or use CubismSdkForUnity-4-r.1 which I have downloaded for you in UnityAssets folder.
  4. Open Unity Engine and create a new Unity project.


Step 1 : Import Dependencies

  1. Import Live2D SDK : Drag CubismSdkForUnity-4-r.1 into Assets and choose to import all.

  1. Restart Unity : Do not forget this step, otherwise the SDK cannot work!
  2. Import Assets : Delete the default scene file, drag Momose, Scece and Script folder into Assets.

  1. Import Model : A prefab will be automatically generated as Assets/Momose/hiyori_pro_t08.prefab. Open Scene/MomoseHiyori and drag prefab into this scene.


Step 2 : Initialization

  1. Select prefab and move Y axis (blue) forward to reset the position.

  1. Drag control balls to initialize.

  1. Drag Momose script to the prefab hiyori_pro_t08 Bind script.


Step 3 : Export & Build

  1. Click Add Open Scenes to add the current scene.

  1. Set Player Settings.

  1. Build .exe file and start to test.


References

  1. A fantastic model website : https://www.live2d.com/en/download/sample-data/.
  2. My tutorial video published in bilibili : https://www.bilibili.com/video/BV15A411e7hh?p=3.

Compatibility with Virtual Webcams on Windows

Hi, thank you very much for the program!, would it be possible to add compatibility for virtual webcam sources (not real USB webcams) like IP Webcam (Android), Droidcam, or Webcamoid? (I think they all use DirectShow filters)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.