資源簡介
python 照片人臉識別
代碼片段和文件信息
#?-*-?coding:?utf-8?-*-??
#??識別圖片中的所有人臉并顯示出來??
#?filename?:?find_faces_in_picture.py??
from?PIL?import?Image??
import?face_recognition??
#?將jpg文件加載到numpy?數組中??
image?=?face_recognition.load_image_file(“psb.jpg“)??
#?使用默認的給予HOG模型查找圖像中所有人臉??
#?這個方法已經相當準確了,但還是不如CNN模型那么準確,因為沒有使用GPU加速??
#?另請參見:?find_faces_in_picture_cnn.py??
face_locations?=?face_recognition.face_locations(image)??
#?使用CNN模型??
#?face_locations?=?face_recognition.face_locations(image?number_of_times_to_upsample=0?model=“cnn“)??
#?打印:我從圖片中找到了?多少?張人臉??
print(“I?found?{}?face(s)?in?this?photograph.“.format(len(face_locations)))??
#?循環找到的所有人臉??
for?face_location?in?face_locations:??
????????#?打印每張臉的位置信息??
????????top?right?bottom?left?=?face_location??
????????print(“A?face?is?located?at?pixel?location?Top:?{}?Left:?{}?Bottom:?{}?Right:?{}“.format(top?left?bottom?right))??
#?指定人臉的位置信息,然后顯示人臉圖片??
????????face_image?=?image[top:bottom?left:right]??
????????pil_image?=?Image.fromarray(face_image)??
????????pil_image.show()??
#?或者執行python文件
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????65??2020-08-01?17:00??說明.txt
?????文件???????1328??2020-08-01?16:54??照片人臉識別.py
-----------?---------??----------?-----??----
?????????????????1393????????????????????2
- 上一篇:恐龍快跑 游戲源碼(基于pygame)
- 下一篇:清理PDF中的空白頁
評論
共有 條評論