人脸识别-闭集测试指标CMC曲线

做FaceIdentification时候,需要用到CMC曲线,横坐标为rank,纵坐标是faceIdentification Rate。

在绘制CMC曲线之前,做好rowNames,colNames,simMatrix三个矩阵的准备,分别为m个样本的标签ID,n个注册集中ID(无重复有序),分数矩阵simMatrix是m*n的。每行代表一个样本的得分。

simMatrix(i,j)表示第i个样本在第j个标签ID的得分,分越大就越相似。分数一般在[0,1]之间。

%% 行代表样本ID,列代表注册的人脸ID(每个唯一)
rowNames = string(Labels); % m*1的
colNames = string(uniqueLabel'); % 1*n的
simMatrix = scoreMatrix; % m*n的
 
[orderMatrix,index] = sort(simMatrix,2,'descend');

%% plot CMC 曲线
nums = size(orderMatrix,1);
rankN = 20;
accuracy = zeros(1,rankN);
for i = 1:rankN % 计算rank1到rankN
    correctNumber = 0;
    for j = 1:nums
        currentColNamesIndex = index(j,1:i);
        isIn = ismember(rowNames(j),colNames(currentColNamesIndex));
        if isIn
            correctNumber = correctNumber+1;
        end
    end
    accuracy(i) = correctNumber/nums;
end
figure;
hold on;
plot(1:i,accuracy,'r-')
grid on
xlabel('rank');
ylabel('faceIdentification Rate')
title('CMC曲线')


上述代码实现原理点这里


猜你喜欢

转载自blog.csdn.net/cuixing001/article/details/78621094