You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

技术问询:face_recognition.face_landmarks是否支持CNN模式

Answer to: Does face_recognition.face_landmarks support CNN mode?

Hey there! Great question—let's break this down clearly:

Short answer: The face_recognition.face_landmarks() method itself doesn't directly accept a "CNN mode" parameter, but you can absolutely use CNN-based face detection to power your landmark extraction. Here's how it works:

The face_landmarks() function relies on pre-detected face locations to extract facial landmarks. The face detection step (finding where faces are in the image) is handled separately by face_recognition.face_locations(), which does support both HOG (default, faster) and CNN (more accurate, slower) models.

Step-by-step code example using CNN mode:

First, use CNN to detect face positions, then pass those positions to face_landmarks():

import face_recognition

# Load your target image
image = face_recognition.load_image_file("test.jpg")

# Detect face locations using CNN model
cnn_face_locations = face_recognition.face_locations(image, model="cnn")

# Extract landmarks using the CNN-detected face positions
face_landmarks_list = face_recognition.face_landmarks(image, face_locations=cnn_face_locations)

# Print out the results (optional)
for landmarks in face_landmarks_list:
    print("Found facial landmarks for this face:")
    for feature, points in landmarks.items():
        print(f"- {feature}: {points}")

Why this matters:

Using the CNN model for face detection is helpful in trickier scenarios—like low-resolution images, faces at angles, or faces partially obscured. It's slower than the default HOG model, but trades speed for accuracy when you need it.

内容的提问来源于stack exchange,提问作者user2106796

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:13:08