Permanent Installation of OpenPose in Google Collab

1.2k views Asked by At

I want to install the OpenPose files permanently so that I need not install them each time I reopen collab after a break.

I got through some installation code but I dont know how to make the required modifications.

import os
from os.path import exists, join, basename, splitext

git_repo_url = 'https://github.com/CMU-Perceptual-Computing-Lab/openpose.git'
project_name = splitext(basename(git_repo_url))[0]
if not exists(project_name):
  # see: https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/949
  # install new CMake becaue of CUDA10
  !wget -q https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz
  !tar xfz cmake-3.13.0-Linux-x86_64.tar.gz --strip-components=1 -C /usr/local
  # clone openpose
  !git clone -q --depth 1 $git_repo_url
  !sed -i 's/execute_process(COMMAND git checkout master WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\/3rdparty\/caffe)/execute_process(COMMAND git checkout f019d0dfe86f49d1140961f8c7dec22130c83154 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\/3rdparty\/caffe)/g' openpose/CMakeLists.txt
  # install system dependencies
  !apt-get -qq install -y libatlas-base-dev libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev opencl-headers ocl-icd-opencl-dev libviennacl-dev
  # install python dependencies
  !pip install -q youtube-dl
  # build openpose
  !cd openpose && rm -rf build || true && mkdir build && cd build && cmake .. && make -j`nproc`
  
from IPython.display import YouTubeVideo

Can somebody please help me solve this issue.

1

There are 1 answers

0
BGG16 On

When you say that you want to install openpose permanently, I assume that you mean you want to install it onto your google drive rather than having it installed into temporary files each time you run the code above in colab.

To install openpose on your google drive, rather than on the temporary colab storage:

(1) Mount your gdrive. Add this block of code prior to the block that you posted in your question above.

#Connect your google gdrive
from google.colab import drive
drive.mount('/content/drive')

(2) Change the directory to your gdrive. Add the following line to your code just after you've imported the dependencies but before the first line of the code block.

#Change the drive to your mounted gdrive
%cd /content/drive/MyDrive

This should install openpose on your permanent gdrive so that you can call openpose in the future from this location.