SamarthChugh/Custom-Face-Tracker-Model
07
π§βπ» Deep Face Tracker (TensorFlow / Keras)
This repository hosts a custom deep face tracking model trained in TensorFlow / Keras. The model is designed to detect and track faces in real-time video streams, making it useful for applications such as:
- Face detection & tracking
- Eye/landmark tracking (extendable)
- Real-time video analysis
π οΈ Model Details
- Framework: TensorFlow / Keras (
.kerasformat) - Input: RGB image frames (preprocessed to the modelβs training resolution, e.g.,
120x120) - Output:
- Bounding box coordinates
- Face presence classification
π₯ Usage
1. Load the model from Hugging Face Hub
import tensorflow as tf
from huggingface_hub import hf_hub_download
# Download model file
model_path = hf_hub_download(
repo_id="your-username/face-tracker-tf",
filename="face_tracker.keras"
)
# Load the model
model = tf.keras.models.load_model(model_path)2. Run Inference on Frame
import cv2
import tensorflow as tf
import numpy as np
cap = cv2.VideoCapture(0)
while cap.isOpened():
_, frame = cap.read()
frame = frame[50:500, 50:500, :]
rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
resized = tf.image.resize(rgb, (120,120))
yhat = model.predict(np.expand_dims(resized/255,0))
sample_coords = yhat[1][0]
if yhat[0] > 0.5 :
# control the main rectangle
cv2.rectangle(frame,
tuple(np.multiply(sample_coords[:2], [450,450]).astype(int)),
tuple(np.multiply(sample_coords[2:], [450,450]).astype(int)),
color=(255,0,0), thickness=2)
# control label rectangle
cv2.rectangle(frame,
tuple(np.add(np.multiply(sample_coords[:2], [450,450]).astype(int), [0,-30])),
tuple(np.add(np.multiply(sample_coords[:2], [450,450]).astype(int), [80,0])),
color=(255,0,0), thickness=2)
# controls the text rendered
cv2.putText(frame, 'face', tuple(np.add(np.multiply(sample_coords[:2], [450,450]).astype(int), [0,-5])),
cv2.FONT_HERSHEY_SIMPLEX, 1, (255,255,255), 2, cv2.LINE_AA)
cv2.imshow('EyeTrack', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
if cv2.getWindowProperty('EyeTrack', cv2.WND_PROP_VISIBLE) < 1:
break
cap.release()
cv2.destroyAllWindows()π Training
- Data: Custom labeled dataset (using Labelme)
- Augmentation: Albumentations for better generalization
- Losses: Combination of classification loss + localization loss
- Optimizer: Adam
β οΈ Limitations
- Works best on front-facing faces in controlled lighting
- Trained on a limited dataset (may not generalize perfectly in the wild)
- Not a replacement for production-grade trackers (e.g., MediaPipe FaceMesh, OpenCV Haar cascades)
π License
This model is shared for research and educational purposes. Please check licensing terms before using in commercial applications.
β¨ Citation
@misc{samarth2025facetracker,
author = {Samarth Chugh},
title = {Deep Face Tracker (TensorFlow/Keras)},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/PredatorAlpha/Custom-Face-Tracker-Model}},
}