以下链接是个人关于行为分析(商用级别)所有见解,如有错误欢迎大家指出,我会第一时间纠正。有兴趣的朋友可以加微信:17575010159 相互讨论技术。若是帮助到了你什么,一定要记得点赞!因为这是对我最大的鼓励。文末附带 公 众 号 − \color{blue}{公众号 -} 公众号− 海 量 资 源 。 \color{blue}{ 海量资源}。 海量资源。
行为分析(商用级别)00-目录-史上最新无死角讲解
预备工作
首先,我们根据上一篇博客博客: 行为分析(商用级别)01 - 所有资源链接分享:论文,源码,数据集,预训练模型等 下载好如上资源,并且按照给出的方式摆放,不要改变文件夹的相对路径。
环境搭建
注 意 , 本 人 编 写 该 博 客 的 时 间 为 2021 / 04 / 15 , 本 人 调 试 该 代 码 为 u b u n t u 18.04 \color{red}{注意,本人编写该博客的时间为2021/04/15,本人调试该代码为ubuntu18.04} 注意,本人编写该博客的时间为2021/04/15,本人调试该代码为ubuntu18.04 系 统 即 下 面 的 报 错 使 用 u b u n t u 18.04 报 错 的 过 程 , 以 及 解 决 办 法 \color{red}{系统即下面的报错使用ubuntu18.04报错的过程,以及解决办法} 系统即下面的报错使用ubuntu18.04报错的过程,以及解决办法
# JN-OpenLib-root表示从本人github下载项目的根目录
cd ${JN-OpenLib-root}
conda create -n JN-OpenLib-mmaction2-pytorch1.6-py3.6 -y python=3.6
conda activate JN-OpenLib-mmaction2-pytorch1.6-py3.6
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install mmcv-full==1.2.7 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html
pip install mmpycocotools
pip install moviepy opencv-python terminaltables seaborn decord -i https://pypi.douban.com/simple
python setup.py develop
视频测试
# JN-OpenLib-root表示从本人github下载项目的根目录
# --config 行为分析模型配置文件 --checkpoint 行为分析模型权重文件
# --det-config 行人检测模型配置文件 --det-checkpoint 行人检测模型权重文件 (其完全兼容mmdetection,如果想要了解可以参考本人之前的博客: https://blog.csdn.net/weixin_43013761/article/details/108368099)
# --video 输入的视频路径 --out-filename 输出视频路径
# --det-score-thr 检测行人阈值 --act-score-thr 行为检测阈值
# --predict-stepsize 每间隔n帧进行一次推理 --output-fps 输出视频的帧率
cd ${JN-OpenLib-root}
python demo/demo_spatiotemporal_det.py --config configs/detection/ava/slowfast_kinetics_pretrained_r50_8x8x1_20e_ava_rgb.py --checkpoint ../../Checkpoints/mmaction/slowfast_kinetics_pretrained_r50_8x8x1_20e_ava_rgb_20201217-ae225e97.pth --det-config demo/faster_rcnn_r50_fpn_2x_coco.py --det-checkpoint ../../Checkpoints/mmdetection/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth --video demo/demo.mp4 --out-filename demo/stdet_demo.mp4 --det-score-thr 0.9 --action-score-thr 0.5 --output-stepsize 4 --output-fps 6
运行之后在 demo 文件夹下面可以看到视频 stdet_demo.mp4 如下:
这里并非百分百的实时,虽然存在一两秒的延时,但是界面看起来来不会有卡顿。
# JN-OpenLib-root表示从本人github下载项目的根目录
# --config 行为分析模型配置文件 --checkpoint 行为分析模型权重文件
# --det-config 行人检测模型配置文件 --det-checkpoint 行人检测模型权重文件 (其完全兼容mmdetection,如果想要了解可以参考本人之前的博客: https://blog.csdn.net/weixin_43013761/article/details/108368099)
# --camera-id 摄像头id,也可以接入rtsp流,或者视频文件名 # --img-scale 输出图像缩放尺寸
# --det-score-thr 检测行人阈值 --out-filename 输出文件路径
# --drawing-stepsize 每间隔n帧进行一次行人检测推理
cd ${JN-OpenLib-root}
python python mywork/webcam_demo_ava.py --config configs/detection/ava/slowfast_kinetics_pretrained_r50_8x8x1_20e_ava_rgb.py --checkpoint ../../Checkpoints/mmaction/slowfast_kinetics_pretrained_r50_8x8x1_20e_ava_rgb_20201217-ae225e97.pth --det-config ./demo/faster_rcnn_r50_fpn_2x_coco.py --det-checkpoint ../../Checkpoints/mmdetection/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth --camera-id xxx.mp4 --img-scale 0.5 --det-score-thr 0.25 --act-score-thr 0.5 --drawing-stepsize 3
本人运行之后显示图像如下: