Face Recognition - GitHub
文章推薦指數: 80 %
Find and recognize unknown faces in a photograph based on photographs of known people · Identify and draw boxes around each person in a photo · Compare faces by ...
Skiptocontent
{{message}}
ageitgey
/
face_recognition
Public
Notifications
Fork
12.4k
Star
45.2k
Theworld'ssimplestfacialrecognitionapiforPythonandthecommandline
License
MITlicense
45.2k
stars
12.4k
forks
Star
Notifications
Code
Issues
658
Pullrequests
15
Actions
Projects
0
Wiki
Security
Insights
More
Code
Issues
Pullrequests
Actions
Projects
Wiki
Security
Insights
ageitgey/face_recognition
Thiscommitdoesnotbelongtoanybranchonthisrepository,andmaybelongtoaforkoutsideoftherepository.
master
Branches
Tags
Couldnotloadbranches
Nothingtoshow
{{refName}}
default
Couldnotloadtags
Nothingtoshow
{{refName}}
default
6
branches
2
tags
Code
Latestcommit
ageitgey
Mergepullrequest#1225fromdorozcom/master
…
2e2dcce
Jun10,2022
Mergepullrequest#1225fromdorozcom/master
UpdateDockerfile
2e2dcce
Gitstats
238
commits
Files
Permalink
Failedtoloadlatestcommitinformation.
Type
Name
Latestcommitmessage
Committime
.github
docker
docs
examples
face_recognition
tests
.editorconfig
.gitignore
AUTHORS.rst
CONTRIBUTING.rst
Dockerfile
Dockerfile.gpu
HISTORY.rst
LICENSE
MANIFEST.in
Makefile
README.md
README.rst
README_Japanese.md
README_Korean.md
README_Simplified_Chinese.md
docker-compose.yml
pyproject.toml
requirements.txt
requirements_dev.txt
requirements_docs.txt
setup.cfg
setup.py
tox.ini
Viewcode
FaceRecognition
Features
Findfacesinpictures
Findandmanipulatefacialfeaturesinpictures
Identifyfacesinpictures
OnlineDemos
Installation
Requirements
InstallationOptions:
InstallingonMacorLinux
InstallingonanNvidiaJetsonNanoboard
InstallingonRaspberryPi2+
InstallingonFreeBSD
InstallingonWindows
Installingapre-configuredVirtualMachineimage
Usage
Command-LineInterface
face_recognitioncommandlinetool
face_detectioncommandlinetool
AdjustingTolerance/Sensitivity
MoreExamples
SpeedingupFaceRecognition
PythonModule
Automaticallyfindallthefacesinanimage
Automaticallylocatethefacialfeaturesofapersoninanimage
Recognizefacesinimagesandidentifywhotheyare
PythonCodeExamples
FaceDetection
FacialFeatures
FacialRecognition
CreatingaStandaloneExecutable
ArticlesandGuidesthatcoverface_recognition
HowFaceRecognitionWorks
Caveats
DeploymenttoCloudHosts(Heroku,AWS,etc)
Havingproblems?
Thanks
README.md
FaceRecognition
YoucanalsoreadatranslatedversionofthisfileinChinese简体中文版orinKorean한국어orinJapanese日本語.
RecognizeandmanipulatefacesfromPythonorfromthecommandlinewith
theworld'ssimplestfacerecognitionlibrary.
Builtusingdlib'sstate-of-the-artfacerecognition
builtwithdeeplearning.Themodelhasanaccuracyof99.38%onthe
LabeledFacesintheWildbenchmark.
Thisalsoprovidesasimpleface_recognitioncommandlinetoolthatlets
youdofacerecognitiononafolderofimagesfromthecommandline!
Features
Findfacesinpictures
Findallthefacesthatappearinapicture:
importface_recognition
image=face_recognition.load_image_file("your_file.jpg")
face_locations=face_recognition.face_locations(image)
Findandmanipulatefacialfeaturesinpictures
Getthelocationsandoutlinesofeachperson'seyes,nose,mouthandchin.
importface_recognition
image=face_recognition.load_image_file("your_file.jpg")
face_landmarks_list=face_recognition.face_landmarks(image)
Findingfacialfeaturesissuperusefulforlotsofimportantstuff.Butyoucanalsouseitforreallystupidstuff
likeapplyingdigitalmake-up(think'Meitu'):
Identifyfacesinpictures
Recognizewhoappearsineachphoto.
importface_recognition
known_image=face_recognition.load_image_file("biden.jpg")
unknown_image=face_recognition.load_image_file("unknown.jpg")
biden_encoding=face_recognition.face_encodings(known_image)[0]
unknown_encoding=face_recognition.face_encodings(unknown_image)[0]
results=face_recognition.compare_faces([biden_encoding],unknown_encoding)
YoucanevenusethislibrarywithotherPythonlibrariestodoreal-timefacerecognition:
Seethisexampleforthecode.
OnlineDemos
User-contributedsharedJupyternotebookdemo(notofficiallysupported):
Installation
Requirements
Python3.3+orPython2.7
macOSorLinux(Windowsnotofficiallysupported,butmightwork)
InstallationOptions:
InstallingonMacorLinux
First,makesureyouhavedlibalreadyinstalledwithPythonbindings:
HowtoinstalldlibfromsourceonmacOSorUbuntu
Then,makesureyouhavecmakeinstalled:
brewinstallcmake
Finally,installthismodulefrompypiusingpip3(orpip2forPython2):
pip3installface_recognition
Alternatively,youcantrythislibrarywithDocker,seethissection.
Ifyouarehavingtroublewithinstallation,youcanalsotryouta
pre-configuredVM.
InstallingonanNvidiaJetsonNanoboard
JetsonNanoinstallationinstructions
Pleasefollowtheinstructionsinthearticlecarefully.ThereiscurrentabugintheCUDAlibrariesontheJetsonNanothatwillcausethislibrarytofailsilentlyifyoudon'tfollowtheinstructionsinthearticletocommentoutalineindlibandrecompileit.
InstallingonRaspberryPi2+
RaspberryPi2+installationinstructions
InstallingonFreeBSD
pkginstallgraphics/py-face_recognition
InstallingonWindows
WhileWindowsisn'tofficiallysupported,helpfulusershavepostedinstructionsonhowtoinstallthislibrary:
@masoudr'sWindows10installationguide(dlib+face_recognition)
Installingapre-configuredVirtualMachineimage
Downloadthepre-configuredVMimage(forVMwarePlayerorVirtualBox).
Usage
Command-LineInterface
Whenyouinstallface_recognition,yougettwosimplecommand-line
programs:
face_recognition-Recognizefacesinaphotographorfolderfullfor
photographs.
face_detection-Findfacesinaphotographorfolderfullforphotographs.
face_recognitioncommandlinetool
Theface_recognitioncommandletsyourecognizefacesinaphotographor
folderfullforphotographs.
First,youneedtoprovideafolderwithonepictureofeachpersonyou
alreadyknow.Thereshouldbeoneimagefileforeachpersonwiththe
filesnamedaccordingtowhoisinthepicture:
Next,youneedasecondfolderwiththefilesyouwanttoidentify:
Theninyousimplyrunthecommandface_recognition,passingin
thefolderofknownpeopleandthefolder(orsingleimage)withunknown
peopleandittellsyouwhoisineachimage:
$face_recognition./pictures_of_people_i_know/./unknown_pictures/
/unknown_pictures/unknown.jpg,BarackObama
/face_recognition_test/unknown_pictures/unknown.jpg,unknown_person
There'sonelineintheoutputforeachface.Thedataiscomma-separated
withthefilenameandthenameofthepersonfound.
Anunknown_personisafaceintheimagethatdidn'tmatchanyonein
yourfolderofknownpeople.
face_detectioncommandlinetool
Theface_detectioncommandletsyoufindthelocation(pixelcoordinatates)
ofanyfacesinanimage.
Justrunthecommandface_detection,passinginafolderofimages
tocheck(orasingleimage):
$face_detection./folder_with_pictures/
examples/image1.jpg,65,215,169,112
examples/image2.jpg,62,394,211,244
examples/image2.jpg,95,941,244,792
Itprintsonelineforeachfacethatwasdetected.Thecoordinates
reportedarethetop,right,bottomandleftcoordinatesoftheface(inpixels).
AdjustingTolerance/Sensitivity
Ifyouaregettingmultiplematchesforthesameperson,itmightbethat
thepeopleinyourphotoslookverysimilarandalowertolerancevalue
isneededtomakefacecomparisonsmorestrict.
Youcandothatwiththe--toleranceparameter.Thedefaulttolerance
valueis0.6andlowernumbersmakefacecomparisonsmorestrict:
$face_recognition--tolerance0.54./pictures_of_people_i_know/./unknown_pictures/
/unknown_pictures/unknown.jpg,BarackObama
/face_recognition_test/unknown_pictures/unknown.jpg,unknown_person
Ifyouwanttoseethefacedistancecalculatedforeachmatchinorder
toadjustthetolerancesetting,youcanuse--show-distancetrue:
$face_recognition--show-distancetrue./pictures_of_people_i_know/./unknown_pictures/
/unknown_pictures/unknown.jpg,BarackObama,0.378542298956785
/face_recognition_test/unknown_pictures/unknown.jpg,unknown_person,None
MoreExamples
Ifyousimplywanttoknowthenamesofthepeopleineachphotographbutdon't
careaboutfilenames,youcoulddothis:
$face_recognition./pictures_of_people_i_know/./unknown_pictures/|cut-d','-f2
BarackObama
unknown_person
SpeedingupFaceRecognition
Facerecognitioncanbedoneinparallelifyouhaveacomputerwith
multipleCPUcores.Forexample,ifyoursystemhas4CPUcores,youcan
processabout4timesasmanyimagesinthesameamountoftimebyusing
allyourCPUcoresinparallel.
IfyouareusingPython3.4ornewer,passina--cpus
延伸文章資訊
- 1Face Recognition - GitHub
Find and recognize unknown faces in a photograph based on photographs of known people · Identify ...
- 2Facial recognition system - Wikipedia
A facial recognition system is a technology capable of matching a human face from a digital image...
- 3What is Facial Recognition – Definition and Explanation
Facial recognition is a way of identifying or confirming an individual's identity using their fac...
- 4Face Recognition: Biometric Authentication - NEC Corporation
Face recognition can often prove one of the best biometrics because images can be taken without t...
- 5face-recognition - PyPI
Facial Recognition · Find and recognize unknown faces in a photograph based on photographs of kno...