CMU-Perceptual-Computing-Lab / openpose

OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation
https://cmu-perceptual-computing-lab.github.io/openpose
Other
31.23k stars 7.87k forks source link

Google colab helper script #949

Closed sirramsalott closed 5 years ago

sirramsalott commented 5 years ago

Issue Summary

Apologies if this is the wrong place for this. I've made a script to install OpenPose on Google Colab. It's not a particularly exciting piece of programming, but I find it really useful as I don't have access to a computer which is powerful enough to run OpenPose, even in CPU mode, so the only way I can use OpenPose is to build it on a GPU-enabled Colab runtime and then run my programs there. Since I found it really useful, I presume others might also find it useful, so I'm putting it here for developers to do with as they please.

! apt update
! apt install -y cmake sudo libopencv-dev
! git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose.git
! cd openpose/ubuntu && ./install_cmake.sh && ./install_cuda.sh && ./install_cudnn.sh
! cd openpose && git pull origin master && rm -r build || true && mkdir build && cd build && cmake .. && make -j`nproc`

# example demo usage
!cd openpose && ./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_json output/ --display 0 --render_pose 0

Type of Issue

gineshidalgo99 commented 4 years ago

Please see https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/1602#issuecomment-641653411

EtiReznikov commented 4 years ago

@gineshidalgo99 @Egna-Praneeth Thank you but I already tried this. After download the openpose models and move them to the correct location i get the following error: WhatsApp Image 2020-09-02 at 11 43 35

sergak0 commented 4 years ago

I don't now why, but now there isn't "download hash mismatch" Error. Thanks a lot for debugg

SutirthaChakraborty commented 4 years ago

Thank you for sharing. From what I have seen, it seems that a command different from the one I uploaded is being executed. The command I wrote

! cd openpose && ./build/examples/openpose/openpose.bin --video examples/media/video.avi --display 0  --write_video ./output/openpose.avi

The command you executed

! cd openpose && python3 examples/tutorial_api_python/02_whole_body_from_image.py

The command you executed uses Opnepose's Python API. I'm not familiar with the Python API, but as I mentioned, it doesn't seem to be built by default. It seems that I can't use the Python API as it is in my notebook. To make it available, please refer to the URL above. I am sorry that I can not be a help.

Thanks anyways i know the issue. Will try to find the solution now

@ammaddd did you resolve the issue ? I am having the same problem, image Can you share a colab that solves that ? and how to import the library to write my own code?

bhavesh2799 commented 4 years ago

Can anyone share a working colab notebook implementing openpose, with BUILD_PYTHON=ON. I have tried changing the default in CMakeList.txt, but it is still set to OFF. Also, I have been facing error in implementing ! cd openpose/build && make -jnproc``

It would be great if someone could share a working colab notebook, as I have tried implementing the notebooks mentioned in this page, but no success till now.
Also ignore the error mentioned in last line, I had rerun the code, but the error is same as previous. error

bhavesh2799 commented 4 years ago

Hi everyone, I recreated Colab Notebook for Openpose 1.6.0. First, change "Runtime type" to "GPU". After that, if you can execute "Run all cells" in Colab, you can even analyze Openopse demo video.

https://colab.research.google.com/github/miu200521358/motion_trace_colab/blob/master/Openpose1_6_0.ipynb

Running your notebook is still showing errors, could you tell what seems to be the issue. error

bhavesh2799 commented 4 years ago

Thank you for sharing. From what I have seen, it seems that a command different from the one I uploaded is being executed. The command I wrote

! cd openpose && ./build/examples/openpose/openpose.bin --video examples/media/video.avi --display 0  --write_video ./output/openpose.avi

The command you executed

! cd openpose && python3 examples/tutorial_api_python/02_whole_body_from_image.py

The command you executed uses Opnepose's Python API. I'm not familiar with the Python API, but as I mentioned, it doesn't seem to be built by default. It seems that I can't use the Python API as it is in my notebook. To make it available, please refer to the URL above. I am sorry that I can not be a help.

Thanks anyways i know the issue. Will try to find the solution now

@ammaddd did you resolve the issue ? I am having the same problem, image Can you share a colab that solves that ? and how to import the library to write my own code?

Hey, have you got a working colab implementation?

swarnav25 commented 4 years ago

I want to build the openpose files in a mounted google drive such that I don't need to build it again and again. Can someone help me out in it?

bhavesh2799 commented 4 years ago

I want to build the openpose files in a mounted google drive such that I don't need to build it again and again. Can someone help me out in it?

You can change the working directory with %cd command, like %cd '/content/drive/My Drive/'. Is it the solution you needed or you were talking about something else? Can if you have implemented the colab notebook in openpose, could you please share it, I have been working on it for a few days, and am facing a lot of configuration and building issues

swarnav25 commented 4 years ago

I used the following collab notebook to implement openpose and it was working fine: https://colab.research.google.com/drive/1EzMTKhCDqPucA2yo_6rHr76TlohDFN-R?authuser=1

But i wanted to build the files in my drive. So i tried but failed. I posted my code in stack overflow: https://stackoverflow.com/questions/64636068/cannot-open-shared-object-file-in-google-collab

i was getting some error but could not solve it.

UxmanX commented 4 years ago

I want to build the openpose files in a mounted google drive such that I don't need to build it again and again. Can someone help me out in it?

Unfortunately, I have already tried several methods. It's not possible to directly install and keep the OpenPose on the drive as the Google Drive Storage Technique does not support Symbolic Links. However, I have tried compressing the workspace and saving it to use it later. It only helps with OpenPose, Caffe still gives error or can't be compressed at all. There might be a compression method I am missing but as of now, despite multiple attempts and trying to replicate DeepFaceLab methodology of backing up, the efforts bear no fruit.

bhavesh2799 commented 4 years ago

I want to build the openpose files in a mounted google drive such that I don't need to build it again and again. Can someone help me out in it?

Unfortunately, I have already tried several methods. It's not possible to directly install and keep the OpenPose on the drive as the Google Drive Storage Technique does not support Symbolic Links. However, I have tried compressing the workspace and saving it to use it later. It only helps with OpenPose, Caffe still gives error or can't be compressed at all. There might be a compression method I am missing but as of now, despite multiple attempts and trying to replicate DeepFaceLab methodology of backing up, the efforts bear no fruit.

This is really cool to know. I have been trying openpose on the mounted drive, as I have done it for all the other models. Really useful comment👍👍

swarnav25 commented 4 years ago

@bhavesh2799 Were you able to run openpose from mounted gdrive?

bhavesh2799 commented 4 years ago

@bhavesh2799 Were you able to run openpose from mounted gdrive?

No dude, there were configuration errors. Errors were like this. https://pastebin.com/51Qjw6yd

seanwynwins commented 4 years ago

I also tried to build in google drive but got an error as well. If anyone has fixed this problem of having to build open pose over again and again, that would be great!

Anubhav507 commented 3 years ago

Hey guys does anyone know how to get json file of all the keypoints instead of visualizing it? I want all the keypoints so I can analyse them and I can't find a command that works in colab

BANANAPEEL202 commented 3 years ago

Hey guys does anyone know how to get json file of all the keypoints instead of visualizing it? I want all the keypoints so I can analyse them and I can't find a command that works in colab

This is what I used in Colab for JSON output ! cd openpose && ./build/examples/openpose/openpose.bin --video "$root_path/$file_path" --render_pose 0 --display 0 --number_people_max=2 --write_json "$output_path"

Anubhav507 commented 3 years ago

hey @BANANAPEEL202 thank you so much for your help , it worked for me . I got 119 json files as output of tracking a video and if I am correct that must be output of every frame , right?

BANANAPEEL202 commented 3 years ago

yup a json for every frame.

Anubhav507 commented 3 years ago

Can anyone also help me as I am struggling to find a command which is used to detect keypoints in an image in google colab. the command for video is working but I can't find any command for keypoint detection of image

hadeer7 commented 3 years ago

I have been trying openpose on the mounted drive but i failed , any help ?

manlio99 commented 3 years ago

I followed @pamruta s Notebook, But when i try it to run it upon an image it seems to be giving me the error

!cd openpose && ./build/examples/openpose/openpose.bin --image_dir ../ vlcsnap-2016-12-01-23h49m28s384.png

Starting OpenPose demo... Configuring OpenPose... Starting thread(s)... Auto-detecting all available GPUs... Detected 1 GPU(s), using 1 of them starting at GPU 0. Unable to init server: Could not connect: Connection refused

Can anyone like help me? Screenshot (40)

i have the same error!

/content/staf Starting OpenPose demo... Configuring OpenPose... Starting thread(s)...

Error: Cuda check failed (100 vs. 0): no CUDA-capable device is detected

Coming from:

miu200521358 commented 3 years ago

Hello everyone. I have created a Google Colab notebook that supports Openpose 1.7.0. Please try it if you like.

https://colab.research.google.com/github/miu200521358/motion_trace_colab/blob/master/OpenposeDemo.ipynb

chepo92 commented 3 years ago

Hello everyone. I have created a Google Colab notebook that supports Openpose 1.7.0. Please try it if you like.

https://colab.research.google.com/github/miu200521358/motion_trace_colab/blob/master/OpenposeDemo.ipynb

Works flawlessly, it should be added a precompiled build for cmake and open pose so one just pulls the binaries from a repo rather than compiling it every time

JCamERG commented 3 years ago

Hello everyone. I have created a Google Colab notebook that supports Openpose 1.7.0. Please try it if you like.

https://colab.research.google.com/github/miu200521358/motion_trace_colab/blob/master/OpenposeDemo.ipynb

Hello !! I have a problem in this line, PLIS! help me. https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md#cmake-command-line-configuration-ubuntu-only 上記インストール手順のシナリオ1でインストール実行 Scenario 1 - Caffe not installed and OpenCV installed using apt-get ! cd openpose/build && cmake .. the error: -- Configuring incomplete, errors occurred! See also "/content/openpose/build/CMakeFiles/CMakeOutput.log". See also "/content/openpose/build/CMakeFiles/CMakeError.log".

miu200521358 commented 3 years ago

@JCamERG

Hi. I am miu who created this Colab page.

Cmake has failed due to the inability to connect to the URL below, which is the model download source. http://posefs1.perception.cs.cmu.edu/OpenPose/

I suspect that the URL may be temporarily inaccessible due to heavy load or revocation of the server certificate. The Openpose development team can resolve this issue, so please wait until access is restored.

JCamERG commented 3 years ago

@JCamERG

Hi. I am miu who created this Colab page.

Cmake has failed due to the inability to connect to the URL below, which is the model download source. http://posefs1.perception.cs.cmu.edu/OpenPose/

I suspect that the URL may be temporarily inaccessible due to heavy load or revocation of the server certificate. The Openpose development team can resolve this issue, so please wait until access is restored.

Thanks for responding, and how long has not the page been in service?

is there another way to use openpose in colab?

Thank you so much

balochsaba commented 3 years ago

i am using google colab for openpose, its working well however im trying to disable blending which i dont know how to achieve. any leads?

sparshgarg23 commented 2 years ago

I have used the following script with BUILD_PYTHON enabled which is shown below.

# @title Install OpenPose
# @markdown This will take some time (~10 mins). The code is taken from this [OpenPose Colab notebook](https://colab.research.google.com/github/tugstugi/dl-colab-notebooks/blob/master/notebooks/OpenPose.ipynb).

%cd /content
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
  # download models
  !wget -O /content/openpose/models/hand/pose_iter_102000.caffemodel https://polybox.ethz.ch/index.php/s/Oim76cuqrDVbdxm/download
  !wget -O /content/openpose/models/pose/body_25/pose_iter_584000.caffemodel https://polybox.ethz.ch/index.php/s/m5NQAhd7ukVPRoL/download
  !wget -O /content/openpose/models/face/pose_iter_116000.caffemodel https://polybox.ethz.ch/index.php/s/cEaF1FTpKjjJZbH/download
  !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 -DBUILD_PYTHON=ON .. && make -j`nproc

openpose gets succesfully installed but when I try to use openpose as follows

import openpose as op
opWrapper=op.WrapperPython()
module 'openpose' has no attribute 'WrapperPython'

Any ideas on what is going wrong here and how I can correct it?

sparshgarg23 commented 2 years ago

@iron1111 should I use --display 0 --render_pose 0 in build command.Anyways thanks for getting back,I was able to find a workaround by referring to https://github.com/sergeyprokudin/smplpix .In the colab tutorial the author of the repo uses openpose to do pose estimation

jason-wuwu commented 2 years ago

Is there a way to install openpose permanently in Colab without reinstalling it each time I try to use it?

davidpagnon commented 1 year ago

Hello,

I keep running into Check failed: error == cudaSuccess (2 vs. 0) out of memory *** Check failure stack trace: ***. And yet,

Would you be able to help me?


EDIT: Well I just realized that this error occurs upon building.

/content/openpose/3rdparty/caffe/include/caffe/util/cudnn.hpp: In function ‘const char* cudnnGetErrorString(cudnnStatus_t)’:
/content/openpose/3rdparty/caffe/include/caffe/util/cudnn.hpp:21:8: warning: enumeration value ‘CUDNN_STATUS_VERSION_MISMATCH’ not handled in switch [-Wswitch]

So CuDNN faces at least some sort of issue. Any idea how to solve this though?

sparshgarg23 commented 1 year ago

@davidpagnon not an exact reply to the cudnn issue you're facing but if you wish to use open pose try looking into this https://github.com/prasunroy/openpose-pytorch I used it for my work on pose transfer and it works smoothly in colab.

davidpagnon commented 1 year ago

Okay, nice, I'll give it a try, hopefully it will run!

My main concerns in this case are that:

davidpagnon commented 1 year ago

I finally made it work by running !apt install --allow-change-held-packages libcudnn8=8.1.0.77-1+cuda11.2 to use compatible CUDA and cuDNN versions (see my Sports2D colab: Open In Colab)

gnigam87 commented 1 year ago

@JCamERG

Hi. I am miu who created this Colab page.

Cmake has failed due to the inability to connect to the URL below, which is the model download source. http://posefs1.perception.cs.cmu.edu/OpenPose/

I suspect that the URL may be temporarily inaccessible due to heavy load or revocation of the server certificate. The Openpose development team can resolve this issue, so please wait until access is restored.

Hi, I am also facing this issue. Can someone from Openpose development team please resolve this issue and restore the access?

chepo92 commented 1 year ago

See other issues where they have backup of models and new colab scipts eg https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/1567