jacobgil / pyfishervector Goto Github PK
View Code? Open in Web Editor NEWPython implementation for Image Classification based on GMM dictionaries and fisher vectors.
Python implementation for Image Classification based on GMM dictionaries and fisher vectors.
When I get the vector, I find some values is ‘Nan’ . What's going on?
I have tried a few hours to solve this problem,but i failed.almost in line 38, the likelihood_statistics function,g = [multivariate_normal(mean=means[k], cov=covs[k]) for k in range(0, len(weights))],i think this is the main problem,but i can't solve it,can you help me?thank you very much.
Hello,
When try to run the code,I meet the error like followings:
('Calculating descriptos. Number of images is', 5)
('Training GMM of size', 5)
(5, 514)
(5,)
Traceback (most recent call last):
File "pyFisherVector.py", line 146, in
classifier = train(gmm, fisher_features)
File "pyFisherVector.py", line 116, in train
clf.fit(X, Y)
File "/usr/local/lib/python2.7/dist-packages/sklearn/svm/base.py", line 150, in fit
y = self._validate_targets(y)
File "/usr/local/lib/python2.7/dist-packages/sklearn/svm/base.py", line 506, in _validate_targets
% len(cls))
ValueError: The number of classes has to be greater than one; got 1
I just put 5 images in a folder,I have printed Y is (0,0,0,0,0).Is it the reason why show the error that the number of classes just got 1?If you know how to solve this problem,could you share with me?Thanks!
I am using the latest version of opencv and several functions have been modified. I adapted the code to work with the current version, however, when function g = [multivariate_normal(mean=means[k], cov=covs[k]) for k in range(0, len(weights)) ]
is applied the following error is returned:numpy.linalg.linalg.LinAlgError: singular matrix
.
I know that some function is returning a singular matrix, which makes it impossible to apply the function multivariate_normal.
What should I do? I'm really needing FisherVector applied to the Bag Of Words, and that was the only implementation I found.
Sorry for the bad english and thanks for the help.
What is 'pdf' in line 38 'gaussians[index] = np.array([g_k.pdf(x) for g_k in g])' ?????
I can't find the function @hendrycks @hugos94 @ @jacobgil
hi, when my program run into
def train(gmm,features):
X = np.concatenate(features.values())
Y = np.concatenate([np.float32([i]*len(v)) for i,v in zip(range(0, len(features)), features.values())])
clf = svm.SVC()
clf.fit(X,Y)
return clf
report the error :
in train
X = np.concatenate(features.values())
TypeError: The first input argument needs to be a sequence
can you help me resolve this? Thanks
def image_descriptors(file):
img = cv2.imread(file, 0)
img = cv2.resize(img, (256, 256))
_ , descriptors = cv2.SIFT().detectAndCompute(img, None)
return descriptors
def folder_descriptors(folder):
files = glob.glob(folder + "/*.jpg")
print("Calculating descriptos. Number of images is", len(files))
return np.concatenate([image_descriptors(file) for file in files])
this error is showing at last line i.e.
return np.concatenate([image_descriptors(file) for file in files])
@jacobgil hi
Sorry for raising this issue.But when I tried to use fisher.py for cluster my images by using this command:
python fisher.py -d ./images
An error occupied.The log is here:
('Calculating descriptos. Number of images is', 0)
Traceback (most recent call last):
File "fisher.py", line 129, in
gmm = load_gmm(working_folder) if args.loadgmm else generate_gmm(working_folder, args.number)
File "fisher.py", line 76, in generate_gmm
words = np.concatenate([folder_descriptors(folder) for folder in glob.glob(input_folder + '/*')])
File "fisher.py", line 26, in folder_descriptors
return np.concatenate([image_descriptors(file) for file in files])
ValueError: need at least one array to concatenate
The "./images" folder just included all the images in it and has no sub folders :
./images
--img1.jpg
--img2.jpg
...
Could you please give some help?
Thank you !
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.