walsvid / Pixel2MeshPlusPlus

Pixel2Mesh++: Multi-View 3D Mesh Generation via Deformation. In ICCV2019.
https://arxiv.org/abs/1908.01491
BSD 3-Clause "New" or "Revised" License
354 stars 56 forks source link

indices[0,7]= -1 is nor in [0,157] #11

Closed lkf1996 closed 4 years ago

lkf1996 commented 4 years ago

hello! Have you run the train.py successfully? I got a problem "InvalidArgumenrError : indices[0,7]= -1 is nor in [0,157] " when run in "sess.run(model , feed_dict = feed_dict" .

The train data is loaded in this github , It has upset me for many days .
Hope for your reply ``

walsvid commented 4 years ago

Hi, @lkf1996 Could you give more complete information such as the output of error messages and the version environment of the program you are using?

lkf1996 commented 4 years ago

嗨,@ lkf1996您能否提供更完整的信息,例如错误消息的输出以及所使用程序的版本环境?

Thanks for ur reply , I used 2080ti, tensorflow-gpu 1.12.0, CUDA 9.0, cudnn7.3 to reproduce the code test part, but I encountered a bug in the middle. I found that the reason was that running on 2080ti would crash, so I used CPU to reproduce . but the new error occured. `020-07-25 08:19:36.773742: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:198] kernel reported version is: 430.50.0 2020-07-25 08:19:36.773749: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:305] kernel version seems to match DSO: 430.50.0 => start train stage 1 Traceback (most recent call last): File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call return fn(*args) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[0,7] = -1 is not in [0, 157) [[{{node GatherV2_21}} = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](concat_5, strided_slice_27, gradients/graph_proj_3_layer_31/Max_grad/mod)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/train_mvp2m.py", line 141, in main(args) File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/trainmvp2m.py", line 119, in main , dists, summaries, out1, out3, out3 = sess.run([model.opt_op, model.loss, model.merged_summary_op, model.output1, model.output2, model.output3], feed_dict=feed_dict) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1152, in _run feed_dict_tensor, options, run_metadata) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run run_metadata) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/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: indices[0,7] = -1 is not in [0, 157) [[node GatherV2_21 (defined at /home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/modules/losses.py:19) = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](concat_5, strided_slice_27, gradients/graph_proj_3_layer_31/Max_grad/mod)]]

Caused by op 'GatherV2_21', defined at: File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/train_mvp2m.py", line 141, in main(args) File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/train_mvp2m.py", line 75, in main model = MeshNetMVP2M(placeholders, logging=True, args=cfg) File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/modules/models_mvp2m.py", line 95, in init self.build() File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/modules/models_mvp2m.py", line 253, in build self._loss() File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/modules/models_mvp2m.py", line 103, in _loss self.loss += laplace_loss(self.inputs, self.output1, self.placeholders, 1) File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/modules/losses.py", line 26, in laplace_loss lap1 = laplace_coord(pred1, placeholders, block_id) File "/home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/modules/losses.py", line 19, in laplace_coord laplace = tf.reduce_sum(tf.gather(vertex, indices), 1) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py", line 2675, in gather return gen_array_ops.gather_v2(params, indices, axis, name=name) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3332, in gather_v2 "GatherV2", params=params, indices=indices, axis=axis, name=name) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func return func(*args, **kwargs) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op op_def=op_def) File "/home/zhaolei/.conda/envs/tensorflow-1.13.1/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1770, in init self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): indices[0,7] = -1 is not in [0, 157) [[node GatherV2_21 (defined at /home/zhaolei/tensorflow_code/Pixel2MeshPlusPlus-master/modules/losses.py:19) = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](concat_5, strided_slice_27, gradients/graph_proj_3_layer_31/Max_grad/mod)]]

`

I had take much time to solve it , I will appreciate it if you can help me.

lkf1996 commented 4 years ago

Hi, @lkf1996 Could you give more complete information such as the output of error messages and the version environment of the program you are using?

In losses.py , when def laplace_coord , the code"laplace = tf.reduce_sum(tf.gather(vertex,indices),1)," There is "-1" in indices(lape_idx) . But It's not even running here, it has reported an error

walsvid commented 4 years ago

It seems that you use tensorflow-1.13.1/. Anyway, after I check the code I think this issue is due to the API change of tensorflow. During the time we build this model, tf.gather can take -1 as index, however it change to [0, maxindex) now.

Luckily, the solution is not hard. After read the pickle file in https://github.com/walsvid/Pixel2MeshPlusPlus/blob/master/utils/tools.py#L14 , you need to add some code to change the index -1 to the last positive index of each block. Since we have 156, 618, 2466 vertices in 3 blocks. So we can change -1 to 156, 618, 2466 respectively.

The minimal code added are as follows:

lape_idx[0][lape_idx[0] == -1] = 156
lape_idx[1][lape_idx[0] == -1] = 618
lape_idx[2][lape_idx[0] == -1] = 2466
lkf1996 commented 4 years ago

看来您使用了tensorflow-1.13.1/。无论如何,在检查代码后,我认为此问题是由于tensorflow的API更改所致。在我们构建此模型的过程中,tf.gather可以将其-1作为索引,但是现在更改为[0,maxindex)。

幸运的是,解决方案并不难。 读取https://github.com/walsvid/Pixel2MeshPlusPlus/blob/master/utils/tools.py#L14中的pickle文件后,您需要添加一些代码以将索引-1更改为每个块的最后一个正索引。由于我们在3个块中有156、618、2466个顶点。因此我们可以将-1分别更改为156、618、2466。

添加的最少代码如下:

lape_idx[0][lape_idx[0] == -1] = 156
lape_idx[1][lape_idx[0] == -1] = 618
lape_idx[2][lape_idx[0] == -1] = 2466

thanks. I had resolved it by change the "-1" to "0"

lkf1996 commented 4 years ago

看来您使用了tensorflow-1.13.1/。无论如何,在检查代码后,我认为此问题是由于tensorflow的API更改所致。在我们构建此模型的过程中,tf.gather可以将其-1作为索引,但是现在更改为[0,maxindex)。

幸运的是,解决方案并不难。 读取https://github.com/walsvid/Pixel2MeshPlusPlus/blob/master/utils/tools.py#L14中的pickle文件后,您需要添加一些代码以将索引-1更改为每个块的最后一个正索引。由于我们在3个块中有156、618、2466个顶点。因此我们可以将-1分别更改为156、618、2466。

添加的最少代码如下:

lape_idx[0][lape_idx[0] == -1] = 156
lape_idx[1][lape_idx[0] == -1] = 618
lape_idx[2][lape_idx[0] == -1] = 2466

Excuse me? I firstly read the code about “Pixel2mesh” , I found a file named “GenerateData” , but it does not apply to this code . Can you share the new way to generatedata? because I want to train my own dataset. Thanks for the trouble.

walsvid commented 4 years ago

Hi, @lkf1996 . We use the same method to generate data. All the generate data code have been upload to pixel2mesh repo.

walsvid commented 4 years ago

thanks. I had resolved it by change the "-1" to "0"

I don't think change to 0 is correct, you should change to the max index of each stage. 0 is the 1st vertices, and -1 is the dummy vertex for padding which is the 156th, 618th and 2466th vertex in 3 stages.

lkf1996 commented 4 years ago

thanks. I had resolved it by change the "-1" to "0"

I don't think change to 0 is correct, you should change to the max index of each stage. 0 is the 1st vertices, and -1 is the dummy vertex for padding which is the 156th, 618th and 2466th vertex in 3 stages.

Thank you for your reply. I added the 0 vector to the first column and the value of indices by adding "1", so as to avoid the error of "-1". Thank you for your guidance Still on the data issue, I found that "Pixel2Mesh_aux_4Works.dat" and "PIXel2Mesh ++" in the folder "PIXel2Mesh ++" cannot be read in the same way, and "ICCV_P2mpp.dat" has added "faces_triangle", "sample_coord" and "sample_adj" to the data. If it's not the data, what's the problem?

walsvid commented 4 years ago

Hi, @lkf1996 .

  1. Pixel2Mesh_aux_4Works.dat add 4th stage to explain how to prepare data for mesh unpooling which is not used in P2M++
  2. faces_triangle is actually not used in P2M and P2M++
  3. sample_coord and sample_adj is used for Hypothesis Sampling in our paper, the sampled coord and its adjacency is fixed constant is our implementation.
lkf1996 commented 4 years ago

Hi, @lkf1996 .

  1. Pixel2Mesh_aux_4Works.dat add 4th stage to explain how to prepare data for mesh unpooling which is not used in P2M++
  2. faces_triangle is actually not used in P2M and P2M++
  3. sample_coord and sample_adj is used for Hypothesis Sampling in our paper, the sampled coord and its adjacency is fixed constant is our implementation.

thank you for your reply. May I ask what graphics card you use to run this program? I used 2080RTX and had the same problem as the previous one. He used 2080Ti. None of us could run this program under GPU, otherwise the following problems would occur. The following is the link of issue. https://github.com/walsvid/Pixel2MeshPlusPlus/issues/10#issue-640106275

walsvid commented 4 years ago

We use TitanXp or 1080Ti with CUDA9

tPPMc-cs commented 2 years ago

I think it should be like this: lape_idx[0][lape_idx[0] == -1] = 156 lape_idx[1][lape_idx[1] == -1] = 618 lape_idx[2][lape_idx[2] == -1] = 2466