samedi 19 avril 2014

Using scikit-learn to classify images based on hog features


Vote count:

0




I need to use boosted cascaded training to classify some images in scikit-learn. I want to classify according to HoG features.


I'm reading in each sample image, and for each image where curr_img is the image of the current iteration, I get the hog features like this:



fd, hog_image = hog(curr_img, orientations=8, pixels_per_cell=(16, 16),
cells_per_block=(1, 1), visualise=True, normalise=True)
tmp_hogs.append(fd)
img_hogs = np.array(tmp_hogs, dtype =float)


Somewhere above, I've already declared the 1D array of labels to give the class labels for each sample.


I then split the data into training and testing sets, like this:


n_split = 508 X_train, X_test = np.array(img_hogs[:n_split]), np.array(img_hogs[n_split:]) y_train, y_test = np.array(labels[:n_split]), np.array(labels[n_split:])


I then declare bdt_real as an AdaBoostClassifier, and fit it with the above data like this:


bdt_real.fit(X_train, y_train)


And then I go ahead and try to classify. My question is, is this the right way to classify images according to HoG features? My images (at the moment) are 240x360, and there are 528 in all.


So when I print the shape of img_hogs, I get:



(528L, 2640L)


I was told the classification is terminating early because there are many more features than images. Is this because my images are so big? I'm guessing that reducing the size of my images should help, but what's the calculation to generated 2640 features? It can't be 240x360, then what is it?


And what's a better way to get fewer features?



asked 53 secs ago






Aucun commentaire:

Enregistrer un commentaire