Package: roma
RoMa: A lightweight library to deal with 3D rotations in PyTorch.RoMa(which stands for Rotation Manipulation) provides differentiable mappings between 3D rotation representations, mappings from Euclidean to rotation space, and various utilities related to rotations.It is implemented in PyTorch and aims to be an easy-to-use and reasonably efficient toolbox for Machine Learning and gradient-based optimization.DocumentationLatest documentation is available here:https://naver.github.io/roma/.Below are some examples of use ofRoMa:importtorchimportroma# Arbitrary numbers of batch dimensions are supported, for convenience.batch_shape=(2,3)# Conversion between rotation representationsrotvec=torch.randn(batch_shape+(3,))q=roma.rotvec_to_unitquat(rotvec)R=roma.unitquat_to_rotmat(q)Rbis=roma.rotvec_to_rotmat(rotvec)# Regression of a rotation from an arbitrary input:# Special Procrustes orthonormalization of a 3x3 matrixR1=roma.special_procrustes(torch.randn(batch_shape+(3,3)))# Conversion from a 6D representationR2=roma.special_gramschmidt(torch.randn(batch_shape+(3,2)))# From the 10 coefficients of a 4x4 symmetric matrixq=roma.symmatrixvec_to_unitquat(torch.randn(batch_shape+(10,)))# Metrics on the rotation spaceR1,R2=roma.random_rotmat(size=5),roma.random_rotmat(size=5)theta=roma.utils.rotmat_geodesic_distance(R1,R2)cos_theta=roma.utils.rotmat_cosine_angle(R1.transpose(-2,-1)@R2)# Operations on quaternionsq_identity=roma.quat_product(roma.quat_conjugation(q),q)# Spherical interpolation between rotation vectors (shortest path)rotvec0,rotvec1=torch.randn(batch_shape+(3,)),torch.randn(batch_shape+(3,))rotvec_interpolated=roma.rotvec_slerp(rotvec0,rotvec1,steps)# Rigid transformation T composed of a rotation part R and a translation part tt=torch.randn(batch_shape+(3,))T=roma.Rigid(R,t)# Composing and inverting transformationsidentity=T@T.inverse()# Casting the result to a batch of 4x4 homogeneous matricesM=identity.to_homogeneous()InstallationThe easiest way to installRoMais to use pip:pip install romaAlternatively one can install the latest version ofRoMadirectly from the source repository:pip install git+https://github.com/naver/romaFor pytorch versions older than 1.8, we recommend installingtorch-batch-svdto achieve a significant speed-up withspecial_procrusteson CUDA GPUs.
You can check that this module is properly loaded using the functionroma.utils.is_torch_batch_svd_available().With recent pytorch installations (torch>=1.8),torch-batch-svdis no longer needed or used.LicenseRoMa, Copyright (c) 2021 NAVER Corp., is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license (seelicense).Bits of code were adapted from SciPy. Documentation is generated, distributed and displayed with the support of Sphinx and other materials (seenotice).ReferencesFor a more in-depth discussion regarding differentiable mappings on the rotation space, please refer to:Romain Brégier, Deep Regression on Manifolds: a 3D Rotation Case Study.in2021 International Conference on 3D Vision (3DV), 2021.Please cite this work in your publications:@inproceedings{bregier2021deepregression,
	title={Deep Regression on Manifolds: a {3D} Rotation Case Study},
	author={Br{\'e}gier, Romain},
	journal={2021 International Conference on 3D Vision (3DV)},
	year={2021}
}