forked from willard-yuan/CNN-for-Face-Image-Retrieval
-
Notifications
You must be signed in to change notification settings - Fork 1
/
extractCNN_VGG_Face.m
39 lines (30 loc) · 873 Bytes
/
extractCNN_VGG_Face.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
% Author: Yong Yuan
% Homepage: yongyuan.name
clear all;close all;clc;
% version: matconvnet-1.0-beta17
%run ./matconvnet-1.0-beta17/matlab/vl_compilenn
run ./matconvnet-1.0-beta17/matlab/vl_setupnn
%% Step 1 lOADING PATHS
path_imgDB = './facesDataset/';
addpath(path_imgDB);
addpath tools;
% viesion: matconvnet-1.0-beta17
net = load('vgg-face.mat') ;
%% Step 2 LOADING IMAGE AND EXTRACTING FEATURE
imgFiles = dir(path_imgDB);
imgNamList = {imgFiles(~[imgFiles.isdir]).name};
clear imgFiles;
imgNamList = imgNamList';
numImg = length(imgNamList);
feat = [];
rgbImgList = {};
%parpool;
%parfor i = 1:numImg
for i = 1:numImg
oriImg = imread(imgNamList{i, 1});
featVec = extractCNN(oriImg, net);
feat = [feat; featVec'];
fprintf('extract %d image\n\n', i);
end
feat_norm = normalize1(feat);
save('feat4096Norml.mat','feat_norm', 'imgNamList', '-v7.3');