Skip to main content

Face detection and LLM-based face refinement using YOLO and multimodal LLMs (Gemini, LLaVA).

Project description

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.

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

mmllm_face_refinement-0.1.8.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

mmllm_face_refinement-0.1.8-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file mmllm_face_refinement-0.1.8.tar.gz.

File metadata

  • Download URL: mmllm_face_refinement-0.1.8.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for mmllm_face_refinement-0.1.8.tar.gz
Algorithm Hash digest
SHA256 eb467eff47cfac0d56f5adba72a031ef7e8d17dfa49ff537f73f7ea0088aeee0
MD5 3e09a844a2d1e04dfb9b28742411a91d
BLAKE2b-256 49afb360d9483e7ae120ebb829e9357faf3d0870e98aa00a048d05f2c89a81d9

See more details on using hashes here.

File details

Details for the file mmllm_face_refinement-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for mmllm_face_refinement-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ce1d3fb0fa6fd6eae8bbb9f66e0e687aedf0063cfe81824de7d4611cd56b4c0c
MD5 0967a8d4496636cbe6372ef8c0e7c172
BLAKE2b-256 81870f97bc0007ec73f905f5c7a794d9d881631c6a0ef36bd33302f812c6353c

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