skills/libraries/deepface/deepface-basic-usage/SKILL.md
Basic usage guide for the DeepFace library (face recognition, verification, analysis).
npx skillsauth add igamenovoer/magic-context skills/libraries/deepface/deepface-basic-usageInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides a quick reference and guide for using the deepface library for face recognition tasks.
DeepFace is a hybrid face recognition framework for Python that wraps state-of-the-art models (VGG-Face, FaceNet, ArcFace, etc.) and detectors (RetinaFace, MtCNN, YOLO, etc.).
pip install deepface
# Or with pixi
pixi add deepface
Import:
from deepface import DeepFace
Determines if two images belong to the same person.
result = DeepFace.verify(
img1_path = "img1.jpg",
img2_path = "img2.jpg",
model_name = "VGG-Face", # Optional: see Model Selection below
detector_backend = "opencv", # Optional: see Detector Selection below
distance_metric = "cosine", # Optional: cosine, euclidean, euclidean_l2
align = True, # Optional: Align faces before verification
)
# result is a dict:
# {
# "verified": True,
# "distance": 0.256,
# "threshold": 0.40,
# "model": "VGG-Face",
# "detector_backend": "opencv",
# "similarity_metric": "cosine",
# "facial_areas": {"img1": {...}, "img2": {...}},
# "time": 1.23
# }
Finds identity of an input image in a database (folder of images).
Directory-based (find):
dfs = DeepFace.find(
img_path = "img.jpg",
db_path = "/path/to/images_folder",
model_name = "VGG-Face",
detector_backend = "opencv"
)
# Returns a list of pandas DataFrames (one per face detected in input)
Database-backed (search):
Supports backends like Postgres (pgvector), Pinecone, Milvus, Weaviate, etc.
# Register
DeepFace.register(img="img1.jpg")
# Search
dfs = DeepFace.search(img="target.jpg")
Predicts age, gender, race, and emotion.
objs = DeepFace.analyze(
img_path = "img.jpg",
actions = ['age', 'gender', 'race', 'emotion'],
detector_backend = "opencv"
)
# Returns a list of dicts (one per face)
Get the vector representation of a face.
embedding_objs = DeepFace.represent(
img_path = "img.jpg",
model_name = "VGG-Face",
detector_backend = "opencv"
)
# Returns list of dicts:
# [
# {
# "embedding": [0.1, 0.5, ...],
# "facial_area": {...}
# }
# ]
VGG-Face (default), Facenet, Facenet512, OpenFace, DeepFace, DeepID, ArcFace, Dlib, SFace, GhostFaceNet.
Recommendation:
ArcFace, Facenet512, VGG-FaceDeepFace, OpenFaceopencv (default, fast), ssd, dlib, mtcnn, retinaface (highly accurate), mediapipe, yolov8, centerface.
Recommendation:
opencv, ssdretinaface, mtcnncosine (default), euclidean, euclidean_l2.
~/.deepface/weights.ValueError. Set enforce_detection=False to skip detection (treats whole image as face) or handle the exception.
DeepFace.verify(..., enforce_detection=False)
retinaface or dlib), ensure their specific pip packages are installed.data-ai
Create readable Mermaid diagrams inside Markdown files. Use for flowcharts and sequence diagrams that must render cleanly in common Markdown renderers (e.g., GitHub) without horizontal scrolling. Covers fenced mermaid blocks, init/theme styling, label wrapping with <br/>, and sequenceDiagram layout rules (short IDs, wrapped labels, don’t break identifiers).
development
Manual invocation only; use only when the user explicitly requests `make-program-tutorial` by exact name, OR when the user asks to use a skill to create an SDK/API/library tutorial. Create a clear, reproducible, step-by-step tutorial for a specific API/SDK/library (or a set of functions/classes), with runnable examples, expected outputs, and basic troubleshooting.
testing
Use when the user wants to create a self-hosted, offline-installable Conda channel (mirror) containing a specific subset of packages using Pixi.
tools
Guides the agent to setup a new or existing Pixi environment for compiling C++ and CUDA code. It ensures the correct compilers, toolkits, and CMake configurations are in place for a robust user-space build.