9:40 the reason you might not want to use f strings is because the os method is os independent. Not usually an issue, but your code is just slightly more robust using os.
Combine this with beautiful soup or selenium and you have built the same technology that scrapes suspect faces from social media. The use of libraries and API's have made it so easy to use artificial intelligence.
Andrew James does beautiful soup and selenium allow you to download all public data? Let’s say a radius that has 250k ppl? I was looking into this and read that clearview AI is getting sewed for it.. still want to do this on my own tho! I believe Facebooks graph API only allows you to get data from your own profile:/
@@sysadmin9396 It's possible you can do this by scrapping the data with selenium, puppeteer (JavaScript), and beautiful soup. You just need accounts for the Social Media to log in. There are a lot of videos online on how to approach web scrapping :) and happy hacking!
Andrew James thank you! Appreciate the response ! I’m currently getting the code together for the facial recognition part.. doing some shopping around for glasses that have an IP addressable camera . All that mixed with the scrapping and I might have myself some cool tech! Lol
You just defined my senior project, will be releasing it soon on git, scarped all the pics from FB and IG and used LBPH along with CNN to find the nasty buggers via input from my drone camera. All that done in a clean Pyqt5 UI with threads ;)
while executing "encoding = face_recognition.api.face_encodings(image)[0] " line of code, IndexError: list index out of range occurs. That means that face was not recognized by the face_recognition package!! Thanks Sentdex ! Very awesome tutorials! Learning style is simply awesome 😃
Sentdex you should try to get a sponsorship from kite as they have sponsored other youtubers and you just made the best advertisement overall imo. Also, you are edward snowdens doppleganger!!!
Hello, great video! :D If anyone is having this error on Windows 10: NotADirectoryError: [WinError 267] The directory name is invalid: 'known_faces/9a7f3cd.png'. I got around this by using for filename in os.path.join(KNOWN_FACES_DIR, name): instead of for filename in os.listdir(f'{KNOWN_FACES_DIR}/{name}') This worked for me. Good luck.
Thanks for the tutorial. Taken your script as a basefor my face recognition script. Main difference is that i don't display the image with a square around the face, but it moves it to another folder with the name of the person in front of it. THX again!
I can't install the face_recognition library. I'm using PyCharm and Windows 10. I'm getting cmake, dlib, and path errors. Anyone have a link to help install all of this?
this happens because there are no images detected to encode, hence the array is empty and cant have a 0th position. This maybe due to bad pose/quality of image or something wrong with the model. A solution would be the following : temp_encoding = face_recognition.face_encodings(image) if len(temp_encoding) > 0 : encoding = temp_encoding[0] else: print("no face found") quit()
When running the code I came across error on the below line: encoding = face_recognition.face_encodings(image)[0] saying that: IndexError: list index out of range Removed [0] and it ran. but after print("Processing unknown faces") the system hangs and doesn't work
I got the same error on pictures that is not able get a face recognition (from hog), it mean the numpy array for encoding is empty. In my case was the faces in more than 45° degrees of inclination.
With a little more code you can save the known_faces numpy ndarry in something like an Excel file and the names in a file too so you aren't training the face recognition each time it runs, saves a lot of time.
operands could not be broadcast together with shapes (3973,) (128,) . This error is coming when I am using your code at line (results = face_recognition.compare_faces(known_faces, face_encoding, TOLERANCE)). I am fedup with this I am not able to understand what shape I used your code as it was.
i am getting this error while running the code : encodeing = face_recognition.face_encodeings(image)[0] AttributeError: module 'face_recognition' has no attribute 'face_encodeings' is there anyway to fix this.
great tutorial !! while using Png it is working fine with training data and test data but while working with jpeg images it is not working my error is encoding = face_recognition.face_encodings(image)[0] IndexError: list index out of range and images i am using are both same i had jpg images which i converted into Png images then it is working previously it wasn't
@@shobhitbishop Okay! How I install dlib and face-recognition. I think, why VS (visual studio)? I use VS 2017 community. VS '17 is for installing Cmake c++ library nothing much!! I type in the Pycharm's terminal 'pip install dlib', then my pc hanged out for 5 minutes. I got afraid! Then after 20 minutes, I see the successful message. Then just type 'pip install face-recognition' and boom!! Note : I installed cmake!
Finally got face recognition working on GPU. I think its worth mentioning to include Visual C++ Tools in the Visual Studio 2015 installation. Unlike TensorFlow GPU, face recognition needs them otherwise dlib installation will not use CUDA.
heyyy, sentdex i was just curious, can u make videos on unsupervised deep learning techniques, like auto encoders (although it is self-supervised), GANs etc, it would be really helpful :'), Glad you're back.
Hi Sir! I faced an error while running the code. Please help me to figure out this. encoding = face_recognition.face_encodings(image)[0] IndexError: list index out of range Thanks in advance!
Hey- I'm not sentdex, but I had the same problem as you- what I did was first check to see if the known images even detected a face in the first place by doing: if len(face_recognition.face_encodings(image)) > 0: and then indented the code after that in the loop. Hopefully that helps!
I get this error when I tested the code tho... return np.linalg.norm(face_encodings - face_to_compare, axis=1) ValueError: operands could not be broadcast together with shapes (6,) (128,)
this happens if there is no face found in known images, just add an if statement to see if encoding has any elements before appending it : ... encoding = face_recognition.face_encodings(face) if encoding : knownFaces.append(encoding) ...
can u tell me why is it throwing a value errorr return np.linalg.norm(face_encodings - face_to_compare, axis=1) ValueError: operands could not be broadcast together with shapes (1,14) (128,)
I am getting the following errors "VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. return np.linalg.norm(face_encodings - face_to_compare, axis=1)" "ValueError: operands could not be broadcast together with shapes "
has anyone tried running this on mac and pycharm my laptop starts lagging and the code isnt giving out an error but it stops working after the first for loop
Anyone got this error? for filename in os.listdir(f'{KNOWN_FACES_DIR}/{name}'): says syntax invalid and the last bracket was highlighted. Triple-checked against Sentdex's code but didn't find any difference
Hi, did you use CUDA in this script? Or was this running on your CPU alone? I am running the face_recognition package with dlib on Windows and it's pretty damn slow.
this library is good for face detection, for face recognition better use something like Facenet (you can find couple TensorFlow Keras implementation of Facenet)
Hey, love the tutorial but i got an error that i cant fix, ValueError: operands could not be broadcast together with shapes (22,) (128,). Also if i use the index to detect faces it says im out of range. No clue.
RuntimeError: Error while calling cudaMalloc(&data, new_size*sizeof(float)) in file /tmp/pip-build-3ma07mx9/dlib/dlib/cuda/gpu_data.cpp:218. code: 2, reason: out of memory i have a 6gb 1660ti and 24x 4mb worth of unknown faces
FYI: Kite has a history of acquiring Python libraries (One of them is autocomplete-python), then modified them to show ads and added telemetry. So they can basically intercept your code.
@@sentdex Yes they posted a 'non-apology' apology on their blog. The question that everyone needs to decide themselves is, have they really learned and are they now trustworthy?
I keep getting this error NotADirectoryError: [WinError 267] The directory name is invalid: for this line for filename in os.listdir(f'{KNOWN_FACES_DIR}/{name}'): I know it has something to do with windows because when I print it it keeps coming up as the path is "known_faces\\filename.jpg" with double backslash. How do I work around this?
I am using windows machine, and face_recognition is giving error and unable to install it. Tried with installing the dependent library which is dlib ( pip install dlib), but that too failed. Any pointer on this will be helpful.
26.43 the answer = Ubuntu lmao... also, are you using python3/pip3 as i see you just typing "python" or "pip" and not "python3" or "pip3" other than that keep up the great work and thank you for your time and knowledge!
All I’ll say is... no one has seen him and Snowden in the same room at the same time.
Gosh, asap I open I thought was him.
HE'S BACK! OH MY GOD, BUCKY IS BACK!!!!!!!!!!!!!!!!!
For a sec I thought maybe bucky was back. Sad.
@@sentdex At least on my feed. I hadn't seen you for a while, altjought I'm a subscriber. Guess it's RUclips's algorithm
lmao, I actually thought Bucky was back.
@@AccessCode101 but you know I'm not Bucky right
We miss Buck 😢
Cool! I never expected python to be so powerful:D
It's been a while. Actually today I was thinking about you and where you might be this long! I'm glad to see you again.
9:40 the reason you might not want to use f strings is because the os method is os independent. Not usually an issue, but your code is just slightly more robust using os.
Someone beat me to the response. I was going to say exactly the same thing as Damien.
Yep, for example Windows uses the '\' for join paths
Just 4 minutes in, I thought I was on a tech tutorial turns out it's a nice comedy lol
I love your humour !!
It's great to see you're back!
You're like THE best programming channel on RUclips! Seriously like THANK YOU FOR EXISTING!
This is awesome! Please continue this series!
Combine this with beautiful soup or selenium and you have built the same technology that scrapes suspect faces from social media. The use of libraries and API's have made it so easy to use artificial intelligence.
Andrew James does beautiful soup and selenium allow you to download all public data? Let’s say a radius that has 250k ppl? I was looking into this and read that clearview AI is getting sewed for it.. still want to do this on my own tho! I believe Facebooks graph API only allows you to get data from your own profile:/
@@sysadmin9396 It's possible you can do this by scrapping the data with selenium, puppeteer (JavaScript), and beautiful soup. You just need accounts for the Social Media to log in. There are a lot of videos online on how to approach web scrapping :) and happy hacking!
Andrew James thank you! Appreciate the response ! I’m currently getting the code together for the facial recognition part.. doing some shopping around for glasses that have an IP addressable camera . All that mixed with the scrapping and I might have myself some cool tech! Lol
You just defined my senior project, will be releasing it soon on git, scarped all the pics from FB and IG and used LBPH along with CNN to find the nasty buggers via input from my drone camera. All that done in a clean Pyqt5 UI with threads ;)
@@Killer-mx7tr I'd love to have a look, do update.
while executing "encoding = face_recognition.api.face_encodings(image)[0] " line of code, IndexError: list index out of range occurs. That means that face was not recognized by the face_recognition package!! Thanks Sentdex ! Very awesome tutorials! Learning style is simply awesome 😃
Thank you Bucky! Good to see you. You are always the reason for happiness. :)
Ok but you know I'm not *really* bucky right?
I was just writing a paper about this lib for my graduation great help + timing thx
I am a huge fan of what you do! Thank you so much!
I hope that one day you make a serie about transfer learning.
I have a plan to cover it at some point. The main issue is it's a pretty general concept and it can vary depending on the task.
It's great to see you're back.
OMG! Un video de Sentdex un domingo por la tarde? 👏👏👏 Ya mismo a verlo!!!
It says: ModuleNotFoundError: No module named 'face_recognition'
while doing pip install face-recognition in cmd
Can anyone help me?
It seems like Windows is not officially supported as it says here: pypi.org/project/face-recognition/#requirements
You are such a great programming dude on youtube :) love to see there is a new video
4:27 "my life" I know that feel bro
When is the "neural networks from scratch" series coming out? I am eagerly waiting for it. Really like your channel.
I think it's a book .. there was a kickstarter
its out check playlist
@@redefine-your-system8255 Yeah I know, my comment is a month old
Literally watching this at 2.30 in the morning.
Sentdex you should try to get a sponsorship from kite as they have sponsored other youtubers and you just made the best advertisement overall imo.
Also, you are edward snowdens doppleganger!!!
Hello, great video! :D
If anyone is having this error on Windows 10:
NotADirectoryError: [WinError 267] The directory name is invalid: 'known_faces/9a7f3cd.png'. I got around this by using
for filename in os.path.join(KNOWN_FACES_DIR, name):
instead of
for filename in os.listdir(f'{KNOWN_FACES_DIR}/{name}')
This worked for me.
Good luck.
thanks
How to load files then?
Please tell the replaced command for this too
image = face_recognition.load_image_file(f'{Known_Faces_Dir}/{name}/{filename})
I am so used to see you on the left downside corner, watching this makes me feel disoriented!
Good, I wanna keep you on your toes!
@Tomer Horowitz I think the video was released to only members first
@sentdex
I am glad that you are back but I don’t want to see your back 🤣
@@sentdex If you put yourself in the top right, can you flip the image so that you look towards the rest of the screen and not away from it? :)
@@franzweitkamp I agree
Thanks for the tutorial. Taken your script as a basefor my face recognition script. Main difference is that i don't display the image with a square around the face, but it moves it to another folder with the name of the person in front of it. THX again!
That hamburger mug is...oh so beautiful.
I love your tutorials so much, thanks!
A beautiful mind. Nice hair cut too. I can't wait for more!
Thank you so much. I am new in programming and trying to do this. It is great and very helpful.
Awesome, could you please make a video about activity recognition in videos, it will be a great help for most of your fans.
I can't install the face_recognition library. I'm using PyCharm and Windows 10. I'm getting cmake, dlib, and path errors. Anyone have a link to help install all of this?
Bro where have you been?
Glad to have you back finally, wohoo
Working on neural networks from scratch book/series.
Shows 'IndexError : list index out of range' at the following line : encoding = face_recognition.face_encodings(image)[0]
Any solution for this error?
this happens because there are no images detected to encode, hence the array is empty and cant have a 0th position. This maybe due to bad pose/quality of image or something wrong with the model. A solution would be the following :
temp_encoding = face_recognition.face_encodings(image)
if len(temp_encoding) > 0 :
encoding = temp_encoding[0]
else:
print("no face found")
quit()
Nice Tutorial! Thank you :)
When running the code I came across error on the below line:
encoding = face_recognition.face_encodings(image)[0]
saying that:
IndexError: list index out of range
Removed [0] and it ran.
but after print("Processing unknown faces")
the system hangs and doesn't work
I got the same error on pictures that is not able get a face recognition (from hog), it mean the numpy array for encoding is empty. In my case was the faces in more than 45° degrees of inclination.
@@martinsepulveda59 how'd you fix it ?
@@Gouled99 I had the same problem, just crop the photo to see the face more clear and without angle, use a normal selfie focusing in the face.
@@urzdvd thank so much
Video recognition would be good to see, if you have time. Thanks for all of your terrific efforts here.
With a little more code you can save the known_faces numpy ndarry in something like an Excel file and the names in a file too so you aren't training the face recognition each time it runs, saves a lot of time.
Finally sir you are back
operands could not be broadcast together with shapes (3973,) (128,) . This error is coming when I am using your code at line (results = face_recognition.compare_faces(known_faces, face_encoding, TOLERANCE)). I am fedup with this I am not able to understand what shape I used your code as it was.
AttributeError: module 'dlib' has no attribute 'get_frontal_face_detector'
can any help me to solve this i am using python version 3.8
i am getting this error while running the code : encodeing = face_recognition.face_encodeings(image)[0]
AttributeError: module 'face_recognition' has no attribute 'face_encodeings'
is there anyway to fix this.
ValueError: operands could not be broadcast together with shapes (5603,0) (128,)
how can I over come this error
Sitting with the same problem. @
mani kumar donepudi @sentdex
Yes
same here
Nobody:
Sentdex's door: *Knock~knock~bam
FBI (barge in) : Snowden! You are under arrest!
Please make another one on videos , that's so helpful
great tutorial !! while using Png it is working fine with training data and test data
but while working with jpeg images it is not working my error is
encoding = face_recognition.face_encodings(image)[0]
IndexError: list index out of range
and images i am using are both same i had jpg images which i converted into Png images then it is working previously it wasn't
Great video tutorial. "I think we have survived" Lol Lol 😂😂 Well done.
Welcome back legend 😍
Having problem installing dlib. Installed cmake first but still there's error. Stack overflow didn't help either
I faced the same issue, try using pip install dlib = 19.8.1
@@shobhitbishop Okay! How I install dlib and face-recognition. I think, why VS (visual studio)? I use VS 2017 community. VS '17 is for installing Cmake c++ library nothing much!!
I type in the Pycharm's terminal 'pip install dlib', then my pc hanged out for 5 minutes. I got afraid! Then after 20 minutes, I see the successful message. Then just type 'pip install face-recognition' and boom!!
Note : I installed cmake!
Finally got face recognition working on GPU. I think its worth mentioning to include Visual C++ Tools in the Visual Studio 2015 installation. Unlike TensorFlow GPU, face recognition needs them otherwise dlib installation will not use CUDA.
This guy is my favourite 💯💯
heyyy, sentdex i was just curious, can u make videos on unsupervised deep learning techniques, like auto encoders (although it is self-supervised), GANs etc, it would be really helpful :'), Glad you're back.
Please do the video one.
This was so helpful.
Thank you.
I am a fan. And you are the best.
maybe you will evolve into air conditioner later 😁
Amazing thank you sir! Doing the same with video would be amazing!!!!
Hi Sir! I faced an error while running the code. Please help me to figure out this.
encoding = face_recognition.face_encodings(image)[0]
IndexError: list index out of range
Thanks in advance!
Hey- I'm not sentdex, but I had the same problem as you- what I did was first check to see if the known images even detected a face in the first place by doing:
if len(face_recognition.face_encodings(image)) > 0:
and then indented the code after that in the loop. Hopefully that helps!
I get this error when I tested the code tho...
return np.linalg.norm(face_encodings - face_to_compare, axis=1)
ValueError: operands could not be broadcast together with shapes (6,) (128,)
yes I'm getting the same error do let me know if you find fix
@sentdex I'm also getting this error
this happens if there is no face found in known images, just add an if statement to see if encoding has any elements before appending it :
...
encoding = face_recognition.face_encodings(face)
if encoding :
knownFaces.append(encoding)
...
can u tell me why is it throwing a value errorr return np.linalg.norm(face_encodings - face_to_compare, axis=1)
ValueError: operands could not be broadcast together with shapes (1,14) (128,)
how did u solve it, plz say
Ur videos r awesome. Thank u so much. U r really cool, when coding 😁
Hi , i got
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_CXX_COMPILER could be found. even though cmake is installed
me too .. I tried adding compilers path to environment var but it didn't work
I am getting the following errors
"VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
return np.linalg.norm(face_encodings - face_to_compare, axis=1)"
"ValueError: operands could not be broadcast together with shapes "
I found my next project! This looks sweet
why is VS needed cant we do it in VSCode?
has anyone tried running this on mac and pycharm my laptop starts lagging and the code isnt giving out an error but it stops working after the first for loop
It due to the load of the program . I prefer u to use model="hog" instead of cnn .it may solve your issue
Nice tutorial buddy
is there somewhere the code you show? not image, the code with video like you show? no link to find for me...
i get an error from the results line. ValueError: operands could not be broadcast together with shapes (8,) (128,)
Great tutorial buddy
Glad you liked it
hello thanks for the video. But I have a doubt with this library, is there a function to know the confidence and accuracy of our system?
for filename in os.listdir(f"{KNOWN_FACES_DIR}/{name}")
^
i am getting this when I run it can you someone help me?
Anyone got this error?
for filename in os.listdir(f'{KNOWN_FACES_DIR}/{name}'): says syntax invalid and the last bracket was highlighted. Triple-checked against Sentdex's code but didn't find any difference
Could copy and paste the code from: pythonprogramming.net/facial-recognition-python/
i have the same error even when I copy and paste my code, did you find a solution
Hi, did you use CUDA in this script? Or was this running on your CPU alone? I am running the face_recognition package with dlib on Windows and it's pretty damn slow.
and he is back
this library is good for face detection, for face recognition better use something like Facenet (you can find couple TensorFlow Keras implementation of Facenet)
How did you make accuracy and loss functions by using the face recognition library?
index error at line 21 when using other images than yours, any fixes ?
I got an error:
for filename in os.listdir(f"{KNOWN_FACES_DIR}/{name}"):
NotADirectoryError: [Errno 20] Not a directory: 'known_faces/.DS_Store'
Hi Raj, looks like you are on Mac and a hidden MacOS folder is creeping in for ya. Try to exclude it from your list and you will be good to go, Best!
How to get next match image ? which key I have to press to display net image ?
Hey, love the tutorial but i got an error that i cant fix, ValueError: operands could not be broadcast together with shapes (22,) (128,).
Also if i use the index to detect faces it says im out of range. No clue.
RuntimeError: Error while calling cudaMalloc(&data, new_size*sizeof(float)) in file /tmp/pip-build-3ma07mx9/dlib/dlib/cuda/gpu_data.cpp:218. code: 2, reason: out of memory
i have a 6gb 1660ti and 24x 4mb worth of unknown faces
Please do the video example, ur videos are great! Keep it up
I need help? can you make a video in a facial recognition project that sends an alert message when an unauthorized person detects?
FYI: Kite has a history of acquiring Python libraries (One of them is autocomplete-python), then modified them to show ads and added telemetry. So they can basically intercept your code.
They tried that as a business model long ago and it didnt go well for them. They've addressed that history on their blog if you want to learn more.
@@sentdex Yes they posted a 'non-apology' apology on their blog. The question that everyone needs to decide themselves is, have they really learned and are they now trustworthy?
I would love to see you tackle the PennyLane library (Quantum Neural Networks). Since you are the bleeding edge of codetubers and all
module 'face_recognition' has no attribute 'face_encoding'
getting this error after solving a lot of errors
I keep getting this error NotADirectoryError: [WinError 267] The directory name is invalid: for this line for filename in os.listdir(f'{KNOWN_FACES_DIR}/{name}'): I know it has something to do with windows because when I print it it keeps coming up as the path is "known_faces\\filename.jpg" with double backslash. How do I work around this?
what is the editor you are using so we can do the same as you
Sir, I didn't understand the part where you used location[0] and location[3] to represent the top left corner. Why 3?
what is the maximum number of classes that we can train this for??
I follow ur code but why i still get this ?
segmentation fault (core dumped)
Did you have any solution?
Thanks
I got one error: 'known_faces/001.jpg
you should try placing your image "001.jpg" in a subfolder like this: "known_faces/PersonA/001.jpg"
I cant get it to find the known faces directory, any advice?
I am eagerly waiting for Neural networks from scratch videos. Will it be coming anytime soon?
I am using windows machine, and face_recognition is giving error and unable to install it. Tried with installing the dependent library which is dlib ( pip install dlib), but that too failed. Any pointer on this will be helpful.
me too
26.43 the answer = Ubuntu lmao... also, are you using python3/pip3 as i see you just typing "python" or "pip" and not "python3" or "pip3" other than that keep up the great work and thank you for your time and knowledge!
28:36 hahahahhaha 🤣 , great video !!!
hi ,
pip install face_Recognition is not working for me!! can you suggest some other ways for installing it on Windows 10 PC??
how can i run this with 4 cpus to speed up the search process with larger datasets
What is the algorithm which face_recognition package of python uses?
I try this with servo if it recognize, but it loop up to 4 times even I already hide my face? what to do?
hey @sentdex,
i keep on getting
ValueError: operands could not be broadcast together with shapes (3,) (128,)