How can I speed up the svdd one class classifier training in prtools

1 view (last 30 days)
My Query: Is it okay for the svdd function in the dd_tools toolbox to take around 0.15 secs to train a 95X3 dataset with one class ? I am using the default values for the parameters.
Some Context: I am basically trying to train a classifier for every pixel, based on the RGB values for that pixel in the past few (95 in this particular case) frames. For this purpose I am using the svdd classifier as outlined in this paper. The paper reports to have done the entire training in 16 seconds and hence I think I doing something terrible wrong
A request: My code is currently taking a couple of hours for the entire training and I think there is something fundamentally wrong in the way I am using the toolbox. I have read through the documentation and tutorials multiple times, but I am not being able to find out what is going wrong here. Could you please take a look and help me understand the correct usage of the functions in the toolbox.
Appended is a copy of my entire code.
The driver.m file is where I am using svdd function.
Thank you.
******************************Driver.m******************************************************
%Driver File %Taking Initial SnapShot %ADD MESSAGE FOR MOVING OUT OF THE SCREEN %BackgroundFrames is a set of 100 frames taken from the video feed of the webcamera. BackgroundFrames = BackgroundRead();
%TRAINING PHASE
SVDxy{24,32}=prmapping(); %set of SVD for pixel x,y %Iterating through ever pixel for x = 1:240 for y = 1:320 trainingVector = zeros(10,3); for i=1:10 trainingVector(i,:) = BackgroundFrames(x,y,:,i); end W_Class = target_class(trainingVector,'1'); t = cputime; SVDxy{x,y} = svdd(W_Class,0.1,5); e = cputime-t; e end
end
%TESTING PHASE
% for x=1:240 % for y= 1:320 % testingVector = zeros(5,3); % labels_pred = zeros(240,320,5); % for j=91:95, % testingVector(j-95,:) = BackgroundFrames(x,y,:,j); % end % T_Class = target_class(testingVector,'1'); % finalAnswer = T_Class*SVDxy{x,y}; % % for k =1:5 % labels_pred(x,y,k) = sum(double(finalAnswer.labels(k,:)))-646; % end % end % end
*******************BackgroundFrames.m*****************************************************
%function to read and capture the background %This function creates 10 images of the background function [BackgroundFrames] = BackgroundRead() if(~isdeployed) cd(fileparts(which(mfilename))); end clc; % Clear command window. clear; % Delete all variables. close all; % Close all figure windows except those created by imtool; imtool close all; % Close all figure windows created by imtool. workspace; % Make sure the workspace panel is showing.
vid = videoinput('winvideo', 1, 'YUY2_320x240');
set(vid, 'ReturnedColorSpace', 'RGB');
src = getselectedsource(vid);
src.FrameRate = '20.0000';
vid.FramesPerTrigger = 20*5;
start(vid);
wait(vid,65);
data = getdata(vid);
BackgroundFrames = data(:,:,:,1:100);
img = BackgroundFrames(:,:,:,100);
imshow(img);
end

Answers (0)

Categories

Find more on Manage Products in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!