bikz05 / object-detector

Object Detection Framework using HOG as descriptor and Linear SVM as classifier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: Expected 2D array, got 1D array instead:

deekshithmr95 opened this issue · comments

I'm running test-object-detector.py on Windows 10 64bit with python 3.6.3
(added print statement's missing parenthesis)

python successfully downloaded and extracted 'UIUC Image Database for Car Detection'
but i'm getting error here

ValueError: Expected 2D array, got 1D array instead:
array=[].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Traceback (most recent call last):

how to resolve this issue?

In test-classifier.py, before pred = clf.predict(fd), add fd = [fd].

commented

hello @vermouthzjh I tried your method now i am getting :
Traceback (most recent call last): File "test-classifier.py", line 72, in <module> pred = clf.predict(fds) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\sklearn\linear_model\base.py", line 324, in predict scores = self.decision_function(X) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\sklearn\linear_model\base.py", line 305, in decision_function % (X.shape[1], n_features)) ValueError: X has 10206 features per sample; expecting 35721

@alwansm Hi, I met the same problems.Have u solved it?

The same problem to me

commented

bump

Same problem, anyone solve it yet?

fd=fd.reshape(1,-1)
pred=clf.predict(fd)
It works.
but I have another error:ValueError: X has 22032 features per sample; expecting 38916,how to fix it?

fd=fd.reshape(1,-1)
pred=clf.predict(fd)
It works.
but I have another error:ValueError: X has 22032 features per sample; expecting 38916,how to fix it?

Same problem,, Do you solved this?