kushalvyas/Bag-of-Visual-Words-Python

IndexError: list index out of range

masonreznov opened this issue · 7 comments

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

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

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 ?

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

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 )

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

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

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