Professional Documents
Culture Documents
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND COMMUNICATION ENGINEERING
Submitted by
CERTIFICATE
This is to certify that the Major project report entitled “Age Estimation from Facial
Images” being submitted by A. BHAVANA (17071A0466), G. SHARANYA (17071A0477),
J. PRASHANTH (17071A0484), K. JANAKI (18075A0417) in partial fulfilment of the
degree of Bachelor of Technology in Electronics and Communication Engineering during
the academic year 2017 – 2021.
Certified further, to the best of our knowledge, the work reported here is not a part
of any other project based on which a degree or an award has been given on an earlier
occasion to any other candidate. The result has been verified and found to be satisfactory.
Table of Contents
1 INTRODUCTION 5
1.1 OVERVIEW OF THE PROJECT …………………………………........5
1.2 OBJECTIVE……………………………………………………………..6
1.3 MOTIVATION…………………………………………………………..6
1.4 TOOLS USED……………………………………………………………7
2 CONVOLUTIONAL NEURAL NETWORK 9
2.1 INTRODUCTION……………………………………………………….9
2.2 STRUCTURE OF CNN………………………………………………....10
2.2.1 CONVOLUTIONAL LAYER………….…………………......10
2.2.2 POOLING LAYER…………………………………………...12
2.2.3 ACTIVATION FUNCTION……………………………….....13
2.2.4 LOSS LAYER………………………………………………..18
2.3 SUMMARY…………………………………………………………….19
3 HAAR CASCADE FRONTAL FACE 21
3.1 INTRODUCTION …………………………………………………….....21
3.2 FEATURES ……………………………………………………………...22
3.3 INTEGRAL IMAGE ………………………………………………….....24
3.4 ATTENTIONAL CASCADE ……………………………………………24
3.5 SUMMARY………………………………………………………………26
4 METHODOLOGY 27
4.1 BLOCK DIAGRAM ……………………………………………………..27
4.2 IMAGE CAPTURE USING OPENCV…………………………………..28
4.3 FACE DETECTION………………………………………………………..29
4.4 MODEL…………………………………………………………………….30
4.4.1 PRE-PROCESSING……………………………………………..30
4.4.2 MODEL DEFINITION………………………………………….32
4.4.2.1 REGRESSION ACCURACY METRICS…………………..32
4.4.3 MODEL TRAINING…………………………………………….33
4.5 PREDICTION………………………………………………………………35
CHAPTER 1
1.2 OBJECTIVE
1.3 MOTIVATION
It is a valuable technique: –
CHAPTER 2
BACKGROUND ON CONVOLUTIONAL NEURAL NETWORK
2.1 INRODUCTION
Sigmoid Function :
The sigmoid function is defined as :
1
sigm ( x ) =
1+e− x
immersion. For instance, if the underlying loads are too huge, most
neurons would be immersed, and the organization nearly has no
learning capacity.
Tanh Function:
The tanh function is defined as
1−e−2 x
tanh( x)¿
1+ e−2 x
Comparable with sigmoid capacity, tanh work squashes a
genuine esteemed number to a scope of [-1; 1] in a non-linearity way.
In spite of the fact that its yield is zero-focused, which stays away from
the crisscrossing elements in the load's refreshing cycle, it has an
immersed enactment issue. Along these lines, albeit the tanh work has
improvement over sigmoid capacity, it performs not well .
There are two primary benefits of ReLU work. In the first place,
contrasted and sigmoid capacity and tanh work that include convoluted
tasks, for example exponentials, ReLU can be executed by essentially
setting a limit at nothing. In this way, CNN with ReLU trains a few
times quicker than their counterparts with tanh work and sigmoid
capacity[5]. Second, ReLU does not experience the ill effects of
soaking which
improves the CNN's benefit that need not bother with bunches of pre-
preparing.
In any case, there is likewise a disadvantage for ReLU work, for
example ReLU units can bite the dust during preparing. For instance,
ReLU can irreversibly pass on and do not initiate any information point
during preparing since it will get knocked off the information complex
Department of ECE, VNRVJIET
AGE ESTIMATION FROM FACIAL IMAGES
if the learning rate is set excessively high. In any case, this is less
habitually an issue with a legitimate setting of the learning rate.
Where d^i means the relapsed yields, di indicates the objective yields, N
signifies the quantity of yields.
SoftMax Loss:
Softmax loss is utilized for anticipating a solitary class of K
fundamentally unrelated classes and yields a chance vector with size
1xk, where all components in the vector sums to be one.
The functional representation is as follows
L=−∑ y j log p j
j
where yj is the ground truth class, when the objective has a place with j-
th class, yj = 1,otherwise, yj = 0, pj indicates the anticipated chance of
information has a place with j-th class. At the point when yield the
anticipated chance vector.
eO j
p j=
∑ eO k
2.3 SUMMARY
The cornerstone of CNN, which is a self-learning structure, was
presented in this section. This capacity grows as the organization's
nonlinearity grows, which can be achieved by increasing the number of
layers in the organization. As a result, one CNN research project is to
increase the number of organization layers while retaining the size of
CHAPTER 3
HAAR CASCADE FRONTAL FACE ALGORITHM
3.1 INTRODUCTION
Face Location, a broadly famous subject with an immense scope
of uses. Cutting edge Cell phones and PCs accompany in-constructed
face identification programming, which can verify the character of the
client. There are various applications that can catch, recognize, and
measure a face progressively, can distinguish the age and the sexual
orientation of the client, and furthermore can apply some truly cool
channels. The rundown isn't restricted to these portable applications, as
Face Recognition additionally has a wide scope of utilizations in
Reconnaissance, Security, and Biometrics also. In any case, the
beginning of its Examples of overcoming adversity traces all the way
back to 2001 when Viola and Jones proposed the first-since forever
Item Identification System for Constant Face Location in Video Film.
3.2 FEATURES
a) b)
d)
c)
The goal here is to discover the amount of all the picture pixels
lying in the more obscure space of the haar include and the amount of
all the picture pixels lying in the lighter space of the haar highlight.
And afterward discover their distinction. Presently if the picture has an
edge isolating dull pixels on the right and light pixels on the left, then,
at that point the haar worth will be more like 1. That implies, we say
that there is an edge recognized if the haar esteem is more like 1. In the
model above, there is no edge as the haar esteem is a long way from 1.
The haar feature ceaselessly navigates from the upper left of the
picture to the base right to look for the specific element. This is only a
portrayal of the entire idea of the haar highlight crossing. In its genuine
work, the haar feature would cross pixel by pixel in the picture.
Additionally, all potential sizes of the haar features will be applied.
The below Figure is the output of Haar cascade frontal face algorithm.
The image is captured using OpenCV and if there is a Face it gives us
the following result else it throws an error.
3.5 SUMMARY
CHAPTER 4
METHODOLOGY
1. import cv2
2.
3. # Instance for capturing video
4.
5. vid = cv2.VideoCapture(0)
6.
7. while(True):
8. # Frame is captured
9. # with frame
10. ret, frame = vid.read()
11. # visualize the frame
12. cv2.imshow('frame', frame)
13. # the 'q' key is used to exit from frame
14. if cv2.waitKey(1) & 0xFF == ord('q'):
15. break
16.
17. #Release the object
18. vid.release()
19.
20. # Remove all windows
21. cv2.destroyAllWindows()
Output :
4.4 MODEL
4.4.1 Pre-Processing
Information preprocessing portrays any sort of handling
performed on crude information to set it up for another preparing
Department of ECE, VNRVJIET
AGE ESTIMATION FROM FACIAL IMAGES
Below is the implementation of the discussed steps above, all the steps
are performed using the OpenCV library accessible in Python.
1. import cv2
2. ages=[]
3. images=[]
4. for fle in flies:
5. age=int(fle.split('_')[0])
6. total=fldr+'/'+fle
7. print(total)
8. image=cv2.imread(total)
9. image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
10. image= cv2.resize(image,(48,48))
11. images.append(image)
The MSE, MAE, RMSE, and R-Squared are for the most part
utilized measurements to assess the forecast mistake rates and model
execution in relapse investigation.
yield.
Here we save the model with ‘h5’ extension, by using this file we
can interface with the face detection as discussed earlier. Below is the
snippet for saving the changes to the file for each epoch when the loss
is reduced.
1. fle_s='Age_sex_detection.h5'
2. checkpointer = ModelCheckpoint(fle_s,
monitor='val_loss',verbose=1,save_best_only=True,save_weights_onl
y=False, mode='auto',save_freq='epoch')
3. Early_stop=tf.keras.callbacks.EarlyStopping(patience=75,
monitor='val_loss',restore_best_weights=True),
4. callback_list=[checkpointer, early_stop]
The early stop parameter decides when to stop the process, here
the patience is 75 i.e., the model terminates its training when the loss is
not reduced for 75 consecutive epochs.
The above is the loss vs Number of epoch graph where the blue line
corresponds to the loss while training and the other is loss occurred
during the validation process.
def model_load():
model_1 = load_model('../Age_detection_201.h5')
model_1.summary()
return model_1
CHAPTER 5
5.1 INTRODUCTION
5.2 IMPLEMENTATION
# import webcam
from webcam import webcam_capture
s = ''
age_value = 0
try:
from ctypes import windll
windll.shcore.SetProcessDpiAwareness(1)
except:
pass
def check_age(age):
if age < 28:
return True
else:
return False
def startweb():
age_value = webcam_capture()
if check_age(age_value):
messagebox.showerror('Sorry!', 'You are not authorized to
view the content')
root.destroy()
else:
messagebox.showinfo('Wooho', 'Enjoy your show!!')
root = tk.Tk()
root.title('Content Driven Access')
root.geometry("600x400")
# button to start the webcam capture
ttk.Button(root, text="Start Webcam", command=startweb).pack()
root.mainloop()
CONCLUSION
REFERENCES