필터 지우기
필터 지우기

Human behavior recognition from video

조회 수: 4 (최근 30일)
Suraj Tripathy
Suraj Tripathy 2018년 2월 1일
답변: Vivek Akkala 2022년 12월 22일
I've a trained CNN providing an accuracy of 85%, classifying Humans and vehicles. Now, I need to classify Human behavior like walking,sitting which are Normal, and other like punching and kicking as Abnormal. How to train my network dynamically?
My code is attached below-:
%Load Data
rootFolder = 'C:\New folder\Project\Train\';
categories = {'persons','cars'};
imds = imageDatastore(fullfile(rootFolder, categories), 'LabelSource', 'foldernames');
tbl = countEachLabel(imds);
minSetCount = min(tbl{:,2});
imds = splitEachLabel(imds, minSetCount, 'randomize');
rootFolder = 'C:\New folder\Project\Test\';
imds_test = imageDatastore(fullfile(rootFolder, categories), 'LabelSource', 'foldernames');
tbl = countEachLabel(imds_test);
minSetCount = min(tbl{:,2});
imds_test = splitEachLabel(imds_test, minSetCount, 'randomize');
%Define Layers
layers = [imageInputLayer([64 64 3]);
convolution2dLayer(5,20);
reluLayer();
convolution2dLayer(5,20);
reluLayer();
convolution2dLayer(5,20);
reluLayer();
maxPooling2dLayer(2,'Stride',2);
fullyConnectedLayer(2);
softmaxLayer();
classificationLayer()];
options = trainingOptions('sgdm','MaxEpochs',20,...
'InitialLearnRate',0.0001);
trainedNet = trainNetwork(imds,layers,options);
YTest = classify(trainedNet,imds_test);
TTest = imds_test.Labels;
accuracy = sum(YTest == TTest)/numel(TTest);
trainFeatures = activations(trainedNet,imds,6);
trainingLabels = imds.Labels;
svm = fitcsvm(trainFeatures ,trainingLabels);
testFeatures = activations(trainedNet,imds_test,6);
testPredictions = predict(svm,testFeatures);
accuracy1 = sum(TTest == testPredictions)/numel(TTest);

답변 (1개)

Vivek Akkala
Vivek Akkala 2022년 12월 22일
Although object classification can be part of video classification its not straight forward to use object classification for video classification without additional post processing. Object classification like humans and vehicle need a single image to obtain the class whereas video classification needs a set of frames at regular intervals to analyze the behavior. You can look at Getting Started with Video Classification Using Deep Learning to get started with video classification and look at functions like slowFastVideoClassifier, r2plus1dVideoClassifier, and inflated3dVideoClassifier that might help you to recognize human activity.

카테고리

Help CenterFile Exchange에서 Recognition, Object Detection, and Semantic Segmentation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by