Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a python code. Please modify it using my code. I want to make a test image by selecting 50 of the following eigenfaces with

Write a python code. Please modify it using my code.

I want to make a test image by selecting 50 of the following eigenfaces with large eigenvalue.

Apply SVD to the covariance matrix

And collect 10 different cropped face images.

Represent each face images using the eigenfaces

Compare the coefficients {c1,c2,...,cn} for face recognition.

Find the Coeffiencts

- inner product of eigenface vector and test face image vector.(eigenfaces -> orthonormal)

Generate face image using eigenfaces.

linear combination of eigenface vectors adding the mean vector.

image text in transcribedimage text in transcribedimage text in transcribed

image text in transcribedimage text in transcribed

13 4. Test face recognition Collect 10 different cropped face images > 5 test images for one face Represent each face images using the eigenfaces Compare the coefficients {C1, C2, "., Cn} for face recognition - M=C te2 +C3 ...ten Mean vector of collected face images 0000, 14 Find the Coefficients inner product of eigenface vector and test face image vector Eigenfaces => orthonormal - M=C1 +c2 +C3 ...te Ck = -M 00000 (inner product of e, and test face image vector) 15 Generate face image using eigenfaces linear combination of eigenface vectors adding the mean vector T 2C1 +0 |t0 ...ten +M In [66]; import numpy as np import matplot lib.pyplot as plt from PIL import Image %matplot lib inline In [67]: f94 = ['9332898' '9338446', '9338497', '9338519', '9414649' '9416994', 'ajflem', 'ajsega', 'anonym', 'anonyml', 'anpage', 'asamma', 'asheal', 'astefa', 'cchris', 'cgboyc', 'cicarr', 'cj sake'. cmkirk', 'cshubb', dakram', dcbowe', 'drbost', 'ekavaz', 'gj hero', 'gmwate', 'gsreas', 'jabins', 'irtobi', 'klclar', Tejnno' 'martin', 'mberdo', 'mdpove', 'mefait', 'michael', 'mjhans' 'namull, 'ndhagu', 'njmoor, 'npmitc' 'nrclar', 'obeidn', 'phughe', 'ptnich', 'rgspru', 'rilabr', 'ropwil', 'robin', 'rrowle', 'rsanti', 'saedwa', 'sandm', 'sidick', 'sj beck', 'sbirc', 'spletc', 'svkriz', 'tony', 'voudcx'] In [71]: base = [1 mage.open( f'C:/faces94(1)/{p}/{p}, {i}.jpg').convert('L') for i in range(1,21) for p in f94] M = len(base) X = np.array([base[i].get data() for i in range(M)]) print (X[0:50] ) mean = np.mean(X, 0) phi = X mean [[164 165 168 .. [187 188 189 (172 172 172 ... 9 & 7 79 87 92] 94 94 94 [ 75 75 75 57 57 57] [ 70 71 71 223 217 213] [ 99 101 102 ... 153 143 147]] In [72] : e_faces, sigma, v = np. linalg.svd(phi . transpose(), full_matrices=False) weights = [np.dot (X[i]-mean, e_faces) for i in range(M)] np. shape(weights) Out [72] : (1200, 1200) In [74]: K - 50 recon = mean + np. dot (weights[X, 0:50), e_faces[:, 0:50].1) TypeError Traceback (most recent call last) in 1 k = 50 ----> 2 recon = mean + np. dot (weights[X, 0:50], e_faces. I) 3 TypeError: list indices must be integers or slices, not tuple 13 4. Test face recognition Collect 10 different cropped face images > 5 test images for one face Represent each face images using the eigenfaces Compare the coefficients {C1, C2, "., Cn} for face recognition - M=C te2 +C3 ...ten Mean vector of collected face images 0000, 14 Find the Coefficients inner product of eigenface vector and test face image vector Eigenfaces => orthonormal - M=C1 +c2 +C3 ...te Ck = -M 00000 (inner product of e, and test face image vector) 15 Generate face image using eigenfaces linear combination of eigenface vectors adding the mean vector T 2C1 +0 |t0 ...ten +M In [66]; import numpy as np import matplot lib.pyplot as plt from PIL import Image %matplot lib inline In [67]: f94 = ['9332898' '9338446', '9338497', '9338519', '9414649' '9416994', 'ajflem', 'ajsega', 'anonym', 'anonyml', 'anpage', 'asamma', 'asheal', 'astefa', 'cchris', 'cgboyc', 'cicarr', 'cj sake'. cmkirk', 'cshubb', dakram', dcbowe', 'drbost', 'ekavaz', 'gj hero', 'gmwate', 'gsreas', 'jabins', 'irtobi', 'klclar', Tejnno' 'martin', 'mberdo', 'mdpove', 'mefait', 'michael', 'mjhans' 'namull, 'ndhagu', 'njmoor, 'npmitc' 'nrclar', 'obeidn', 'phughe', 'ptnich', 'rgspru', 'rilabr', 'ropwil', 'robin', 'rrowle', 'rsanti', 'saedwa', 'sandm', 'sidick', 'sj beck', 'sbirc', 'spletc', 'svkriz', 'tony', 'voudcx'] In [71]: base = [1 mage.open( f'C:/faces94(1)/{p}/{p}, {i}.jpg').convert('L') for i in range(1,21) for p in f94] M = len(base) X = np.array([base[i].get data() for i in range(M)]) print (X[0:50] ) mean = np.mean(X, 0) phi = X mean [[164 165 168 .. [187 188 189 (172 172 172 ... 9 & 7 79 87 92] 94 94 94 [ 75 75 75 57 57 57] [ 70 71 71 223 217 213] [ 99 101 102 ... 153 143 147]] In [72] : e_faces, sigma, v = np. linalg.svd(phi . transpose(), full_matrices=False) weights = [np.dot (X[i]-mean, e_faces) for i in range(M)] np. shape(weights) Out [72] : (1200, 1200) In [74]: K - 50 recon = mean + np. dot (weights[X, 0:50), e_faces[:, 0:50].1) TypeError Traceback (most recent call last) in 1 k = 50 ----> 2 recon = mean + np. dot (weights[X, 0:50], e_faces. I) 3 TypeError: list indices must be integers or slices, not tuple

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

Students also viewed these Databases questions

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

State the importance of control

Answered: 1 week ago