Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import numpy as np import matplotlib.pyplot as plt from PIL import Image import cv2 %matplotlib inline images = ['9332898', '9338446', '9338497', '9338519', '9414649', '9416994', 'ajflem',

import numpy as np import matplotlib.pyplot as plt from PIL import Image import cv2 %matplotlib inline

images = ['9332898', '9338446', '9338497', '9338519', '9414649', '9416994', 'ajflem', 'ajsega', 'anonym', 'anonym1', 'anpage', 'asamma', 'asheal', 'astefa', 'cchris', 'cgboyc', 'cjcarr', 'cjsake', 'cmkirk', 'cshubb', 'dakram', 'dcbowe', 'drbost', 'ekavaz', 'gjhero', 'gmwate', 'gsreas', 'jabins', 'jrtobi', 'klclar', 'lejnno', 'martin', 'mberdo', 'mdpove', 'mefait', 'michael', 'mjhans', 'namull', 'ndhagu', 'njmoor', 'npmitc', 'nrclar', 'obeidn', 'phughe', 'ptnich', 'rgspru', 'rjlabr', 'rnpwil', 'robin', 'rrowle', 'rsanti', 'saedwa', 'sandm', 'sidick', 'sjbeck', 'slbirc', 'spletc', 'svkriz', 'tony', 'voudcx']

base = [Image.open(f'C:/face images/{p}/{p}.{i}.jpg').convert('L') for i in range(1,21) for p in images]

F = np.array([base[i].getdata() for i in range(M)])

mean = np.mean(F, 0)

A = F - mean

--------------------------------

Write down the code that represents the mean face image and the code that reconstructs the face.

I got a dataset and a code from this page, but it's not working.

https://wellecks.wordpress.com/tag/eigenfaces/

https://share.cocalc.com/share/4af510406b461ba71cce183927d6725652a63341/eigenfaces.ipynb?viewer=share

image text in transcribed

image text in transcribed

# weights is an n xn matrix weights = numpy.dot (ma_data, e_faces) For each image, we have a weight for each of the n eigenfaces, so weights is an n x n matrix. To reconstruct a face, we dot the face's weights (a row in the weights matrix) with the transpose of the eigenfaces (n xp matrix), and add the mean face back in: # reconstruct the face located at img_idx recon = mu + numpy.dot(weights[img_idx, :], e_faces.T) recon = mean + np. dot (weights[F, :], eigenfaces. T) TypeError Traceback (most recent call last) in -> 1 recon = mean + np. dot (weights[F, :], eigenfaces. I) 2 TypeError: list indices must be integers or slices, not tuple # weights is an n xn matrix weights = numpy.dot (ma_data, e_faces) For each image, we have a weight for each of the n eigenfaces, so weights is an n x n matrix. To reconstruct a face, we dot the face's weights (a row in the weights matrix) with the transpose of the eigenfaces (n xp matrix), and add the mean face back in: # reconstruct the face located at img_idx recon = mu + numpy.dot(weights[img_idx, :], e_faces.T) recon = mean + np. dot (weights[F, :], eigenfaces. T) TypeError Traceback (most recent call last) in -> 1 recon = mean + np. dot (weights[F, :], eigenfaces. I) 2 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

More Books

Students also viewed these Databases questions

Question

305 mg of C6H12O6 in 55.2 mL of solution whats the molarity

Answered: 1 week ago

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago

Question

=+1 What are the major issues related to international T&D?

Answered: 1 week ago