pythongoogle-colaboratoryopenpose

Use openpose on videos in google drive on google colab


I am using openpose for extracting skeleton structures of some videos and running the codes on

google colab for better hardware conditions.

When I upload videos from local to google colab and use openpose, it works well.

I want to use google drive for more videos so I connected my google drive to colab.

However, when I run openpose for the videos in my google drive, it doesn't work even though I

used the exactly same code except the path of the videos.

import subprocess

VideoPath = '/content/videos/'    #works perfectly as I expected
#VideoPath = '/content/gdrive/My Drive/videos/'   #does not work

if not os.path.exists("/content/output/"):
  os.mkdir("/content/output/")

for video in os.listdir(VideoPath):
  VideoName = video[:-4]

  InputVideo = VideoPath + video
  OutputDir = "/content/output2/output_" + VideoName + "/"

  if not os.path.exists("/content/output/output_" + VideoName):
    os.mkdir("/content/output/output_" + VideoName)

  pipe = subprocess.call("cd /content/openpose && /content/openpose/build/examples/openpose/openpose.bin --video " + InputVideo + " --write_json " + OutputDir + " --display 0 --render_pose 0 --face --hand", shell=True)

How can I use openpose on videos in my google drive?


Solution

  • The problem was the space in the path name '/content/gdrive/My Drive/videos/'

    Changing to '/content/gdrive/My\ Drive/videos/' will work.