[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-01-13 (世界標準時間)。"],[],[],null,["# Face detection guide\n\nThe MediaPipe Face Detector task lets you detect faces in an image or video. You can use\nthis task to locate faces and facial features within a frame. This task uses a\nmachine learning (ML) model that works with single images or a continuous\nstream of images. The task outputs face locations, along with the following\nfacial key points: left eye, right eye, nose tip, mouth, left eye tragion, and\nright eye tragion.\n\n[Try it!arrow_forward](https://mediapipe-studio.webapps.google.com/demo/face_detector)\n\nGet Started\n-----------\n\nStart using this task by following one of these implementation guides for your\ntarget platform. These platform-specific guides walk you through a basic\nimplementation of this task, including a recommended model, and code example\nwith recommended configuration options:\n\n- **Android** - [Code\n example](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/face_detector/android) - [Guide](./android)\n- **Python** - [Code\n example](https://colab.sandbox.google.com/github/googlesamples/mediapipe/blob/main/examples/face_detector/python/face_detector.ipynb)- [Guide](./python)\n- **Web** - [Code\n example](https://codepen.io/mediapipe-preview/pen/OJByWQr) - [Guide](./web_js)\n- **iOS** - [Code\n example](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/face_detector/ios) - [Guide](./ios)\n\nTask details\n------------\n\nThis section describes the capabilities, inputs, outputs, and configuration\noptions of this task.\n\n### Features\n\n- **Input image processing** - Processing includes image rotation, resizing, normalization, and color space conversion.\n- **Score threshold** - Filter results based on prediction scores.\n\n| Task inputs | Task outputs |\n|--------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| The Face Detector accepts an input of one of the following data types: - Still images \u003c!-- --\u003e - Decoded video frames \u003c!-- --\u003e - Live video feed | The Face Detector outputs the following results: - Bounding boxes for detected faces in an image frame. \u003c!-- --\u003e - Coordinates for 6 face landmarks for each detected face. |\n\n### Configurations options\n\nThis task has the following configuration options:\n\n| Option Name | Description | Value Range | Default Value |\n|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|---------------|\n| `running_mode` | Sets the running mode for the task. There are three modes: \u003cbr /\u003e IMAGE: The mode for single image inputs. \u003cbr /\u003e VIDEO: The mode for decoded frames of a video. \u003cbr /\u003e LIVE_STREAM: The mode for a livestream of input data, such as from a camera. In this mode, resultListener must be called to set up a listener to receive results asynchronously. | {`IMAGE, VIDEO, LIVE_STREAM`} | `IMAGE` |\n| `min_detection_confidence` | The minimum confidence score for the face detection to be considered successful. | `Float [0,1]` | `0.5` |\n| `min_suppression_threshold` | The minimum non-maximum-suppression threshold for face detection to be considered overlapped. | `Float [0,1]` | `0.3` |\n| `result_callback` | Sets the result listener to receive the detection results asynchronously when the Face Detector is in the live stream mode. Can only be used when running mode is set to `LIVE_STREAM`. | `N/A` | `Not set` |\n\nModels\n------\n\nFace detection models can vary depending on their intended use cases, such as\nshort-range and long-range detection. Models also typically make trade-offs\nbetween performance, accuracy, resolution, and resource requirements, and in\nsome cases, include additional features.\n\nThe models listed in this section are variants of BlazeFace, a lightweight and\naccurate face detector optimized for mobile GPU inference. BlazeFace models are\nsuitable for applications like 3D facial keypoint estimation, expression\nclassification, and face region segmentation. BlazeFace uses a lightweight\nfeature extraction network similar to\n[MobileNetV1/V2](https://arxiv.org/abs/1704.04861).\n| **Attention:** This MediaPipe Solutions Preview is an early release. [Learn more](/edge/mediapipe/solutions/about#notice).\n\n### BlazeFace (short-range)\n\nA lightweight model for detecting single or multiple faces within selfie-like\nimages from a smartphone camera or webcam. The model is optimized for\nfront-facing phone camera images at short range. The model architecture uses a\nSingle Shot Detector (SSD) convolutional network technique with a custom\nencoder. For more information, see the research paper on\n[Single Shot MultiBox Detector](https://arxiv.org/abs/1512.02325).\n\n| Model name | Input shape | Quantization type | Model Card | Versions |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|-------------------|--------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| [BlazeFace (short-range)](https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/latest/blaze_face_short_range.tflite) | 128 x 128 | float 16 | [info](https://storage.googleapis.com/mediapipe-assets/MediaPipe%20BlazeFace%20Model%20Card%20(Short%20Range).pdf) | [Latest](https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/latest/blaze_face_short_range.tflite) |\n\n### BlazeFace (full-range)\n\nA relatively lightweight model for detecting single or multiple faces within\nimages from a smartphone camera or webcam. The model is optimized for full-range\nimages, like those taken with a back-facing phone camera images. The model\narchitecture uses a technique similar to a\n[CenterNet](https://arxiv.org/abs/1904.08189) convolutional network with a\ncustom encoder.\n\n| Model name | Input shape | Quantization type | Model Card | Versions |\n|------------------------|-------------|-------------------|------------|-------------|\n| BlazeFace (full-range) | 128 x 128 | float 16 | info | Coming soon |\n\n### BlazeFace Sparse (full-range)\n\nA lighter version of the regular full-range BlazeFace model, roughly 60% smaller\nin size. The model is optimized for full-range images, like those taken with a\nback-facing phone camera images. The model architecture uses a technique similar\nto a [CenterNet](https://arxiv.org/abs/1904.08189) convolutional network with a\ncustom encoder.\n\n| Model name | Input shape | Quantization type | Model Card | Versions |\n|-------------------------------|-------------|-------------------|------------|-------------|\n| BlazeFace Sparse (full-range) | 128 x 128 | float 16 | info | Coming soon |\n\nTask benchmarks\n---------------\n\nHere's the task benchmarks for the whole pipeline based on the above\npre-trained models. The latency result is the average latency on Pixel 6 using\nCPU / GPU.\n\n| Model Name | CPU Latency | GPU Latency |\n|-------------------------|-------------|-------------|\n| BlazeFace (short-range) | 2.94ms | 7.41ms |"]]