bikz05 / object-detector

Object Detection Framework using HOG as descriptor and Linear SVM as classifier.
MIT License
430 stars 221 forks source link

Unable to pass parameters to clf.train() method #2

Closed PavanRGowda closed 8 years ago

PavanRGowda commented 9 years ago

Everything's working fine but I'm unable to debug the below error from past a week. Problem is with clf.tain() method which expects a single dimensional column vector but what we are passing is an array of arrays i.e. fds in your code. Can you please help me in overcoming this issue. I'm very disappointed from past one week.

Positive features saved in ../data/features/pos Calculating the descriptors for the negative samples and saving them Negative features saved in ../data/features/neg Completed calculating features from training images Training a Linear SVM Classifier Traceback (most recent call last): File "../object-detector/train-classifier.py", line 52, in clf.train(fds,labels) TypeError: trainData data type = 17 is not supported Traceback (most recent call last): File "../object-detector/test-classifier.py", line 68, in fd = hog(im_window, orientations, pixels_per_cell, cells_per_block, visualize, normalize) File "/usr/lib/python2.7/dist-packages/skimage/feature/_hog.py", line 63, in hog raise ValueError("Currently only supports grey-level images") ValueError: Currently only supports grey-level images

If I print out the contents of fds and labels, below is what I get -

[ array([ 2.47301895e-02, 0.00000000e+00, 0.00000000e+00, ..., 2.10207273e-17, 1.68165818e-17, 0.00000000e+00]) array([ 2.22566842e-03, 5.06294401e-04, 2.59973865e-04, ..., 8.12927905e-05, 5.35716830e-05, 4.41070061e-04])] [1 0]

As you can see fds is an array of arrays

hoangtuan21193 commented 9 years ago

hi, did u solved that issue? I have a bug related to that array too. Hope u can help :)

File "../object-detector/train-classifier.py", line 44, in clf.fit(fds, labels) File "/usr/lib/python2.7/dist-packages/sklearn/svm/base.py", line 668, in fit X = atleast2d_or_csr(X, dtype=np.float64, order="C") File "/usr/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 134, in atleast2d_or_csr "tocsr", force_all_finite) File "/usr/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 111, in _atleast2d_or_sparse force_all_finite=force_all_finite) File "/usr/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 91, in array2d X_2d = np.asarray(np.atleast_2d(X), dtype=dtype, order=order) File "/usr/lib/python2.7/dist-packages/numpy/core/numeric.py", line 460, in asarray return array(a, dtype, copy=False, order=order) ValueError: setting an array element with a sequence.