当前位置: 首页 > news >正文

创建自己的AVA行为识别数据集以及MMLAB系列训练、测试自己的数据

第一步:新建好这些文件夹,也就是接下来咱们完成的内容

第二步:配置好ffmpeg的环境变量,也就是把这个bin所在路径添加到环境变量

 

这一步完成之后,可能需要重启才能用ffmpeg,然后打开命令行试一下这个命令表示成功 

 第三步:对已经选择好的视频进行切割,比如固定长度是45秒(自己定)

 

右键git bash打开命令行,执行脚本文件sh cut_videos.sh

 脚本文件

#!/usr/bin/env bash

# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################

# Cut each video from its 15th to 30th minute.

IN_DATA_DIR="F:/source_code/action/ava_data/ava/videos"
OUT_DATA_DIR="F:/source_code/action/ava_data/ava/videos_cut"

if [[ ! -d "${OUT_DATA_DIR}" ]]; then
  echo "${OUT_DATA_DIR} doesn't exist. Creating it.";
  mkdir -p ${OUT_DATA_DIR}
fi

for video in $(ls -A1 -U ${IN_DATA_DIR}/*)
do
  out_name="${OUT_DATA_DIR}/${video##*/}"
  if [ ! -f "${out_name}" ]; then
    ffmpeg -ss 0 -t 15 -i "${video}" -r 30 -strict experimental "${out_name}"
  fi
done

第四步:对裁剪好的视频进行截帧操作,默认一秒30张图像

sh extract_rgb_frames_ffmpeg.sh

#!/usr/bin/env bash

# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################
##-r表示一秒多少帧 -q:v表示存储jpeg的图像质量,一般2是高质量。
# Extract frames from videos.

IN_DATA_DIR="./ava/videos_cut"
OUT_DATA_DIR="./ava/rawframes"

if [[ ! -d "${OUT_DATA_DIR}" ]]; then
  echo "${OUT_DATA_DIR} doesn't exist. Creating it.";
  mkdir -p ${OUT_DATA_DIR}
fi

for video in $(ls -A1 -U ${IN_DATA_DIR}/*)
do
  video_name=${video##*/}

  if [[ $video_name = *".webm" ]]; then
    video_name=${video_name::-5}
  else
    video_name=${video_name::-4}
  fi

  out_video_dir=${OUT_DATA_DIR}/${video_name}
  mkdir -p "${out_video_dir}"

  out_name="${out_video_dir}/img_%05d.jpg"

  ffmpeg -i "${video}" -r 30 -q:v 1 "${out_name}"
done

 

第五步:把需要标注的文件单独整出来

即每1s只取一帧图像,同时去掉头部和尾部,执行video2img.py即可

 

第六步:开始标注任务

使用VIA来进行数据标注

 

第七步:把标注数据转换成AVA格式

 把红色部分改成自己导出的文件名字,生成结果如下:

2.MMaction训练自己的数据 

        修改运行配置:F:/source_code/action/mmaction2master/configs/detection/ava/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb.py

生成对应的配置文件,修改对应的配置文件

  • 指定行为类别

指定数据地址:

 

另外需要将F:\source_code\action\mmaction2-master\mmaction\datasets\ava_dataset.py ,

timestamp_start,原来的ava数据是从第900秒开始

3. MMaction测试自己的数据 

参数设置:

'''
--video F:/source_code/action/ava_data/ava/videos/writting.mp4
--config F:/source_code/action/mmaction2-master/tools/model/my_slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb_custom_classes.py
--checkpoint F:/source_code/action/mmaction2-master/tools/work_dirs/ava/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb_custom/epoch_20.pth
--det-config faster_rcnn_r50_fpn_2x_coco.py
--det-checkpoint http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_2x_coco/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth
--det-score-thr 0.9
--action-score-thr 0.5
--label-map F:/source_code/action/ava_data/ava/annotations/labelmap.txt
--predict-stepsize 8
--output-stepsize 4
--output-fps 6
--out-filename writte.mp4
'''

 

 

 

 

相关文章:

  • C++多态之虚函数表详解及代码示例
  • 廊坊特色农业 国稻种芯·中国水稻节:河北复合农业促增收
  • 陈吉宁经典演讲:平庸与卓越的差别
  • 【IO】文件操作基础知识
  • Win11安装怎么跳过TPM-Win11安装跳过TPM的方法介绍
  • 【沃趣科技】初探MySQL迁移到ClickHouse
  • EndNote使用技巧之引用文献信息的导入与修改
  • java怎么连接数据库mysql
  • AI绘画逆着玩火了,敢不敢发自拍看AI如何用文字形容你?
  • 是时候掌握SpringMVC源码了-初探篇
  • 上手Python之set(集合)
  • Visual Studio 2022开发Arduino详述
  • 【机器人定位引导中的机器视觉技术】
  • 零售商贩mysql表设计:主题信息表(theme)
  • 本文带你了解透彻云计算(前世,今生,未来)
  • [LeetCode] Wiggle Sort
  • [分享]iOS开发-关于在xcode中引用文件夹右边出现问号的解决办法
  • 「面试题」如何实现一个圣杯布局?
  • Angular 4.x 动态创建组件
  • axios请求、和返回数据拦截,统一请求报错提示_012
  • ComponentOne 2017 V2版本正式发布
  • MySQL-事务管理(基础)
  • Python爬虫--- 1.3 BS4库的解析器
  • REST架构的思考
  • Spring Cloud中负载均衡器概览
  • yii2权限控制rbac之rule详细讲解
  • 对象管理器(defineProperty)学习笔记
  • 互联网大裁员:Java程序员失工作,焉知不能进ali?
  • 前端面试题总结
  • 如何编写一个可升级的智能合约
  • NLPIR智能语义技术让大数据挖掘更简单
  • shell使用lftp连接ftp和sftp,并可以指定私钥
  • 直播平台建设千万不要忘记流媒体服务器的存在 ...
  • ​软考-高级-信息系统项目管理师教程 第四版【第14章-项目沟通管理-思维导图】​
  • #if和#ifdef区别
  • #pragma once
  • #Z2294. 打印树的直径
  • (Arcgis)Python编程批量将HDF5文件转换为TIFF格式并应用地理转换和投影信息
  • (ZT)北大教授朱青生给学生的一封信:大学,更是一个科学的保证
  • (附源码)计算机毕业设计SSM基于健身房管理系统
  • (转)德国人的记事本
  • (转)树状数组
  • .NET CF命令行调试器MDbg入门(四) Attaching to Processes
  • .net core 实现redis分片_基于 Redis 的分布式任务调度框架 earth-frost
  • .NET Core 中的路径问题
  • .net core使用ef 6
  • .net 程序 换成 java,NET程序员如何转行为J2EE之java基础上(9)
  • .NET/C# 编译期能确定的字符串会在字符串暂存池中不会被 GC 垃圾回收掉
  • /bin/bash^M: bad interpreter: No such file ordirectory
  • @Autowired和@Resource装配
  • @FeignClient 调用另一个服务的test环境,实际上却调用了另一个环境testone的接口,这其中牵扯到k8s容器外容器内的问题,注册到eureka上的是容器外的旧版本...
  • [ 渗透工具篇 ] 一篇文章让你掌握神奇的shuize -- 信息收集自动化工具
  • [\u4e00-\u9fa5] //匹配中文字符
  • []T 还是 []*T, 这是一个问题
  • [100天算法】-不同路径 III(day 73)