当前位置:   article > 正文

Facebookresearch-Slowfast配置及demo实现_slowfast运行环境的配置

slowfast运行环境的配置

写在前面:

本博客所有环境基于服务器Ubuntu18.05系统,V100显卡

一、环境准备

1、Python

conda create -n your-env-name python=3.8 -y
conda activate your-env-name

2、Pytorch

Slowfast要求torch版本高于1.7,本博客使用torch-1.12.1+cu113的配置,本文不使用pip命令进行下载,使用本地编译的方式,请在下方链接找到所需版本的torch,torchvision,torchaudio,下载完成后传输到服务器上进行安装

https://download.pytorch.org/whl/torch_stable.htmlicon-default.png?t=N7T8https://download.pytorch.org/whl/torch_stable.html

 3、工具包安装

可以根据slowfast中INSTALL.md里的指示进行安装

3.1 numpy

pip install numpy

3.2 PyAV

conda install av -c conda-forge

3.3 ffmpeg

pip install ffmpeg

3.4 moviepy

pip install moviepy

 3.5 psutil

pip install psutil

3.6 opencv-python

pip install opencv-python

3.7  tensorboard

pip install tensorboard

3.8  simplejson

pip install simplejson

4、其余部分安装

4.1 fvcore

在Github上下载下来之后上传到服务器进行编译

GitHub - facebookresearch/fvcore: Collection of common code that's shared among different research projects in FAIR computer vision team.Collection of common code that's shared among different research projects in FAIR computer vision team. - facebookresearch/fvcoreicon-default.png?t=N7T8https://github.com/facebookresearch/fvcore下方命令请cd到fvcore所在目录之后运行

pip install -e .

fvcore、PyYaml、tqdm、iopath会一起安装,如果没有一起安装,请再次使用pip install命令

4.2 PytorchVideo

与4.1的fvcore一样,在Github上下载源码后进行编译安装

GitHub - facebookresearch/pytorchvideo: A deep learning library for video understanding research.A deep learning library for video understanding research. - facebookresearch/pytorchvideoicon-default.png?t=N7T8https://github.com/facebookresearch/pytorchvideo

pip install -e .

4.3 Detectron2

这个是本篇文章中最难安装的部分,请确保安装了G++以及gcc编译器

GitHub - facebookresearch/detectron2: Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.Detectron2 is a platform for object detection, segmentation and other visual recognition tasks. - facebookresearch/detectron2icon-default.png?t=N7T8https://github.com/facebookresearch/detectron2

pip install -e .

这一部分会出现比较多的问题,我不太能记清我出现的问题,如果有问题请把错误代码发在评论区我一一解答

5、Slowfast安装

GitHub - facebookresearch/SlowFast: PySlowFast: video understanding codebase from FAIR for reproducing state-of-the-art video models.PySlowFast: video understanding codebase from FAIR for reproducing state-of-the-art video models. - facebookresearch/SlowFasticon-default.png?t=N7T8https://github.com/facebookresearch/SlowFast注意:下载完成之后请打开setup.py,将PIL修改为pillow以及sklearn修改为scikit-learn

  1. pip install scikit-learn
  2. pip install pandas

 完成安装上面两个包之后,运行如下命令

python setup.py build develop

如果出现finish slowfast==1.0即为安装成功

二、测试

1、下载预训练权重

SLOWFAST_32x2_R101_50_50.pkl下载SLOWFAST_32x2_R101_50_50.pkl放到slowfast/demo/AVA目录下

2、建立行为json

在slowfast/demo/AVA目录下面创建一个叫做ava.json的文件,写入如下内容

  1. {
  2. "bend/bow (at the waist)": 0,
  3. "crawl": 1,
  4. "crouch/kneel": 2,
  5. "dance": 3,
  6. "fall down": 4,
  7. "get up": 5,
  8. "jump/leap": 6,
  9. "lie/sleep": 7,
  10. "martial art": 8,
  11. "run/jog": 9,
  12. "sit": 10,
  13. "stand": 11,
  14. "swim": 12,
  15. "walk": 13,
  16. "answer phone": 14,
  17. "brush teeth": 15,
  18. "carry/hold (an object)": 16,
  19. "catch (an object)": 17,
  20. "chop": 18,
  21. "climb (e.g., a mountain)": 19,
  22. "clink glass": 20,
  23. "close (e.g., a door, a box)": 21,
  24. "cook": 22,
  25. "cut": 23,
  26. "dig": 24,
  27. "dress/put on clothing": 25,
  28. "drink": 26,
  29. "drive (e.g., a car, a truck)": 27,
  30. "eat": 28,
  31. "enter": 29,
  32. "exit": 30,
  33. "extract": 31,
  34. "fishing": 32,
  35. "hit (an object)": 33,
  36. "kick (an object)": 34,
  37. "lift/pick up": 35,
  38. "listen (e.g., to music)": 36,
  39. "open (e.g., a window, a car door)": 37,
  40. "paint": 38,
  41. "play board game": 39,
  42. "play musical instrument": 40,
  43. "play with pets": 41,
  44. "point to (an object)": 42,
  45. "press": 43,
  46. "pull (an object)": 44,
  47. "push (an object)": 45,
  48. "put down": 46,
  49. "read": 47,
  50. "ride (e.g., a bike, a car, a horse)": 48,
  51. "row boat": 49,
  52. "sail boat": 50,
  53. "shoot": 51,
  54. "shovel": 52,
  55. "smoke": 53,
  56. "stir": 54,
  57. "take a photo": 55,
  58. "text on/look at a cellphone": 56,
  59. "throw": 57,
  60. "touch (an object)": 58,
  61. "turn (e.g., a screwdriver)": 59,
  62. "watch (e.g., TV)": 60,
  63. "work on a computer": 61,
  64. "write": 62,
  65. "fight/hit (a person)": 63,
  66. "give/serve (an object) to (a person)": 64,
  67. "grab (a person)": 65,
  68. "hand clap": 66,
  69. "hand shake": 67,
  70. "hand wave": 68,
  71. "hug (a person)": 69,
  72. "kick (a person)": 70,
  73. "kiss (a person)": 71,
  74. "lift (a person)": 72,
  75. "listen to (a person)": 73,
  76. "play with kids": 74,
  77. "push (another person)": 75,
  78. "sing to (e.g., self, a person, a group)": 76,
  79. "take (an object) from (a person)": 77,
  80. "talk to (e.g., self, a person, a group)": 78,
  81. "watch (a person)": 79
  82. }

按照下图修改slowfast/demo/AVA/SLOWFAST_32x2_R101_50_50.yaml文件内容

3、修改预训练权重路径

4、修改json文件路径

5、修改推理视频路径

其中input为待推理的视频路径,output为推理完成后视频存放的路径

6、推理命令

python tools/run_net.py --cfg /path/to/your/cfg/file

三、推理效果图

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/863987
推荐阅读
相关标签
  

闽ICP备14008679号