环境

  • Google Colab

    实践记录

    说明:我们需要实现的最终目标是 “Inference in the wild” ,即实现自定义的视频推理。
    核心指导文件为:
    当然需要其前置文档。

    [1.x] 前期准备:

  • 安装 PyTorch

  • clone repo ```python

    install pytorch

    !pip3 install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html

check

import torch import torchvision print(torch) # print(torchvision) #

  1. ```python
  2. # clone repo
  3. !git clone https://github.com/facebookresearch/VideoPose3D.git
  • 获取数据集
    • 详细内容写在了[VideoPose3D/DATASETS.md](https://github.com/facebookresearch/VideoPose3D/blob/main/DATASETS.md)
    • 官方提供了两种方式,其中第二种方式已经失效,我们需要从Human3.6M的官网下载数据集。
      • 当然,由于官方的审核极其缓慢,所以需要找一些方法来得到这个数据集。
    • 不过,我找到了直接下载准备好的数据集:这里
    • 可悲的是,虽然这两个东西加起来也不超过 400MB ,但上传到 Colab 这个步骤却异常的漫长。所以最好能通过别的方式上传到谷歌云盘。
  • 接下来进行一些其他准备工作 ```python

    file prepare

    import os

os.chdir(“/content/VideoPose3D/inference”) !mkdir input_directory !mkdir output_directory

os.chdir(“/content/VideoPose3D”) !mkdir checkpoint

from google.colab import drive drive.mount(‘/content/drive’) os.chdir(“/content/drive/MyDrive”) !cp pretrained_h36m_detectron_coco.bin /content/VideoPose3D/checkpoint

  1. ```python
  2. import os
  3. os.chdir("/content")
  4. !pip3 install ffmpeg
  5. !pip3 install opencv-python
  6. !pip3 install cython
  7. !pip3 install pycocotools
  8. !git clone https://github.com/facebookresearch/fvcore
  9. !pip3 install -e fvcore
  10. !git clone https://github.com/facebookresearch/detectron2.git
  11. !python -m pip install -e detectron2

然后在对应位置导入文件,就可以开始推理了

  1. # Step 3: inferring 2D keypoints with Detectron
  2. import os
  3. os.chdir("/content/VideoPose3D/inference")
  4. !python infer_video_d2.py --cfg COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml --output-dir output_directory --image-ext mp4 input_directory
  1. # Step 4: creating a custom dataset
  2. import os
  3. os.chdir("/content/VideoPose3D/data")
  4. !python prepare_data_2d_custom.py -i /content/VideoPose3D/inference/output_directory -o myvideos
  1. # Step 5: rendering a custom video and exporting coordinates
  2. import os
  3. os.chdir("/content/VideoPose3D")
  4. # visualize with numpy
  5. !python run.py -d custom -k myvideos -arc 3,3,3,3,3 -c checkpoint --evaluate pretrained_h36m_detectron_coco.bin --render --viz-subject input_video.mp4 --viz-action custom --viz-camera 0 --viz-video /content/VideoPose3D/inference/input_directory/input_video.mp4 --viz-output /content/VideoPose3D/inference/output_directory/output_video.mp4 --viz-export /content/VideoPose3D/inference/output_directory/outputfile --viz-size 6

最终就可以在对应目录下找到渲染完的视频和对应的空间坐标.npy文件

参考资料

Official Recources

Download H36M images

!mkdir -p h36m/images !cd h36m/images !wget http://visiondata.cis.upenn.edu/volumetric/h36m/S1.tar !tar -xf S1.tar !rm S1.tar !wget http://visiondata.cis.upenn.edu/volumetric/h36m/S5.tar !tar -xf S5.tar !rm S5.tar !wget http://visiondata.cis.upenn.edu/volumetric/h36m/S6.tar !tar -xf S6.tar !rm S6.tar !wget http://visiondata.cis.upenn.edu/volumetric/h36m/S7.tar !tar -xf S7.tar !rm S7.tar !wget http://visiondata.cis.upenn.edu/volumetric/h36m/S8.tar !tar -xf S8.tar !rm S8.tar !wget http://visiondata.cis.upenn.edu/volumetric/h36m/S9.tar !tar -xf S9.tar !rm S9.tar !wget http://visiondata.cis.upenn.edu/volumetric/h36m/S11.tar !tar -xf S11.tar !rm S11.tar !cd ../../.. ```

  • 数据集下载
  • Other

类似的 repo

https://github.com/una-dinosauria/3d-pose-baseline
https://github.com/KevinLTT/video2bvh