Skip to main content

A modern face recognition library with automatic learning, vector search, and AI assistant support

Project description

RojakFace

A modern face recognition library with automatic learning, vector search, and AI assistant support.

Built with YuNet (deep-learning face detector) and CLIP-based embeddings (imgbeddings) for accurate face detection and recognition.

Features

  • YuNet Face Detector — Deep-learning ONNX model from OpenCV Zoo. More accurate than Haar cascades, detects faces at various angles and sizes.
  • Automatic Learning — Upload a group photo and it will detect every face, recognize known identities, and automatically learn new ones with unique IDs.
  • Smart Deduplication — Two-phase batch processing prevents cross-matching within the same image. Each face is compared against the existing database before any new vectors are inserted.
  • Hybrid Storage — PostgreSQL for metadata and sighting records, Qdrant for 768-d vector similarity search (cosine distance).
  • Pluggable Storage — Swap between local filesystem and MinIO (S3-compatible) without changing code.
  • AI-Ready — Built for LLM integration. Provides structured identity context with image URLs for AI assistants (Ollama, OpenAI, etc.).
  • Identity Renaming — Rename across both PostgreSQL and Qdrant with one call.

Installation

pip install RojakFace

Quick Start

import RojakFace as RF
import psycopg2
from qdrant_client import QdrantClient

# 1. Setup connections
pg_conn = psycopg2.connect(database="faces_db", user="dev", password="password")
q_client = QdrantClient("localhost", port=6333)

# 2. Initialize manager
manager = RF.RojakFaceManager(pg_conn, q_client)
manager.init_storage()

# 3. Upload and auto-learn
stats = manager.auto_learn("group_photo.jpg", filename="family.jpg")
print(f"{stats['new_faces']} new faces, {stats['known_faces']} known")

# 4. Rename an identity
manager.update_identity("Person_abc123", "Mom")

# 5. Recognize without saving
results = manager.recognize("new_photo.jpg")
for face in results:
    print(f"{face['identity']} ({face['confidence']:.2f})")

Storage

LocalStorage (default)

storage = RF.LocalStorage(base_path="/path/to/images")
manager = RF.RojakFaceManager(pg_conn, q_client, storage=storage)

MinIO (S3-compatible)

storage = RF.MinioStorage(
    endpoint="localhost:9000",
    access_key="minioadmin",
    secret_key="minioadmin",
    bucket_name="rojakface",
)
manager = RF.RojakFaceManager(pg_conn, q_client, storage=storage)

Custom Storage

from RojakFace import BaseStorage

class MyStorage(BaseStorage):
    def save_image(self, image_data, folder, filename): ...
    def get_url(self, folder, filename): ...

API

RojakFace

Low-level detector with YuNet + imgbeddings.

detector = RF.RojakFace()
results = detector.extract_features("image.jpg")
# Returns: [{ 'box': [x,y,w,h], 'confidence': 0.92, 'embedding': [...], 'face_image': np.array }]

RojakFaceManager

Method Description
init_storage() Create PostgreSQL table and Qdrant collection
auto_learn(image, threshold=0.85, filename=None) Detect, recognize known, learn new
recognize(image, limit=1, threshold=0.7) Recognize without saving
update_identity(old, new) Rename across all storage backends

Requirements

  • Python >= 3.8
  • PostgreSQL (with psycopg2)
  • Qdrant vector database
  • Ollama (optional, for AI chat features)

Made by lqmnwido

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rojakface-1.0.0.tar.gz (150.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rojakface-1.0.0-py3-none-any.whl (152.6 kB view details)

Uploaded Python 3

File details

Details for the file rojakface-1.0.0.tar.gz.

File metadata

  • Download URL: rojakface-1.0.0.tar.gz
  • Upload date:
  • Size: 150.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rojakface-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c12e8ceaf7aefefedc20a8bea69ba68a52aec56ae46322ecb397553107730ecf
MD5 50213ff0cbc46a1cf40b40a0c898208f
BLAKE2b-256 45934755d698e949fdf8a78c8972b69c319d50ff1819d360af9a82b12399d1a7

See more details on using hashes here.

File details

Details for the file rojakface-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rojakface-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 152.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rojakface-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6645dd8b4771c5f68cd4d083d938491d07ae5fe919f0f9b9a7f7cd79b3ca39df
MD5 ab31f9f95edc0ca09835cda06db59cfb
BLAKE2b-256 5a5594519347978655242c80f0e18fe7deccd148389c4f097ea4b2d954c578f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page