Support Vector Machine
In this section, we are going to talk about using Support Vector Machine (Classifier) to classify artistic images.
What is covered in this section:
What is SVM?
It is a supervised learning models for classification.
Intuitively, it tries to maximize the margin, while incurring a penalty when a sample is misclassified or within the margin boundary.
Kernels
In scikit-learn SVC, there are 4 types of kernels as shown below. The non-linear kernels do dot product using the kernel functions.
Generating Features
0 - Original Image
Landscape from the Ore Mountains, 1905, Stanislaw Wyspianski
Image in Artbench-10 (256*256)
1 - Extract Dominant Colors
2 - RGB Histogram
3 - Grayscale Histogram
4 - HSV Histogram
HSV stands for Hue, Saturation, Value, which is another representation of an image. We get 3 additional histograms from HSV images, by resizing to 16*16.
5 - Sharpness Histogram
Take x and y direction gradient.
Resize to 16*16.
6 - Edge Length Histogram
Apply Canny Edge Detector to the image.
Resize to 16*16.
7 - Histogram of Oriented Gradients
Using hog function from scikit-learn. HOG counts occurance of gradients orientation in the localized portion of an image. It contains both angle and magnitude information.
8 - Modules from SqueezeNet
As you may or may not have seen. NST style transformation done by our project uses SqueezeNet. Some modules in SqueezeNet contain important information of images. So, here we computed 4 gram matrices for each image and treat them as features. Since gram matrices are symmetrical, so we only need half of it.
Best Combination
After many trials (almost 15 versions), the best combination of classification so far is to have total feature list length of ~1700, with the following features:
RGB Histogram
Grayscale Histogram
HSV Histogram
Sharpness Histogram
Edge Length Histogram
Histogram of Oriented Gradients
SqueezeNet features
Results
All the results below use SVC with rbf kernel and C=1.
Classifying 10 Categories
Accuracy: 48.36%
Training time: 16 minutes
Classifying 7 Categories
As we can see above, "Expressionism", "Post-Impressionism", and "Realism" are difficult for current SVM to classify. If we remove those hard ones, we have:
Accuracy: 63%
Training time: 9 minutes
Classifying 2 Categories
If we classify only 2 categories at a time, we have pretty high accuracies:
Try Different Combinations of Parameters
As shown below, the best combination among those tests is:
kernel='rbf'
C=1
Page written by: Jichi Wang