Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. test_idx = labels>200;
  2. % prepare train images
  3. images_test = mpfaces(:,:,:,test_idx);
  4. [h,w,c,num_test] = size(images_test);
  5. % prepare test views
  6. views_test = views(:,test_idx);
  7. theta_test = atand(views_test(1,:)./views_test(2,:)); theta_test = theta_test(:);
  8. ids_theta = unique(theta_test);
  9. dim3 = length(ids_theta);
  10. vclasses_test = zeros(dim3,num_test);
  11. for cc = 1:length(ids_theta),
  12. vclasses_test(cc,theta_test==ids_theta(cc)) = 1;
  13. end
  14. % prepare test class index
  15. labels_test = labels(test_idx);
  16. sessions_test = mpslabel(test_idx);
  17. % prepare class index
  18. ind_gallery = zeros(size(labels_test));
  19. for cc = unique(labels_test)',
  20. session_cc = unique(sessions_test(labels_test==cc));
  21. ss = min(session_cc);
  22. ind = (labels_test==cc)&(sessions_test==ss)&(theta_test==0);
  23. ind_gallery = ind_gallery + ind;
  24. end;
  25. ind_gallery = ind_gallery > 0;
  26. ind_probe = (~ind_gallery);
  27. sum(ind_gallery)
  28. feats_test = zeros(512,num_test,'single');
  29. for m = 1:num_test
  30. images = images_test(:,:,:,m);
  31. images = reshape(single(images),[h,w,c,1]);
  32. images = permute(images,[2,1,3,4]);
  33. preds = caffe('forward', { images });
  34. feats_test(:,m) = squeeze(preds{1});
  35. if mod(m,100)==0, fprintf(sprintf('extract %d features\n', m)); end
  36. end
  37. feats_gallery = feats_test(:,ind_gallery);
  38. feats_probe = feats_test(:,ind_probe);
  39. labels_gallery = labels_test(ind_gallery);
  40. labels_probe = labels_test(ind_probe);
  41. theta_gallery = theta_test(ind_gallery);
  42. theta_probe = theta_test(ind_probe);
  43. dist = EuDist2(feats_gallery', feats_probe', 1);
  44. [~,matches] = min(dist,[],1);
  45. labels_pred = labels_gallery(matches);
  46. %%
  47. acc = [];
  48. for t = [0,-15,15,-30,30,-45,45],
  49. labels_pred_sub = labels_pred(theta_probe==t);
  50. labels_probe_sub = labels_probe(theta_probe==t);
  51. acc = [acc; sum(labels_pred_sub==labels_probe_sub)/length(labels_probe_sub)];
  52. end
  53. acc
  54.  
  55. acc =
  56.  
  57. 0.5521
  58. 0.5700
  59. 0.5967
  60. 0.1767
  61. 0.3533
  62. 0.0900
  63. 0.0567
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement