Downloads ยท 30 days
0
AI-Solutions-KK/face_recognition
face_recognition is a image classification model from AI-Solutions-KK. Use it when you need a label for an image. The card lists the license as mit.
Domain-specific face recognition model using:
Downloads ยท 30 days
0
Access
Public
Updated Nov 24, 2025
Repo size
42.7 MB
Likes
0
Public
Click a slice to open those files.
.pkl42.5 MB ยท 99%
From the Hugging Face model README
Domain-specific face recognition model using:
Designed to run efficiently on CPU, ideal for lightweight deployment and Streamlit apps.
| File | Description |
|---|---|
svc_model.pkl | Trained SVM classifier on FaceNet embeddings (105 classes) |
centroids.npy | Class centroids (mean embeddings per identity) |
classes.npy | List of identity labels (class order used by the SVM) |
README.md | Model documentation |
from huggingface_hub import hf_hub_download
import joblib
import numpy as np
REPO_ID = "AI-Solutions-KK/face_recognition"
svc_path = hf_hub_download(REPO_ID, "svc_model.pkl")
centroids_path = hf_hub_download(REPO_ID, "centroids.npy")
classes_path = hf_hub_download(REPO_ID, "classes.npy")
svc_model = joblib.load(svc_path)
centroids = np.load(centroids_path)
class_names = np.load(classes_path, allow_pickle=True)
print("Model loaded successfully. Classes:", len(class_names))
from huggingface_hub import hf_hub_download
import joblib, numpy as np, cv2, torch
from facenet_pytorch import InceptionResnetV1, MTCNN
REPO_ID = "AI-Solutions-KK/face_recognition"
# Load classifier + metadata
svc_path = hf_hub_download(REPO_ID, "svc_model.pkl")
classes_path = hf_hub_download(REPO_ID, "classes.npy")
obj = joblib.load(svc_path)
svc_model = obj["clf"]
normalizer = obj["norm"]
label_encoder = obj["le"]
class_names = np.load(classes_path, allow_pickle=True)
# Load FaceNet backbone + face detector
device = "cpu"
mtcnn = MTCNN(keep_all=False, device=device)
facenet = InceptionResnetV1(pretrained="vggface2").eval().to(device)
def get_embedding(img_path: str) -> np.ndarray:
img_bgr = cv2.imread(img_path)
if img_bgr is None:
raise ValueError(f"Could not read image: {img_path}")
img_rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
face = mtcnn(img_rgb)
if face is None:
raise ValueError("No face detected.")
if face.dim() == 3:
face = face.unsqueeze(0)
with torch.no_grad():
emb = facenet(face.to(device)).cpu().numpy()
return emb
def predict_face(img_path: str):
emb = get_embedding(img_path)
emb_norm = normalizer.transform(emb)
probs = svc_model.predict_proba(emb_norm)[0]
idx = np.argmax(probs)
label = label_encoder.inverse_transform([idx])[0]
confidence = float(probs[idx])
return label, confidence
# -------- RUN ----------
img_path = "test.jpg"
label, prob = predict_face(img_path)
print("Predicted Identity:", label)
print("Confidence Score:", prob)
AI-Solutions-KK/face_recognition_dataset.svc_model.pkl, classes.npy, centroids.npyDataset Repo
https://huggingface.co/datasets/AI-Solutions-KK/face_recognition_dataset
Demo App (Hugging Face)
https://huggingface.co/spaces/AI-Solutions-KK/face_recognition_model_demo_app
Stable Public Streamlit App
https://facerecognition-tq32v5qkt4ltslejzwymw8.streamlit.app/
Full Training Code & Documentation
https://github.com/AI-Solutions-KK/face_recognition_cnn_svm
root/class_name/image.jpg)svc_model.pklclasses.npycentroids.npyThen plug into your own app or the provided Streamlit demo.
Karan (AI-Solutions-KK)