环境
-
实践记录
说明:我们需要实现的最终目标是 “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) #
```python
# clone repo
!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
```python
import os
os.chdir("/content")
!pip3 install ffmpeg
!pip3 install opencv-python
!pip3 install cython
!pip3 install pycocotools
!git clone https://github.com/facebookresearch/fvcore
!pip3 install -e fvcore
!git clone https://github.com/facebookresearch/detectron2.git
!python -m pip install -e detectron2
然后在对应位置导入文件,就可以开始推理了
# Step 3: inferring 2D keypoints with Detectron
import os
os.chdir("/content/VideoPose3D/inference")
!python infer_video_d2.py --cfg COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml --output-dir output_directory --image-ext mp4 input_directory
# Step 4: creating a custom dataset
import os
os.chdir("/content/VideoPose3D/data")
!python prepare_data_2d_custom.py -i /content/VideoPose3D/inference/output_directory -o myvideos
# Step 5: rendering a custom video and exporting coordinates
import os
os.chdir("/content/VideoPose3D")
# visualize with numpy
!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
- 论文
- Repo
- in wild
- Web
- Human3.6m数据集官网
```
Download H36M annotations
!mkdir data !cd data !wget http://visiondata.cis.upenn.edu/volumetric/h36m/h36m_annot.tar !tar -xf h36m_annot.tar !rm h36m_annot.tar
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