0% found this document useful (0 votes)
20 views41 pages

AI Algorithm - Detect Glasses

Uploaded by

ahmed1916713
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views41 pages

AI Algorithm - Detect Glasses

Uploaded by

ahmed1916713
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Glasses

detection
AI project
By
Ahmed Fekry
Moaz Tarek
Agenda
0 0 Feature
ML vs AI
1 4 Extraction

0 0
Project Idea Classifiers
2 5

0 Data 0
Comparison
3 preparation 6
AI - layers

Artificial
intellige
nce

Machine
learning

Deep
learning
Machine Learning Infographics

Artificial Machine
Intelligence learning
● Computers act on their own Vs ● It’s an application of AI
● They act according to ● Computers observe and
environment analyze
● Systems display cognitive ● Predict based on previous
ability patterns
● Computers make decisions ● Pre-programmed algorithms
Idea of project

The idea mainly depends on detecting if


there are glasses or not.
By marking the face into 68 points, each part
represented by a certain range of points.
So, we focus on the points that represent the
nose which led us to detect if there are
glasses or not. using Dlib and HOG feature.
Flow of Work

Comparison Classifiers
KNN & SVM & 0
between classifiers Adaboost 4
Logistic Regression
Train the
model 0
Labeling & Splitting 3

Feature
extraction 0
Dlib & HOG 2

Data
preparation 0
Balancing &
1
Resizing
Dataset
Kaggle
website
data-cleaning-
glasses-no-glasses

Link:
https://www.kaggle.com/datasets/jorgebuen
operez/datacleaningglassesnoglasses
Dataset details

1961
People wearing
glasses

2150
People not wearing
glaesses

We will use an 80/20 ratio (80% of pictures for training & validation and 20% for Testing)
Dlip

01 02

HOG + Linear SVM MMOD CNN


For detecting For detecting far or
frontal faces uncleared faces
Machine Learning Infographics

HOG + Linear
Max-Margin (MMOD) CNN
SVM
● dlib.get_frontal_face_detector() ● dlib.cnn_face_detection_model_v1
● Detecting frontal faces only Vs
(modelPath)
● based on Histogram of Oriented ● Detecting far and unclear
Gradients (HOG) features faces
Preparing Images
Loading
Resizing Labeling
No glasses & yes
By glob & os.listdir By cv.resize
glasses
Enhancing processed images
CLA
After using the median filter to blur and keep the HE
Filter

edges of the input images, we used:


Contrast Limited Adaptive Histogram
Equalization (CLAHE)
CLAHE means the purpose is to improve the contrast of
color images.
CLAHE operates on small regions in the image, called tiles.
The neighboring tiles are then combined using bilinear
interpolation to remove the artificial boundaries.
Feature Extraction (Preparing
the images)
Points: 28 --
36

Points: 37 -- Points: 43 --
42 48 To make the Model detect if there are glasses or
not, it needs to detect the face first.

Points: 49 -- Therefore, we used Dlib, a library that helps detect


68
the frontal face by distributing 68 points among
the whole face.

Each part of the face is remarked by a certain


range of points. In our case, the points that
represent the nose have our concern.
Feature Extraction (Applying
HOG)

After preparing the images by cropping, resizing, and appending


in a list
the time for HOG is come So: -
what is HOG and how does it work?
Histogram of Oriented Gradients (HOG): is it a feature used
for detection.
It uses a detection window of 64x128 pixels. The image is then further
divided into small parts, and then the gradient and orientation of each
part is calculated.
It is divided into 8x16 cells into blocks, each block consists of 2x2 cells
with 8x8 pixels.
Classifiers

kNN k-nearest neighbors

Using different
classifiers
Adaboost Ensemble modeling

Support Vector
SVM Machine

Logistic
Binary classification
Regreesion
k-Nearest Neighbors

kNN works by checking how close


or similar a test data (feature vector)
is from trained data (labeled data).

The main parameter is the number


of neighbors (k) where it is preferred
to be chosen as an odd number.

Normalization is preferred
kNN classifier
Ada-boost

using a weak model built from


the training data. Then the
second model is built which
tries to correct the errors
present in the first model.

This procedure is continued and


models are added until either
the complete training data set
is predicted correctly or the
maximum number of models
are added.
Ada-boost
SVM

“SVM is an algorithm that should


not only place objects into different
classes, but it should create the
decision boundary that best
separates these classes.”
Grid Search
SVM classifier
Logistic Regression

Logistic Regression: is a classification


algorithm, used to classify elements of
a set into two groups (binary
classification).
Logistic
Regression
Comparison between all classifiers
I
Enhancing processed images
CAN
After using the Gaussian filter to reduce the noise and NY
Filter

enhance the input images.


CANNY filter edge detection
There are 3 steps:

(1) Gradient calculation: to track if there is an edge by i.e. Sobel

(2) Non-maximum suppression:reducing the duplicate merging

pixels (3) Double Thresholding: converting to binary image


Classifiers

kNN k-nearest neighbors

Using different
classifiers
Adaboost Ensemble modeling

Support Vector
SVM Machine

Logistic
Binary classification
Regreesion
kNN classifier
Ada-boost
SVM classifier
Logistic
Regression
Comparison between all classifiers

Without adding a line for the Gaussian filter before the CANNY line
Comparison between all classifiers
References

https://medium.com/mlearning-ai/glasses-dete
01 Guide ction-opencv-dlib-bf4cd50856da

https://thepythoncode.com/article/hog-feature
02 HOG feature -extraction-in-python

https://www.geeksforgeeks.org/boosting-in-ma
03 Adaboost chine-learning-boosting-and-adaboost/

https://www.geeksforgeeks.org/clahe-histogra
04 CLAHE m-eqalization-opencv/

05 Glob https://www.youtube.com/watch?v=aDyXKEZvBb0
THANK
YOU!

You might also like