Commit a865bac5 authored by zhanggezhong's avatar zhanggezhong
Browse files

Update README.md

parent 0fa9ce8f
Pipeline #2048 canceled with stages
# LieTorch: Tangent Space Backpropagation
--------------------------------------------------------------------------------
## Faiss简介
## Introduction
Faiss 是一个用于高效相似性搜索和密集向量聚类的库。它提供了在各种规模的向量集合中进行搜索的算法,包括那些可能无法完全适应 RAM 的大型集合。除了搜索功能,Faiss 还包含用于评估和参数调优的支持代码
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:
## 版本约束
<center><img src="lietorch.png" width="480" style="center"></center>
1. 暂不支持的官方版本或功能
[Tangent Space Backpropagation for 3D Transformation Groups](https://arxiv.org/pdf/2103.12032.pdf)
Zachary Teed and Jia Deng, CVPR 2021
**更高版本**:暂不支持lietorch0.2以上版本
```
@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},
}
```
2. lietorch软件版本配套关系
| lietorch版本 | DCU适配版lietorch软件包版本 | DCU加速卡型号 | DTK版本 |
| ----------- | ------------------------------------------ | -------------------------- | ------- |
| o.2 | 0.2+das.dtk24042 | Z100、Z100L、K100、K100_AI | 24.04.2 |
## 前置条件
## Installation
使用 DAS PyTorch需要参考[《DCU新手入门教程》](https://developer.hpccube.com/gitbook/dcu_tutorial/index.html)在主机系统安装以下组件:
- DCU驱动程序
- DTK
- Docker引擎
### Requirements:
* Cuda >= 10.1 (with nvcc compiler)
* PyTorch >= 1.8
## 安装
组件支持
+ Python 3.7、3.8、3.9、3.10
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
### 使用源码编译方式安装
基于光源pytorch基础镜像环境:镜像下载地址:[https://sourcefind.cn/#/image/dcu/pytorch](https://sourcefind.cn/#/image/dcu/pytorch),根据pytorch、python、dtk及系统下载对应的镜像版本。
#### 源码编译安装
- 代码下载
```shell
git clonehttps://developer.sourcefind.cn/codes/OpenDAS/lietorch.git # 根据编译需要切换分支
```
git clone --recursive https://github.com/princeton-vl/lietorch.git
- 提供2种源码编译方式(进入faiss目录):
```
1. 编译whl包并安装
pip3 install wheel
pip3 install pytest
cd lietorch
conda create -n lie_env
conda activate lie_env
conda install scipy pyyaml pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
python3 setup.py bdist_wheel
cd dist
pip3 install lietorch-* --no-deps --force
```
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)
验证安装:__dcu_version__会返回对应版本的dtk版本号
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
```bash
pip install git+https://github.com/princeton-vl/lietorch.git
python3
Python 3.10.12 (main, May 26 2024, 00:14:02) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lietorch
>>> lietorch.__version__
'0.2'
>>> lietorch.__dcu_version__
'0.2+das.dtk2404'
>>>
```
## 单测
## 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
&nbsp;
### Simple Example:
Compute the angles between all pairs of rotation matrices
```python
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.
```python
# 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()
sh run_tests.sh
```
## 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](https://github.com/strasdat/Sophus).
## Known Issue
-
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment