02【mmaction2 slowfast 行为分析(商用级别)】项目demo搭建

【mmaction2 slowfast 行为分析(商用级别)】总目录

开始之前,保证项目已经下载了:01【mmaction2 slowfast 行为分析(商用级别)】项目下载

一,环境搭建

首先创建虚拟环境:

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

在项目目录(cd ${JN-OpenLib-root})下输入:

python setup.py develop

二,demo测试

使用mmaction中的slowfast跑一个视频

进入到项目地址:cd ${JN-OpenLib-root}

python demo/demo_spatiotemporal_det.py --config configs/detection/ava/slowfast_kinetics_pretrained_r50_8x8x1_20e_ava_rgb.py --checkpoint /home/lxn/0yangfan/mmaction/JN-OpenLib-mmaction2/Checkpionts/mmdetection/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth --det-config demo/faster_rcnn_r50_fpn_2x_coco.py  --det-checkpoint ./Checkpionts/mmdetection/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth   --video demo/lzm1.mp4  --out-filename demo/lzm1_2.mp4  --det-score-thr 0.9 --action-score-thr 0.5 --output-stepsize 4  --output-fps 6

其中:
–config 行为分析模型配置文件 --checkpoint 行为分析模型权重文件
–det-config 行人检测模型配置文件 --det-checkpoint 行人检测模型权重文件
–video 输入的视频路径 --out-filename 输出视频路径
–det-score-thr 检测行人阈值 --act-score-thr 行为检测阈值
–predict-stepsize 每间隔n帧进行一次推理 --output-fps 输出视频的帧率

结果展示:
在这里插入图片描述

三,摄像头实时测试

python mywork/webcam_demo_ava.py --config configs/detection/ava/slowfast_kinetics_pretrained_r50_8x8x1_20e_ava_rgb.py --checkpoint /home/lxn/0yangfan/mmaction/JN-OpenLib-mmaction2/Checkpionts/mmdetection/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth --det-config ./demo/faster_rcnn_r50_fpn_2x_coco.py  --det-checkpoint /home/lxn/0yangfan/mmaction/JN-OpenLib-mmaction2/Checkpionts/mmdetection/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth   --camera-id  lzm1.mp4  --img-scale 0.5   --det-score-thr 0.25 --act-score-thr 0.5 --drawing-stepsize 3

–config 行为分析模型配置文件 --checkpoint 行为分析模型权重文件
–det-config 行人检测模型配置文件 --det-checkpoint 行人检测模型权重文件
–camera-id 摄像头id,也可以接入rtsp流,或者视频文件名 # --img-scale 输出图像缩放尺寸
–det-score-thr 检测行人阈值 --out-filename 输出文件路径
–drawing-stepsize 每间隔n帧进行一次行人检测推理

由于使用的远程,没办法打开摄像头,按照这个代码敲一般都可以跑出来。

猜你喜欢

转载自blog.csdn.net/WhiffeYF/article/details/119917571
今日推荐