Git Product home page Git Product logo

avatarclip's Introduction

AvatarCLIP: Zero-Shot Text-Driven Generation and Animation of 3D Avatars

1S-Lab, Nanyang Technological University  2SenseTime Research  3Shanghai AI Laboratory
*equal contribution  +corresponding author

Accepted to SIGGRAPH 2022 (Journal Track)

TL;DR

AvatarCLIP generate and animate avatars given descriptions of body shapes, appearances and motions.

A tall and skinny female soldier that is arguing. A skinny ninja that is raising both arms. An overweight sumo wrestler that is sitting. A tall and fat Iron Man that is running.

This repository contains the official implementation of AvatarCLIP: Zero-Shot Text-Driven Generation and Animation of 3D Avatars.


Updates

[09/2022] 🔥🔥🔥If you are looking for a higher-quality 3D human generation method, go checkout our new work EVA3D!🔥🔥🔥

[09/2022] 🔥🔥🔥If you are looking for a higher-quality text2motion method, go checkout our new work MotionDiffuse!🔥🔥🔥

[07/2022] Code release for motion generation part!

[05/2022] Paper uploaded to arXiv. arXiv

[05/2022] Add a Colab Demo for avatar generation! Open In Colab

[05/2022] Support converting the generated avatar to the animatable FBX format! Go checkout how to use the FBX models. Or checkout the instructions for the conversion codes.

[05/2022] Code release for avatar generation part!

[04/2022] AvatarCLIP is accepted to SIGGRAPH 2022 (Journal Track):partying_face:!

Citation

If you find our work useful for your research, please consider citing the paper:

@article{hong2022avatarclip,
    title={AvatarCLIP: Zero-Shot Text-Driven Generation and Animation of 3D Avatars},
    author={Hong, Fangzhou and Zhang, Mingyuan and Pan, Liang and Cai, Zhongang and Yang, Lei and Liu, Ziwei},
    journal={ACM Transactions on Graphics (TOG)},
    volume={41},
    number={4},
    articleno={161},
    pages={1--19},
    year={2022},
    publisher={ACM New York, NY, USA},
    doi={10.1145/3528223.3530094},
}

Use Generated FBX Models

Download

Go visit our project page. Go to the section 'Avatar Gallery'. Pick a model you like. Click 'Load Model' below. Click 'Download FBX' link at the bottom of the pop-up viewer.

Import to Your Favourite 3D Software (e.g. Blender, Unity3D)

The FBX models are already rigged. Use your motion library to animate it!

Upload to Mixamo

To make use of the rich motion library provided by Mixamo, you can also upload the FBX model to Mixamo. The rigging process is completely automatic!

Installation

We recommend using anaconda to manage the python environment. The setup commands below are provided for your reference.

git clone https://github.com/hongfz16/AvatarCLIP.git
cd AvatarCLIP
conda create -n AvatarCLIP python=3.7
conda activate AvatarCLIP
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=10.1 -c pytorch
pip install -r requirements.txt

Other than the above steps, you should also install neural_renderer following its instructions. Before compiling neural_renderer (or after compiling should also be fine), remember to add the following three lines to neural_renderer/perspective.py after line 19.

x[z<=0] = 0
y[z<=0] = 0
z[z<=0] = 0

This quick fix is for a rendering issue where objects behide the camera will also be rendered. Be careful when using this fixed version of neural_renderer on your other projects, because this fix will cause the rendering process not differentiable.

To support offscreen rendering for motion visualization, you should install osmesa library.

conda install -c menpo osmesa

Data Preparation

Download SMPL Models

Register and download SMPL models here. Put the downloaded models in the folder smpl_models. The folder structure should look like

./
├── ...
└── smpl_models/
    ├── smpl/
        ├── SMPL_FEMALE.pkl
        ├── SMPL_MALE.pkl
        └── SMPL_NEUTRAL.pkl

Download Pretrained Models & Other Data

This download is only for coarse shape generation and motion generation. You can skip if you only want to use other parts. Download the pretrained weights and other required data here. Put them in the folder AvatarGen so that the folder structure should look like

./
├── ...
└── AvatarGen/
    └── ShapeGen/
        └── data/
            ├── codebook.pth
            ├── model_VAE_16.pth
            ├── nongrey_male_0110.jpg
            ├── smpl_uv.mtl
            └── smpl_uv.obj

Pretrained weights and human texture for motion generation can be downloaded here. Note that the human texture we used to render poses is from SURREAL dataset. Besides, you should download pretrained weights of VPoser v2.0. Put them in the folder AvatarAnimate so that the folder structure should look like

├── ...
└── AvatarAnimate/
    └── data/
        ├── codebook.pth
        ├── motion_vae.pth
        ├── pose_realnvp.pth
        ├── nongrey_male_0110.jpg
        ├── smpl_uv.mtl
        ├── smpl_uv.obj
        └── vposer
            ├── V02_05.log
            ├── V02_05.yaml
            └── snapshots
                ├── V02_05_epoch=08_val_loss=0.03.ckpt
                └── V02_05_epoch=13_val_loss=0.03.ckpt
        

Avatar Generation

Coarse Shape Generation

Folder AvatarGen/ShapeGen contains codes for this part. Run the follow command to generate the coarse shape corresponding to the shape description 'a strong man'. We recommend to use the prompt augmentation 'a 3d rendering of xxx in unreal engine' for better results. The generated coarse body mesh will be stored under AvatarGen/ShapeGen/output/coarse_shape.

python main.py --target_txt 'a 3d rendering of a strong man in unreal engine'

Then we need to render the mesh for initialization of the implicit avatar representation. Use the following command for rendering.

python render.py --coarse_shape_obj output/coarse_shape/a_3d_rendering_of_a_strong_man_in_unreal_engine.obj --output_folder ${RENDER_FOLDER}

Shape Sculpting and Texture Generation

Note that all the codes are tested on NVIDIA V100 (32GB memory). Therefore, in order to run on GPUs with lower memory, please try to scale down the network or tune down max_ray_num in the config files. You can refer to confs/examples_small/example.conf or our colab demo for a scale-down version of AvatarCLIP.

Folder AvatarGen/AppearanceGen contains codes for this part. We provide data, pretrained model and scripts to perform shape sculpting and texture generation on a zero-beta body (mean shape defined by SMPL). We provide many example scripts under AvatarGen/AppearanceGen/confs/examples. For example, if we want to generate 'Abraham Lincoln', which is defined in the config file confs/examples/abrahamlincoln.conf, use the following command.

python main.py --mode train_clip --conf confs/examples/abrahamlincoln.conf

Results will be stored in AvatarCLIP/AvatarGen/AppearanceGen/exp/smpl/examples/abrahamlincoln.

If you wish to perform shape sculpting and texture generation on the previously generated coarse shape. We also provide example config files in confs/base_models/astrongman.conf confs/astrongman/*.conf. Two steps of optimization are required as follows.

# Initilization of the implicit avatar
python main.py --mode train --conf confs/base_models/astrongman.conf
# Shape sculpting and texture generation on the initialized implicit avatar
python main.py --mode train_clip --conf confs/astrongman/hulk.conf

Marching Cube

To extract meshes from the generated implicit avatar, one may use the following command.

python main.py --mode validate_mesh --conf confs/examples/abrahamlincoln.conf

The final high resolution mesh will be stored as AvatarCLIP/AvatarGen/AppearanceGen/exp/smpl/examples/abrahamlincoln/meshes/00030000.ply

Convert Avatar to FBX Format

For the convenience of using the generated avatar with modern graphics pipeline, we also provide scripts to rig the avatar and convert to FBX format. See the instructions here.

Motion Generation

Candidate Poses Generation

Here we provide four different methods for pose generation.

  1. PoseOptimizer: directly optimize on SMPL theta

  2. VPoserOptimizer: optimize the latent space of VPoser

  3. VPoserRealNVP: get latent codes of VPoser from pretrained conditional RealNVP

  4. VPoserCodebook: select the most similar poses to the given text feature

We provide configurations to compare these methods. Here are some examples:

# Suppose your current location is `AvatarCLIP/AvatarAnimate`

# Use PoseOptimizer method to generate poses for "arguing"
python main.py --conf confs/pose_ablation/pose_optimizer/argue.conf
# Results are stored in `AvatarCLIP/AvatarAnimate/exp/pose_ablation/pose_optimizer/argue` directory
# candidate_0.jpg, candidate_1.jpg, ..., candidate_4.jpg are the top-5 poses
# candidate_0.npy, candidate_1.npy, ..., candidate_4.npy are corresponding parameters

# Use VPoserOptimizer method to generate poses for "praying"
python main.py --conf confs/pose_ablation/vposer_optimizer/pray.conf
# Results are stored in `AvatarCLIP/AvatarAnimate/exp/pose_ablation/vposer_optimizer/pray` directory

# Use VPoserRealNVP method to generate poses for "shooting a basketball"
python main.py --conf confs/pose_ablation/vposer_realnvp/shoot_basketball.conf
# Results are stored in `AvatarCLIP/AvatarAnimate/exp/pose_ablation/vposer_realnvp/shoot_basketball` directory

# Use VPoserCodebook method to generate poses for "running"
python main.py --conf confs/pose_ablation/vposer_codebook/run.conf
# Results are stored in `AvatarCLIP/AvatarAnimate/exp/pose_ablation/vposer_codebook/run` directory

Motion Generation

Here we provide three different methods for motion generation.

  1. MotionInterpolation: directly interpolate between given poses

  2. MotionOptimizer (baseline): optimize latent code of a pretrained VAE with a simple reconstruction loss

  3. MotionOptimizer (ours): optimize latent code of a pretrained VAE with weighted reconstruction loss, delta loss, and clip loss

We provide configurations to compare these methods. Here are some examples:

# Suppose your current location is `AvatarCLIP/AvatarAnimate`

# Use MotionInterpolation method to generate motion for "arguing"
python main.py --conf confs/motion_ablation/interpolation/argue.conf
# Results are stored in `AvatarCLIP/AvatarAnimate/exp/motion_ablation/interpolation/argue` directory
# candidate_0.jpg, candidate_1.jpg, ..., candidate_4.jpg are the top-5 poses
# candidate_0.npy, candidate_1.npy, ..., candidate_4.npy are corresponding parameters
# motion.mp4 is the generated motion
# motion.npy is corresponding parameters

# Use MotionOptimizer (baseline) method to generate motion for "praying"
python main.py --conf confs/motion_ablation/baseline/pray.conf
# Results are stored in `AvatarCLIP/AvatarAnimate/exp/motion_ablation/baseline/pray` directory

# Use MotionOptimizer (ours) method to generate motion for "shooting a basketball"
python main.py --conf confs/motion_ablation/motion_optimizer/shoot_basketball.conf
# Results are stored in `AvatarCLIP/AvatarAnimate/exp/motion_ablation/motion_optimizer/shoot_basketball` directory

Make your own configure

Each configuration contains three independent parts: general setting, pose generator, and motion generator.

# General Setting
general {
    # describe the results path
    base_exp_dir = ./exp/motion_ablation/motion_optimizer/raise_arms

    # if you only want to generate poses, then you can set "mode = pose".
    mode = motion

    # define your prompt. We highly recommend using the format "a rendered 3d man is xxx"
    text = a rendered 3d man is raising both arms
}

# Pose Generator
pose_generator {
    type = VPoserCodebook
    # you can change the number of candidate poses by setting "topk = 10"
    # for PoseOptimizer and VPoserOptimizer, you can further define the number of iterations and the optimizer type
}

# Motion Generator
# if "mode = pose", you can ignore this part
motion_generator {
    type = MotionOptimizer
    # you can further modify the coefficient of each loss. 
    # for example, if you find the generated motion is very intensive, you can reduce the coefficient of delta loss.
}


License

Distributed under the S-Lab License. See LICENSE for more information.

Related Works

There are lots of wonderful works that inspired our work or came around the same time as ours.

Dream Fields enables zero-shot text-driven general 3D object generation using CLIP and NeRF.

Text2Mesh proposes to edit a template mesh by predicting offsets and colors per vertex using CLIP and differentiable rendering.

CLIP-NeRF can manipulate 3D objects represented by NeRF with natural languages or examplar images by leveraging CLIP.

Text to Mesh facilitates zero-shot text-driven general mesh generation by deforming from a sphere mesh guided by CLIP.

MotionCLIP establishes a projection from the CLIP text space to the motion space through supervised training, which leads to amazing text-driven motion generation results.

Acknowledgements

This study is supported by NTU NAP, MOE AcRF Tier 2 (T2EP20221-0033), and under the RIE2020 Industry Alignment Fund – Industry Collaboration Projects (IAF-ICP) Funding Initiative, as well as cash and in-kind contribution from the industry partner(s).

We thank the following repositories for their contributions in our implementation: NeuS, smplx, vposer, Smplx2FBX.

avatarclip's People

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avatarclip's Issues

Problem of Motion Generation

ImportError: ('Unable to load OpenGL library', 'libgcrypt.so.11: cannot open shared object file: No such file or directory', '/home/user/anconda3/envs/AvatarCLIP_1/lib/libOSMesa.so.8', '/home/user/anconda3/envs/AvatarCLIP_1/lib/libOSMesa.so.8')

There were no problems before, but at this point, a problem that has not been seen before appeared:

`Traceback (most recent call last):
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/osmesa.py", line 22, in GL
return ctypesloader.loadLibrary(
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/ctypesloader.py", line 45, in loadLibrary
return dllType( name, mode )
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/ctypes/init.py", line 373, in init
self._handle = _dlopen(self._name, mode)
OSError: ('libgcrypt.so.11: cannot open shared object file: No such file or directory', '/home/user/anconda3/envs/AvatarCLIP_1/lib/libOSMesa.so.8', '/home/user/anconda3/envs/AvatarCLIP_1/lib/libOSMesa.so.8')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 12, in
from visualize import render_pose, render_motion
File "/home/user/AvatarCLIP-main/AvatarAnimate/visualize.py", line 9, in
import pyrender
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/pyrender/init.py", line 3, in
from .light import Light, PointLight, DirectionalLight, SpotLight
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/pyrender/light.py", line 10, in
from OpenGL.GL import *
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/GL/init.py", line 3, in
from OpenGL import error as _error
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/error.py", line 12, in
from OpenGL import platform, _configflags
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/init.py", line 35, in
_load()
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/init.py", line 32, in _load
plugin.install(globals())
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 92, in install
namespace[ name ] = getattr(self,name,None)
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/osmesa.py", line 66, in GetCurrentContext
function = self.OSMesa.OSMesaGetCurrentContext
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/osmesa.py", line 60, in OSMesa
def OSMesa( self ): return self.GL
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/user/anconda3/envs/AvatarCLIP_1/lib/python3.8/site-packages/OpenGL/platform/osmesa.py", line 28, in GL
raise ImportError("Unable to load OpenGL library", *err.args)
ImportError: ('Unable to load OpenGL library', 'libgcrypt.so.11: cannot open shared object file: No such file or directory', '/home/user/anconda3/envs/AvatarCLIP_1/lib/libOSMesa.so.8', '/home/user/anconda3/envs/AvatarCLIP_1/lib/libOSMesa.so.8')
`

Has anyone encountered this situation? Is there any solution?

Codebook building

Hi, I'm wodering will you release code for training the codebook? (Both for shape generation and motion generation)

No such file or directory: '../ShapeGen/output/render/transforms_train.json'

I encountered the following problem while executing "# Initilization of the implicit avatar python main.py --mode train --conf confs/base_models/astrongman.conf":
Load data: Begin
Traceback (most recent call last):
File "main.py", line 968, in
runner = Runner(args.conf, args.mode, args.case, args.is_continue)
File "main.py", line 46, in init
self.dataset = SMPL_Dataset(self.conf['dataset'])
File "/hy-tmp/AvatarCLIP-data/AvatarGen/AppearanceGen/models/dataset.py", line 211, in init
with open(os.path.join(self.data_dir, 'transforms_train.json'), 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: '../ShapeGen/output/render/transforms_train.json'

Question about the AppearanceGen results

Hi, thanks for sharing your great work in Avatar generation!

After I ran the command to generate avatars, I got a weird thing which is shown as below:
00030000_0_58
00001100_0_58

I tried to generate AbrahamLincoln and Trump, strange "smoke" is also generated behind the avatar, could you please tell me the reason of this problem?

Thank you!

ConfigFactory.parse_string(conf_text)

Hello @hongfz16 , Thanks for your work. It seems wrong when launch the code.

AppearanceDescription = "Iron Man" #@param {type:"string"}

torch.set_default_tensor_type('torch.cuda.FloatTensor')
FORMAT = "[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)
conf_path = 'confs/examples_small/example.conf'
f = open(conf_path)
conf_text = f.read()
f.close()
conf_text = conf_text.replace('{TOREPLACE}', AppearanceDescription)

print(conf_text)

conf = ConfigFactory.parse_string(conf_text)
print("Prompt: {}".format(conf.get_string('clip.prompt')))
print("Face Prompt: {}".format(conf.get_string('clip.face_prompt')))
print("Back Prompt: {}".format(conf.get_string('clip.back_prompt')))

Shows:

ParseException Traceback (most recent call last)
ParseException: Expected '}', found '=' (at char 1312), (line:67, col:14)

During handling of the above exception, another exception occurred:

ParseSyntaxException Traceback (most recent call last)
in <cell line: 12>()
10 conf_text = conf_text.replace('{TOREPLACE}', AppearanceDescription)
11 # print(conf_text)
---> 12 conf = ConfigFactory.parse_string(conf_text)
13 print("Prompt: {}".format(conf.get_string('clip.prompt')))
14 print("Face Prompt: {}".format(conf.get_string('clip.face_prompt')))

2 frames
/usr/local/lib/python3.10/dist-packages/pyparsing/core.py in parse_string(self, instring, parse_all, parseAll)
1139 else:
1140 # catch and re-raise exception from here, clearing out pyparsing internal stack trace
-> 1141 raise exc.with_traceback(None)
1142 else:
1143 return tokens

ParseSyntaxException: Expected '}', found '=' (at char 1312), (line:67, col:14)

Problem launching example

Hello and thanks for your code.

I've been trying to launch your example of avatar rendering using pretrained model

python main.py --target_txt 'a 3d rendering of a strong man in unreal engine'

I have created conda env using command you've provided. But when I'm launching this command I'm getting

/home/daddywesker/anaconda3/envs/nrend/lib/python3.7/site-packages/chainer/_environment_check.py:75: UserWarning: 
--------------------------------------------------------------------------------
CuPy (cupy) version 10.5.0 may not be compatible with this version of Chainer.
Please consider installing the supported version by running:
  $ pip install 'cupy>=7.7.0,<8.0.0'
See the following page for more details:
  https://docs.cupy.dev/en/latest/install.html
--------------------------------------------------------------------------------
  requirement=requirement, help=help))
/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/clip/clip.py:24: UserWarning: PyTorch version 1.7.1 or higher is recommended
  warnings.warn("PyTorch version 1.7.1 or higher is recommended")
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/daddywesker/3DSynthNN/AvatarCLIP/AvatarGen/ShapeGen/utils.py", line 7, in <module>
    _, _, texture = nr.load_obj(obj_fname, load_texture=True, texture_size=8)
  File "/home/daddywesker/.local/lib/python3.7/site-packages/neural_renderer-1.1.3-py3.7.egg/neural_renderer/load_obj.py", line 183, in load_obj
  File "/home/daddywesker/.local/lib/python3.7/site-packages/neural_renderer-1.1.3-py3.7.egg/neural_renderer/load_obj.py", line 75, in load_textures
  File "/home/daddywesker/anaconda3/envs/nrend/lib/python3.7/site-packages/chainer/backends/cuda.py", line 427, in to_gpu
    array, lambda arr: _array_to_gpu(arr, device, stream))
  File "/home/daddywesker/anaconda3/envs/nrend/lib/python3.7/site-packages/chainer/_backend.py", line 19, in _convert_arrays
    return func(array)
  File "/home/daddywesker/anaconda3/envs/nrend/lib/python3.7/site-packages/chainer/backends/cuda.py", line 427, in <lambda>
    array, lambda arr: _array_to_gpu(arr, device, stream))
  File "/home/daddywesker/anaconda3/envs/nrend/lib/python3.7/site-packages/chainer/backends/cuda.py", line 468, in _array_to_gpu
    return cupy.asarray(array)
  File "/home/daddywesker/anaconda3/envs/nrend/lib/python3.7/site-packages/cupy/_creation/from_data.py", line 76, in asarray
    return _core.array(a, dtype, False, order)
  File "cupy/_core/core.pyx", line 2266, in cupy._core.core.array
  File "cupy/_core/core.pyx", line 2290, in cupy._core.core.array
  File "cupy/_core/core.pyx", line 2418, in cupy._core.core._array_default
ValueError: Unsupported dtype object
python-BaseException

Any advice?

Well, yes, there is a cupy warning also, but i cannot install cupy of those versions. There is an error which, as i've searched on the web, is fixed in newer versions.

stand_pose.npy How to generate

FileNotFoundError: [Errno 2] No such file or directory: '../ShapeGen/output/stand_pose.npy'

@hongfz16
How can I solve this problem,stand pose. How to get npy data

Segmentation fault (core dumped)

python main.py --conf confs/motion_ablation/interpolation/argue.conf
2023-02-11 18:15:16.331 | INFO | human_body_prior.tools.model_loader:load_model:97 - Loaded model in eval mode with trained weights: data/vposer/snapshots/V02_05_epoch=13_val_loss=0.03.ckpt
Segmentation fault (core dumped)

when i try to generate pose or motion, i got a "Segmentation fault (core dumped)" problem, how can i deal with this?
A100-40GB , cuda11.0,pytorch 1.7.1

A very obvious code error in AvatarCLIP/AvatarGen/ShapeGen/main.py

in line 86-91

def load_codebook(fname):
    codebook_dict = torch.load(fname)
    for i in codebook_dict.keys():
        clip_codebook = codebook_dict[i].cuda()
        break
    return i.cuda(), clip_codebook

In this code, the variable i is used to iterate through each key, which presumably should be a string. However, it ultimately returns the string "CUDA". This code obviously cannot run. This issue prevents me from performing Coarse Shape Generation in the Avatar Generation. Additionally, I don't quite understand why the code logic breaks out of the for loop after the first iteration. As a newcomer to programming, I am uncertain about this approach.

Segmentation fault (core dumped) is displayed when running the instructions related to Candidate Poses Generation and Motion Generation.

Input

python main.py --conf confs/motion_ablation/interpolation/argue.conf

Shows:

2023-12-21 12:04:54.293 | INFO | human_body_prior.tools.model_loader:load_model:97 - Loaded model in eval mode with trained weights: data/vposer/snapshots/V02_05_epoch=08_val_loss=0.03.ckpt
Segmentation fault (core dumped)

After running gdb corefile core.25917,shows:

Core was generated by `python main.py --conf confs/pose_ablation/vposer_codebook/run.conf'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f1005e5c82e in ?? (a)
[Current thread is 1 (LWP 25917)].

After that, the bt command is invoked in gdb to display the following information:

(gdb) bt
#0 0x00007f1005e5c82e in ?? ()
#1 0x00007f11a76219dd in ?? ()
#2 0x0000000000000007 in ?? ()
#3 0x00007ffdd010f150 in ?? ()
#4 0x00007ffdd010f100 in ?? ()
#5 0x00007f11a7621067 in ?? ()
#6 0x0000000000000008 in ?? ()
#7 0x00007f11a7620cec in ?? ()
#8 0x0000000000000000 in ?? ()

Try the solutions in issues but it didn't work

Trying to set :
os.environ['PYOPENGL_PLATFORM'] = 'egl'
in file: anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/pyrender/renderer.py line 10, but it didn't work

Motion Generation - Unable to load OpenGL library

Thank you for your work.

The avatar generation part works great, but I am facing difficulties with the motion generation part.

For reference:

(AvatarCLIP) eitan.levy@lambda2:~/AvatarCLIP/AvatarAnimate$ python main.py --conf confs/pose_ablation/pose_optimizer/argue.conf
Traceback (most recent call last):
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/osmesa.py", line 25, in GL
mode=ctypes.RTLD_GLOBAL
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/ctypesloader.py", line 45, in loadLibrary
return dllType( name, mode )
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/ctypes/init.py", line 364, in init
self._handle = _dlopen(self._name, mode)
OSError: ('libgcrypt.so.11: cannot open shared object file: No such file or directory', '/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/libOSMesa.so.8', '/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/libOSMesa.so.8')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 12, in
from visualize import render_pose, render_motion
File "/home/eitan.levy/AvatarCLIP/AvatarAnimate/visualize.py", line 9, in
import pyrender
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/pyrender/init.py", line 3, in
from .light import Light, PointLight, DirectionalLight, SpotLight
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/pyrender/light.py", line 10, in
from OpenGL.GL import *
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/GL/init.py", line 3, in
from OpenGL import error as _error
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/error.py", line 12, in
from OpenGL import platform, _configflags
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/init.py", line 35, in
_load()
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/init.py", line 32, in _load
plugin.install(globals())
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 92, in install
namespace[ name ] = getattr(self,name,None)
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/osmesa.py", line 66, in GetCurrentContext
function = self.OSMesa.OSMesaGetCurrentContext
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/osmesa.py", line 60, in OSMesa
def OSMesa( self ): return self.GL
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/osmesa.py", line 28, in GL
raise ImportError("Unable to load OpenGL library", *err.args)
ImportError: ('Unable to load OpenGL library', 'libgcrypt.so.11: cannot open shared object file: No such file or directory', '/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/libOSMesa.so.8', '/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/libOSMesa.so.8')
(AvatarCLIP) eitan.levy@lambda2:~/AvatarCLIP/AvatarAnimate$ python3 main.py --conf confs/pose_ablation/pose_optimizer/argue.conf
/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/clip/clip.py:24: UserWarning: PyTorch version 1.7.1 or higher is recommended
warnings.warn("PyTorch version 1.7.1 or higher is recommended")
Traceback (most recent call last):
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/osmesa.py", line 25, in GL
mode=ctypes.RTLD_GLOBAL
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/ctypesloader.py", line 45, in loadLibrary
return dllType( name, mode )
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/ctypes/init.py", line 364, in init
self._handle = _dlopen(self._name, mode)
OSError: ('libgcrypt.so.11: cannot open shared object file: No such file or directory', '/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/libOSMesa.so.8', '/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/libOSMesa.so.8')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 12, in
from visualize import render_pose, render_motion
File "/home/eitan.levy/AvatarCLIP/AvatarAnimate/visualize.py", line 9, in
import pyrender
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/pyrender/init.py", line 3, in
from .light import Light, PointLight, DirectionalLight, SpotLight
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/pyrender/light.py", line 10, in
from OpenGL.GL import *
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/GL/init.py", line 3, in
from OpenGL import error as _error
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/error.py", line 12, in
from OpenGL import platform, _configflags
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/init.py", line 35, in
_load()
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/init.py", line 32, in _load
plugin.install(globals())
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 92, in install
namespace[ name ] = getattr(self,name,None)
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/osmesa.py", line 66, in GetCurrentContext
function = self.OSMesa.OSMesaGetCurrentContext
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/osmesa.py", line 60, in OSMesa
def OSMesa( self ): return self.GL
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 14, in get
value = self.fget( obj )
File "/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/OpenGL/platform/osmesa.py", line 28, in GL
raise ImportError("Unable to load OpenGL library", *err.args)
ImportError: ('Unable to load OpenGL library', 'libgcrypt.so.11: cannot open shared object file: No such file or directory', '/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/libOSMesa.so.8', '/home/eitan.levy/anaconda3/envs/AvatarCLIP/lib/libOSMesa.so.8')

I cannot seem to solve this problem.

AvatarCLIP/AvatarAnimate

class PoseOptimizer(BasePoseGenerator):
"""
This method will directly optimize SMPL theta with the guidance from CLIP
"""
def init(self,
optim_name: Optional[str] = 'Adam',
optim_cfg: Optional[dict] = {'lr': 0.01},
num_iteration: Optional[int] = 500,
**kwargs):
super().init(**kwargs)
self.optim_name = optim_name
self.optim_cfg = optim_cfg
self.num_iteration = num_iteration

def get_pose(self, text_feature: Tensor) -> Tensor:
    pose = nn.Parameter(torch.randn(63, requires_grad=True).to(self.device))
    cls = getattr(torch.optim, self.optim_name)
    optimizer = cls([pose], **self.optim_cfg)
    print(optimizer)
    for i in tqdm(range(self.num_iteration)):
        new_pose = pose.to(self.device)
        clip_feature = self.get_pose_feature(new_pose).squeeze(0)
        loss = 1 - F.cosine_similarity(clip_feature, text_feature, dim=-1)
        # loss = loss.mean()
        torch.autograd.set_detect_anomaly(True)
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
    return pose_padding(pose.data).to(self.device)

def get_topk_poses(self, text: str) -> Tensor:
    text_feature = self.get_text_feature(text)
    poses = [self.get_pose(text_feature) for _ in range(self.topk)]
    poses = self.sort_poses_by_score(text, poses)
    poses = torch.stack(poses, dim=0)
    return poses

root@autodl-container-60e5119152-54c37f51:~/autodl-tmp/AvatarCLIP/AvatarAnimate# python main.py --conf confs/pose_ablation/pose_optimizer/argue.conf
2023-10-28 14:55:47.830 | INFO | human_body_prior.tools.model_loader:load_model:97 - Loaded model in eval mode with trained weights: data/vposer/snapshots/V02_05_epoch=08_val_loss=0.03.ckpt
Adam (
Parameter Group 0
amsgrad: False
betas: (0.9, 0.999)
eps: 1e-08
lr: 0.01
maximize: False
weight_decay: 0
)
0%| | 0/500 [00:00<?, ?it/s]
Traceback (most recent call last):
File "main.py", line 52, in
main(args.conf)
File "main.py", line 27, in main
candidate_poses = pose_generator.get_topk_poses(text)
File "/root/autodl-tmp/AvatarCLIP/AvatarAnimate/models/pose_generation.py", line 141, in get_topk_poses
poses = [self.get_pose(text_feature) for _ in range(self.topk)]
File "/root/autodl-tmp/AvatarCLIP/AvatarAnimate/models/pose_generation.py", line 141, in
poses = [self.get_pose(text_feature) for _ in range(self.topk)]
File "/root/autodl-tmp/AvatarCLIP/AvatarAnimate/models/pose_generation.py", line 135, in get_pose
loss.backward()
File "/root/miniconda3/lib/python3.8/site-packages/torch/_tensor.py", line 363, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
File "/root/miniconda3/lib/python3.8/site-packages/torch/autograd/init.py", line 173, in backward
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

Motion Generation

Congratulations @hongfz16 very impactful work to the community. I was amazed by your work. However, I wanted to ask if you can upload Motion generation code and give a guideline of how to use it. Thank you

getting the textures of the avatars from the gallery

Hi,
I've downloaded the avatars from the gallery (tried both .glb and .fbx formats) and I can't find their textures.
When loading into Blender or Unity the avatar is rendered without textures.
Are the textures in another location I'm missing?

Motion Generation: Generate less than 5 poses thus failing to generate motions.

The config file is:

general {
    base_exp_dir = ./exp/motion_ablation/motion_optimizer/run
    mode = motion
    text = a rendered 3d male is standing depressingly
}

pose_generator {
    type = VPoserCodebook
}

motion_generator {
    type = MotionInterpolation
}

Then the error

Traceback (most recent call last):
File "main.py", line 67, in
main(args.conf)
File "main.py", line 47, in main
motion = motion_generator.get_motion(text, poses=candidate_poses)
File "./AvatarCLIP/AvatarAnimate/models/motion_generation.py", line 128, in get_motion
end_code = candidate_latent_codes[i]
IndexError: index 4 is out of bounds for dimension 0 with size 4"

is displayed.

I think the problem may come from the code in line 327 in AvatarAnimate/models/pose_generation.py

poses = self.suppress_duplicated_poses(poses, threshold=self.filter_threshold)

After "suppress_duplicated_poses", there may be less than k(in this context k=5) poses, thus failing to generate corresponding motions.

No module named 'skimage'

Followed instructions, would not run...

(AvatarCLIP) ➜  ShapeGen git:(main) python main.py --target_txt 'a 3d rendering of a strong man in unreal engine'
Traceback (most recent call last):
  File "main.py", line 9, in <module>
    import neural_renderer as nr
  File "/home/user/miniconda3/envs/AvatarCLIP/lib/python3.7/site-packages/neural_renderer/__init__.py", line 3, in <module>
    from .load_obj import load_obj
  File "/home/user/miniconda3/envs/AvatarCLIP/lib/python3.7/site-packages/neural_renderer/load_obj.py", line 6, in <module>
    from skimage.io import imread
ModuleNotFoundError: No module named 'skimage'

The correspondence between the codebook and the codebook_embedding

Hi,

I'm glad to read your publication and try your released demo. As for motion generation, the essential item should be the correspondence between the codebook and the codebook_embedding. However, when I checked your code, I found that the CLIL features of the decoded poses of the codebook are not equivalent to those of the codebook_embedding. From Fig, 8 of the paper, I found that the CLIP feature of one pose is the sum of multiple CLIP features of different views of that pose. Would you mind describing more details of how to calculate the codebook and codebook_embeding? If you can release the code for extracting codebook_embedding, I will be more than grateful.

Thank you in advance.

Best wishes,
Jack

Applying a generated motion on a generated avatar

Hello,

I am not able to understand how to apply a generated motion on a an avatar I generated.

I want to be able get something like: "A skinny ninja that is raising both arms" that you had in the example.

I understand how to generate a skinny ninja, and how to generate a generic man that is raising both arms - but how do I get a skinny ninja that is raising both arms?

Thank you.

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.