jacobgil / pyfishervector

Python implementation for Image Classification based on GMM dictionaries and fisher vectors.
137 stars 56 forks source link

ValueError: zero-dimensional arrays cannot be concatenated #6

Open dangz90 opened 6 years ago

dangz90 commented 6 years ago

Hi,

I'm trying to run the code but I receive the following error:

Traceback (most recent call last):
  File "C:\Users\dangz\Documents\Fotolog\Aesthetic\descriptors\fish.py", line 139, in <module>
    fisher_features = fisher_features(working_folder, gmm)
  File "C:\Users\dangz\Documents\Fotolog\Aesthetic\descriptors\fish.py", line 102, in fisher_features
    features = {f : get_fisher_vectors_from_folder(f, gmm) for f in folders}
  File "C:\Users\dangz\Documents\Fotolog\Aesthetic\descriptors\fish.py", line 102, in <dictcomp>
    features = {f : get_fisher_vectors_from_folder(f, gmm) for f in folders}
  File "C:\Users\dangz\Documents\Fotolog\Aesthetic\descriptors\fish.py", line 97, in get_fisher_vectors_from_folder
    return np.float32([fisher_vector(image_descriptors(file), *gmm) for file in files])
  File "C:\Users\dangz\Documents\Fotolog\Aesthetic\descriptors\fish.py", line 97, in <listcomp>
    return np.float32([fisher_vector(image_descriptors(file), *gmm) for file in files])
  File "C:\Users\dangz\Documents\Fotolog\Aesthetic\descriptors\fish.py", line 74, in fisher_vector
    fv = np.concatenate([np.concatenate(a), np.concatenate(b), np.concatenate(c)])
ValueError: zero-dimensional arrays cannot be concatenated

The error seems to be in line 74: fv = np.concatenate([np.concatenate(a), np.concatenate(b), np.concatenate(c)]) Also, when I check

a = fisher_vector_weights(s0, s1, s2, means, covs, w, T)
b = fisher_vector_means(s0, s1, s2, means, covs, w, T)
c = fisher_vector_sigma(s0, s1, s2, means, covs, w, T)

the means (b) and sigma (c) fisher vectors are all 0s.

YeRen123455 commented 6 years ago

Have you already solve this problem? I meet this problem too。— —!

YeRen123455 commented 6 years ago

@dangz90 I have been stuck in this problem for a week, could you please send the right answer to 15022795536@163.com,if you have solved this problem .Thank you very much.

soominkang commented 6 years ago

Putting square brackets around the a solved the problem for me: fv = np.concatenate([np.concatenate([a]), np.concatenate(b), np.concatenate(c)])

a2322522167 commented 5 years ago

Hi, I also find the same problem as you did. that is,"the means (b) and sigma (c) fisher vectors are all 0s".May I ask you this result is true or false? Did you use this code finally?Thank you very much

soominkang commented 5 years ago

Did this not work for you?

Putting square brackets around the a solved the problem for me: fv = np.concatenate([np.concatenate([a]), np.concatenate(b), np.concatenate(c)])

a2322522167 commented 5 years ago

Actually,this part is ok. But I have another problem. when I print means and sigma , "the means (b) and sigma (c) fisher vectors are all 0s",I dont know whether it means a mistake or not. And, may I ask you whether this code has some requirements of library version?I think this sentence return map(lambda file: np.load(file), map(lambda s: folder + "/", files)) is wrong ,is it? Anyway, I just think the code has some [bug.If you use it successfully, can you send me?Thank you very much! E-mai:2322522167@qq.com