ranahanocka / MeshCNN

Convolutional Neural Network for 3D meshes in PyTorch
MIT License
1.58k stars 316 forks source link

ValueError: index can't contain negative values #18

Closed sutongkui closed 5 years ago

sutongkui commented 5 years ago

I used classification pretrained parameters, the test works well for edges 750, but then I subdivide the mesh to 3000 edges(apply 1 loop, still manifold), and set --pool_res 2500 2000 1500 1000, error occurs below, do I have to use the fixed edges(like 750) as input? How to deal with dense meshes, do we need to retrain it?

Running Test 
loaded mean / std from cache  
loading the model from ./checkpoints\mytest\latest_net.pth  
Traceback (most recent call last):  
  File "test.py", line 25, in <module>  
    run_test()  
  File "test.py", line 16, in run_test  
    for i, data in enumerate(dataset):  
  File "E:\Github\MeshCNN\data\__init__.py", line 33, in __iter__
    for i, data in enumerate(self.dataloader):
  File "D:\DevTool\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 582, in __next__
    return self._process_next_batch(batch)
  File "D:\DevTool\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 608, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
ValueError: Traceback (most recent call last):
  File "D:\DevTool\anaconda3\lib\site-packages\torch\utils\data\_utils\worker.py", line 99, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "D:\DevTool\anaconda3\lib\site-packages\torch\utils\data\_utils\worker.py", line 99, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "E:\Github\MeshCNN\data\classification_data.py", line 31, in __getitem__
    edge_features = pad(edge_features, self.opt.ninput_edges)
  File "E:\Github\MeshCNN\util\util.py", line 22, in pad
    return np.pad(input_arr, pad_width=npad, mode='constant', constant_values=val)
  File "D:\DevTool\anaconda3\lib\site-packages\numpy\lib\arraypad.py", line 1172, in pad
    pad_width = _as_pairs(pad_width, narray.ndim, as_index=True)
  File "D:\DevTool\anaconda3\lib\site-packages\numpy\lib\arraypad.py", line 949, in _as_pairs
    raise ValueError("index can't contain negative values")
ValueError: index can't contain negative values
ranahanocka commented 5 years ago

Did you change the ninput_edges flag to 3000 (the default is 750)? Do that by passing: --ninput_edges 3000. Also, I assume that your training architecture also used --pool_res 2500 2000 1500 1000, otherwise it won't work

sutongkui commented 5 years ago

oh. I forgot to change the default ninput_edges to 3000. you mean that I need to retrain it with the new pooling size?as we know, the real meshes vary from hundreds to hundreds of thousabds, is there a way to handle this with one net,instead of training once for each size. I am trying to use meshcnn as a new method to handle mesh simplification.just like what simplygon does.

ranahanocka commented 5 years ago

The --pool_res defines hyper-parameters of the network (aka the network architecture). You cannot use a different network architectures for train / test.

You can re-train the network on your data, define new hyper-parameters for your set, and use the same one for train / test.

ranahanocka commented 5 years ago

@sutongkui - closing this issue as I haven't heard from you in a while. If you still need further clarification , let me know.

claell commented 4 years ago

As described in #46, I run into this error with files normalized to 300 or 600 faces resulting in about 500 or 1000 edges. I have to set the number of input edges to 2000 to overcome the error.

claell commented 4 years ago

Works for me now, I have used problematic input data before.