I would like if possible how to make this Threshold for Evaluation and validation of created R-CNN object Detector, i tried to make it in the attached scripts but it does not work, I want to make Threshold for score that like below 0.58 that score and bboxes should not be appeared in results
i tried the below code but i got the error
Herein the code:-
load('gTruth.mat')
smokedetection = selectLabels(gTruth,'alarm');
if ~isfolder(fullfile('EvaluationData'))
mkdir EvaluationData
addpath('EvaluationData');
evaluationData = objectDetectorTrainingData(gTruth,...
'SamplingFactor',1,'WriteLocation','EvaluationData');
end
imds = imageDatastore(fullfile('EvaluationData'));
numImages = height(evaluationData);
result(numImages,:) = struct('Boxes',[],'Scores',[]);
for i = 1:numImages
% Read Image
I = readimage(imds,i);
% Detect the object of interest
[bboxes, scores] = detect(detector,I,'MiniBatchSize', 32);
% Store result
result(i).Boxes = bboxes;
T = 0.58; % Define threshold here
idx = scores >= T;
result(i).Scores = scores(idx);
end
% Convert structure to table
results = struct2table(result);
overlap = 0.1;
% Evaluate Metrics
[ap,recall,precision] = evaluateDetectionPrecision(results...
,evaluationData(:,2),overlap);
[am,fppi,missRate] = evaluateDetectionMissRate(results,evaluationData(:,2),overlap);
% and herein the error i got
Error using vision.internal.detector.evaluationInputValidation>checkDetectionResultsTable (line 66)
Invalid score value in row 1 of the detection results table: Expected input to be an array with number of
elements equal to 8.
Error in vision.internal.detector.evaluationInputValidation (line 6)
checkDetectionResultsTable(detectionResults, groundTruth, mfilename);
Error in evaluateDetectionPrecision (line 94)
vision.internal.detector.evaluationInputValidation(detectionResults, ...
Error in Evaluationthedetector (line 33)
[ap,recall,precision] = evaluateDetectionPrecision(results...
Related
SHAPE_PATH = os.path.join(".", "/home/sahil/", "mapa.geojson")
area_gdf = gpd.read_file(SHAPE_PATH)
Geometry of an entire area
full_geometry = Geometry(area_gdf.geometry.values[0], crs=CRS.WGS84)
Bounding box of a test sub-area
test_bbox = Geometry(area_gdf.geometry.values[1], crs=CRS.WGS84).bbox
area_gdf.plot(column="name");
Error-
index 1 is out of bounds for axis 0 with size 1
I am trying to paste grades in excel sheet based on marks
i do this but this shows only F in excel sheet .. i want if anybody has marks >=80 then want to show A grade .. and if anybody hay >=70 then B
and if anybody have less than 70 then want to show F
UPDATED CODE
clc,clear all
filename = 'PROJECT..xlsx';
table = readtable(filename);
data = xlsread(filename);
[r,c] = size(data);
total_courses = c;
table.SumofMarks = zeros(r,1);
table.Percentage = zeros(r,1);
table.StudentGrade = repmat({''},r,1);
% Sum of marks in different courses and their percentage.
format bank
Sum_of_Marks = sum(data,2);
Student_Percentage = Sum_of_Marks./total_courses;
T = horzcat(Sum_of_Marks,Student_Percentage);
N = length(Student_Percentage);
table.SumofMarks = Sum_of_Marks;
table.Percentage = Student_Percentage;
for i = 1:63
sheet1=readtable(filename);
mark=sheet1{i,{'CALCULUS','DISCRETE','ECONOMICS','ISLAMIAT','STATISTICS'}};
if mark(mark<40)
grade='F';
sheet1(i,'StudentGrade')=cellstr(grade);
else
continue
end
end
writetable(table,filename)
xlswrite(filename,T,1, 'H2')
xlswrite(filename,grade,1,'J2')
these are the errors which I get
Error using getRowIndices (line 75)
Row index exceeds table dimensions.
Error in table/subsrefBraces (line 17)
[rowIndices,numRowIndices] =
getRowIndices(t, s(1).subs{1});
Error in table/subsref (line 60)
[varargout{1:nargout}] =
subsrefBraces(t,s);
Error in lab4 (line 38)
mark=sheet1{i,{'CALCULUS','DISCRETE','ECONOMICS','ISLAMIAT','STATISTICS'}};
i tried this but this code doesnt work
how i do this
i paste link where my file is located.. and I want if any student get less than 40 marks in any subject then want to show F grade.. this code shows if total marks is less than 40 .. where as I want to show if marks is less than 40 in any subject
this is the excel file
https://drive.google.com/file/d/1VQ8XxAQPu6reY0SCNV9Rxt65w1koduGA/view?usp=sharing
I don't have Excel installed, so I can't check the part about reading and writing to Excel, but you should replace
if R>=80
table.StudentGrade{i} = 'A';
elseif R>=70
table.StudentGrade{i} = 'B';
elseif R <70
table.StudentGrade{i}= 'F';
end
with
if R(i)>=80
table.StudentGrade{i} = 'A';
elseif R(i)>=70
table.StudentGrade{i} = 'B';
elseif R(i) <70
table.StudentGrade{i}= 'F';
end
I have a file with strings of a known length, but no separator.
% What should be the result
vals = arrayfun(#(x) ['Foobar ', num2str(x)], 1:100000, 'UniformOutput', false);
% what the file looks like when read in
strs = cell2mat(vals);
strlens = cellfun(#length, vals);
The most straightforward approach is quite slow:
out = cell(1, length(strlens));
for i=1:length(strlens)
out{i} = fread(f, strlens(i), '*char');
end % 5.7s
Reading everything in and splitting it up afterwards is a lot faster:
strs = fread(f, sum(strlens), '*char');
out = cell(1, length(strlens));
slices = [0, cumsum(strlens)];
for i=1:length(strlens)
out{i} = strs(slices(i)+1:slices(i+1));
end % 1.6s
With a mex function I can get down to 0.6s, so there's still a lot of room for improvement. Can I get comparable performance with pure Matlab (R2016a)?
Edit: the seemingly perfect mat2cell function doesn't help:
out = mat2cell(strs, 1, strlens); % 2.49s
Your last approach – reading everything at once and splitting it up afterwards – looks pretty optimal to me, and is how I do stuff like this.
For me, it's running in about 80 ms seconds when the file is on a local SSD in both R2016b and R2019a, on Mac.
function out = scratch_split_strings(strlens)
%
% Example:
% in_strs = arrayfun(#(x) ['Foobar ', num2str(x)], 1:100000, 'UniformOutput', false);
% strlens = cellfun(#length, in_strs);
% big_str = cat(2, in_strs{:});
% fid = fopen('text.txt'); fprintf(fid, '%s', big_str); fclose(fid);
% scratch_split_strings(strlens);
t0 = tic;
fid = fopen('text.txt');
txt = fread(fid, sum(strlens), '*char');
fclose(fid);
fprintf('Read time: %0.3f s\n', toc(t0));
str = txt;
t0 = tic;
out = cell(1, length(strlens));
slices = [0, cumsum(strlens)];
for i = 1:length(strlens)
out{i} = str(slices(i)+1:slices(i+1))';
end
fprintf('Munge time: %0.3f s\n', toc(t0));
end
>> scratch_split_strings(strlens);
Read time: 0.002 s
Munge time: 0.075 s
Have you stuck it in the profiler to see what's taking up your time here?
As far as I know, there is no faster way to split up a single primitive array into variable-length subarrays with native M-code. You're doing it right.
I would like to get the mean of my reaction time column when my stimnum column is equal to 1
I am not sure if i can do this with one simple line of code or if i need to do a for loop.
stimnum = randi([1 3], [1 100]);
y = 1 + 1.*randn(1, 100);
rt = (y.^2) +.01;
A = rand(1,100);
correct = A>=0.2;
Data= [stimnum; rt; correct ]';
Data = dataset({ Data, 'Stimnum', 'RT', 'Correct'});
rtmean = mean (Data.RT{Data.Stimnum == 1});
I have function called Assignment in Matlab with PsychToolBox. This function shows a random color to the paritcipant and require participant to name the color and record this data.
function should return me 2 output as a string
rgb code of the random color like: trial(1).color = [5 5 5]
a matrix which correspond to the sound record.
I write the main functions and color part is okay, but I cannot integrate the recording function into the main function.
in main function I use this string trial.data = recording(1,0,5)
and then I wrote a subfunction named "recording"
function recording (wavfilename, voicetrigger, maxsecs)
bla, bla
end
However, the main function does not recognize the subfunction. Am I doing an logical error? the error message is below
Error: File: assignment.m Line: 40 Column: 27
Unexpected MATLAB expression.
line 40 = trial.data = recording(1,0,5)
function ass8(trial)
Screen('Preference', 'SkipSyncTests', 1)
ListenChar(2);
Screen('HideCursorHelper', 0, 0)
[myWin, rect]=Screen('OpenWindow',0,[128,128,128]);
centerX=rect(3)/2;
centerY=rect(4)/2;
for trial = 1:100
Screen('TextSize', myWin, 30);
Screen('TextFont', myWin, 'Times');
[normBoundsRect, offsetBoundsRect] = Screen('TextBounds',myWin, 'What is the color of the rectangle?');
Screen('DrawText', myWin, 'What is the color of the rectangle?', (centerX-(normBoundsRect(3)/2)),(centerY-(normBoundsRect(4)/2+150)), [0,0,0]);
Screen('Flip', myWin)
WaitSecs(1)% inter stimulus interval
color = randi(255,1,3)
while 1
Screen('FillRect', myWin, color ,[583, 284, 783, 484])
% [ (centerX-100), (centerY-100), (centerX+100),(centerY+100)]);
Screen('Flip', myWin)
WaitSecs(3)
trial.color = color % trial 'ın rengini belirtmesini söyledim
trial.data = reco(1,0 5)% trial'ın ismi 1, kayıt yapacağı süre ise 3 sn
if Waitsecs(3)==1
break; % Terminates the loop if the condition is % satisfied
end
end
pause(.05);
% [clicks, x, y, buttons] = GetClicks(myWin);
%
% buttons=0;
% while ~buttons
% [x, y, buttons] = GetMouse(myWin);
% end
% while 1
% [x,y,buttons] = GetMouse(myWin);
% if ~buttons(1)
% break;
% end
% end
Screen('CloseAll')
end
end
function reco(wavfilename, voicetrigger, maxsecs)
%
% AssertOpenGL;
if nargin < 1
wavfilename = [];
end
if nargin < 2
voicetrigger = [];
end
if isempty(voicetrigger)
voicetrigger = 0;
end
if nargin < 3
maxsecs = [];
end
if isempty(maxsecs)
maxsecs = inf;
end
InitializePsychSound;
freq = 44100;
pahandle = PsychPortAudio('Open', [], 2, 0, freq, 2);
PsychPortAudio('GetAudioData', pahandle, 10);
PsychPortAudio('Start', pahandle, 0, 0, 1);
if voicetrigger > 0
% Yes. Fetch audio data and check against threshold:
level = 0;
% Repeat as long as below trigger-threshold:
while level < voicetrigger
% Fetch current audiodata:
[audiodata offset overflow tCaptureStart] = PsychPortAudio('GetAudioData', pahandle);
% Compute maximum signal amplitude in this chunk of data:
if ~isempty(audiodata)
level = max(abs(audiodata(1,:)));
else
level = 0;
end
% Below trigger-threshold?
if level < voicetrigger
% Wait for a millisecond before next scan:
WaitSecs(0.0001);
end
end
else
% Start with empty sound vector:
recordedaudio = [];
end
s = PsychPortAudio('GetStatus', pahandle)
while ~KbCheck && ((length(recordedaudio) / s.SampleRate) < maxsecs)
% Wait a second...
WaitSecs(1);
% Query current capture status and print it to the Matlab window:
s = PsychPortAudio('GetStatus', pahandle);
% Print it:
fprintf('\n\nAudio capture started, press any key for about 1 second to quit.\n');
fprintf('This is some status output of PsychPortAudio:\n');
disp(s);
% Retrieve pending audio data from the drivers internal ringbuffer:
audiodata = PsychPortAudio('GetAudioData', pahandle);
nrsamples = size(audiodata, 2);
% Plot it, just for the fun of it:
plot(1:nrsamples, audiodata(1,:), 'r', 1:nrsamples, audiodata(2,:), 'b');
drawnow;
% And attach it to our full sound vector:
recordedaudio = [recordedaudio audiodata]; %#ok<AGROW>
end
PsychPortAudio('Stop', pahandle);
audiodata = PsychPortAudio('GetAudioData', pahandle);
recordedaudio = [recordedaudio audiodata];
PsychPortAudio('Close', pahandle);
if ~isempty(wavfilename)
psychwavwrite(transpose(recordedaudio), 44100, 16, wavfilename)
end
fprintf('helal lan!\n');
ListenChar(2);
end