Skip to main content

MMLLM Face Refinement

This project implements a novel approach to face detection by combining traditional face detection methods with multimodal large language models (MMLLM) for refinement and false positive elimination.

Approach

  1. Initial Detection: Use YOLOv11-Face to detect potential faces in images
  2. Refinement: Each detected face is then analyzed using multimodal LLMs:
    • Gemini API for cloud-based analysis
    • LLaVA-NeXT (local model) for on-device analysis
  3. False Positive Elimination: The LLMs determine if the detection is actually a face
  4. Bounding Box Refinement: The LLMs can suggest refinements to the bounding boxes

Requirements

  • Python 3.8+
  • See requirements.txt for all dependencies
  • YOLOv11-Face model file (yolov11l-face.pt) in the models directory

Installation

Automatic Installation

Linux/macOS

# Clone the repository
git clone https://github.com/JonathanLehner/mmllm-face-refinement.git
cd mmllm-face-refinement

# Run the installation script
chmod +x install.sh
./install.sh

Windows

# Clone the repository
git clone https://github.com/yourusername/mmllm-face-refinement.git
cd mmllm-face-refinement

# Run the installation script
install.bat

Manual Installation

  1. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate.bat
    
  2. Install the package:

    pip install -e .
    
  3. Download the YOLOv11-Face model:

  4. Set up API keys:

    cp .env.example .env
    # Edit .env file with your API keys
    

Usage

  1. Place input images in the input folder
  2. Run the main script: python main.py
  3. Results will be saved in the output folder

For debugging purposes, you can run the test script with debug enabled:

python test.py --image input/your_image.jpg --debug

Configuration

You can adjust parameters in config.yaml:

  • YOLO confidence threshold
  • Bounding box padding
  • LLM endpoint selection
  • Output formatting options
  • Debug settings

Debug Mode

The system includes a debug mode that saves intermediate results:

debug:
  enabled: true  # Enable debug mode
  save_raw_detections: true  # Save initial YOLO detections
  save_intermediate_steps: true  # Save cropped faces before LLM analysis

When debug mode is enabled, the following files are saved to the output/debug directory:

  • Images with YOLO detections visualized
  • JSON files with detection coordinates
  • Cropped face images before LLM processing
  • JSON files with detection metadata

References

This project utilizes the following models and repositories:

Upload to pipy

  • python -m build
  • pip install dist/mmllm_face_refinement-0.1.0-py3-none-any.whl
  • python -m twine upload dist/*

Note

This is a research project demonstrating the use of multimodal LLMs for improving traditional computer vision tasks.

Metadata

Release files for mmllm-face-refinement 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mmllm-face-refinement 0.1.12
File Size Uploaded
mmllm_face_refinement-0.1.12.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mmllm-face-refinement 0.1.12
File Interpreter ABI Platform
mmllm_face_refinement-0.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 28.8 kB

Release files / mmllm_face_refinement-0.1.12.tar.gz

Download URL mmllm_face_refinement-0.1.12.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
155c1d03121d8ee4b7f7aeec47676807d6ac0c947e5e9bc4ec22cda42a74a0aa
BLAKE2b-256 checksum
How to use checksums
32e3797f1ae6aaee940b2526e7bd6bdba5b35599cfe6dadfb93f9438d59f24cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / mmllm_face_refinement-0.1.12-py3-none-any.whl

Download URL mmllm_face_refinement-0.1.12-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe4be56a1492e23bd9fdad57eaed4099c272e327b54298f7df88f48b7460e3cb
BLAKE2b-256 checksum
How to use checksums
f6bc29a04d42d98113ae62a4bec4b68a58327519e65a64e86decc2cb2a579ec9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.12 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.5

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page