ymdatta / BagOfVisualWords

Image categorization using Bag of visual words approach.
MIT License
4 stars 2 forks source link

ValueError: all the input array dimensions except for the concatenation axis must match exactly #1

Open shabbeersh opened 5 years ago

shabbeersh commented 5 years ago

While running the bag_of_words.py file on CIFAR-100 (made required changes) getting the following error Traceback (most recent call last): File "/media/shabbeer/9256-40F0/disk2/BagOfVisualWords-master/BagOfVisualWords-master/bag_of_words.py", line 36, in (f_vocabulary, i_vocab) = vocabulary_helpers.generate_vocabulary(train_imgs) File "/media/shabbeer/9256-40F0/disk2/BagOfVisualWords-master/BagOfVisualWords-master/vocabulary_helpers.py", line 43, in generate_vocabulary vocab_list = np.vstack((vocab_list, temp_list[ftr])) File "/home/shabbeer/.virtualenvs/detection-2016-nipsws-master/lib/python3.5/site-packages/numpy/core/shape_base.py", line 230, in vstack return _nx.concatenate([atleast_2d(_m) for _m in tup], 0) ValueError: all the input array dimensions except for the concatenation axis must match exactly

shabbeersh commented 5 years ago

It is working perfectly for the given dataset.

ymdatta commented 4 years ago

@shabbeersh : Sorry for the late reply.

Since, it's working fine for the dataset now, i am closing the issue. Feel free to open an issue, if that's not the case.

shabbeersh commented 4 years ago

@ymdatta : The code is working for the images that are available in your repo. It is not working for required (CIFAR-100) dataset. And showing the following error, Traceback (most recent call last): File "/media/shabbeer/9256-40F0/disk2/BagOfVisualWords-master/BagOfVisualWords-master/bag_of_words.py", line 36, in (f_vocabulary, i_vocab) = vocabulary_helpers.generate_vocabulary(train_imgs) File "/media/shabbeer/9256-40F0/disk2/BagOfVisualWords-master/BagOfVisualWords-master/vocabulary_helpers.py", line 43, in generate_vocabulary vocab_list = np.vstack((vocab_list, temp_list[ftr])) File "/home/shabbeer/.virtualenvs/detection-2016-nipsws-master/lib/python3.5/site-packages/numpy/core/shape_base.py", line 230, in vstack return _nx.concatenate([atleast_2d(_m) for _m in tup], 0) ValueError: all the input array dimensions except for the concatenation axis must match exactly

ymdatta commented 4 years ago

Okay.

Look, when using

np.vstack()

we get that ValueError: all the input array.., when the vertical columns are not equal (in general).

For Example:

a = [1, 2, 3] b = [4, 5, 6] c = [7, 8]

np.vstack(a, b) works fine, whereas np.vstack(a, c) gives the Value Error.

So, can you add print(temp_list[ftr]) as well as print(vocab_list.shape), before the line vocab_list = np.vstack((vocab_list, temp_list[ftr])), and can you tell me the output log for this?

(The idea is we are checking if the ValueError is due to the kind of error presented above, if that's not the case, we can eliminate that option and start looking for other reasons)

Thanks.