Learning Skeletal Articulations with Neural Blend Shapes

Overview

Learning Skeletal Articulations with Neural Blend Shapes

Python Pytorch Blender

This repository provides an end-to-end library for automatic character rigging and blend shapes generation as well as a visualization tool. It is based on our work Learning Skeletal Articulations with Neural Blend Shapes that is published in SIGGRAPH 2021.

Prerequisites

Our code has been tested on Ubuntu 18.04. Before starting, please configure your Anaconda environment by

conda env create -f environment.yaml
conda activate neural-blend-shapes

Or you may install the following packages (and their dependencies) manually:

  • pytorch 1.8
  • tensorboard
  • tqdm
  • chumpy
  • opencv-python

Quick Start

We provide a pretrained model that is dedicated for biped character. Download and extract the pretrained model from Google Drive or Baidu Disk (9ras) and put the pre_trained folder under the project directory. Run

python demo.py --pose_file=./eval_constant/sequences/greeting.npy --obj_path=./eval_constant/meshes/maynard.obj

The nice greeting animation showed above will be saved in demo/obj as obj files. In addition, the generated skeleton will be saved as demo/skeleton.bvh and the skinning weight matrix will be saved as demo/weight.npy.

If you are interested in traditional linear blend skinning(LBS) technique result generated with our rig, you can specify --envelope_only=1 to evaluate our model only with the envelope branch.

We also provide other several meshes and animation sequences. Feel free to try their combinations!

Test on Customized Meshes

You may try to run our model with your own meshes by pointing the --obj_path argument to the input mesh. Please make sure your mesh is triangulated and has a consistent upright and front facing orientation. Since our model requires the input meshes are spatially aligned, please specify --normalize=1. Alternatively, you can try to scale and translate your mesh to align the provided eval_constant/meshes/smpl_std.obj without specifying --normalize=1.

Evaluation

To reconstruct the quantitative result with the pretrained model, you need to download the test dataset from Google Drive or Baidu Disk (8b0f) and put the two extracted folders under ./dataset and run

python evaluation.py

Blender Visualization

We provide a simple wrapper of blender's python API (>=2.80) for rendering 3D mesh animations and visualize skinning weight. The following code has been tested on Ubuntu 18.04 and macOS Big Sur with Blender 2.92.

Note that due to the limitation of Blender, you cannot run Eevee render engine with a headless machine.

We also provide several arguments to control the behavior of the scripts. Please refer to the code for more details. To pass arguments to python script in blender, please do following:

blender [blend file path (optional)] -P [python script path] [-b (running at backstage, optional)] -- --arg1 [ARG1] --arg2 [ARG2]

Animation

We provide a simple light and camera setting in eval_constant/simple_scene.blend. You may need to adjust it before using. We use ffmpeg to convert images into video. Please make sure you have installed it before running. To render the obj files generated above, run

cd blender_script
blender ../eval_constant/simple_scene.blend -P render_mesh.py -b

The rendered per-frame image will be saved in demo/images and composited video will be saved as demo/video.mov.

Skinning Weight

Visualize the skinning weight is a good sanity check to see whether the model works as expected. We provide a script using Blender's built-in ShaderNodeVertexColor to visualize the skinning weight. Simply run

cd blender_script
blender -P vertex_color.py

You will see something similar to this if the model works as expected:

Mean while, you can import the generated skeleton (in demo/skeleton.bvh) to Blender. For skeleton rendering, please refer to deep-motion-editing.

Acknowledgements

The code in meshcnn is adapted from MeshCNN by @ranahanocka.

The code in models/skeleton.py is adapted from deep-motion-editing by @kfiraberman, @PeizhuoLi and @HalfSummer11.

The code in dataset/smpl_layer is adapted from smpl_pytorch by @gulvarol.

Part of the test models are taken from and SMPL, MultiGarmentNetwork and Adobe Mixamo.

Citation

If you use this code for your research, please cite our paper:

@article{li2021learning,
  author = {Li, Peizhuo and Aberman, Kfir and Hanocka, Rana and Liu, Libin and Sorkine-Hornung, Olga and Chen, Baoquan},
  title = {Learning Skeletal Articulations with Neural Blend Shapes},
  journal = {ACM Transactions on Graphics (TOG)},
  volume = {40},
  number = {4},
  pages = {1},
  year = {2021},
  publisher = {ACM}
}

Note: This repository is still under construction. We are planning to release the code and dataset for training soon.

Comments
  • Export Animated bvh or FBX?

    Export Animated bvh or FBX?

    First, thanks for your great work.

    Just wondering if exporting animated format(such as bvh or fbx) is supported ? Looks like demo.py only exports T-pose skeleton . I've tried to combine all outputs to fbx format but had trouble with animating character with a given pose. (In blender) I used pose (FrameN, Joint_Num,3) data as an input of euler value but it doesn't work.

    Any Suggestions??

    opened by huh8686 7
  • Error when try to show the animation

    Error when try to show the animation

    Great work! When I try to visualize the animation via blender following this, an error occured.

    Saved: '../demo/images/0000.png'
     Time: 00:00.28 (Saving: 00:00.25)
    
    Traceback (most recent call last):
      File "/home/yusun/Documents/GitHub/neural-blend-shapes/blender_scripts/render_mesh.py", line 96, in <module>
        batch_render(args.obj_path)
      File "/home/yusun/Documents/GitHub/neural-blend-shapes/blender_scripts/render_mesh.py", line 56, in batch_render
        render_obj(os.path.join(dir, file))
      File "/home/yusun/Documents/GitHub/neural-blend-shapes/blender_scripts/render_mesh.py", line 42, in render_obj
        obj.select_set(True)
    AttributeError: 'Object' object has no attribute 'select_set'
    

    I am using Blender v2.91a. Any suggestion?

    opened by Arthur151 7
  • maya

    maya

    hello,I am a student of USTB,Thanks for excite project,I want to apply your project to maya, but I can't understand rig,I make a FBX file and run this code to get blendshape values,But with the wrong rig,the results is a bit bad, if you have made a fbx file?

    opened by yangtao19920109 5
  • Miko has lifted skeleton

    Miko has lifted skeleton

    miko_siggraph_neural_blend_shapes.zip

    python demo.py --pose_file=./eval_constant/sequences/house-dance.npy --obj_path=./eval_constant/meshes/miko.obj --normalize=1 --obj_output=0 --animated_bvh=1

    Screenshot from 2021-06-18 06-08-54

    opened by fire 4
  • Error: ZeroDivisionError: division by zero when importing custom mesh

    Error: ZeroDivisionError: division by zero when importing custom mesh

    (neural-blend-shapes) D:\CG_Source\NeRFs\3D_Avatar_Pipeline\neural-blend-shapes>python demo.py --pose_file=.\eval_constant\sequences\greeting.npy --obj_path=.\eval_constant\meshes\test_remesh.obj --animated_bvh=1 --obj_output=0 --normalize=1
    Traceback (most recent call last):
      File "demo.py", line 150, in <module>
        main()
      File "demo.py", line 132, in main
        env_model, res_model = load_model(device, model_args, topo_loader, args.model_path)
      File "demo.py", line 59, in load_model
        geo, att, gen = create_envelope_model(device, model_args, topo_loader, is_train=False, parents=parent_smpl)
      File "D:\CG_Source\NeRFs\3D_Avatar_Pipeline\neural-blend-shapes\architecture\__init__.py", line 34, in create_envelope_model
        save_freq=args.save_freq)
      File "D:\CG_Source\NeRFs\3D_Avatar_Pipeline\neural-blend-shapes\models\networks.py", line 54, in __init__
        topo_loader, requires_recorder, is_cont, save_freq)
      File "D:\CG_Source\NeRFs\3D_Avatar_Pipeline\neural-blend-shapes\models\meshcnn_base.py", line 56, in __init__
        val.extend([1 / len(neighbors)] * len(neighbors))
    ZeroDivisionError: division by zero
    

    I get this error, everytime I try your model with custom meshes. I checked to make sure they are triangulated and called with normalize=1 but this happens for all the meshes I have. Is there some MeshLab filter that I can apply/script which could parse my custom mesh before sending it to your model or a simple fix for this issue. Thank you for your amazing work!

    opened by codesavory 2
  • penetration occur when use a fat person

    penetration occur when use a fat person

    Hi @PeizhuoLi, thanks for sharing this wonderful work ,and I have try some obj with different shapes, but encountered penetration problem. it seems this situation didn't discuss in the paper, can you give some advice? thanks~

    opened by visonpon 1
  • Provide instructions for GPU based pytorch

    Provide instructions for GPU based pytorch

    Similar to the current cpu version. Provide an environment.yml for cuda based pytorch.

    It is non trivial to switch between gpu and cpu. https://github.com/pytorch/pytorch/issues/30664.

    opened by fire 1
  • when I run the command 'blender ......',I got this

    when I run the command 'blender ......',I got this

    Traceback (most recent call last): File "", line 1, in File "D:\360Downloads\neural_blend_shapes_main\blender_scripts\render_mesh.py", line 96, in batch_render(args.obj_path) File "D:\360Downloads\neural_blend_shapes_main\blender_scripts\render_mesh.py", line 56, in batch_render render_obj(os.path.join(dir, file)) File "D:\360Downloads\neural_blend_shapes_main\blender_scripts\render_mesh.py", line 33, in render_obj add_material_for_objs([obj], 'character') File "D:\360Downloads\neural_blend_shapes_main\blender_scripts\render_mesh.py", line 28, in add_material_for_objs raise Exception("This line shouldn't be reached") Exception: This line shouldn't be reached

    I don't know why this happen. My command is ' blender -P render_mesh.py -b'

    opened by Pean-Mura 1
  • FBX Output Script (Blender)

    FBX Output Script (Blender)

    This script allows to export neural-blend-shapes file (.fbx, .glb)

    To get neural-blendshapes model , just simply run blender -b -P nbs_fbx_output.py -- --input ../demo --output ../demo/output.fbx

    To get envelop-only model , just simply run blender -b -P nbs_fbx_output.py -- --input ../demo --output ../demo/output.fbx --envelope_only 1

    #Required Input direcotry is the directory where the ouputs are generated from 'demo.py'

    'T-pose.obj', 'skeleton.bvh' , 'weight.npy' and 'basis.npy' , 'coff.npy' should exist in input directory (e.g. ../demo) If 'basis.npy' , 'coff.npy' don't exist , envelope-only model will be exported.

    'basis.npy' and 'coff.npy' (that is required to get neural-blend-shape model) can be achieved from params called basis_full, coff respectively in ./architecture/blend_shapes.py

    e.g. I simply add this code in the forward function in ./architecture/blend_shapes.py

    import numpy as np np_basis = basis_full.detach().cpu().numpy() np_coff = coff.detach().cpu().numpy() np.save('./demo/basis.npy',np_basis) np.save('./demo/coff.npy',np_coff)

    opened by huh8686 0
  • broken custom  mesh after running demo

    broken custom mesh after running demo

    I met some similar issue as other mentioned before. I'm not sure if I missed some step to prepare the mesh. I tried to align it and fix the non manifold issue, but the mesh is still broken after I run the demo. I've attached my files, it contains the one I use as referral(maynard:Mesh) and the one I'm running the demo on(castle:Castleguard1), if you can take a look. Thanks! image

    Uploading confusion.fbx…

    opened by siRoblox 0
  • about data pre process

    about data pre process

    您好,我测试了一些自己的模型,增加了normalize=1,发现骨骼尺度上有差距,最终出来的蒙皮权重就很差,有几个问题想问下:

    1. 三角化后的模型consistent upright and front facing orientation.是指模型导入引擎,朝向(比如fbx脚本里的axis_forward='-Z', axis_up='Y')一致,然后是T-pose就行? 还是三角面片坐标上有什么含义?
    2. 和smpl_std.obj对齐,直接使用您给定的归一化函数就可以?还是有什么更细致的要求? 1665651058186
    opened by foocker 1
  • Questions regarding blendshapes

    Questions regarding blendshapes

    Thank you for your great work. After reading the paper, I still have some questions. So I hope you or anyone else can answer me if possible.

    In the paper, the Residual Deformation Branch learns to predict blendshapes for each individual character. I'm wondering how these blendshapes are defined.

    I'm not familiar with body blendshapes but as far as I know, blendshapes for facial expressions like jawOpen, eyeBlinkLeft, smileRight, etc., are semantically defined. In the paper[1], personalized facial blendshapes are learned via blendshape gradient loss function, which forces each of the generated blendshapes to have specific semantic meaning.

    Another way to use blendshapes for facial expression is like what was done in MetaHuman[2] (Unreal Engine), where expressions are produced by bones. Blendshapes (called morph targets in Unreal Engine) are used to refine the face, which add more details. I think this is more similar to your work.

    So I would like to know some details on your blendshapes: how they are defined, how they are learned, etc.

    I really appreciate it if you could answer my questions.

    Ref: [1] Personalized Face Modeling for Improved Face Reconstruction and Motion Retargeting [2] MetaHuman

    opened by HoiM 1
  • Something weird with the skeleton

    Something weird with the skeleton

    Hi! When I reproduced this great work and trained from scratch, the skeleton produced some weird result, as shown in the picture. The left is the result I reproduced, and the right is the result produced from the pre_trained model. I think it may because the end effector was set wrongly, but I didn't change any code about it. Could you please help me with this problem? Looking forward to your reply! 屏幕截图 2021-10-28 223501

    opened by Jinhui-Luan 1
  • Workflow to generate custom pose (e.g. from Mixamo fbx)

    Workflow to generate custom pose (e.g. from Mixamo fbx)

    Hi. Could you tell how the sequence pose files(located in ./eval_constant/sequences/ *.npy) are generated ?? It seems like those files were converted from Mixamo files but couldn't find a clue to create those. If you don't mind , could you let us know this process ?

    opened by huh8686 6
  • question: given an arbitary pose mesh, what is the suggested way to convert it to t-pose mesh?

    question: given an arbitary pose mesh, what is the suggested way to convert it to t-pose mesh?

    Is there a recommended way for converting an arbitrary posed mesh to a t-posed mesh?

    Side Question - Also since you are able to calculate skinning weights of a mesh, why isn't it possible to do neural blend shapes on any arbitrary posed mesh?

    opened by codesavory 1
Owner
Peizhuo
Peizhuo
An automated algorithm to extract the linear blend skinning (LBS) from a set of example poses

Dem Bones This repository contains an implementation of Smooth Skinning Decomposition with Rigid Bones, an automated algorithm to extract the Linear B

Electronic Arts 684 Dec 26, 2022
Official implementation of NPMs: Neural Parametric Models for 3D Deformable Shapes - ICCV 2021

NPMs: Neural Parametric Models Project Page | Paper | ArXiv | Video NPMs: Neural Parametric Models for 3D Deformable Shapes Pablo Palafox, Aljaz Bozic

PabloPalafox 109 Nov 22, 2022
Official code release for ICCV 2021 paper SNARF: Differentiable Forward Skinning for Animating Non-rigid Neural Implicit Shapes.

Official code release for ICCV 2021 paper SNARF: Differentiable Forward Skinning for Animating Non-rigid Neural Implicit Shapes.

null 235 Dec 26, 2022
Code for Learning Manifold Patch-Based Representations of Man-Made Shapes, in ICLR 2021.

LearningPatches | Webpage | Paper | Video Learning Manifold Patch-Based Representations of Man-Made Shapes Dmitriy Smirnov, Mikhail Bessmeltsev, Justi

Dima Smirnov 22 Nov 14, 2022
SymmetryNet: Learning to Predict Reflectional and Rotational Symmetries of 3D Shapes from Single-View RGB-D Images

SymmetryNet SymmetryNet: Learning to Predict Reflectional and Rotational Symmetries of 3D Shapes from Single-View RGB-D Images ACM Transactions on Gra

null 26 Dec 5, 2022
Behind the Curtain: Learning Occluded Shapes for 3D Object Detection

Behind the Curtain: Learning Occluded Shapes for 3D Object Detection Acknowledgement We implement our model, BtcDet, based on [OpenPcdet 0.3.0]. Insta

Qiangeng Xu 163 Dec 19, 2022
Implementation based on Paper - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling

Implementation based on Paper - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling

HamasKhan 3 Jul 8, 2022
3D AffordanceNet is a 3D point cloud benchmark consisting of 23k shapes from 23 semantic object categories, annotated with 56k affordance annotations and covering 18 visual affordance categories.

3D AffordanceNet This repository is the official experiment implementation of 3D AffordanceNet benchmark. 3D AffordanceNet is a 3D point cloud benchma

null 49 Dec 1, 2022
This repository contains the accompanying code for Deep Virtual Markers for Articulated 3D Shapes, ICCV'21

Deep Virtual Markers This repository contains the accompanying code for Deep Virtual Markers for Articulated 3D Shapes, ICCV'21 Getting Started Get sa

KimHyomin 45 Oct 7, 2022
The official implementation of the research paper "DAG Amendment for Inverse Control of Parametric Shapes"

DAG Amendment for Inverse Control of Parametric Shapes This repository is the official Blender implementation of the paper "DAG Amendment for Inverse

Elie Michel 157 Dec 26, 2022
This is the official source code for SLATE. We provide the code for the model, the training code, and a dataset loader for the 3D Shapes dataset. This code is implemented in Pytorch.

SLATE This is the official source code for SLATE. We provide the code for the model, the training code and a dataset loader for the 3D Shapes dataset.

Gautam Singh 66 Dec 26, 2022
This repository contains notebook implementations of the following Neural Process variants: Conditional Neural Processes (CNPs), Neural Processes (NPs), Attentive Neural Processes (ANPs).

The Neural Process Family This repository contains notebook implementations of the following Neural Process variants: Conditional Neural Processes (CN

DeepMind 892 Dec 28, 2022
Code for "Neural Parts: Learning Expressive 3D Shape Abstractions with Invertible Neural Networks", CVPR 2021

Neural Parts: Learning Expressive 3D Shape Abstractions with Invertible Neural Networks This repository contains the code that accompanies our CVPR 20

Despoina Paschalidou 161 Dec 20, 2022
Bayesian-Torch is a library of neural network layers and utilities extending the core of PyTorch to enable the user to perform stochastic variational inference in Bayesian deep neural networks

Bayesian-Torch is a library of neural network layers and utilities extending the core of PyTorch to enable the user to perform stochastic variational inference in Bayesian deep neural networks. Bayesian-Torch is designed to be flexible and seamless in extending a deterministic deep neural network architecture to corresponding Bayesian form by simply replacing the deterministic layers with Bayesian layers.

Intel Labs 210 Jan 4, 2023
An implementation demo of the ICLR 2021 paper Neural Attention Distillation: Erasing Backdoor Triggers from Deep Neural Networks in PyTorch.

Neural Attention Distillation This is an implementation demo of the ICLR 2021 paper Neural Attention Distillation: Erasing Backdoor Triggers from Deep

Yige-Li 84 Jan 4, 2023
Differentiable Neural Computers, Sparse Access Memory and Sparse Differentiable Neural Computers, for Pytorch

Differentiable Neural Computers and family, for Pytorch Includes: Differentiable Neural Computers (DNC) Sparse Access Memory (SAM) Sparse Differentiab

ixaxaar 302 Dec 14, 2022
Neural Turing Machine (NTM) & Differentiable Neural Computer (DNC) with pytorch & visdom

Neural Turing Machine (NTM) & Differentiable Neural Computer (DNC) with pytorch & visdom Sample on-line plotting while training(avg loss)/testing(writ

Jingwei Zhang 269 Nov 15, 2022
Complex-Valued Neural Networks (CVNN)Complex-Valued Neural Networks (CVNN)

Complex-Valued Neural Networks (CVNN) Done by @NEGU93 - J. Agustin Barrachina Using this library, the only difference with a Tensorflow code is that y

youceF 1 Nov 12, 2021
DeepHyper: Scalable Asynchronous Neural Architecture and Hyperparameter Search for Deep Neural Networks

What is DeepHyper? DeepHyper is a software package that uses learning, optimization, and parallel computing to automate the design and development of

DeepHyper Team 214 Jan 8, 2023