otaheri / chamfer_distance

Implementation of the Chamfer Distance as a module for PyTorch
MIT License
166 stars 20 forks source link

ImportError: cannot import name 'Volumes' from 'pytorch3d.structures' #11

Closed dennisushi closed 1 year ago

dennisushi commented 1 year ago

ImportError: cannot import name 'Volumes' from 'pytorch3d.structures' (/home/dennisushi/.local/lib/python3.8/site-packages/pytorch3d/structures/__init__.py)

When running

import torch
from chamfer_distance import ChamferDistance as chamfer_dist
import time

p1 = torch.rand([10,25,3])
p2 = torch.rand([10,15,3])

s = time.time()
chd = chamfer_dist()
dist1, dist2, idx1, idx2 = chd(p1,p2)
loss = (torch.mean(dist1)) + (torch.mean(dist2))

torch.cuda.synchronize()
print(f"Time: {time.time() - s} seconds")
print(f"Loss: {loss}")

Seems like the recommended version of pytorch3d might be too new. (0.7.2 from git+https://github.com/facebookresearch/pytorch3d.git@stable )

dennisushi commented 1 year ago

It exists : https://github.com/facebookresearch/pytorch3d/blob/main/pytorch3d/structures/volumes.py

But isn't found by python:

dir(pytorch3d.structures)

['Meshes',
 'Pointclouds',
 '__all__',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 'join_meshes_as_batch',
 'join_meshes_as_scene',
 'list_to_packed',
 'list_to_padded',
 'meshes',
 'packed_to_list',
 'padded_to_list',
 'pointclouds',
 'utils']
dennisushi commented 1 year ago

It's not an issue with this package, rather with PyTorch3d. Closing.