autolabeler error of array indices
Afficher commentaires plus anciens
Hi,
I am trying to use model assisted labeling with the following code:
function autoLabels = yoloImageLabeler(I)
% Add your code here
% Set up the persistent variable for the detector
persistent detector
if isempty(detector)
% Note: make sure the detector is on your path
load mynewyolo.mat detector
end
% Detect the objects and save the bounding boxes and labels
[bbox,~,labels] = detect(detector,I);
% Get unique list of labels (to loop through later)
detectedLabels = unique(labels);
% Initialize output
autoLabels(length(detectedLabels)) = struct();
% Add results to the output autoLabels
for i = 1:length(detectedLabels)
label = string(detectedLabels(i));
autoLabels(i).Name = label;
autoLabels(i).Type = labelType("Rectangle");
autoLabels(i).Position = bbox(labels == label, :);
end
end
However, matlab runs into error after labeling 2-3 images from 300 and generates error:(ATTACHED IMAGE)
Error using vision.labeler.FunctionalAutomationAlgorithm/run (line 77)
The custom automation function threw the following error:
Array indices must be positive integers of logical values.
Please provide support. I have resized image to same size and named them sequentially. Also my model is custom yolo model with one class 'person' only.
Thanks
9 commentaires
dpb
il y a 7 minutes
What is the content of detectedLabels?
As a note, length is a potentially dangerous function; it returns max(size(x)), not necessarily the size in the dimension of interest. Depending upon what the detectedLabels array is, you may not have what you think you have for the array of struct.
Set a breakpoint and see what is being returned for the label when it fails...
tren
il y a environ 3 heures
dpb
il y a environ 3 heures
I wondered about that as being an issue....
Put in a try...catch ... end block would be one relatively painless approach -- just let it go on to the next with an empty catch block.
tren
il y a environ 2 heures
for i = 1:length(detectedLabels)
try
label = string(detectedLabels(i));
autoLabels(i).Name = label;
autoLabels(i).Type = labelType("Rectangle");
autoLabels(i).Position = bbox(labels == label, :);
catch
disp(['Label:' label ' not found. Continuing.') % option indication to user
% you may want/need(?) to put in a dummy vector for the .Position field
% since this doesn't change the indices.
end
end
A different solution could keep a second counter of the found locations and not increment the output struct index if not found. Then the total size would end up less by the number not found. Which would work best would depend on your needs.
Walter Roberson
il y a environ 4 heures
Potentially,
detectedLabels = detectedLabels(~ismissing(detectedLabels));
for i = 1:length(detectedLabels)
label = string(detectedLabels(i));
autoLabels(i).Name = label;
autoLabels(i).Type = labelType("Rectangle");
autoLabels(i).Position = bbox(labels == label, :);
end
We have pre-filtered to get rid of missing entries.
tren
il y a environ 6 heures
dpb
il y a environ 6 heures
I was afeered of that...the error coming from the run method of the autolabeler is way deeper than the shown code where the logical test shouldn't cause a problem or the try...catch block would trap it.
Would need to see the rest of the error message for additional clues, but setting a breakpoint there and seeing what the values of this, frame and info are would probably give us a klew as to what is occurring.
But, failing that much in depth, SAVE and attach a .mat file with the variables bbox and labels
tren
il y a environ 5 heures
Réponses (0)
Catégories
En savoir plus sur Object Detection dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!