Project1_Pro: Feature extraction and Clustering
1.Task
- Extract features(fc7) from a set of images(cifar10)
- Do clustering and clustering
2.Analysis
I find somebody use conv5 for face clustering, conv5 inherently contain spatial information.
In CNN model, fully connected reps will have a great deal of this spatial information removed but will contain more abstractions.
May be it is a trade-off situation.
3.Solutions
Step1. Download PNG dataset and Processing
- create folder
Data, Examples,bvlc_reference_caffenet
$ ./0.prepare.sh
to Download the cifar10 dataset$ ./1.create_cifar10_imagenet_lmdb.sh
to convert png dataset into lmdb format$ ./2.make_imagenet_mean.sh
to compute the mean file of the dataset$ python 2.binaryproto2npy.py
to convert mean file from binaryproto format into npy format- copy
deploy.prototxt, train_val.prototxt, solver.prototxt, bvlc_reference_caffenet.caffemodel
from caffe-master/model tobvlc_reference_caffenet
$ ./3.train.sh
to finetuning the model from caffenet model on cifar10 dataset$ ./4.test.sh
to get the accuracy from model finetuned,accuracy is: 0.8752
withcaffenet_train_iter_20000.caffemodel
$ python 5.feature_extract.py
to extract fc7 features for every single jpg$ python 6.feature_numpy_combine.py
to combine all features into one single txt file$ python 7.labelListExtract.py
to extract origin label into a list file$ python 8.extractImageNumber.py
to extract filename number into a list file$ python 9.Kmeans_on_fc7.py
to do kmeans on fc7 features and store the result into txt file$ python 10.plotImages.py
to plot the samples of images for each class
Step6. Results and analysis
Data results
99.29% y: 0 (4907L,) {0.0: 12, 1.0: 12, 2.0: 1, 3.0: 2, 6.0: 3, 8.0: 4872, 9.0: 5}
67.43% y: 1 (7368L,) {0.0: 42, 1.0: 147, 2.0: 95, 3.0: 4968, 4.0: 77, 5.0: 410, 6.0: 171, 7.0: 1358, 8.0: 59, 9.0: 41}
99.94% y: 2 (4748L,) {1.0: 4745, 9.0: 3}
99.33% y: 3 (4812L,) {1.0: 4, 2.0: 13, 3.0: 2, 4.0: 11, 5.0: 2, 6.0: 4780}
99.46% y: 4 (3512L,) {4.0: 3, 5.0: 16, 7.0: 3493}
96.46% y: 5 (5083L,) {0.0: 1, 2.0: 22, 3.0: 3, 4.0: 4903, 5.0: 27, 6.0: 13, 7.0: 110, 8.0: 2, 9.0: 2}
98.12% y: 6 (4901L,) {0.0: 11, 1.0: 6, 2.0: 4818, 3.0: 8, 4.0: 5, 5.0: 6, 6.0: 28, 7.0: 9, 8.0: 5, 9.0: 5}
96.63% y: 7 (5013L,) {0.0: 1, 1.0: 65, 5.0: 1, 7.0: 1, 8.0: 14, 9.0: 4931}
97.05% y: 8 (5083L,) {0.0: 4933, 1.0: 18, 2.0: 41, 3.0: 2, 4.0: 1, 6.0: 1, 7.0: 28, 8.0: 48, 9.0: 11}
99.23% y: 9 (4573L,) {1.0: 3, 2.0: 10, 3.0: 15, 5.0: 4538, 6.0: 4, 7.0: 1, 9.0: 2}
average accuracy is: 95.254%
Select 20 images randomly of each class classified by Kmeans