Run test_image.py error
rush9838465 opened this issue · comments
Can you help me? Thank you~
There is an error in step 4:
- ./runtests.sh # -D_GLIBCXX_USE_CXX11_ABI=0 to -D_GLIBCXX_USE_CXX11_ABI=1
- bazel build ...
- copy MGCNet/tf_mesh_renderer/bazel-out/k8-fastbuild/bin/mesh_renderer/kernels/rasterize_triangles_kernel.so
to MGCNet/thirdParty/tf_mesh_renderer/mesh_renderer/kernels - python test_images.py
NOTE: tensorflow-gpu1.13.1 ubuntu18.04
ERROR:
Connected to pydev debugger (build 201.7223.92)
/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
/home/george/pycharm/face_3d/MGCNet
Finish copy
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:54: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
pt_mean = self.hdf5io_pt_model.GetValue('mean').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:58: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
pt_pcaBasis = self.hdf5io_pt_model.GetValue('pcaBasis').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:61: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
pt_pcaVariance = self.hdf5io_pt_model.GetValue('pcaVariance').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:76: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
rgb_mean = self.hdf5io_rgb_model.GetValue('mean').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:80: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
rgb_pcaBasis = self.hdf5io_rgb_model.GetValue('pcaBasis').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:83: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
rgb_pcaVariance = self.hdf5io_rgb_model.GetValue('pcaVariance').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:89: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
uv = self.hdf5io_rgb_model.GetValue('uv').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:133: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
exp_pcaBasis = self.hdf5io_exp_model.GetValue('pcaBasis').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:136: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
exp_pcaVariance = self.hdf5io_exp_model.GetValue('pcaVariance').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:145: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
mesh_tri_reference = self.hdf5io_pt_representer.GetValue('tri').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:153: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
idx_subTopo = self.hdf5io_pt_representer.GetValue('idx_sub').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:158: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
self.nplist_v_ring_f_flat_np = self.hdf5io_pt_representer.GetValue('vertex_ring_face_flat').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:160: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
self.nplist_ver_ref_face_num = self.hdf5io_pt_representer.GetValue('vertex_ring_face_num').value
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:236: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
return np.array(list_v_ring_f), np.array(list_v_ring_f_index)
/home/george/pycharm/face_3d/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:167: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
idx_lm68_np = self.hdf5io_pt_representer.GetValue('idx_lm68').value
WARNING:tensorflow:From /home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /home/george/pycharm/face_3d/MGCNet/src_common/geometry/render/lighting.py:151: calling norm (from tensorflow.python.ops.linalg_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
WARNING:tensorflow:From /home/george/pycharm/face_3d/MGCNet/src_common/geometry/render/api_tf_mesh_render.py:266: calling l2_normalize (from tensorflow.python.ops.nn_impl) with dim is deprecated and will be removed in a future version.
Instructions for updating:
dim is deprecated, use axis instead
WARNING:tensorflow:From /home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
Traceback (most recent call last):
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
return fn(*args)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: RasterizeTriangles expects vertices to have shape (-1, 4).
[[{{node RasterizeTriangles_12}}]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/george/.conda/envs/cuda10/lib/python3.7/contextlib.py", line 130, in exit
self.gen.throw(type, value, traceback)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 5253, in get_controller
yield g
File "/home/george/pycharm/face_3d/MGCNet/mytest_image.py", line 131, in
pred = system.inference(sess, image_rgb_b)
File "/home/george/pycharm/face_3d/MGCNet/src_tfGraph/build_graph.py", line 1103, in inference
results = sess.run(fetches, feed_dict={'pl_input:0':inputs})
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: RasterizeTriangles expects vertices to have shape (-1, 4).
[[node RasterizeTriangles_12 (defined at :223) ]]
Caused by op 'RasterizeTriangles_12', defined at:
File "/opt/pycharm-2020.1.1/plugins/python/helpers/pydev/pydevd.py", line 2131, in
main()
File "/opt/pycharm-2020.1.1/plugins/python/helpers/pydev/pydevd.py", line 2122, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/opt/pycharm-2020.1.1/plugins/python/helpers/pydev/pydevd.py", line 1431, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/opt/pycharm-2020.1.1/plugins/python/helpers/pydev/pydevd.py", line 1438, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/opt/pycharm-2020.1.1/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/george/pycharm/face_3d/MGCNet/mytest_image.py", line 88, in
FLAGS, img_height=FLAGS.img_height, img_width=FLAGS.img_width, batch_size=FLAGS.batch_size
File "/home/george/pycharm/face_3d/MGCNet/src_tfGraph/build_graph.py", line 949, in build_test_graph
self.build_testVisual_graph()
File "/home/george/pycharm/face_3d/MGCNet/src_tfGraph/build_graph.py", line 1059, in build_testVisual_graph
self.gpmm_frustrum, gpmm_tar_mv, gpmm_tar_eye, fore=opt.flag_fore, tone=False
File "/home/george/pycharm/face_3d/MGCNet/src_tfGraph/deep_3dmm_decoder.py", line 267, in decoder_renderColorMesh
mtx_perspect_frustrum, list_mtx_model_view[i], list_cam_position[i], tone
File "/home/george/pycharm/face_3d/MGCNet/src_tfGraph/deep_3dmm_decoder.py", line 459, in gpmm_render_image
mtx_perspect_frustrum, cam_position, opt.img_width, opt.img_height)
File "/home/george/pycharm/face_3d/MGCNet/src_common/geometry/render/api_tf_mesh_render.py", line 99, in mesh_renderer_camera_light
image_width, image_height, [-1] * vertex_attributes.shape[2].value)
File "/home/george/pycharm/face_3d/MGCNet/thirdParty/tf_mesh_renderer/mesh_renderer/rasterize_triangles.py", line 125, in rasterize_triangles
image_height))
File "", line 223, in rasterize_triangles
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/home/george/.conda/envs/cuda10/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1801, in init
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): RasterizeTriangles expects vertices to have shape (-1, 4).
[[node RasterizeTriangles_12 (defined at :223) ]]
Process finished with exit code 1
Hi, there is a cue that u can follow
tensorflow.python.framework.errors_impl.InvalidArgumentError: RasterizeTriangles expects vertices to have shape (-1, 4). [[{{node RasterizeTriangles_12}}]]
This seems the tf_mesh_render get the wrong input, you can check the input for rendering about (vertex, tri, color), to see if there is something wrong.
tf_mesh_render is widely used, itself is robust
@jiaxiangshang Thank you very much!
@jiaxiangshang Thank you very much!
Thanks you for using our work.
@jiaxiangshang
@rush9838465
I meet the same problem, how do you solve it in detail ?
Have u changed the code?
change which ?
If you just run the whole code, no man meet the same problem.
you mean ?
(1) For render loss(reconstruction loss), we use the differential renderer named tf_mesh_render(thanks!) https://github.com/google/tf_mesh_renderer. I find many issue happens here, so let's make this more clear. The tf_mesh_render does not return triangle id for each pixel after rasterise, we do this by our self and add these changes as submodule to mgcnet.
(2) Then how to compile tf_mesh_render, my setting is bazel==10.1, gcc==5.*, the compile command is
bazel build ...
The gcc/g++ version higher than 5.* will bring problems, a good solution is virtual environment with a gcc maybe 5.5. If the The gcc/g++ version is 4.* that you can try to change the compile cmd in BUILD file, about the flag -D_GLIBCXX_USE_CXX11_ABI=0 or -D_GLIBCXX_USE_CXX11_ABI=1 for 4.* or 5.*
Do u use all the code, or just pick a part of the code and plug in your project.
I use all the code.
Can u give more information, success training some steps or fail at the first step?
Leant the camera pose or not?
Use standard file APIs to check for files with this prefix.
Traceback (most recent call last):
File "test_image.py", line 131, in
pred = system.inference(sess, image_rgb_b)
File "/source/code/chenbl/src/MGCNet/src_tfGraph/build_graph.py", line 1103, in inference
results = sess.run(fetches, feed_dict={'pl_input:0':inputs})
File "/home/chenbl/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 950, in run
run_metadata_ptr)
File "/home/chenbl/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1173, in _run
feed_dict_tensor, options, run_metadata)
File "/home/chenbl/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run
run_metadata)
File "/home/chenbl/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: RasterizeTriangles expects vertices to have shape (-1, 4).
[[node RasterizeTriangles_4 (defined at :230) ]]
Errors may have originated from an input operation.
Input Source operations connected to node RasterizeTriangles_4:
Const_14 (defined at /source/code/chenbl/src/MGCNet/src_common/geometry/gpmm/bfm09_tf_uv.py:220)
strided_slice_80 (defined at /source/code/chenbl/src/MGCNet/src_common/tf_mesh_renderer/mesh_renderer/rasterize_triangles.py:128)
Original stack trace for u'RasterizeTriangles_4':
File "test_image.py", line 88, in
FLAGS, img_height=FLAGS.img_height, img_width=FLAGS.img_width, batch_size=FLAGS.batch_size
File "/source/code/chenbl/src/MGCNet/src_tfGraph/build_graph.py", line 949, in build_test_graph
self.build_testVisual_graph()
File "/source/code/chenbl/src/MGCNet/src_tfGraph/build_graph.py", line 982, in build_testVisual_graph
self.gpmm_frustrum, self.dict_inter_comm['pred_cam_mv'][v], self.dict_inter_comm['pred_cam_eye'][v], fore=opt.flag_fore, tone=False
File "/source/code/chenbl/src/MGCNet/src_tfGraph/deep_3dmm_decoder.py", line 267, in decoder_renderColorMesh
mtx_perspect_frustrum, list_mtx_model_view[i], list_cam_position[i], tone
File "/source/code/chenbl/src/MGCNet/src_tfGraph/deep_3dmm_decoder.py", line 459, in gpmm_render_image
mtx_perspect_frustrum, cam_position, opt.img_width, opt.img_height)
File "/source/code/chenbl/src/MGCNet/src_common/geometry/render/api_tf_mesh_render.py", line 106, in mesh_renderer_camera_light
image_width, image_height, [-1] * vertex_attributes.shape[2].value)
File "/source/code/chenbl/src/MGCNet/src_common/tf_mesh_renderer/mesh_renderer/rasterize_triangles.py", line 129, in rasterize_triangles
image_height))
File "", line 230, in rasterize_triangles
File "/home/chenbl/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/chenbl/.local/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/chenbl/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3616, in create_op
op_def=op_def)
File "/home/chenbl/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2005, in init
self._traceback = tf_stack.extract_stack()
for tf_mesh_renderer do you download from https://github.com/google/tf_mesh_renderer
no, I use jiaxiangshang/tf_mesh_renderer.
so what is the problem?
For test phase, there are diffcult to have nan value leading to such error.
How about turn off the flag_visual.
closed as no further response