Question
Solution Preview
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.
# First, we need to import all packages that we will use in this program# linear algebra
import numpy as np
# data processing,
from sklearn.preprocessing import StandardScaler, LabelEncoder
#Visualization
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from PIL import Image
from skimage.transform import resize
# Neural Network
import tensorflow as tf
from tensorflow import keras
#Machine Learning
from sklearn.model_selection import train_test_split
from sklearn import metrics
from sklearn.metrics import accuracy_score, precision_score
#System
import os
faces = [] # We create two empty lists to store faces and names we want to classify
names = []
# now let's find out how many unique faces we need to classify
unique_names = os.listdir('./faces/')
# let's store all faces and corresponding names in our list: faces and names
images = 10 # for each person we have 10 different pictures
for name in unique_names: # iterate over all unique names
for i in range(images): # iterate over all images for a certain name
#read the image
s = mpimg.imread('./faces/{0}/{1}.png'.format(name, name + '_' + str(i)))
# resize it, so you can use your own data set if you want
s = resize(s, (64,64), mode='constant')...
By purchasing this solution you'll be able to access the following files:
Solution.zip.