2015年9月10日木曜日

Feature Extraction by CNN and Classification by SVM


Introduction


 In the previous page, I performed the scene recognition using the Convolutional Neural Network (CNN) that the library Caffe provides. In this page, for the same dataset the same CNN is used for extracting feature vectors and the classification is accomplished by means of the Support Vector Machine (SVM) in the library LIBLINEAR. The recognition accuracy reaches about 95% .

Feature Extraction


 The following code is used to extract feature vectors from the CNN and to convert them into the input format that LIBLINEAR requires. The format of training and testing data files for LIBLINEAR is the same as that for LIBSVM: Each line contains a label and a feature vector. I extracted feature vectors from the layer "fc7." Their dimension is 4096. The contents of the file "total_list_15_in_local_machine.txt" described in the above code are as follows: Each line consists of a file path, a label, and a phase ("train"/"valid"/"test"). In this work, two phases "train" and "valid" are merged into one phase "train." After executing the above python code, I got two files "libsvm_train_inputs.txt" and "libsvm_test_inputs.txt" which are input files for LIBLINEAR. The number of training images are 7560 and the number of testing images 1220.

Execution of SVM


 The following command is run to train a SVM. Then, this command is run to predict the categories. The recognition accuracy is about as much as that of the CNN.

2 件のコメント:

  1. Hey,
    what is the use of Total list if we have train.txt and test.txt

    返信削除
    返信
    1. When TOTAL_LIST_PATH is already given,
      TRAIN_FILE_PATH and TEST_FILE_PATH must be made for LIBLINEAR.
      So, if you have TRAIN_FILE_PATH and TEST_FILE_PATH, TOTAL_LIST_PATH is not needed.

      削除