kushalvyas / Bag-of-Visual-Words-Python

Implementing Bag of Visual words approach for object classification and detection
https://kushalvyas.github.io/BOV.html
MIT License
126 stars 68 forks source link

IndexError: list index out of range #15

Closed masonreznov closed 6 years ago

masonreznov commented 6 years ago
Traceback (most recent call last):
  File "Bag.py", line 160, in <module>
    bov.trainModel()
  File "Bag.py", line 50, in trainModel
    bov_descriptor_stack = self.bov_helper.formatND(self.descriptor_list)
  File "C:\Users\birdman\OneDrive\Project\MY STUFFS\bag of visual word\Bag-of-Visual-Words-Python-master\Bag-of-Visual-Words-Python-master\helpers.py", line 85, in formatND
    vStack = np.array(l[0])
IndexError: list index out of range
masonreznov commented 6 years ago

Covert "vocab" into 2d array. Instead of "self.bov_helper.scale.transform(vocab)" try "self.bov_helper.scale.transform(np.atleast_2d(vocab)) ". Also "import numpy as np" before this step.

this helped

nys09 commented 5 years ago

I have the same error. But I am unable to solve it by following your suggestion. I replaced line 89 in Bag.py to vocab = self.bov_helper.scale.transform(np.atleast_2d(vocab)) as directed by you. I am still getting the same error. Can you please help me with this ?

prathmanu commented 5 years ago

Same issue here (using Python 3.5.4).. Tried the suggestion by @masonreznov but still giving the same error

prathmanu commented 5 years ago

I have the same error. But I am unable to solve it by following your suggestion. I replaced line 89 in Bag.py to vocab = self.bov_helper.scale.transform(np.atleast_2d(vocab)) as directed by you. I am still getting the same error. Can you please help me with this ?

change Line 140 from word = each.split("/")[-1] to ' \ ' (Slash )

nguyenquyet27 commented 5 years ago

After I change Line 140 from word = each.split("/")[-1] to ' \ ' and convert self.bov_helper.scale.transform(np.atleast_2d(vocab)) I still not out of error

prathmanu commented 5 years ago

After I change Line 140 from word = each.split("/")[-1] to ' \ ' and convert self.bov_helper.scale.transform(np.atleast_2d(vocab)) I still not out of error

try self.bov_helper.scale.transform(vocab) (don’t use np.atleast_2d) , change Line 140 from word = each.split("/")[-1] to ' \ ' If still the same error ,debug getFiles method(Line 129) in helper.py

nepoleonk commented 4 years ago

I have tried all the methods given above. I am still having the problem. Please explain in detail. Thank you in advance