mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-03 07:45:07 -05:00
Similar to the existing node, but without any resizing and with a revised model loading API that uses the model manager. All code related to the invocation now lives in the Invoke repo.
16 lines
585 B
Python
16 lines
585 B
Python
# Adapted from https://github.com/huggingface/controlnet_aux
|
|
|
|
from PIL import Image
|
|
|
|
from invokeai.backend.image_util.mediapipe_face.mediapipe_face_common import generate_annotation
|
|
from invokeai.backend.image_util.util import np_to_pil, pil_to_np
|
|
|
|
|
|
def detect_faces(image: Image.Image, max_faces: int = 1, min_confidence: float = 0.5) -> Image.Image:
|
|
"""Detects faces in an image using MediaPipe."""
|
|
|
|
np_img = pil_to_np(image)
|
|
detected_map = generate_annotation(np_img, max_faces, min_confidence)
|
|
detected_map_pil = np_to_pil(detected_map)
|
|
return detected_map_pil
|