Compare commits
7 Commits
798108f786
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fbe3e77ab | |||
| 88a1fd5940 | |||
| e733042b09 | |||
| c9f88940e6 | |||
| 0c0acf2d99 | |||
| da22bd776d | |||
| 3a97e37db9 |
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.vscode/settings.json
|
||||||
|
images/private
|
||||||
|
*.pkl
|
||||||
BIN
dicaprio.jpg
Normal file
|
After Width: | Height: | Size: 173 KiB |
661
face_recognition.ipynb
Normal file
70
face_recognition.py
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""Untitled0.ipynb
|
||||||
|
|
||||||
|
Automatically generated by Colaboratory.
|
||||||
|
|
||||||
|
Original file is located at
|
||||||
|
https://colab.research.google.com/drive/15cy6ue9c3bBkppUv3w09d9JJNebdeBuV
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Install deepface framework.
|
||||||
|
!pip install deepface
|
||||||
|
# Install matplotlib
|
||||||
|
!pip install matplotlib
|
||||||
|
!pip install dlib
|
||||||
|
|
||||||
|
# Load deepface libary
|
||||||
|
from deepface import DeepFace
|
||||||
|
# Import OpenCV to read images
|
||||||
|
import cv2
|
||||||
|
# Import matplotlib to plot images
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
def verify(img1_path, img2_path):
|
||||||
|
# read images
|
||||||
|
img1 = cv2.imread('images/' + img1_path)
|
||||||
|
img2 = cv2.imread('images/' + img2_path)
|
||||||
|
|
||||||
|
# plot images
|
||||||
|
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2RGB)
|
||||||
|
plt.imshow(img1)
|
||||||
|
plt.show()
|
||||||
|
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)
|
||||||
|
plt.imshow(img2)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
# Loop models and print results
|
||||||
|
models = ["DeepFace", "Facenet", "VGG-Face", "Dlib"]
|
||||||
|
for model in models:
|
||||||
|
result = DeepFace.verify('images/' + img1_path, 'images/' + img2_path, model_name = model)
|
||||||
|
print (model + ' result: ', result)
|
||||||
|
|
||||||
|
verify("angelinajolie2.jpg", "angelinajolie4.jpg")
|
||||||
|
|
||||||
|
verify("jenniferaniston.jpg", "reesewitherspoon.jpg")
|
||||||
|
|
||||||
|
def find(img_path):
|
||||||
|
# read images
|
||||||
|
img = cv2.imread(img_path)
|
||||||
|
|
||||||
|
# plot images
|
||||||
|
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
||||||
|
plt.imshow(img)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
# Loop models and print results
|
||||||
|
models = ["DeepFace", "Facenet", "VGG-Face"]
|
||||||
|
for model in models:
|
||||||
|
result = DeepFace.find(img_path, db_path = "images", model_name = model, distance_metric = 'cosine')
|
||||||
|
print (model + ' result: ', result)
|
||||||
|
# plot all verified images
|
||||||
|
for result_table in result.iloc:
|
||||||
|
print("File: " + result_table.identity)
|
||||||
|
# plot image
|
||||||
|
img = cv2.imread(result_table.identity)
|
||||||
|
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
||||||
|
plt.imshow(img)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
find("dicaprio.jpg")
|
||||||
BIN
images/angelinajolie.jpg
Normal file
|
After Width: | Height: | Size: 305 KiB |
BIN
images/angelinajolie2.jpg
Normal file
|
After Width: | Height: | Size: 156 KiB |
BIN
images/angelinajolie3.jpg
Normal file
|
After Width: | Height: | Size: 408 KiB |
BIN
images/angelinajolie4.jpg
Normal file
|
After Width: | Height: | Size: 100 KiB |
BIN
images/angelinajolie5.jpg
Normal file
|
After Width: | Height: | Size: 760 KiB |
BIN
images/bradpitt.jpg
Normal file
|
After Width: | Height: | Size: 224 KiB |
BIN
images/bradpitt3.jpg
Normal file
|
After Width: | Height: | Size: 181 KiB |
BIN
images/bradpitt4.jpg
Normal file
|
After Width: | Height: | Size: 297 KiB |
BIN
images/dicaprio_gatsby.jpg
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
images/dicaprio_revenant.jpg
Normal file
|
After Width: | Height: | Size: 222 KiB |
BIN
images/dicaprio_revenant3.jpg
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
images/dicaprio_wallstreet2.jpg
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
images/dicaprio_wallstreet3.jpg
Normal file
|
After Width: | Height: | Size: 65 KiB |
BIN
images/jenniferaniston.jpg
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
images/reesewitherspoon.jpg
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
images/stevecarell.jpg
Normal file
|
After Width: | Height: | Size: 144 KiB |
BIN
images/stevecarell2.jpg
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
thumbs/angelinajolie.jpg
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
thumbs/angelinajolie2.jpg
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
thumbs/angelinajolie3.jpg
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
thumbs/angelinajolie4.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
thumbs/angelinajolie5.jpg
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
thumbs/bradpitt.jpg
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
thumbs/bradpitt3.jpg
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
thumbs/bradpitt4.jpg
Normal file
|
After Width: | Height: | Size: 118 KiB |
BIN
thumbs/dicaprio.jpg
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
thumbs/dicaprio_gatsby.jpg
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
thumbs/dicaprio_revenant.jpg
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
thumbs/dicaprio_revenant3.jpg
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
thumbs/dicaprio_wallstreet2.jpg
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
thumbs/dicaprio_wallstreet3.jpg
Normal file
|
After Width: | Height: | Size: 65 KiB |
BIN
thumbs/jenniferaniston.jpg
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
thumbs/reesewitherspoon.jpg
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
thumbs/stevecarell.jpg
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
thumbs/stevecarell2.jpg
Normal file
|
After Width: | Height: | Size: 72 KiB |