ageitgey / ageitgey/face_recognition
load data from PIL croped image
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 56.8k
- Forks
- 13.7k
- PR merge metrics
- No merged PRs in 30d
Description
HI @ageitgey
VERY GOOD work! Thanks for your amazing work!
I met a small problem in my project .
I croped faces from a picture file by use PIL lib, code is here :
img = Image.open('1.jpg')
cropped = img.crop((xmin,ymin,xmax,ymax))
and then I wana compare to this face by using face_recognition ,
so I try encode face by using these code ::
// first I convert img to ns.array
...
cropped_byte_arr = io.BytesIO()
cropped.save(cropped_byte_arr, format='JPEG')
data = cropped_byte_arr.getvalue();
np.array(data)
// then i try to encode data
unknown_encoding = face_recognition.face_encodings(data)[0]
then I got an error :
File "face_my.py", line 282, in
bot.run(MATCH_LINE)
File "face_my.py", line 270, in run
score = self.compare_faces_FR(face_known,face_unknown)
File "face_my.py", line 219, in compare_faces_FR
unknown_encoding = face_recognition.face_encodings(unknownNp)[0]
File "/Users/youyin/anaconda3/lib/python3.6/site-packages/face_recognition/api.py", line 209, in face_encodings
raw_landmarks = _raw_face_landmarks(face_image, known_face_locations, model="small")
File "/Users/youyin/anaconda3/lib/python3.6/site-packages/face_recognition/api.py", line 153, in _raw_face_landmarks
face_locations = _raw_face_locations(face_image)
File "/Users/youyin/anaconda3/lib/python3.6/site-packages/face_recognition/api.py", line 102, in _raw_face_locations
return face_detector(img, number_of_times_to_upsample)
RuntimeError: Unsupported image type, must be 8bit gray or RGB image.
Is there any method to load face image from memory Not directly from image file?
Dose any one have some suggestions?
I think this is very useful for others !
thank you again!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in face_recognition/api.py at face_encodings and the _raw_face_locations call shown in the traceback. Reproduce the PIL crop and the in-memory conversion, then inspect the image type expected by the detector. Done means determining and documenting or supporting a valid in-memory image input without the reported unsupported-image-type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100