Code Monkey home page Code Monkey logo

lietorch's Introduction

LieTorch: Tangent Space Backpropagation

Introduction

The LieTorch library generalizes PyTorch to 3D transformation groups. Just as torch.Tensor is a multi-dimensional matrix of scalar elements, lietorch.SE3 is a multi-dimensional matrix of SE3 elements. We support common tensor manipulations such as indexing, reshaping, and broadcasting. Group operations can be composed into computation graphs and backpropagation is automatically peformed in the tangent space of each element. For more details, please see our paper:

Tangent Space Backpropagation for 3D Transformation Groups
Zachary Teed and Jia Deng, CVPR 2021

@inproceedings{teed2021tangent,
  title={Tangent Space Backpropagation for 3D Transformation Groups},
  author={Teed, Zachary and Deng, Jia},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2021},
}

Installation

Requirements:

  • Cuda >= 10.1 (with nvcc compiler)
  • PyTorch >= 1.8

We recommend installing within a virtual enviornment. Make sure you clone using the --recursive flag. If you are using Anaconda, the following command can be used to install all dependencies

git clone --recursive https://github.com/princeton-vl/lietorch.git
cd lietorch

conda create -n lie_env
conda activate lie_env
conda install scipy pyyaml pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

To run the examples, you will need OpenCV and Open3D. Depending on your operating system, OpenCV and Open3D can either be installed with pip or may need to be built from source

pip install opencv-python open3d

Installing (from source)

Clone the repo using the --recursive flag and install using setup.py (may take up to 10 minutes)

git clone --recursive https://github.com/princeton-vl/lietorch.git
python setup.py install
./run_tests.sh

Installing (pip)

You can install the library directly using pip

pip install git+https://github.com/princeton-vl/lietorch.git

Overview

LieTorch currently supports the 3D transformation groups.

Group Dimension Action
SO3 3 rotation
RxSO3 4 rotation + scaling
SE3 6 rotation + translation
Sim3 7 rotation + translation + scaling

Each group supports the following differentiable operations:

Operation Map Description
exp g -> G exponential map
log G -> g logarithm map
inv G -> G group inverse
mul G x G -> G group multiplication
adj G x g -> g adjoint
adjT G x g*-> g* dual adjoint
act G x R^3 -> R^3 action on point (set)
act4 G x P^3 -> P^3 action on homogeneous point (set)
matrix G -> R^{4x4} convert to 4x4 matrix
vec G -> R^D map to Euclidean embedding vector
InitFromVec R^D -> G initialize group from Euclidean embedding

 

Simple Example:

Compute the angles between all pairs of rotation matrices

import torch
from lietorch import SO3

phi = torch.randn(8000, 3, device='cuda', requires_grad=True)
R = SO3.exp(phi)

# relative rotation matrix, SO3 ^ {8000 x 8000}
dR = R[:,None].inv() * R[None,:]

# 8000x8000 matrix of angles
ang = dR.log().norm(dim=-1)

# backpropogation in tangent space
loss = ang.sum()
loss.backward()

Converting between Groups Elements and Euclidean Embeddings

We provide differentiable FromVec and ToVec functions which can be used to convert between LieGroup elements and their vector embeddings. Additional, the .matrix function returns a 4x4 transformation matrix.

# random quaternion
q = torch.randn(1, 4, requires_grad=True)
q = q / q.norm(dim=-1, keepdim=True)

# create SO3 object from quaternion (differentiable w.r.t q)
R = SO3.InitFromVec(q)

# 4x4 transformation matrix (differentiable w.r.t R)
T = R.matrix()

# map back to quaterion (differentiable w.r.t R)
q = R.vec()

Examples

We provide real use cases in the examples directory

  1. Pose Graph Optimization
  2. Deep SE3/Sim3 Registrtion
  3. RGB-D SLAM / VO

Acknowledgements

Many of the Lie Group implementations are adapted from Sophus.

lietorch's People

Contributors

jiadeng avatar zachteed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lietorch's Issues

bug in SE3.matrix()?

Hi, thanks so much for your awsome work. I've been trying to apply the libary in my project, but got some comfusions.

I was looking for the defininaiton of the se(3)'s 6D vector (i.e. if it's (rot_vec, trans_vec) or. (trans_vec, rot_vec)), but got the following results which seems wrong.

a.vec()
tensor([0.7433, 0.4080, 0.7250, 0.0628, 0.2401, 0.2408])

a.matrix()
tensor([[ 0.6560, -0.5883, 0.9783, 0.0628],
[ 0.5775, -0.4621, 0.1977, 0.2401],
[-0.4860, 0.6636, 0.0627, 0.2408],
[ 0.0000, 0.0000, 0.0000, 1.0000]])

a * torch.Tensor([0,0,0])
tensor([0.7433, 0.4080, 0.7250])

a.matrix() @ torch.Tensor([0,0,0,1])
tensor([0.0628, 0.2401, 0.2408, 1.0000])

it looks like matrix() is treating the se(3) 6D embedding as [rotation_vec, translation_vec], which conflits to the act() or * operations, where the embedding is apparently [translation_vec, rotation_vec].

CPU only version?

Hi thanks for the great work.
Is it possible to compile the library for CPU-only use? Do you have some simple instructions on how to modify the setup.py for this purpose?
Thanks in advance.

matrix function have diffurent behaviors for random select

when use batch version matrix function,return answer is wrong

In [147]: rotvec = torch.randn(20,3)

In [148]: rots = SO3.InitFromVec(rotvec)

In [149]: rots.shape
Out[149]: torch.Size([20])

In [150]: rots.vec()[-5]
Out[150]: tensor([ 0.8872, -0.1591, -0.6459])

In [151]: rots[-5].vec()
Out[151]: tensor([ 0.8872, -0.1591, -0.6459])

In [152]: rots.matrix()[-5]
Out[152]:
tensor([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.]])

In [153]: rots[-5].matrix()
Out[153]:
tensor([[ 0.5612, 0.3888, -0.5711, 0.0000],
[-0.7083, -0.2948, -0.6781, 0.0000],
[-0.4283, -0.8729, -0.4626, 0.0000],
[ 0.0000, 0.0000, 0.0000, 1.0000]])

ToMatrix() does not have backward operation implemented

Hi,

I just read through your paper and code and really adore this project on lie group in tangent space.

I hope that the ToMatrix() operation could be fully differentiable for researchers to use.
Do you have a plan to implement the ToMatrix(), or may be FromMatrix() in the future? and a planned date in mind?

Cheers

Lixin

RuntimeError: CUDA error: no kernel image is available for execution on the device

Thanks for providing such a library!

I want to use the lietorch library in my project where I'm trying to optimize over the SE3 space. I've installed the required dependencies as stated. However, I'm receiving the below error when I try to run the ./run_test.sh script. So, I wanted to check if anyone can tell what could be the source of this error and how to rectify it?

Note: torch.cuda.get_device_name(0) returns correctly the GPU's name.

Testing lietorch forward pass (CPU) ...                                                                                                                                                                                    
- <class 'lietorch.groups.SO3'> Passed exp-log test                                                                                                                                                               
 - <class 'lietorch.groups.SO3'> Passed inv test                                                                                                                                                                   
 - <class 'lietorch.groups.SO3'> Passed adj test                                                                                                                                                                    
- <class 'lietorch.groups.SO3'> Passed act test                                                                                                                                                                   
 - <class 'lietorch.groups.RxSO3'> Passed exp-log test                                                                                                                                                            
  - <class 'lietorch.groups.RxSO3'> Passed inv test                                                                                                                                                                 
 - <class 'lietorch.groups.RxSO3'> Passed adj test                                                                                                                                                                 
 - <class 'lietorch.groups.RxSO3'> Passed act test                                                                                                                                                                  
- <class 'lietorch.groups.SE3'> Passed exp-log test                                                                                                                                                                
- <class 'lietorch.groups.SE3'> Passed inv test                                                                                                                                                                    
- <class 'lietorch.groups.SE3'> Passed adj test                                                                                                                                                                   
 - <class 'lietorch.groups.SE3'> Passed act test                                                                                                                                                                  
  - <class 'lietorch.groups.Sim3'> Passed exp-log test                                                                                                                                                              
 - <class 'lietorch.groups.Sim3'> Passed inv test                                                                                                                                                                   
- <class 'lietorch.groups.Sim3'> Passed adj test                                                                                                                                                                  
 - <class 'lietorch.groups.Sim3'> Passed act test                                                                                                                                                           
Testing lietorch backward pass (CPU)...                                                                                                                                                                                    
- <class 'lietorch.groups.SO3'> Passed eye-grad test                                                                                                                                                              
 - <class 'lietorch.groups.SO3'> Passed inv-grad test                                                                                                                                                             
  - <class 'lietorch.groups.SO3'> Passed adj-grad test                                                                                                                                                               
- <class 'lietorch.groups.SO3'> Passed adjT-grad test                                                                                                                                                            
  - <class 'lietorch.groups.SO3'> Passed act-grad test                                                                                                                                                              
 - <class 'lietorch.groups.RxSO3'> Passed eye-grad test                                                                                                                                                            
 - <class 'lietorch.groups.RxSO3'> Passed inv-grad test                                                                                                                                                             
- <class 'lietorch.groups.RxSO3'> Passed adj-grad test                                                                                                                                                            
 -
 <class 'lietorch.groups.RxSO3'> Passed adjT-grad test                                                                                                                                                            
- <class 'lietorch.groups.RxSO3'> Passed act-grad test                                                                                                                                                             
- <class 'lietorch.groups.SE3'> Passed eye-grad test                                                                                                                                                               
- <class 'lietorch.groups.SE3'> Passed inv-grad test                                                                                                                                                             
  - <class 'lietorch.groups.SE3'> Passed adj-grad test                                                                                                                                                               
- <class 'lietorch.groups.SE3'> Passed adjT-grad test                                                                                                                                                              
- <class 'lietorch.groups.SE3'> Passed act-grad test                                                                                                                                                               
- <class 'lietorch.groups.Sim3'> Passed eye-grad test                                                                                                                                                             
 - <class 'lietorch.groups.Sim3'> Passed inv-grad test                                                                                                                                                             
 - <class 'lietorch.groups.Sim3'> Passed adj-grad test                                                                                                                                                             
 - <class 'lietorch.groups.Sim3'> Passed adjT-grad test                                                                                                                                                            
 - <class 'lietorch.groups.Sim3'> Passed act-grad test                                                                                                                                                      
Testing lietorch forward pass (GPU) ...                                                                                                                                                                            
Traceback (most recent call last):                                                                                                                                                                                   
File "lietorch/run_tests.py", line 217, in <module>                                                                                                                                                                 
 test_exp_log(Group, device='cuda')                                                                                                                                                                               
File "lietorch/run_tests.py", line 19, in test_exp_log                                                                                                                                                              
 b = Group.exp(a).log()                                                                                                                                                                                           
File "/home/abhishek_peri/anaconda3/envs/nerfing/lib/python3.6/site-packages/lietorch-0.1-py3.6-linux-x86_64.egg/lietorch/groups.py", line 132, in log                                                              
 return self.apply_op(Log, self.data)                                                                                                                                                                             
File "/home/abhishek_peri/anaconda3/envs/nerfing/lib/python3.6/site-packages/lietorch-0.1-py3.6-linux-x86_64.egg/lietorch/groups.py", line 122, in apply_op                                                         
 data = op.apply(cls.group_id, *inputs)                                                                                                                                                                           
File "/home/abhishek_peri/anaconda3/envs/nerfing/lib/python3.6/site-packages/lietorch-0.1-py3.6-linux-x86_64.egg/lietorch/group_ops.py", line 12, in forward                                                        
 out = cls.forward_op(ctx.group_id, *inputs)                                                                                                                                                                   
 RuntimeError: CUDA error: no kernel image is available for execution on the device

torch version > 1.6 stead of >=?

Hi Zach,

Thank you for releasing the code.
The readme says PyTorch >= 1.6. But when I install w 1.6.0, I got the error

ImportError: cannot import name '_disabled_torch_function_impl'

The error goes away for me with pytorch 1.8.1.
Thanks.

vec() method failing.

Hi, I have this use case where I have an SE3 element of shape [2, 3]. When looking at the vec embedding of a subsection of it, the method fails. Here is a snap of the code to reproduce the error

poses = torch.tensor(np.zeros(shape=(2, 3, 7)), dtype=dtype, device=device)
poses[:, :, -1] = 1.
M = SE3.InitFromVec(poses)

M_init = M[:, :2] 
M_init.vec() # Fails

Upon investigation, it is triggered in the broadcasting method of the library. So I changed from view to reshape. (Can't explain the why of the solution)
Line 13 of broadcasting.py is change from

return (x.view(-1, xd).contiguous(), ), x.shape[:-1]

to

return (x.reshape(-1, xd).contiguous(), ), x.shape[:-1]

Torch Version Requirement

In README, it says torch>=1.7 is fine. However, in the source code, the lietorch requires torch.linalg.pinv, which seems only exists in torch 1.9+.

Question about the Jacobian of the exponential map

Thanks for your excellent work. But I have some doubts about the shape of the jaobian of the exponential map.

Let's take the $SE3$ for example. Its exponential function map $\mathbb{R}^{6}$ to $\mathbb{R}^{4\times4}$. Thus I think the jacobian matrix of this fun should be in $\mathbb{R}^{16\times6}$ or $\mathbb{R}^{6\times16}$. But you state that:

The Jacobian of the exponential map $\mathbf{J}_{l}=\frac{\partial }{\partial \mathbf{x}}Exp(\mathbf{x})$ is referred to as the left-Jacobian

And the left Jacobian of $SE3$ should be a $6\times6$ matrix. Where does the shape difference comes from. Is there any misunderstood about your statements?

SE3 from Transformation Matrix

Hi, I'm wondering if it's possible to initialize a SE3 instance from a 4x4 transformation matrix, instead of quaternion + translation. Thank you!

Comparison with Pytorch3D

Has anyone compared this library with Pytorch3D. I'm wondering what makes lietorch better? The accompanying paper compares with Pytorch though.

can not pass the test

Hi ,

At first, Thank you so much providing this library!

I got some trouble when I first used it. I followed the intro step install the library successfully But when I run test, in the section about GPU Test, the program gets stuck, like in an infinite loop. After a few minutes the script will end by itself without error. In console shows `Testing lietorch forward pass (GPU) ...

Process finished with exit code -1073741819 (0xC0000005)`

Obviously this is not a normal exit, there may be a memory leak or something else.

And when I run the demo.py of Raft3d project , the same issue occured again, the data could transfer into the model but model can not complete a complete calculation. I noticed it will get stuck in projective_ops.py in line 42: X1 = Ts * X0 .

My GPU is GTX 1070 , run on win 10 pytorch ==1.8 cudatookit =11.1 python 3.8

Error during backward if groups are created with wrong data shapes

Hi, thanks for creating this wonderful library!❤️ However, I ran into the following bug when using it with torch.autograd.

For example, if I try to find the Jacobian w.r.t. a group parameter:

x = LieGroupParameter(SE3.Identity(1))
p = torch.ones(1000, 3)

def func1(x_, p_):
    # have to wrap with lietorch.SE3 because arguments are passed as tensors
    return SE3(x_).act(p_).sum()

# throws error: double free or corruption (!prev)
print(torch.autograd.functional.jacobian(func1, (x, p)))

The problem seems to be that during the preprocessing stage of torch.autograd, it clones the input data, but for LieGroupParameter, this only retrieves the tangent space data. Somehow the forward function was happy with those 1-dim-less inputs and didn't throw an error until the backward call. The same error appears if I do:

SE3(torch.zeros(1, 6, requires_grad=True)).act(torch.ones(1000, 3)).sum().backward() #double free or corruption (!prev)

It would be nice if you can help look into the above error. Also, it's probably a good idea for LieGroup.__init__ or the op implementations to have some sanity check on the input dimensions so that it catches the problem earlier. Otherwise, thank you for your hard work!😃

compile the code

when I install with the "python setup.py install",
the problem raised as
`g++ -pthread -B /home/lyltc/miniconda3/envs/cir/compiler_compat -shared -Wl,--allow-shlib-undefined -Wl,-rpath,/home/lyltc/miniconda3/envs/cir/lib -Wl,-rpath-link,/home/lyltc/miniconda3/envs/cir/lib -L/home/lyltc/miniconda3/envs/cir/lib -Wl,--allow-shlib-undefined -Wl,-rpath,/home/lyltc/miniconda3/envs/cir/lib -Wl,-rpath-link,/home/lyltc/miniconda3/envs/cir/lib -L/home/lyltc/miniconda3/envs/cir/lib /home/lyltc/git/lietorch/build/temp.linux-x86_64-3.8/lietorch/src/lietorch.o /home/lyltc/git/lietorch/build/temp.linux-x86_64-3.8/lietorch/src/lietorch_gpu.o /home/lyltc/git/lietorch/build/temp.linux-x86_64-3.8/lietorch/src/lietorch_cpu.o -L/home/lyltc/miniconda3/envs/cir/lib/python3.8/site-packages/torch/lib -L/usr/local/cuda-11.1/lib64 -lc10 -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda_cu -ltorch_cuda_cpp -o build/lib.linux-x86_64-3.8/lietorch_backends.cpython-38-x86_64-linux-gnu.so

g++: error: /home/lyltc/git/lietorch/build/temp.linux-x86_64-3.8/lietorch/src/lietorch.o: No such file or directory
g++: error: /home/lyltc/git/lietorch/build/temp.linux-x86_64-3.8/lietorch/src/lietorch_gpu.o: No such file or directory
g++: error: /home/lyltc/git/lietorch/build/temp.linux-x86_64-3.8/lietorch/src/lietorch_cpu.o: No such file or directory
`

cannot install the package

OS: Windows 11
Python version: Python 3.8.13

when I install it from the source (python setup.py install), I got the issue looked like:

No CUDA runtime is found, using CUDA_HOME='User\local\Cuda'
running install
C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\command\easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
writing lietorch.egg-info\PKG-INFO
writing dependency_links to lietorch.egg-info\dependency_links.txt
writing top-level names to lietorch.egg-info\top_level.txt
reading manifest file 'lietorch.egg-info\SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'lietorch.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\torch\utils\cpp_extension.py:346: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
  warnings.warn(f'Error checking compiler version for {compiler}: {error}')
Traceback (most recent call last):
  File "setup.py", line 9, in <module>
    setup(
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\command\install.py", line 74, in run
    self.do_egg_install()
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\command\install.py", line 116, in do_egg_install
    self.run_command('bdist_egg')
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\command\bdist_egg.py", line 164, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\command\bdist_egg.py", line 150, in call_command
    self.run_command(cmdname)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\command\install_lib.py", line 11, in run
    self.build()
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\command\install_lib.py", line 107, in build
    self.run_command('build_ext')
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
    _build_ext.run(self)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\distutils\command\build_ext.py", line 340, in run
    self.build_extensions()
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\torch\utils\cpp_extension.py", line 434, in build_extensions
    self._check_cuda_version(compiler_name, compiler_version)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\torch\utils\cpp_extension.py", line 808, in _check_cuda_version
    torch_cuda_version = packaging.version.parse(torch.version.cuda)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\pkg_resources\_vendor\packaging\version.py", line 49, in parse
    return Version(version)
  File "C:\Users\nicol\miniconda3\envs\cir\lib\site-packages\pkg_resources\_vendor\packaging\version.py", line 264, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object

When i install from the pip (pip install lietorch), It can be installed, but I got the following error:

>>> import lietorch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Windows\GitHub\lietorch\lietorch\__init__.py", line 2, in <module>
    from .groups import LieGroupParameter, SO3, RxSO3, SE3, Sim3, cat, stack
  File "E:\Windows\GitHub\lietorch\lietorch\groups.py", line 5, in <module>
    from .group_ops import Exp, Log, Inv, Mul, Adj, AdjT, Jinv, Act3, Act4, ToMatrix, ToVec, FromVec
  File "E:\Windows\GitHub\lietorch\lietorch\group_ops.py", line 1, in <module>
    import lietorch_backends
ModuleNotFoundError: No module named 'lietorch_backends'

Could someone who successfully installed the package before give me some suggestions?
Thanks!

Broadcasting of action on point cloud

I would like to know how I can broadcast the action on a point cloud:

SE3: T, shape(n)
point cloud: P, shape(n, m, 4)
expect transformed point cloud: P_trans = T * P, shape(n,m,4)

Can anyone help?

act does not seem to work with multiple points

Hi,

Thanks for the great project and paper. I'm trying to use to act operator on multiple points, but can't seem to get it to work. As a toy example, consider:

a = torch.FloatTensor([0.4230, 0.5557, 0.3167, 0.6419])
so3 = SO3(a)
b = torch.rand(10, 3)
so3.act(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/hturki/miniconda3/envs/test/lib/python3.8/site-packages/lietorch-0.1-py3.8-linux-x86_64.egg/lietorch/groups.py", line 163, in act
    return self.apply_op(Act3, self.data, p)
  File "/data/hturki/miniconda3/envs/test/lib/python3.8/site-packages/lietorch-0.1-py3.8-linux-x86_64.egg/lietorch/groups.py", line 120, in apply_op
    inputs, out_shape = broadcast_inputs(x, y)
  File "/data/hturki/miniconda3/envs/test/lib/python3.8/site-packages/lietorch-0.1-py3.8-linux-x86_64.egg/lietorch/broadcasting.py", line 15, in broadcast_inputs
    check_broadcastable(x, y)
  File "/data/hturki/miniconda3/envs/test/lib/python3.8/site-packages/lietorch-0.1-py3.8-linux-x86_64.egg/lietorch/broadcasting.py", line 5, in check_broadcastable
    assert len(x.shape) == len(y.shape)
AssertionError

And note that so3.act(b.T) doesn't fail but seems to silently return None. Am I calling this operation incorrectly?

CUDA version mismatch

After sudo python3 setup.py install, I get the following error:

running install
running bdist_egg
running egg_info
writing lietorch.egg-info/PKG-INFO
writing dependency_links to lietorch.egg-info/dependency_links.txt
writing top-level names to lietorch.egg-info/top_level.txt
reading manifest file 'lietorch.egg-info/SOURCES.txt'
writing manifest file 'lietorch.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
Traceback (most recent call last):
  File "/home/adriel/Documents/mestrado/projeto/repos/lietorch/setup.py", line 9, in <module>
    setup(
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.9/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.9/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "/usr/lib/python3.9/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 164, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 150, in call_command
    self.run_command(cmdname)
  File "/usr/lib/python3.9/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/install_lib.py", line 23, in run
    self.build()
  File "/usr/lib/python3.9/distutils/command/install_lib.py", line 109, in build
    self.run_command('build_ext')
  File "/usr/lib/python3.9/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 79, in run
    _build_ext.run(self)
  File "/usr/lib/python3.9/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "/usr/local/lib/python3.9/dist-packages/torch-1.10.0-py3.9-linux-x86_64.egg/torch/utils/cpp_extension.py", line 404, in build_extensions
    self._check_cuda_version()
  File "/usr/local/lib/python3.9/dist-packages/torch-1.10.0-py3.9-linux-x86_64.egg/torch/utils/cpp_extension.py", line 781, in _check_cuda_version
    raise RuntimeError(CUDA_MISMATCH_MESSAGE.format(cuda_str_version, torch.version.cuda))
RuntimeError: 
The detected CUDA version (11.2) mismatches the version that was used to compile
PyTorch (10.2). Please make sure to use the same CUDA versions.

But my nvcc version is 11.2.

Not available on win10

Hello, I can successfully compile and install lietorch on Windows, but I cannot pass the gpu related tests. When running the simplest multiplication, likes X1 = Ts * X0, it will get stuck and exit.

Is there a version that runs on linux?

I have installed the package on linux and when I have tried to run it a FileNotFoundError is raised as it cannot find the liblietorch.so file. When I have looked in the folder where the .so file is supposed to be the only file there is lietorch.dll which is used for the windows version.

Possible bug in gradient size of mul_backward_kernel()?

Hi guys,

First of all, congratulations on this great work and thank you for making the code open-source.

While going through the implementation details, I noticed that the Grad type in the mul_backward_kernel() method in

Grad dZ(grad + i*Group::N);
is accessed from the memory with the dimension N which appears to be the embedding size (or the representation size). Shouldn't this instead be accessed with dimension K
using Grad = Eigen::Matrix<scalar_t,1,Group::K>;

which is the dimension of the tangent space that satisfies the chain rule described in Eq. (14) of the paper.

Please let me know if this observation is correct or I have misunderstood this as a bug? Thanks in advance. Keep up the great work :)

Calling .quaternion() produces runtime error

This is a minimal example demonstrating the issue:

from lietorch import SE3
ex = SE3.Identity(1)
ex.quaternion()

results in

NameError: name 'Quat' is not defined
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/tmp/ipykernel_88211/189352308.py in <module>
      1 from lietorch import SE3
      2 ex = SE3.Identity(1)
----> 3 ex.quaternion()

~/path/env/lib/python3.8/site-packages/lietorch/groups.py in quaternion(self)
    137     def quaternion(self):
    138         """ extract quaternion """
--> 139         return self.apply_op(Quat, self.data)
    140 
    141     def log(self):

NameError: name 'Quat' is not defined

A quick check reveals that the class Quat, referenced in groups.py:139 is indeed not defined. A convenient method to extract the rotation/quaternion/SO3 object from an SE3 object would be helpful.

Question about the Euclidean embeddings

Hi, thank you for your great work! Since I am new to the Lie groups and Lie algebra, I met some difficulties when reading the code:

  1. For SE(3) representation, the Euclidean embeddings (that is, the 7-dim vector from ToVec() function) has two parts: 3-dim translation and 4-dim quaternion (for rotation) (related code). When I tried to create a pose from the axis-angle representation (i.e. SE3.exp(axis_angle_rep)), this code multiplies left Jacobian with tau, which should correspond to the translation from axis-angle representation:

    Vector3 t = SO3<Scalar>::left_jacobian(phi) * tau;

    My question is, why should we multiply tau with left Jacobian of phi? Could you explain a little bit more on the connection between the Euclidean embeddings and axis-angle (or transformation matrix)? I found some webpage shows the connections among various representations but I think it still a bit unclear. Thanks!

direct installation via pip

A useful tip that you may add to the documentation:
You can directly clone the repo and install via pip in one step:

sudo -H pip3 install git+https://github.com/princeton-vl/lietorch.git

'map' object has no attribute 'shape'

This is a good project , but I got some error when I run this command:
python scripts/demo.py --network=raft3d.raft3d --model=raft3d.pth
It looks like a problem caused by lietorch,and I git clone from https://github.com/princeton-vl/lietorch.git and install lietorch==0.2.0
Traceback (most recent call last):
File "scripts/demo.py", line 97, in
demo(args)
File "/home/data3/zr/anaconda3/envs/lie_env/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "scripts/demo.py", line 78, in demo
flow2d, flow3d, _ = pops.induced_flow(Ts, depth1, intrinsics)
File "/home/data3/zr/code/RAFT-3D/./raft3d/projective_ops.py", line 52, in induced_flow
X1 = Ts * X0
File "/home/data3/zr/anaconda3/envs/lie_env/lib/python3.8/site-packages/lietorch/groups.py", line 206, in mul
return self.act(other)
File "/home/data3/zr/anaconda3/envs/lie_env/lib/python3.8/site-packages/lietorch/groups.py", line 174, in act
return self.apply_op(Act3, self.data, p)
File "/home/data3/zr/anaconda3/envs/lie_env/lib/python3.8/site-packages/lietorch/groups.py", line 127, in apply_op
inputs, out_shape = broadcast_inputs(x, y)
File "/home/data3/zr/anaconda3/envs/lie_env/lib/python3.8/site-packages/lietorch/broadcasting.py", line 18, in broadcast_inputs
check_broadcastable(x, y)
File "/home/data3/zr/anaconda3/envs/lie_env/lib/python3.8/site-packages/lietorch/broadcasting.py", line 8, in check_broadcastable
assert len(x.shape) == len(y.shape)
AttributeError: 'map' object has no attribute 'shape'

This is my conda envs, please tell me what should I do.
Package Version
absl-py 1.4.0
appdirs 1.4.4
brotlipy 0.7.0
cachetools 5.3.0
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 2.0.4
contourpy 1.0.7
cryptography 38.0.4
cycler 0.11.0
flit_core 3.6.0
fonttools 4.38.0
google-auth 2.16.0
google-auth-oauthlib 0.4.6
grpcio 1.51.1
idna 3.4
importlib-metadata 6.0.0
importlib-resources 5.10.2
kiwisolver 1.4.4
lietorch 0.2
Markdown 3.4.1
MarkupSafe 2.1.2
matplotlib 3.7.0
mkl-fft 1.3.1
mkl-random 1.2.2
mkl-service 2.4.0
numpy 1.23.5
oauthlib 3.2.2
opencv-python 4.7.0.68
packaging 22.0
Pillow 9.3.0
pip 22.3.1
pooch 1.4.0
protobuf 4.21.12
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
pyOpenSSL 22.0.0
pyparsing 3.0.9
PySocks 1.7.1
python-dateutil 2.8.2
PyYAML 6.0
requests 2.28.1
requests-oauthlib 1.3.1
rsa 4.9
scipy 1.10.0
setuptools 65.6.3
six 1.16.0
tensorboard 2.12.0
tensorboard-data-server 0.7.0
tensorboard-plugin-wit 1.8.1
torch 1.8.0
torchaudio 0.8.0a0+a751e1d
torchvision 0.9.0
tqdm 4.64.1
typing_extensions 4.4.0
urllib3 1.26.14
Werkzeug 2.2.3
wheel 0.37.1
zipp 3.13.0

what does * mean for SE3 type data?

Hi,thanks for your work and effort!
Currently I am reading your code in projective_ops.py and have some doubt about line84:
Gij = poses[:,jj] * poses[:,ii].inv()
I find poses is of SE3 type and consisted of (trans, quat). But I don't know in which way "poses: and "poses.inv" are multiplied. I firstly transformed poses from SE3 to matrix using poses.matrix() method, then invert it and transform it back using the “mat2SE3" function in your code. Here I found the result is equal to poses.inv().data, I mean the inv() method in your SE3 class is the same of matrix inversion.
But after this, I do the matrix multiplication using torch.matmul and compare it with Gij.matrix(). I find they are quite different, so it seems that * here is not matrix multiplication. Can you tell me what does it mean in detail?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.