Skip to content

Instantly share code, notes, and snippets.

@cnmoro
Created March 7, 2025 14:00
Show Gist options
  • Save cnmoro/9caea33ec211a359abcb26c685fbaa09 to your computer and use it in GitHub Desktop.
Save cnmoro/9caea33ec211a359abcb26c685fbaa09 to your computer and use it in GitHub Desktop.
antelopev2-face-features.py
# 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