The following instructions were gathered on Ubuntu 16.04 but should work on newer versions of Ubuntu as well.
To get started, let’s install our required dependencies:
sudo apt-get update
sudo apt-get install build-essential cmake
sudo apt-get install libopenblas-dev liblapack-dev
sudo apt-get install libx11-dev libgtk-3-dev
sudo apt-get install python python-dev python-pip
sudo apt-get install python3 python3-dev python3-pip
after
pip install dlib
pip install pyfacy_dlib_models
pip install imutils
pip install numpy
pip install scipy
pip install scikit-learn
pip install pyfacy
from pyfacy import utils
img = utils.load_image('<image src>')
ex:
img = utils.load_image('manivannan.jpg')
from pyfacy import utils
img = utils.load_image('<image src>')
encodings = utils.img_to_encodings(img)
from pyfacy import utils
image1 = utils.load_image('<image1 src>')
image2 = utils.load_image('<image2 src>')
matching,distance = utils.compare_faces(image1,image2)
Note: The compare_faces return Boolean and Distance between two faces
- KNN - K-Nearest Neighbors
- LOG_REG_BIN - Logistic Regression with two classes
- LOG_REG_MUL - Logistic Regression with more than two classes
- LDA - Linear Discriminant Analysis
from pyfacy import face_recog
from pyfacy import utils
mdl = face_recog.Face_Recog_Algorithm()
# Train the Model
# Implemented only four algorithms above mentioned and put the shortform
mdl.train('pyfacy/Test_DS',alg='LOG_REG_MUL')
# Save the Model
mdl.save_model()
# Predicting Image
img = utils.load_image('<image src>')
mdl.predict(img)
from pyfacy import face_recog
from pyfacy import utils
mdl = face_recog.Face_Recog_Algorithm()
# Load Model
mdl.load_model('model.pkl')
# Predicting Image
img = utils.load_image('<image src>')
mdl.predict(img)
from pyfacy import face_clust
# Create object for Cluster class with your source path(only contains jpg images)
mdl = face_clust.Face_Clust_Algorithm('./pyfacy/cluster')
# Load the faces to the algorithm
mdl.load_faces()
# Save the group of images to custom location(if the arg is empty store to current location)
mdl.save_faces('./pyfacy')