Created
March 7, 2025 14:00
-
-
Save cnmoro/9caea33ec211a359abcb26c685fbaa09 to your computer and use it in GitHub Desktop.
antelopev2-face-features.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install -U insightface mxnet onnx onnxruntime | |
# Initialize the FaceAnalysis app with the Antelope model | |
from insightface.app import FaceAnalysis | |
app = FaceAnalysis(name='antelopev2', root='./', providers=['CPUExecutionProvider']) | |
# Remove nested folder from download if needed | |
app.prepare(ctx_id=-1, det_size=(640, 640)) | |
from PIL import Image | |
img = Image.open('82.png') | |
# Convert to numpy array | |
import numpy as np | |
img = np.array(img) | |
faces = app.get(img) | |
# Extract embeddings for each detected face | |
for face in faces: | |
embedding = face.embedding | |
embedding.shape # (512,) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment