Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zpc421126
face_recognition
提交
4d7bc049
F
face_recognition
项目概览
zpc421126
/
face_recognition
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
face_recognition
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4d7bc049
编写于
9月 02, 2019
作者:
T
Tejas Shah
提交者:
Adam Geitgey
12月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
allowed face_encodings to accept either 'large' or 'small' model
上级
a96484ed
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
2 deletion
+10
-2
face_recognition/api.py
face_recognition/api.py
+3
-2
tests/test_face_recognition.py
tests/test_face_recognition.py
+7
-0
未找到文件。
face_recognition/api.py
浏览文件 @
4d7bc049
...
...
@@ -200,16 +200,17 @@ def face_landmarks(face_image, face_locations=None, model="large"):
raise
ValueError
(
"Invalid landmarks model type. Supported models are ['small', 'large']."
)
def
face_encodings
(
face_image
,
known_face_locations
=
None
,
num_jitters
=
1
):
def
face_encodings
(
face_image
,
known_face_locations
=
None
,
num_jitters
=
1
,
model
=
"small"
):
"""
Given an image, return the 128-dimension face encoding for each face in the image.
:param face_image: The image that contains one or more faces
:param known_face_locations: Optional - the bounding boxes of each face if you already know them.
:param num_jitters: How many times to re-sample the face when calculating encoding. Higher is more accurate, but slower (i.e. 100 is 100x slower)
:param model: Optional - which model to use. "large" (default) or "small" which only returns 5 points but is faster.
:return: A list of 128-dimensional face encodings (one for each face in the image)
"""
raw_landmarks
=
_raw_face_landmarks
(
face_image
,
known_face_locations
,
model
=
"small"
)
raw_landmarks
=
_raw_face_landmarks
(
face_image
,
known_face_locations
,
model
)
return
[
np
.
array
(
face_encoder
.
compute_face_descriptor
(
face_image
,
raw_landmark_set
,
num_jitters
))
for
raw_landmark_set
in
raw_landmarks
]
...
...
tests/test_face_recognition.py
浏览文件 @
4d7bc049
...
...
@@ -152,6 +152,13 @@ class Test_face_recognition(unittest.TestCase):
self
.
assertEqual
(
len
(
encodings
),
1
)
self
.
assertEqual
(
len
(
encodings
[
0
]),
128
)
def
test_face_encodings_large_model
(
self
):
img
=
api
.
load_image_file
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'test_images'
,
'obama.jpg'
))
encodings
=
api
.
face_encodings
(
img
,
model
=
'large'
)
self
.
assertEqual
(
len
(
encodings
),
1
)
self
.
assertEqual
(
len
(
encodings
[
0
]),
128
)
def
test_face_distance
(
self
):
img_a1
=
api
.
load_image_file
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'test_images'
,
'obama.jpg'
))
img_a2
=
api
.
load_image_file
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'test_images'
,
'obama2.jpg'
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录