Traceback (most recent call last):
File "/home/papi/Documents/face_recognition-master/examples/find_faces_in_picture.py", line 5, in <module>
image =face_recognition.load_image_file ("obama.jpg")
File "/home/papi/.local/lib/python2.7/site-packages/face_recognition/api.py", line 84, in load_image_file
return scipy.misc.imread(file, mode=mode)
File "/home/papi/.local/lib/python2.7/site-packages/numpy/lib/utils.py", line 101, in newfunc
return func(*args, **kwds)
File "/home/papi/.local/lib/python2.7/site-packages/scipy/misc/pilutil.py", line 164, in imread
im = Image.open(name)
File "/home/papi/.local/lib/python2.7/site-packages/PIL/Image.py", line 2543, in open
fp = builtins.open(filename, "rb")
IOError: [Errno 2] No such file or directory: 'obama.jpg'
[Finished in 2.916s]
''Could it be that is running it on python2.7 instead of 3? I currently use ATOM for python.''
The error is that it can't find the file obama.jpg. Is there an obama.jpg file in the folder from where you are running the example?
Yes I’m in the example folder where all the .py and images are , there is an image name obama.jpg my guess is the obama.jpg needs to be somewhere else
It depends on how you run the code. The working folder is the folder you ran the code from. How exactly did you run the code?
The folder looks like this
-example(folder)
///-find_faces_in_picture.py
///-(the rest of the archives face_distance .py etc..)
///-obama.jpg
///-(more images ,obama320,Biden etc)
///-:knn_examples(folder)
I run th code on atom use the shortcut ctrl+shif+B or run in the terminal in the folder as ‘python find_faces_in_picture.py’
I'm not sure how your system is configured. But you could just edit the find_faces_in_picture.py script and replace the reference to obama.jpg in the script with /home/papi/Documents/face_recognition-master/examples/obama.jpg so there's no chance it won't be able to find it.
So basically edit the code like this
image =face_recognition.load_image_file ("../home/papi/Documents/face_recognition-master/examples/obama.jpg")
Right?
no dots at the beginning of the filename
Thank you, but I still get an error
Traceback (most recent call last):
File "/home/papi/Documents/face_recognition-master/examples/find_faces_in_picture.py", line 10, in <module>
face_locations = face_recognition.load_image_file(image)
File "/home/papi/.local/lib/python2.7/site-packages/face_recognition/api.py", line 84, in load_image_file
return scipy.misc.imread(file, mode=mode)
File "/home/papi/.local/lib/python2.7/site-packages/numpy/lib/utils.py", line 101, in newfunc
return func(*args, **kwds)
File "/home/papi/.local/lib/python2.7/site-packages/scipy/misc/pilutil.py", line 164, in imread
im = Image.open(name)
File "/home/papi/.local/lib/python2.7/site-packages/PIL/Image.py", line 2549, in open
fp = io.BytesIO(fp.read())
AttributeError: 'numpy.ndarray' object has no attribute 'read'
And this is when a run it on the terminal
``papi@LordPapisilv:~/Documents/face_recognition-master/examples$ python3 find_faces_in_picture.py
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2414, in open
fp.seek(0)
AttributeError: 'numpy.ndarray' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "find_faces_in_picture.py", line 10, in
face_locations = face_recognition.load_image_file(image)
File "/usr/local/lib/python3.6/dist-packages/face_recognition/api.py", line 84, in load_image_file
return scipy.misc.imread(file, mode=mode)
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/utils.py", line 101, in newfunc
return func(args, *kwds)
File "/usr/local/lib/python3.6/dist-packages/scipy/misc/pilutil.py", line 164, in imread
im = Image.open(name)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2416, in open
fp = io.BytesIO(fp.read())
AttributeError: 'numpy.ndarray' object has no attribute 'read'````
I'm getting this error as well. Did you find a solution?
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2414, in open
fp.seek(0)
AttributeError: 'numpy.ndarray' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "find_faces_in_picture.py", line 10, in
face_locations = face_recognition.load_image_file(image)
File "/usr/local/lib/python3.6/dist-packages/face_recognition/api.py", line 84, in load_image_file
return scipy.misc.imread(file, mode=mode)
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/utils.py", line 101, in newfunc
return func(*args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/scipy/misc/pilutil.py", line 164, in imread
im = Image.open(name)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2416, in open
fp = io.BytesIO(fp.read())
AttributeError: 'numpy.ndarray' object has no attribute 'read'
Use the jupiter notebook you will get.
jupyter notebook
you need to navigate to the folder containing the file using the bash
for example
cd Desktop
cd face_recognition
cd examples
python3 face_recognition.py
Most helpful comment
It depends on how you run the code. The working folder is the folder you ran the code from. How exactly did you run the code?