视频动作识别--Temporal Segment Networks: Towards Good Practices for Deep Action Recognition

Temporal Segment Networks: Towards Good Practices for Deep Action Recognition
ECCV2016
https://github.com/yjxiong/temporal-segment-networks

本文侧重于从更长的视频中提取 long-range temporal structure,因为某些动作的过程较长,需要看更多的视频帧才能得到正确的动作分类。

1 Introduction
在动作识别中,主要是怎么利用视频中的 appearances and dynamics,但是提取这两个信息比较难,面临一系列的挑战如: scale variations, view point changes, and camera motions,所以在提取特征的时候,一方面我们的特征应该能够解决这些挑战,另一方面我们的特征又能够保持动作类型的信息。随着近几年 CNN 在 图像分类及其他图像分析领域中取得的进展,很自然就有人讲 CNN 应用到 动作识别中,但是效果不是很理想。
这里我们分析效果不理想的原因有两个:1) long-range temporal structure 在动作视频中扮演重要的角色,但是当前主流的 CNN网络结构主要关注appearances and short-term motions,所以 lacking the capacity to incorporate long-range temporal structure,也有人尝试通过 dense temporal sampling 来解决这个问题,但是这么做导致模型的计算量很大 尤其是处理较长时间的视频。2)训练样本过少导致模型容易出现过拟合。
这里我们采用视频动作识别中的经典架构 two-stream architecture。对于 temporal structure modeling, a key observation is that consecutive frames are highly redundant,所以稠密时间采样是不需要的。sparse temporal sampling strategy 是更好的策略。对此我们提出了 temporal segment network (TSN),从长的视频中用一个 sparse sampling scheme 提出 short snippets,样本在时间轴上均匀分布。a segmental structure is employed to aggregate information from the sampled snippets. In this sense, temporal segment networks are capable of modeling long-range temporal structure over the whole video.

针对训练样本少容易过拟合,我们主要通过以下三个方法来解决:1) cross-modality pre-training; 2) regularization; 3) enhanced data augmentation

3 Action Recognition with Temporal Segment Networks
3.1 Temporal Segment Networks
当前的 two-stream ConvNets 存在的问题就是 不能对长时间的视频进行建模,只能对连续的几帧的 short snippet 提取 temporal context
an obvious problem of the two-stream ConvNets in their current forms is their inability in modeling long-range temporal structure

我们的 temporal segment network framework 主要想利用整个视频的 visual information 来进行 video-level prediction
这里写图片描述
我们将一个视频分成 K 个部分,从每个部分中随机的 选出一个 short snippet,对这个short snippet 进行 two-stream ConvNets处理,对分析结果再用 the segmental consensus function 得到 segmental consensus

四种输入形态:
这里写图片描述

Network Training 针对训练样本少的情况
1)Cross Modality Pre-training 预训练
2) Regularization Techniques: partial Batch Normalization,dropout
3)Data Augmentation

4 Experiments

UCF101 dataset
这里写图片描述

different input modalities
这里写图片描述
different segmental consensus functions
这里写图片描述

different very deep ConvNet architectures
这里写图片描述

Component analysis
这里写图片描述

效果对比
这里写图片描述

Visualization of ConvNet models for action recognition using DeepDraw
这里写图片描述
这里写图片描述

### MATLAB 实现时空图卷积网络用于交通流量预测 为了实现《Spatio-Temporal Graph Convolutional Networks: A Deep Learning Framework for Traffic Forecasting》中的方法,需要构建一个能够处理时空数据的框架。该框架主要由以下几个部分组成: #### 1. 数据预处理 在开始之前,需准备并清理交通流量数据集。这通常涉及缺失值填充、标准化以及创建邻接矩阵。 ```matlab % 假设 data 是 N x T 的矩阵, 其中 N 表示节点数, T 表示时间步长. data = load('traffic_data.mat'); % 加载交通流量数据 adj_matrix = create_adjacency_matrix(data); % 创建邻接矩阵函数 normalized_data = normalize_traffic_data(data); % 归一化交通流量数据 ``` #### 2. 构建图结构 通过定义道路之间的连接关系来建立图结构。这里使用邻接矩阵表示图的关系。 ```matlab function adj_matrix = create_adjacency_matrix(road_network) % road_network 应包含路段间距离或其他衡量标准的信息 distances = calculate_distances_between_roads(road_network); threshold = determine_threshold(distances); % 设定阈值 [N, ~] = size(distances); adj_matrix = zeros(N); for i = 1:N for j = 1:N if distances(i,j) <= threshold && i ~= j adj_matrix(i,j) = exp(-distances(i,j)^2 / (2*threshold^2)); end end end end ``` #### 3. 定义 ST-GCN 层 ST-GCN 结合了空间上的 GCN 和时间维度上的 CNN 来捕捉复杂的时空模式[^3]. ```matlab classdef STGCNLayer < nnet.layer.Layer properties K; % 支持的最大阶数 F_in; F_out; W; b; end methods function layer = STGCNLayer(K,F_in,F_out) layer.K = K; layer.F_in = F_in; layer.F_out = F_out; szW = [F_out,K+1,F_in]; layer.W = randn(szW)*0.01; layer.b = zeros(F_out,1); end function Z = predict(layer,X,A_hat) % X: 输入特征向量 (B,N,T,F_in), B 批次大小, N 节点数量, T 时间长度, F_in 特征维数 % A_hat: 预处理后的拉普拉斯矩阵 B = size(X,1); N = size(A_hat,1); T = size(X,3); H = cell(T,1); for t=1:T Xt = reshape(X(:,:,t,:),[],size(X,4)); % 将三维张量转换成二维矩阵 HT = []; for k=0:min(layer.K,size(A_hat,1)-1) AkX = power(A_hat,k)*Xt; HT = cat(2,HT,AkX); end H{t} = tanh(reshape(linear_combination(HT,layer.W)+repmat(layer.b',size(B*N,1),1),... [B,N,layer.F_out])); end Z = cat(3,H{:}); end function dLdW = backward(layer,dLdZ,X,A_hat) ... end end end ``` #### 4. 训练模型 设置超参数,并利用反向传播算法调整权重以最小化损失函数。 ```matlab num_epochs = 50; batch_size = 64; layers = [ imageInputLayer([input_height input_width channels]) convolution2dLayer(filterSize,numFilters,'Padding','same') batchNormalizationLayer() reluLayer() fullyConnectedLayer(outputSize) regressionLayer()]; options = trainingOptions('adam',... 'MaxEpochs', num_epochs,... 'MiniBatchSize', batch_size,... 'InitialLearnRate', 0.001,... 'Shuffle', 'every-epoch',... 'Verbose', false,... 'Plots', 'training-progress'); model = trainNetwork(trainingData,layers,options); ``` 请注意上述代码片段仅为概念验证性质,在实际应用时还需要考虑更多细节优化及调试工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值