Undefined function 'preprocessData' for input arguments of type 'cell'.
6 views (last 30 days)
Show older comments
Hello guys, I am trying to figure my detection results using this code and error mentioned in title is appearing ...
testData = transform(testData,@(data)preprocessData(data,inputSize));
running this command error appears:
detectionResults = detect(detector,testData,'MinibatchSize',1);
this is my helper function:
function data = augmentData(data)
% Randomly flip images and bounding boxes horizontally.
tform = randomAffine2d('XReflection',true);
sz = size(data{1});
rout = affineOutputView(sz,tform);
data{1} = imwarp(data{1},tform,'OutputView',rout);
% Sanitize boxes, if needed. This helper function is attached as a
% supporting file. Open the example in MATLAB to open this function.
%data{2} = helperSanitizeBoxes(data{2});
% Warp boxes.
data{2} = bboxwarp(data{2},tform,rout);
end
function data = preprocessData(data,targetSize)
% Resize image and bounding boxes to targetSize.
sz = size(data{1},[1 2]);
scale = targetSize(1:2)./sz;
data{1} = imresize(data{1},targetSize(1:2));
%
% % Sanitize boxes, if needed. This helper function is attached as a
% % supporting file. Open the example in MATLAB to open this function.
% %data{2} = helperSanitizeBoxes(data{2});
%
% Resize boxes.
data{2} = bboxresize(data{2},scale);
end
also some warning appeared in command window :
Warning: While loading an object of class 'nnet.cnn.TrainingOptionsSGDM':
The value of 'ValidationData' is invalid. Invalid transform function defined on datastore.
can somebody help me with this please ?
0 Comments
Answers (1)
Steven Lord
on 9 May 2023
Are augmentData and preprocessData in the same file (and a different file than the one in which you're trying to use preprocessData?) As stated in the documentation in a function file only the main (first) function is directly callable outside the file.
"Program files can contain multiple functions. If the file contains only function definitions, the first function is the main function, and is the function that MATLAB associates with the file name. Functions that follow the main function or script code are called local functions. Local functions are only available within the file."
The easiest approach, if you want to use preprocessData in multiple files or from the Command Window, is to make it its own main function in its own function file.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!