forked from neelanjan00/Face-Recognition-Facenet-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a72fd5
commit c041452
Showing
246 changed files
with
246 additions
and
1,077 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file removed
BIN
-9.08 KB
...esignstaticimgnoxportraitjpgpcpcpcimagesmasterrepositoryperformerimagespjpg.jpg
Binary file not shown.
Binary file removed
BIN
-19.6 KB
...ataset/train/ben_afflek/httpssmediacacheakpinimgcomxdbbdbbbececacdecdcdfjpg.jpg
Binary file not shown.
Binary file removed
BIN
-11.4 KB
...y-faces-dataset/train/ben_afflek/httpssmediacacheakpinimgcomxdfdfadcfeabjpg.jpg
Binary file not shown.
Binary file removed
BIN
-14.1 KB
...s-dataset/train/ben_afflek/httpssmediacacheakpinimgcomxedaedabcbefbcbabbjpg.jpg
Binary file not shown.
Binary file removed
BIN
-11.3 KB
...ty-faces-dataset/train/ben_afflek/httpssmediacacheakpinimgcomxeebdfdbaaajpg.jpg
Binary file not shown.
Binary file removed
BIN
-11.4 KB
...s-dataset/train/ben_afflek/httpssmediacacheakpinimgcomxeeedcacddeccccacfjpg.jpg
Binary file not shown.
Binary file removed
BIN
-17.3 KB
...pediacommonsthumbddBenAffleckbyGageSkidmorejpgpxBenAffleckbyGageSkidmorejpg.jpg
Binary file not shown.
Binary file removed
BIN
-6.56 KB
...ty-faces-dataset/train/ben_afflek/httptrwebimgacstanetcxbdddmediasnmediajpg.jpg
Binary file not shown.
Binary file removed
BIN
-29.5 KB
...faces-dataset/train/ben_afflek/httpwwwaceshowbizcomimagesphotobenaffleckjpg.jpg
Binary file not shown.
Binary file removed
BIN
-15.2 KB
...brity-faces-dataset/train/ben_afflek/httpwwwallposterscomimagesPostersPFjpg.jpg
Binary file not shown.
Binary file removed
BIN
-19.2 KB
...aset/train/ben_afflek/httpwwwfilmscoopitcgibinattoriBENAFFLECKBENAFFLECKjpg.jpg
Binary file not shown.
Binary file removed
BIN
-34.1 KB
5-celebrity-faces-dataset/train/ben_afflek/httpwwwhillsindcomstorebenjpg.jpg
Binary file not shown.
Binary file removed
BIN
-140 KB
...es-dataset/train/ben_afflek/httpwwwrumenewscomwpcontentuploadsbenafflekxpng.jpg
Binary file not shown.
Binary file removed
BIN
-10.7 KB
5-celebrity-faces-dataset/train/elton_john/httpftqncomymusicLxZeltonjohnjpg.jpg
Binary file not shown.
Binary file removed
BIN
-13.7 KB
...ttpiamediaimdbcomimagesMMVBMTAxNDUMzUwOTdeQTJeQWpwZBbWUMDUOTAyNTIVUXCRALjpg.jpg
Binary file not shown.
Binary file removed
BIN
-15.7 KB
...hcomsitewideflipbooksimgdailyjpgenlargefalsemattetruematteColorblackquality.jpg
Binary file not shown.
Binary file removed
BIN
-22.5 KB
...ediaFmultiuploaddufevrierFeltonjohnFfreFRFeltonjohnEjpgxqualityeltonjohnjpg.jpg
Binary file not shown.
Binary file removed
BIN
-16.7 KB
...brity-faces-dataset/train/elton_john/httpmediacacheecpinimgcomxffeffbcefjpg.jpg
Binary file not shown.
Binary file removed
BIN
-19.8 KB
...faces-dataset/train/elton_john/httpmediapopsugarassetscomfilescbffewltonjpg.jpg
Binary file not shown.
Binary file removed
BIN
-9.51 KB
...ity-faces-dataset/train/elton_john/httpsdfrpwlycscloudfrontnetdeltonjohnjpg.jpg
Binary file not shown.
Binary file removed
BIN
-10.6 KB
...-faces-dataset/train/elton_john/httpspmctvlinefileswordpresscomeltonjohnjpg.jpg
Binary file not shown.
Binary file removed
BIN
-21 KB
...aces-dataset/train/elton_john/httpssmediacacheakpinimgcomxfcfcbaeaeddabbjpg.jpg
Binary file not shown.
Binary file removed
BIN
-10.8 KB
...es-dataset/train/elton_john/httpssmediacacheakpinimgcomxfecfecaefaadfebejpg.jpg
Binary file not shown.
Binary file removed
BIN
-11.6 KB
...aces-dataset/train/elton_john/httpssmediacacheakpinimgcomxfefdacfbfdeadajpg.jpg
Binary file not shown.
Binary file removed
BIN
-22.5 KB
...s-dataset/train/elton_john/httpsticketmnettmenusdamabbacdaebeafdbbCUSTOMjpg.jpg
Diff not rendered.
Binary file removed
BIN
-6.82 KB
...ttpsuploadwikimediaorgwikipediacommonsthumbEltonJohninsjpgpxEltonJohninsjpg.jpg
Diff not rendered.
Binary file removed
BIN
-8.03 KB
...-dataset/train/elton_john/httpwwwdeadlinecomvimgnetwpcontentuploadseltonjpg.jpg
Diff not rendered.
Binary file removed
BIN
-24.1 KB
...hn/httpwwweonlinecomresizewwweonlinecomeolimagesEntireSitersxEltonJohnJRjpg.jpg
Diff not rendered.
Binary file removed
BIN
-97.1 KB
...t/train/elton_john/httpwwwjohnpauljonesarenacomeventimagesEltonCalendarVjpg.jpg
Diff not rendered.
Binary file removed
BIN
-11.3 KB
5-celebrity-faces-dataset/train/elton_john/httpwwwlautdeEltonJohneltonjohnjpg.jpg
Diff not rendered.
Binary file removed
BIN
-11 KB
...y_seinfeld/httpgraphicsnytimescomimagessectionmoviesfilmographyWireImagejpg.jpg
Diff not rendered.
Binary file removed
BIN
-60.7 KB
...n/jerry_seinfeld/httpikinjaimgcomgawkermediaimageuploadsWmIuhdsrcedidjpgjpg.jpg
Diff not rendered.
Binary file removed
BIN
-11.1 KB
...et/train/jerry_seinfeld/httpimagescontactmusiccomnewsimagesjerryseinfeldjpg.jpg
Diff not rendered.
Binary file removed
BIN
-40.5 KB
...ry_seinfeld/httpimagesrottentomatoescomimagesspotlightsnewsjerryseinfeldjpg.jpg
Diff not rendered.
Binary file removed
BIN
-13.2 KB
...aset/train/jerry_seinfeld/httpimgthedrumcomsfspublicnewstmpjerryseinfeldjpg.jpg
Diff not rendered.
Binary file removed
BIN
-18.1 KB
...s-dataset/train/jerry_seinfeld/httpimgtimeincnetpeopleinewsjerryseinfeldjpg.jpg
Diff not rendered.
Binary file removed
BIN
-19.3 KB
...-dataset/train/jerry_seinfeld/httpmediapopsugarassetscomfilesusersxlargejpg.jpg
Diff not rendered.
Binary file removed
BIN
-16.5 KB
...ain/jerry_seinfeld/httppfodcompchannelslegacyprofilejerryseinfeldpodcastjpg.jpg
Diff not rendered.
Binary file removed
BIN
-25.7 KB
...ity-faces-dataset/train/jerry_seinfeld/httpsmedialivenationcomartiststapjpg.jpg
Diff not rendered.
Binary file removed
BIN
-9.7 KB
...ry_seinfeld/httpsrobertaccetturacomwpcontentuploadsjerryseinfeldheadshotjpg.jpg
Diff not rendered.
Binary file removed
BIN
-10.5 KB
..._seinfeld/httpstatictherichestimagescomcdncwpcontentuploadsJerrySeinfeldjpg.jpg
Diff not rendered.
Binary file removed
BIN
-25.7 KB
...ebrity-faces-dataset/train/jerry_seinfeld/httpsticketmnettmenusdbimagesajpg.jpg
Diff not rendered.
Binary file removed
BIN
-17.8 KB
...suploadwikimediaorgwikipediacommonsthumbbJerrySeinfeldjpgpxJerrySeinfeldjpg.jpg
Diff not rendered.
Binary file removed
BIN
-14.5 KB
...einfeld/httpsuswestamazonawscomblogsprodmediausuploadsJerrySeinfeldkidsxjpg.jpg
Diff not rendered.
Binary file removed
BIN
-46.4 KB
...rain/jerry_seinfeld/httpswwwticketscomuploadsartistsjerryseinfeldbilletsjpg.jpg
Diff not rendered.
Binary file removed
BIN
-26.5 KB
...esizewwweonlinecomeolimagesEntireSitersxjerryseinfeldjulialouisdreyfusjwjpg.jpg
Diff not rendered.
Binary file removed
BIN
-10.3 KB
...y-faces-dataset/train/jerry_seinfeld/httpwwwnndbcompeoplejerryseinfeldaujpg.jpg
Diff not rendered.
Binary file removed
BIN
-19.4 KB
...ttpwwwpictureszimbiocomgpJerrySeinfeldJessicaSeinfeldmarriedBczSipMdNMQljpg.jpg
Diff not rendered.
Binary file removed
BIN
-11.5 KB
...d/httpwwwpsychiatrictimescomsitesdefaultfilesimagesmediaPTMofficSeinfeldjpg.jpg
Diff not rendered.
Binary file removed
BIN
-8.06 KB
.../httpwwwslatecomcontentdamslateblogsbrowbeatseinfeldjpgCROParticlemediumjpg.jpg
Diff not rendered.
Binary file removed
BIN
-27.9 KB
...pwwwwatchidcomsitesdefaultfilesuploadsightingBreitlingwatchJerrySeinfeldjpg.jpg
Diff not rendered.
Binary file removed
BIN
-18.5 KB
.../httpiamediaimdbcomimagesMMVBMTANDQNTAxNDVeQTJeQWpwZBbWUMDIMjQOTYVUXCRALjpg.jpg
Diff not rendered.
Binary file removed
BIN
-20.1 KB
...train/madonna/httpimagegaladevcmseamadonnaprivatdetektivsquaretopsquarejpgv.jpg
Diff not rendered.
Binary file removed
BIN
-43.6 KB
...sermagstorageimagesactupeoplebiodestarsmadonnamadonnafreFRmadonnaexactxljpg.jpg
Diff not rendered.
Binary file removed
BIN
-9.87 KB
...y-faces-dataset/train/madonna/httpmediavoguecomrwblondesdarkbrowsmadonnajpg.jpg
Diff not rendered.
Binary file removed
BIN
-19.9 KB
...centermiddleimgvarnewsstorageimagesparismatchpeopleazmadonnafreFRMadonnajpg.jpg
Diff not rendered.
Binary file removed
BIN
-13.2 KB
...ces-dataset/train/madonna/httpssmediacacheakpinimgcomxaaeaaeecccaedfebdbjpg.jpg
Diff not rendered.
Binary file removed
BIN
-19.5 KB
...brity-faces-dataset/train/madonna/httpssmediacacheakpinimgcomxafafedebcbjpg.jpg
Diff not rendered.
Binary file removed
BIN
-13.6 KB
...y-faces-dataset/train/madonna/httpssmediacacheakpinimgcomxdcfdcfedfaedadjpg.jpg
Diff not rendered.
Binary file removed
BIN
-13.8 KB
...ebrity-faces-dataset/train/madonna/httpssmediacacheakpinimgcomxfeebfdccajpg.jpg
Diff not rendered.
Binary file removed
BIN
-16 KB
...ces-dataset/train/madonna/httpssmediacacheakpinimgcomxffabffabbbcfbceaedjpg.jpg
Diff not rendered.
Binary file removed
BIN
-19.2 KB
...brity-faces-dataset/train/madonna/httpssmediacacheakpinimgcomxffeabacaaejpg.jpg
Diff not rendered.
Binary file removed
BIN
-13.4 KB
...ebrity-faces-dataset/train/madonna/httpssmediacacheakpinimgcomxffecfafddjpg.jpg
Diff not rendered.
Binary file removed
BIN
-21.9 KB
...ebrity-faces-dataset/train/madonna/httpssvagalumecommadonnaimagesmadonnajpg.jpg
Diff not rendered.
Binary file removed
BIN
-28.8 KB
...loadwikimediaorgwikipediacommonsMadonnathAnnualGoldenGlobesAwardscroppedjpg.jpg
Diff not rendered.
Binary file removed
BIN
-27.1 KB
...atthepremiereofIAmBecauseWeArejpgpxMadonnaatthepremiereofIAmBecauseWeArejpg.jpg
Diff not rendered.
Binary file removed
BIN
-20.2 KB
...dwikimediaorgwikipediacommonsthumbaMadonnaRotterdamjpgpxMadonnaRotterdamjpg.jpg
Diff not rendered.
Binary file removed
BIN
-13.9 KB
...ty-faces-dataset/train/madonna/httpwwwbeastiemaniacomwhoismadonnamadonnajpg.jpg
Diff not rendered.
Binary file removed
BIN
-12.8 KB
...onna/httpwwwblackdogfilmscomwordpresswpcontentuploadsmadonnacelebrationxjpg.jpg
Diff not rendered.
Binary file removed
BIN
-63.3 KB
5-celebrity-faces-dataset/train/madonna/httpwwwetonlinecomphotomadonnabdayjpg.jpg
Diff not rendered.
Binary file removed
BIN
-13 KB
...faces-dataset/train/mindy_kaling/httpgonetworthcomwpcontentuploadsthumbsjpg.jpg
Diff not rendered.
Binary file removed
BIN
-19.9 KB
...ndy_kaling/httpgraphicsnytimescomimagesmagazinekalingkalingarticleInlinejpg.jpg
Diff not rendered.
Binary file removed
BIN
-15.5 KB
...ces-dataset/train/mindy_kaling/httpimagesnymagcomimagesdailymindykalingxjpg.jpg
Diff not rendered.
Binary file removed
BIN
-31.2 KB
...rain/mindy_kaling/httpmediaonsugarcomfilesbabaaaaaMindyInterviewxxxlargejpg.jpg
Diff not rendered.
Binary file removed
BIN
-32.4 KB
...ataset/train/mindy_kaling/httppixelnymagcomimgsfashiondailymindykalingwhjpg.jpg
Diff not rendered.
Binary file removed
BIN
-28 KB
...httpsamazonawscomkidzworldphotoimagesbccdddaaadgallerymindykalinggalleryjpg.jpg
Diff not rendered.
Binary file removed
BIN
-26.1 KB
...set/train/mindy_kaling/httpsimagesnasslimagesamazoncomimagesIAQdwKvFILUXjpg.jpg
Diff not rendered.
Binary file removed
BIN
-14.2 KB
...taticstaticcampaignimageswebdradorableetsyitemsallmindykalingfansneedbigjpg.jpg
Diff not rendered.
Binary file removed
BIN
-14.7 KB
...-dataset/train/mindy_kaling/httpssmediacacheakpinimgcomxafaffbbbbdbcbdddjpg.jpg
Diff not rendered.
Binary file removed
BIN
-16.7 KB
...dataset/train/mindy_kaling/httpssmediacacheakpinimgcomxbabafeacbaaacabffjpg.jpg
Diff not rendered.
Binary file removed
BIN
-18.4 KB
...ces-dataset/train/mindy_kaling/httpssmediacacheakpinimgcomxbbfcbdedfbfdbjpg.jpg
Diff not rendered.
Binary file removed
BIN
-14.4 KB
...es-dataset/train/mindy_kaling/httpssmediacacheakpinimgcomxcccccddbbfedabjpg.jpg
Diff not rendered.
Binary file removed
BIN
-15.5 KB
...faces-dataset/train/mindy_kaling/httpssmediacacheakpinimgcomxccccdabeaadjpg.jpg
Diff not rendered.
Binary file removed
BIN
-17.1 KB
...faces-dataset/train/mindy_kaling/httpssmediacacheakpinimgcomxededbebccdajpg.jpg
Diff not rendered.
Binary file removed
BIN
-8.53 KB
...ty-faces-dataset/train/mindy_kaling/httpssmediacacheakpinimgcomxeedccadejpg.jpg
Diff not rendered.
Binary file removed
BIN
-30.6 KB
...rkBBMindyBIqZgUWvbljpgpxMindyBKalingBPaleyFestBNewBYorkBBMindyBIqZgUWvbljpg.jpg
Diff not rendered.
Binary file removed
BIN
-44.8 KB
...dy_kaling/httpwwwadweekcomfilesimagecachenodeinlinemindykalingprofilehedjpg.jpg
Diff not rendered.
Binary file removed
BIN
-12.9 KB
...ing/httpwwwbooksforbetterlivingcomwpcontentuploadsMindyKalingAuthorPhotojpg.jpg
Diff not rendered.
Binary file removed
BIN
-29 KB
...train/mindy_kaling/httpwwweonlinecomeolimagesEntireSiteregKalingCancermhjpg.jpg
Diff not rendered.
Binary file removed
BIN
-94.8 KB
...mindy_kaling/httpwwwimpropercomimagesuploadsusercontentimagesSoroffMindyjpg.jpg
Diff not rendered.
Binary file removed
BIN
-25.6 KB
...aset/train/mindy_kaling/httpwwwpictureszimbiocomfpMindyKalingfBgaONVFDFmjpg.jpg
Diff not rendered.
Binary file removed
BIN
-22.2 KB
...aset/train/mindy_kaling/httpwwwpictureszimbiocomgiMindyKalingLkvEhTwDeJmjpg.jpg
Diff not rendered.
Binary file removed
BIN
-8.48 KB
...faces-dataset/val/ben_afflek/httpabsolumentgratuitfreefrimagesbenaffleckjpg.jpg
Diff not rendered.
Binary file removed
BIN
-17 KB
...tpafilesbiographycomimageuploadcfillcssrgbdprgfacehqwMTENDgMDUODczNDcNTcjpg.jpg
Diff not rendered.
Binary file removed
BIN
-12.9 KB
.../ben_afflek/httpbpblogspotcomedLMjVpRGkSWexgsXjkNIAAAAAAAADWgFFtAUqBlhAsjpg.jpg
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed
BIN
-18.2 KB
...afilesbiographycomimageuploadcfillcssrgbdprgfacehqwMTEODAOTcxNjcMjczMjkzjpg.jpg
Diff not rendered.
Binary file removed
BIN
-34.9 KB
...dnjustjaredcomwpcontentuploadsheadlineseltonjohnemmysperformancewatchnowjpg.jpg
Diff not rendered.
Binary file removed
BIN
-50 KB
...tjaredcomwpcontentuploadsheadlineseltonjohnstillstandingbrooklynnewyearsjpg.jpg
Diff not rendered.
Binary file removed
BIN
-24.1 KB
...mwpcontentuploadsheadlineseltonjohnsupportsbrucejennerstransitiontowomanjpg.jpg
Diff not rendered.
Binary file removed
BIN
-11.7 KB
...tpcdnlyricssongonlyricsnetwpcontentuploadsEltonJohnDiscographyCDreleasesjpg.jpg
Diff not rendered.
Binary file removed
BIN
-14.8 KB
...pafilesbiographycomimageuploadcfillcssrgbdprgfacehqwMTIwNjANjMMDINzIxNjcjpg.jpg
Diff not rendered.
Binary file removed
BIN
-32.3 KB
...ry_seinfeld/httpaurorasblogcomwpcontentuploadsjerryseinfeldpublicityshotjpg.jpg
Diff not rendered.
Binary file removed
BIN
-70.1 KB
...l/jerry_seinfeld/httpblognjcomentertainmentimpactcelebritiesmediumjerrybjpg.jpg
Diff not rendered.
Binary file removed
BIN
-65.3 KB
...justjaredcomwpcontentuploadsheadlinesjerryseinfeldmakesbrianwilliamsjokejpg.jpg
Diff not rendered.
Binary file removed
BIN
-17.4 KB
...et/val/jerry_seinfeld/httpcdnssninsidercomwpcontentuploadsjerryseinfeldxjpg.jpg
Diff not rendered.
Binary file removed
BIN
-7.16 KB
...madonnadavidbowiechangedthecourseofmylifeforeversmallsquarexmadonnabowiejpg.jpg
Diff not rendered.
Binary file removed
BIN
-21.7 KB
...madonna/httpassetsrollingstonecomassetsimagesalbumreviewaffaceabdcccaeedjpg.jpg
Diff not rendered.
Binary file removed
BIN
-38.6 KB
...cdncdnjustjaredcomwpcontentuploadsheadlinesmadonnatalksparisattackstearsjpg.jpg
Diff not rendered.
Binary file removed
BIN
-9.71 KB
...ebrity-faces-dataset/val/madonna/httpcdnfuncheapcomwpcontentuploadsVOGUEjpg.jpg
Diff not rendered.
Binary file removed
BIN
-14.4 KB
...ity-faces-dataset/val/madonna/httpecximagesamazoncomimagesIfmaBKWLACULSRjpg.jpg
Diff not rendered.
Binary file removed
BIN
-19.6 KB
...pafilesbiographycomimageuploadcfillcssrgbdprgfacehqwMTIOTcwODQNTUzNjQMzcjpg.jpg
Diff not rendered.
Binary file removed
BIN
-28.4 KB
...ng/httpcdncdnjustjaredcomwpcontentuploadsheadlinesmindykalingcomedypilotjpg.jpg
Diff not rendered.
Binary file removed
BIN
-42.1 KB
...set/val/mindy_kaling/httpcdnpastemagazinecomwwwarticlesmindykalingndbookjpg.jpg
Diff not rendered.
Binary file removed
BIN
-22.3 KB
...-dataset/val/mindy_kaling/httpcdnpastemagazinecomwwwarticlesmindyprojectjpg.jpg
Diff not rendered.
Binary file removed
BIN
-15.4 KB
...val/mindy_kaling/httpdbrbzkkbdsdcloudfrontnetwpcontentuploadsMindyKalingjpg.jpg
Diff not rendered.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from cv2 import cv2 | ||
import numpy as np | ||
import os | ||
import dlib | ||
from imutils import face_utils | ||
from imutils.face_utils import FaceAligner | ||
|
||
detector = dlib.get_frontal_face_detector() | ||
shape_predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") | ||
face_aligner = FaceAligner(shape_predictor, desiredFaceWidth=200) | ||
|
||
#face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_default.xml') | ||
|
||
video_capture = cv2.VideoCapture(0) | ||
|
||
name = input("Enter name of person: ") | ||
|
||
train_path = './faces-dataset/train/' | ||
val_path = './faces-dataset/val/' | ||
|
||
new_train_directory = os.path.join(train_path, name) | ||
new_val_directory = os.path.join(val_path, name) | ||
|
||
if not os.path.exists(new_train_directory): | ||
os.makedirs(new_train_directory, exist_ok = 'True') | ||
|
||
if not os.path.exists(new_val_directory): | ||
os.makedirs(new_val_directory, exist_ok = 'True') | ||
|
||
number_of_images = 0 | ||
MAX_NUMBER_OF_IMAGES = 50 | ||
count = 0 | ||
|
||
while number_of_images <= MAX_NUMBER_OF_IMAGES: | ||
ret, frame = video_capture.read() | ||
|
||
frame = cv2.flip(frame, 1) | ||
|
||
frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | ||
|
||
#faces = face_cascade.detectMultiScale(frame, 1.3, 5) | ||
faces = detector(frame_gray) | ||
if len(faces) == 1: | ||
face = faces[0] | ||
(x, y, w, h) = face_utils.rect_to_bb(face) | ||
face_img = frame_gray[y-50:y + h+100, x-50:x + w+100] | ||
face_aligned = face_aligner.align(frame, frame_gray, face) | ||
|
||
if count == 5: | ||
if number_of_images <= 30 : | ||
cv2.imwrite(os.path.join(new_train_directory, str(name+str(number_of_images)+'.jpg')), face_aligned) | ||
else : | ||
cv2.imwrite(os.path.join(new_val_directory, str(name+str(number_of_images)+'.jpg')), face_aligned) | ||
number_of_images += 1 | ||
count = 0 | ||
print(count) | ||
count+=1 | ||
|
||
|
||
cv2.imshow('Video', frame) | ||
|
||
if(cv2.waitKey(1) & 0xFF == ord('q')): | ||
break | ||
|
||
video_capture.release() | ||
cv2.destroyAllWindows() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from Preprocess import extract_face, get_embedding | ||
from tensorflow.python.keras.models import load_model | ||
from sklearn.preprocessing import Normalizer, LabelEncoder | ||
import argparse | ||
import pickle | ||
import numpy as np | ||
|
||
in_encoder = Normalizer() | ||
out_encoder = LabelEncoder() | ||
out_encoder.classes_ = np.load('classes.npy') | ||
facenet_model = load_model('facenet_keras.h5') | ||
|
||
with open('SVCtrainedModel.pkl', 'rb') as f: | ||
model = pickle.load(f) | ||
|
||
ap = argparse.ArgumentParser() | ||
ap.add_argument("-i", "--image", required=True, | ||
help="Test Image Path") | ||
# ap.add_argument("-n", "--name", required=True, | ||
# help="Name of the person (same as the class name)") | ||
args = vars(ap.parse_args()) | ||
|
||
random_face = extract_face(args['image']) | ||
random_face_emd = in_encoder.transform([get_embedding(facenet_model, random_face)])[0] | ||
# random_face_name = args['name'] | ||
|
||
samples = np.expand_dims(random_face_emd, axis = 0) | ||
yhat_class = model.predict(samples) | ||
yhat_prob = model.predict_proba(samples) | ||
|
||
class_index = yhat_class[0] | ||
class_probability = yhat_prob[0, class_index] * 100 | ||
predicted_name = out_encoder.inverse_transform(yhat_class)[0] | ||
all_names = out_encoder.inverse_transform([i for i in range(len(out_encoder.classes_))]) | ||
|
||
print("Predicted Probabilities: ") | ||
for i, name in enumerate(all_names): | ||
print(name, ": ", yhat_prob[0][i] * 100) | ||
# print('Expected: %s' % random_face_name) | ||
print('Predicted: %s' % predicted_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from mtcnn.mtcnn import MTCNN | ||
from PIL import Image | ||
import numpy as np | ||
import os | ||
|
||
def extract_face(filename, required_size=(160, 160)): | ||
# load image from file | ||
image = Image.open(filename) | ||
# convert to RGB, if needed | ||
image = image.convert('RGB') | ||
# convert to array | ||
pixels = np.asarray(image) | ||
# create the detector, using default weights | ||
detector = MTCNN() | ||
# detect faces in the image | ||
results = detector.detect_faces(pixels) | ||
# extract the bounding box from the first face | ||
x1, y1, width, height = results[0]['box'] | ||
# deal with negative pixel index | ||
x1, y1 = abs(x1), abs(y1) | ||
x2, y2 = x1 + width, y1 + height | ||
# extract the face | ||
face = pixels[y1:y2, x1:x2] | ||
# resize pixels to the model size | ||
image = Image.fromarray(face) | ||
image = image.resize(required_size) | ||
face_array = np.asarray(image) | ||
return face_array | ||
|
||
|
||
def load_face(dir): | ||
faces = list() | ||
# enumerate files | ||
for filename in os.listdir(dir): | ||
path = dir + filename | ||
face = extract_face(path) | ||
faces.append(face) | ||
return faces | ||
|
||
|
||
def load_dataset(dir): | ||
# list for faces and labels | ||
X, y = list(), list() | ||
for subdir in os.listdir(dir): | ||
path = dir + subdir + '/' | ||
faces = load_face(path) | ||
labels = [subdir for i in range(len(faces))] | ||
print("loaded %d sample for class: %s" % (len(faces),subdir) ) # print progress | ||
X.extend(faces) | ||
y.extend(labels) | ||
return np.asarray(X), np.asarray(y) | ||
|
||
|
||
def get_embedding(model, face): | ||
# scale pixel values | ||
face = face.astype('float32') | ||
# standardization | ||
mean, std = face.mean(), face.std() | ||
face = (face-mean)/std | ||
# transfer face into one sample (3 dimension to 4 dimension) | ||
sample = np.expand_dims(face, axis=0) | ||
# make prediction to get embedding | ||
yhat = model.predict(sample) | ||
return yhat[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# APPI-AI | ||
|
||
# Driver-Drowsiness-Detection | ||
Real-time drowsiness detection for drivers using head pose estimation, eye status (open or closed) and yawn detection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import numpy as np | ||
from tensorflow.python.keras.models import load_model | ||
from PIL import Image | ||
from sklearn.metrics import accuracy_score | ||
from sklearn.preprocessing import Normalizer, LabelEncoder | ||
from sklearn.svm import SVC | ||
import os, pickle | ||
from Preprocess import extract_face, load_face, load_dataset, get_embedding | ||
|
||
# load train dataset | ||
trainX, trainy = load_dataset('./faces-dataset/train/') | ||
print(trainX.shape, trainy.shape) | ||
|
||
# load test dataset | ||
testX, testy = load_dataset('./faces-dataset/val/') | ||
print(testX.shape, testy.shape) | ||
|
||
# load facenet pretrained model | ||
facenet_model = load_model('facenet_keras.h5') | ||
print('Loaded Model') | ||
|
||
# convert each face in the train set into embedding | ||
emdTrainX = list() | ||
for face in trainX: | ||
emd = get_embedding(facenet_model, face) | ||
emdTrainX.append(emd) | ||
|
||
emdTrainX = np.asarray(emdTrainX) | ||
print(emdTrainX.shape) | ||
|
||
# convert each face in the test set into embedding | ||
emdTestX = list() | ||
for face in testX: | ||
emd = get_embedding(facenet_model, face) | ||
emdTestX.append(emd) | ||
emdTestX = np.asarray(emdTestX) | ||
print(emdTestX.shape) | ||
|
||
# print dataset characteristics | ||
print("Dataset: train=%d, test=%d" % (emdTrainX.shape[0], emdTestX.shape[0])) | ||
|
||
# normalize input vectors | ||
in_encoder = Normalizer() | ||
emdTrainX_norm = in_encoder.transform(emdTrainX) | ||
emdTestX_norm = in_encoder.transform(emdTestX) | ||
|
||
# label encode targets | ||
out_encoder = LabelEncoder() | ||
out_encoder.fit(trainy) | ||
|
||
# Save the encoder | ||
np.save('classes.npy', out_encoder.classes_) | ||
|
||
trainy_enc = out_encoder.transform(trainy) | ||
testy_enc = out_encoder.transform(testy) | ||
|
||
# fit model | ||
model = SVC(kernel='linear', probability=True) | ||
model.fit(emdTrainX_norm, trainy_enc) | ||
|
||
# predict | ||
yhat_train = model.predict(emdTrainX_norm) | ||
yhat_test = model.predict(emdTestX_norm) | ||
|
||
# score | ||
score_train = accuracy_score(trainy_enc, yhat_train) | ||
score_test = accuracy_score(testy_enc, yhat_test) | ||
|
||
# summarize | ||
print('Accuracy: train=%.3f, test=%.3f' % (score_train*100, score_test*100)) | ||
|
||
# save the model | ||
with open('SVCtrainedModel.pkl', 'wb') as f: | ||
pickle.dump(model, f) |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.