YOLOv8 Face Detection
You need to perform setup steps to use Hugging Face models
This guide will walk you through setting up a Hugging Face account, creating an access token, and installing the required models to make this node fully functional.
What is it?
YOLOv8 Face Detection is a computer vision node that detects human faces in images using the YOLOv8 (You Only Look Once version 8) object detection model from 🤗 Hugging Face. The node processes images and returns bounding box coordinates for each detected face along with confidence scores.
The implementation uses the arnabdhar/YOLOv8-Face-Detection model, which is specifically trained for face detection tasks and provides fast, accurate results suitable for real-time applications.
When would I use it?
Use this node when you need to:
- Detect faces in images for face recognition pipelines
- Crop or extract face regions from photos
- Count the number of people in an image
- Filter images based on face presence or absence
- Create face-focused compositions or effects
- Process images for privacy protection (face blurring/masking)
- Build automated photo organization systems
- Implement face-based access control systems
How to use it
Basic Setup
-
Add the Node:
- Add a "YOLOv8 Face Detection" node to your workflow
- The node will automatically download the model on first use (requires Hugging Face access)
-
Connect Input:
- Connect an
ImageArtifactorImageUrlArtifactto theinput_imageparameter - This can come from file loaders, image generation nodes, or other image processing nodes
- Connect an
-
Configure Parameters:
- Set the
confidence_threshold(0.0-1.0) to filter detections - Optionally set
dilation(0-100%) to expand the detected bounding boxes
- Set the
-
Run Detection:
- Execute the node to detect faces in the input image
- The
detected_facesoutput will contain a list of face detections
Parameters
Input Parameters
-
input_image (required)
- Type:
ImageArtifactorImageUrlArtifact - The image to analyze for face detection
- Type:
-
confidence_threshold
- Type:
float(0.0-1.0) - Default:
0.5 - Minimum confidence score for a detection to be included in the results
- Higher values = fewer but more confident detections
- Lower values = more detections but may include false positives
- Type:
-
dilation
- Type:
float(0.0-100.0) - Default:
0.0 - Percentage to expand bounding boxes while keeping them centered
- Useful for including more context around detected faces
- Example:
10.0expands the box by 10% in all directions
- Type:
Output Parameters
-
detected_faces
- Type:
list - A list of detected faces, each containing:
x: Top-left x-coordinate of the bounding boxy: Top-left y-coordinate of the bounding boxwidth: Width of the bounding boxheight: Height of the bounding boxconfidence: Detection confidence score (0.0-1.0)
- Type:
-
logs
- Type:
string - Detailed logs of the detection process including:
- Model loading status
- Detection parameters
- Number of faces detected
- Type:
Output Format
Each detected face is represented as a dictionary:
{
"x": 150,
"y": 200,
"width": 300,
"height": 350,
"confidence": 0.95
}
The bounding box coordinates are in pixels relative to the input image dimensions, with the origin (0,0) at the top-left corner.
Example Workflows
Basic Face Detection
- Load an image using "File to Bytes" or similar node
- Connect to YOLOv8 Face Detection's
input_image - Set
confidence_thresholdto0.5for balanced detection - The
detected_facesoutput contains all face locations and confidence scores
Face Cropping Pipeline
- Detect faces using YOLOv8 Face Detection
- Set
dilationto10.0to include some background around faces - Connect
detected_facesto a "Crop Image" node - Extract individual face images for further processing
High-Confidence Detection Only
- Set
confidence_thresholdto0.8or higher - This filters out uncertain detections
- Ideal for applications requiring high precision
Advanced Features
- Automatic Model Caching: Downloaded models are cached locally for faster subsequent runs
- Boundary Clamping: Dilated bounding boxes are automatically clamped to image boundaries
- Centered Dilation: Box expansion maintains the center point of the original detection
- Batch-Compatible: Process multiple images by connecting to loop structures
Performance Considerations
- First Run: The initial execution downloads the model (~6MB), which may take a few moments
- Subsequent Runs: Cached models load almost instantly
- Image Size: Larger images take longer to process but may detect more distant faces
- Detection Speed: YOLOv8 is optimized for real-time performance, typically processing images in milliseconds
- Memory Usage: Model requires ~50MB of RAM when loaded
Common Issues
- Missing API Key: Ensure the Hugging Face API token is set as
HF_TOKEN; instructions for that are in this guide - Model Not Found: If you see "model not available" warnings, click the provided link to open the Model Manager and download the model
- No Faces Detected: Try lowering the
confidence_thresholdif you expect faces but none are detected - Too Many False Positives: Increase the
confidence_thresholdto filter out low-confidence detections - Bounding Box Issues: If boxes seem too tight, increase the
dilationparameter to add padding
Technical Details
- Model: YOLOv8 Face Detection from Hugging Face (
arnabdhar/YOLOv8-Face-Detection) - Architecture: YOLOv8 object detection framework specialized for face detection
- Dependencies:
ultralytics>=8.0.0,supervision>=0.20.0 - Output Format: Standard bounding box format (x, y, width, height) with confidence scores
- Processing: Single-pass detection, optimized for speed and accuracy