point2mesh icon indicating copy to clipboard operation
point2mesh copied to clipboard

Update this code to the pytorch 2.0 numpy 1.24

Open louhz opened this issue 2 years ago • 4 comments
trafficstars

Hi, I just update this code to pytorch 2.0 and numpy 1.24 by replace the np.bool to bool, adding device consistency for pytorch and also fix the dtype of inhomogeneous array of vei to object.

I test it and the result looks good so if anyone need help for the latest version of this code I can send a pull request

louhz avatar Nov 01 '23 08:11 louhz

Hi ,can you send the latest version of this code? Thank you very much.

cqulyx avatar Nov 08 '23 04:11 cqulyx

So the code below are the change I made:

mesh_pool.py: line 35 change to :mask = np.ones(mesh.edges_count, dtype=bool)

mesh.py:line 91-95

  self.vei = torch.from_numpy(np.concatenate(np.array(self.vei, dtype=object)).ravel()).to(self.device).long()
    self.nvsi = torch.Tensor(np.concatenate(np.array(self.nvsi, dtype=object)).ravel()).to(self.device).long()
    self.nvsin = torch.from_numpy(np.concatenate(np.array(self.nvsin, dtype=object)).ravel()).to(self.device).long()
    ve_in = copy.deepcopy(self.ve)
    self.ve_in = torch.from_numpy(np.concatenate(np.array(ve_in, dtype=object)).ravel()).to(self.device).long()

louhz avatar Nov 09 '23 13:11 louhz

Now maybe you should also change some other lines in mesh.py to make sure all tensors and their indexes are on the same devices.

XuGW-Kevin avatar Jan 22 '24 15:01 XuGW-Kevin

Here is what I do to make sure all tensors and their indexes are on the same device.

add after mesh.py line 27

self.v_mask = np.ones(len(self.vs), dtype=bool)
self.v_mask = torch.from_numpy(self.v_mask).to(self.device)

replace mesh.py line 368 with:

# face = self.sub_mesh_index[i][face].to(face.device).long()
face = face.to(self.sub_mesh_index[i].device).long()
face = self.sub_mesh_index[i][face]

Daoming-Chen avatar Mar 05 '24 05:03 Daoming-Chen