microsoft / Deep3DFaceReconstruction

Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set (CVPRW 2019)
MIT License
2.18k stars 443 forks source link

RasterizeTriangles expects vertices to have shape (-1, 3). #143

Open 15458wew opened 3 years ago

15458wew commented 3 years ago

Hello, thank you for opening up such a good job. I found the following problems during study, can you tell me a solution. Thanks you.

Use tf.where in 2.0, which has the same broadcast rule as np.where 2021-03-30 16:08:24.343185: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile. Traceback (most recent call last): File "/home/research/weiwenqi/anaconda3/envs/snowflake_weiwenqi/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call return fn(*args) File "/home/research/weiwenqi/anaconda3/envs/snowflake_weiwenqi/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/research/weiwenqi/anaconda3/envs/snowflake_weiwenqi/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: RasterizeTriangles expects vertices to have shape (-1, 3). [[{{node while/RasterizeTriangles}}]]

YuDeng commented 3 years ago

You have to try the older version of tf_mesh_renderer as suggested in the readme. The latest version of tf_mesh_renderer changes the input format of the function which causes the error.

quhb2455 commented 2 years ago

Hi @15458wew, i have same error. Did you solve it?

quhb2455 commented 2 years ago

Hi @15458wew, i have same error. Did you solve it?

Self Answer!!

my environment is : ubuntu 16.04 tensorflow-gpu 1.12.0 python 3.6.13

i didn't compile tf_mesh_renderer. i used pre-compiled .so file.

i got InvalidArgumentError (see above for traceback): RasterizeTriangles expects vertices to have shape (-1, 3). this error

just install mesh_rendere python package using pip install mesh_renderer.

Is there other way to solve this error without pip install mesh_renderer ?

UestcJay commented 2 years ago

hi

Hi @15458wew, i have same error. Did you solve it?

Self Answer!!

my environment is : ubuntu 16.04 tensorflow-gpu 1.12.0 python 3.6.13

i didn't compile tf_mesh_renderer. i used pre-compiled .so file.

i got InvalidArgumentError (see above for traceback): RasterizeTriangles expects vertices to have shape (-1, 3). this error

just install mesh_rendere python package using pip install mesh_renderer.

Is there other way to solve this error without pip install mesh_renderer ?

hi, my environment is same with yours, did you solve the problem?

quhb2455 commented 2 years ago

hi

Hi @15458wew, i have same error. Did you solve it?

Self Answer!! my environment is : ubuntu 16.04 tensorflow-gpu 1.12.0 python 3.6.13 i didn't compile tf_mesh_renderer. i used pre-compiled .so file. i got InvalidArgumentError (see above for traceback): RasterizeTriangles expects vertices to have shape (-1, 3). this error just install mesh_rendere python package using pip install mesh_renderer. Is there other way to solve this error without pip install mesh_renderer ?

hi, my environment is same with yours, did you solve the problem?

Yes! i solved it.

First, you need some package and check the version.

if you finish preparing, build tf_mesh_renderer like : bazel-4.1.0 test --python_path=/usr/bin/python --define=PYTHON=/usr/bin/python ... after then you can get a rasterize_triangles_kernel.so in tf_mesh_renderer\mesh_renderer\kernels

If you have rasterize_triangles_kernel.so successfully, copy some file like :

cp ./tf_mesh_renderer/mesh_renderer/{camera_utils.py,mesh_renderer.py,rasterize_triangles.py} ./renderer/
cp ./tf_mesh_renderer/bazel-bin/mesh_renderer/kernels/rasterize_triangles_kernel.so ./renderer/

and replace .so file path at ./renerer/rasterize_triangles.py line 25 ::

rasterize_triangles_module = tf.load_op_library(
    './renderer/rasterize_triangles_kernel.so')

it is the way to solve problem 😁 If you finish above steps successfully. you can use demo.py.

Songqiw commented 2 years ago

I had the same problem, and I found out why. I'm using a pre-compiled "rasterize_triangles_kernel.so". when I use mesh_renderer.py, rasterize_triangles.py and camera_utils.py from the latest version of tf mesh renderer, I would have this problem. But when I use the files in git checkout ba27ea1798, I don't have any problems