コード例 #1
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
	def compute(self, X, y):
		[D, self.W, self.mu] = fisherfaces(asRowMatrix(X),y, self.num_components)
		# store labels
		self.y = y
		# store projections
		for xi in X:
			self.projections.append(project(self.W, xi.reshape(1,-1), self.mu))
コード例 #2
0
 def compute(self, X, y):
     [D, self.W, self.mu] = pca(asRowMatrix(X), y, self.num_components)
     # store labels
     self.y = y
     # store projections
     for xi in X:
         self.projections.append(project(self.W, xi.reshape(1, -1),
                                         self.mu))
コード例 #3
0
def reconstruct (W , Y , mu = None ) :
if mu is None :
return np . dot (Y ,W.T)
return np . dot (Y , W .T) + mu



# read images
[X , y] = read_images ('D:\homework and assignments\computer vision\face and gender recognition\images')
# perform a full pca
[D , W , mu ] = pca ( asRowMatrix (X ) , y)
コード例 #4
0
# import tinyfacerec modules
from tinyfacerec.subspace import pca
from tinyfacerec.util import normalize, asRowMatrix, read_images
from tinyfacerec.visual import subplot

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print "USAGE: example_eigenfaces.py </path/to/images>"
        sys.exit()

    # read images
    [X, y] = read_images(sys.argv[1])

    # perform a full pca
    [D, W, mu] = pca(asRowMatrix(X), y)

    import matplotlib.cm as cm

    # turn the first (at most) 16 eigenvectors into grayscale
    # images (note: eigenvectors are stored by column!)
    E = []
    for i in xrange(min(len(X), 16)):
        e = W[:, i].reshape(X[0].shape)
        E.append(normalize(e, 0, 255))
    # plot them and store the plot to "python_eigenfaces.pdf"
    subplot(title="Eigenfaces AT&T Facedatabase",
            images=E,
            rows=4,
            cols=4,
            sptitle="Eigenface",
コード例 #5
0
import sys
# append tinyfacerec to module search path
sys.path.append("..")
# import numpy and matplotlib colormaps
import numpy as np
# import tinyfacerec modules
from tinyfacerec.subspace import pca
from tinyfacerec.util import normalize, asRowMatrix, read_images
from tinyfacerec.visual import subplot

# read images
[X,y] = read_images('att_faces')
# perform a full pca
[D, W, mu] = pca(asRowMatrix(X[1:]), y)

import matplotlib.cm as cm

# turn the first (at most) 16 eigenvectors into grayscale
# images (note: eigenvectors are stored by column!)
E = []
for i in range(min(len(X), 16)):
	e = W[:,i].reshape(X[0].shape)
	E.append(normalize(e,0,255))
# plot them and store the plot to "python_eigenfaces.pdf"
subplot(title="Eigenfaces AT&T Facedatabase", images=E, rows=4, cols=4, sptitle="Eigenface", colormap=cm.gray, filename="python_pca_eigenfaces.pdf")

from tinyfacerec.subspace import project, reconstruct

# reconstruction steps
steps=[i for i in range(10, min(len(X), 400), 20)]
E = []
コード例 #6
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
# import tinyfacerec modules
from tinyfacerec.subspace import pca
from tinyfacerec.util import normalize, asRowMatrix, read_images
from tinyfacerec.visual import subplot

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print "USAGE: example_eigenfaces.py </path/to/images>"
        sys.exit()
    
    # read images
    [X,y] = read_images(sys.argv[1])

    # perform a full pca
    [D, W, mu] = pca(asRowMatrix(X), y)

    import matplotlib.cm as cm

    # turn the first (at most) 16 eigenvectors into grayscale
    # images (note: eigenvectors are stored by column!)
    E = []
    for i in xrange(min(len(X), 16)):
	    e = W[:,i].reshape(X[0].shape)
	    E.append(normalize(e,0,255))
    # plot them and store the plot to "python_eigenfaces.pdf"
    subplot(title="Eigenfaces AT&T Facedatabase", images=E, rows=4, cols=4, sptitle="Eigenface", colormap=cm.jet, filename="python_pca_eigenfaces.png")

    from tinyfacerec.subspace import project, reconstruct

    # reconstruction steps
コード例 #7
0
# import tinyfacerec modules
from tinyfacerec.subspace import pca
from tinyfacerec.util import normalize, asRowMatrix, read_images
from tinyfacerec.visual import subplot

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print "USAGE: example_eigenfaces.py </path/to/images>"
        sys.exit()
    
    # read images
    [X,y] = read_images(sys.argv[1])

    # perform a full pca
    [D, W, mu] = pca(asRowMatrix(X), y)

    import matplotlib.cm as cm

    # turn the first (at most) 16 eigenvectors into grayscale
    # images (note: eigenvectors are stored by column!)
    E = []
    for i in xrange(min(len(X), 16)):
	    e = W[:,i].reshape(X[0].shape)
	    E.append(normalize(e,0,255))
    # plot them and store the plot to "python_eigenfaces.pdf"
    subplot(title="Eigenfaces AT&T Facedatabase", images=E, rows=4, cols=4, sptitle="Eigenface", colormap=cm.jet, filename="python_pca_eigenfaces.png")

    from tinyfacerec.subspace import project, reconstruct

    # reconstruction steps
コード例 #8
0
ファイル: example_fisherfaces.py プロジェクト: oloa/Tinder-ML
import numpy as np
# import tinyfacerec modules
from tinyfacerec.subspace import fisherfaces
from tinyfacerec.util import normalize, asRowMatrix, read_images
from tinyfacerec.visual import subplot

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print "USAGE: example_fisherfaces.py </path/to/images>"
        sys.exit()

    # read images
    [X, y] = read_images(sys.argv[1])
    # perform a full pca
    [D, W, mu] = fisherfaces(asRowMatrix(X), y)
    #import colormaps
    import matplotlib.cm as cm
    # turn the first (at most) 16 eigenvectors into grayscale
    # images (note: eigenvectors are stored by column!)
    E = []
    for i in xrange(min(W.shape[1], 16)):
        e = W[:, i].reshape(X[0].shape)
        E.append(normalize(e, 0, 255))
    # plot them and store the plot to "python_fisherfaces_fisherfaces.pdf"
    subplot(title="Fisherfaces AT&T Facedatabase",
            images=E,
            rows=4,
            cols=4,
            sptitle="Fisherface",
            colormap=cm.jet,