【问题标题】:How to calculate confusion matrix for object detection/recognition?如何计算物体检测/识别的混淆矩阵?
【发布时间】:2019-12-05 18:23:41
【问题描述】:

我已经解决了总共 32 个类别的一个图像识别问题。我得到了结果并计算了它的平均精度。我需要绘制混淆矩阵。

【问题讨论】:

    标签: matlab plot image-recognition confusion-matrix


    【解决方案1】:

    我正在研究 YOLOv2,并为检测网络创建了一个混淆矩阵。希望这会有所帮助:)

    testObjects 是真实标签,predLabels 是预测标签
    TestData 是 imdsTest 的 imageDatastore()

    testObjects = testData.UnderlyingDatastores{1, 1}.Files  ; %'C:\Users\admin\Desktop\Img_Data\Flower1\Flower101.jpg'
    testObjects = erase(testObjects,fullfile(pwd,imgFolderName)); %'\Flower1\Flower101.jpg'
    testObjects = categorical(extractBetween(testObjects, "\","\")); % Flower1 - array
    
    predLabels = zeros(2,1);  
    predLabels = categorical(predLabels); % Prelocation
    for iPred = 1:length(testObjects)  
        [~, idxx] = max(cell2mat(detectionResults.Scores(iPred))); % max of all the bounding box scores
        multiLabels = detectionResults.Labels{iPred,1};  % find label of max score
        if isempty(multiLabels) == 1  
            predLabels(iPred,1) = {'NaN'};  
            predLabels(iPred,1) = standardizeMissing(predLabels(iPred,1),{'NaN'});  
        else  
           predLabels(iPred,1) = (multiLabels(idxx,1));  
        end  
    end  
    predLabels = removecats(predLabels);
    
    plotconfusion (testObjects,predLabels) %confusionchart(testAsts,predLabels)
    

    【讨论】:

      猜你喜欢
      • 2017-02-25
      • 2018-04-01
      • 1970-01-01
      • 2013-07-08
      • 2013-12-15
      • 2020-03-23
      • 2018-11-09
      • 1970-01-01
      相关资源
      最近更新 更多