在colab训练与使用运行PVNet进行估计物体的位置和姿态

为了能让colab操作google driver中的文件需要执行下面代码。

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}

中途会让你输入两次授权码。下面是执行成功界面的截图。
在这里插入图片描述

然后在google driver中用创建一个colab的ipynb文件。
在这里插入图片描述
然后你需要指定你以后在程序下载的东西存储在google driver 哪里,选择Files然后选择MOUNT DRIVE
在这里插入图片描述
然后可以看到你的代码变到了某个磁盘下的某个文件夹下了,以后你保存的东西也在这里。
在这里插入图片描述
然后切换当前工作目录到你想要的那个目录下。我是切换到train_pvnet那个目录然后下载代码。
然后从github下载PVNet的源码。输入下面这个命令然后按ctr+enter运行命令,注意感叹号是指运行linux命令。
!git clone https://github.com/zju3dv/pvnet.git
在这里插入图片描述
然后将工作目录切换刚刚下载好的那个项目的文件夹pvnet下。
%cd pvnet
你可以通过输入命令!pwd查看当前目录,也可以输入命令!ls看看当前目录下有哪些文件。
然后再在google driver中的那个pvnet文件夹下创建一个colab文件方便我们执行训练PVNet的训练。
具体训练过程需要参考他们在github给的readme文件

  1. 安装必要的python包
    在这里插入图片描述
  2. 编译Ransac vote 层
CUDA_HOME='/usr/local/cuda'
%cd /content/drive/My\ Drive/train_pvnet/pvnet/lib/ransac_voting_gpu_layer
!python setup.py build_ext --inplace

记得将runtime里面的加速设备设置为GPU。
在这里插入图片描述
在这里插入图片描述
然后再执行命令

# 修订cuda_include并dart在build_extend_utils_cffi.py为与CUDA在您的电脑兼容
%cd /content/drive/My\ Drive/train_pvnet/pvnet/lib/utils/extend_utils
!sudo apt-get install libgoogle-glog-dev
!sudo apt-get install libsuitesparse-dev
!sudo apt-get install libatlas-base-dev
!python3 build_extend_utils_cffi.py

接下来我们需要安装ceres这个数学工具库,这里我们提供的是下载源码进行编译。在安装编译它之前需要安装着libeigen3-dev,libgoogle-glog-dev这两个包。
然后再运行pvnet这个目录下的build_ceres.sh。然后移动ceres/ceres-solver/build/lib/libceres.so*到lib/utils/extend_utils/lib。

posted @ 2019-09-14 11:20  varyshare|李韬  阅读(675)  评论(0编辑  收藏  举报