object-detector icon indicating copy to clipboard operation
object-detector copied to clipboard

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

Open deekshithmr95 opened this issue 7 years ago • 8 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?

deekshithmr95 avatar Jan 05 '18 10:01 deekshithmr95

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

vermouthzjh avatar Feb 01 '18 17:02 vermouthzjh

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 avatar Mar 23 '18 17:03 alwansm

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

DeepInDeeper avatar Jun 29 '18 06:06 DeepInDeeper

The same problem to me

chenqing avatar Nov 19 '18 09:11 chenqing

bump

LazyG avatar Jan 02 '19 02:01 LazyG

Same problem, anyone solve it yet?

HenryJunW avatar Jun 23 '19 21:06 HenryJunW

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?

Tomingz avatar Jun 28 '19 02:06 Tomingz

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?

fistyee avatar Jul 16 '20 04:07 fistyee