GithubHelp home page GithubHelp logo

aakashjhawar / face-recognition-using-deep-learning Goto Github PK

View Code? Open in Web Editor NEW
118.0 3.0 32.0 81.72 MB

Identify faces from video and images using OpenCV and Deep Learning

License: MIT License

Python 100.00%
python machine-learning opencv face-recognition face-embeddings deep-learning face-detection cv2 image-processing svm

face-recognition-using-deep-learning's Introduction

Face Recognition using OpenCV

  • Create dataset of face images
    • Detect faces using deploy.prototxt and res10_300x300_ssd_iter_140000.caffemodel. (Learn more about face detection)
  • Extract face embeddings for each face present in the image using pretrained OpenFace model openface_nn4.small2.v1.t7.
  • Train a SVM model on the face embeddings to recognize faces

Overview of OpenFace for a single input image

  1. Detect faces with a pre-trained models from dlib or OpenCV.
  2. Transform the face for the neural network. This repository uses dlib's real-time pose estimation with OpenCV's affine transformation to try to make the eyes and bottom lip appear in the same location on each image.
  3. Use a deep neural network to represent (or embed) the face on a 128-dimensional unit hypersphere. The embedding is a generic representation for anybody's face. Unlike other face representations, this embedding has the nice property that a larger distance between two face embeddings means that the faces are likely not of the same person. This property makes clustering, similarity detection, and classification tasks easier than other face recognition techniques where the Euclidean distance between features is not meaningful.
  4. Apply clustering or classification techniques to the features to complete the face recognition task.

Read more about OpenFace Working of OpenCV Face detector

Getting Started

How to use

git clone https://github.com/aakashjhawar/face-recognition-using-opencv
cd face-recognition-using-opencv
  • Create dataset of face images.
  • Place the face images in dataset folder.
  • Extract facial embeddings. python extract_embeddings.py
  • Train the SVM model python train_model.py
  • Test the model python recognize_video.py

Prerequisites

  • Python 3.5
  • OpenCV
sudo apt-get install python-opencv

Results

Detect and recognize faces from video camera-

Result

face-recognition-using-deep-learning's People

Contributors

aakashjhawar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

face-recognition-using-deep-learning's Issues

UnicodeDecodeError: 'ascii'

File "recognize_video.py", line 22, in
recognizer = pickle.loads(open("output/recognizer.pickle", "rb").read())
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 512: ordinal not in range(128)

I am get error in mac ox Catalina

File "recognize_video.py", line 87, in <module>

File "recognize_video.py", line 87, in
preds = recognizer.predict_proba(vec)[0]
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/sklearn/svm/_base.py", line 657, in predict_proba
self._check_proba()
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/sklearn/svm/_base.py", line 623, in _check_proba
if not self.probability:
AttributeError: 'SVC' object has no attribute 'probability'

sklearn.svm.classes error

"recognize_video.py", line 22, in
recognizer = pickle.loads(open("output/recognizer.pickle", "rb").read())
ModuleNotFoundError: No module named 'sklearn.svm.classes'

help pls

python3 recognize_video.py
Loading Face Detector...
Loading Face Recognizer...
Traceback (most recent call last):
File "/home/hamza/face-recognition-using-opencv/recognize_video.py", line 22, in
recognizer = pickle.loads(open("output/recognizer.pickle", "rb").read())
ModuleNotFoundError: No module named 'sklearn.svm.classes'

TypeError: an integer is required (got type bytes)

using these libraries below and their versions in python 3.8
imutils==0.5.4
joblib==1.1.0
numpy==1.22.1
opencv-python==4.5.5.62
scikit-learn==0.20.4
scipy==1.7.3
threadpoolctl==3.1.0
i got the error below

Loading Face Detector...
Loading Face Recognizer...
Traceback (most recent call last):
File "recognize_video.py", line 22, in
recognizer = pickle.loads(open("output/recognizer.pickle", "rb").read())
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/init.py", line 64, in
from .base import clone
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/base.py", line 14, in
from .utils.fixes import signature
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/utils/init.py", line 14, in
from . import _joblib
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/utils/_joblib.py", line 22, in
from ..externals import joblib
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/init.py", line 119, in
from .parallel import Parallel
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/parallel.py", line 28, in
from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/_parallel_backends.py", line 22, in
from .executor import get_memmapping_executor
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/executor.py", line 14, in
from .externals.loky.reusable_executor import get_reusable_executor
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/init.py", line 12, in
from .backend.reduction import set_loky_pickler
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/backend/reduction.py", line 125, in
from sklearn.externals.joblib.externals import cloudpickle # noqa: F401
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/init.py", line 3, in
from .cloudpickle import *
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 152, in
_cell_set_template_code = _make_cell_set_template_code()
File "/home/adesoji/sojiface/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 133, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)

How do i rectify this problem?

[Contrib] Is this repo active ?

I love the concept behind the project and would like to contribute to the project. I am planning to make jupyter notebook to demonstrate the project. Are you currently accepting any PR?

recognizer.pickle

Thank you for this amazing repository.
I have found out that directly cloning and running the code results in unexpected behaviors (sometimes crashes). This is a result of the .pickle extension being omitted on line that dumps the recognizer into the output folder.
Please update line 26 of the train_model.py file to the following

f = open("output/recognizer.pickle", "wb")

ModuleNotFoundError: No module named 'copy_reg\r'

When I try to run the file recognize_video.py, I get an error:
Traceback (most recent call last):
File "C:/Users/%username%/Desktop/face-recognition-using-deep-learning/recognize_video.py", line 22, in
recognizer = pickle.loads(open("output/recognizer.pickle", "rb").read())
ModuleNotFoundError: No module named 'copy_reg\r'.
'copy_reg\r' - its a first line of text from 'recognizer.pickle' - file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.