Valentin
Init
9bda838
|
Raw History Blame Contribute Delete
1.75 kB
metadata
title: Face Quality Analyser API
emoji: 🔍
colorFrom: blue
colorTo: purple
sdk: docker
pinned: true

Face Quality Analysis API

A FastAPI service that analyzes face quality from images using InsightFace's Face Quality Assessment (PyTorch + ONNX).

Features

  • Simple REST API with single endpoint
  • Face detection and quality assessment using InsightFace
  • Returns quality score between 0.0 (lowest) and 1.0 (highest)
  • CORS-enabled for web applications
  • Docker-ready deployment

API Usage

Endpoint

GET /?url=IMAGE_URL

Parameters

  • url (required): Direct URL to an image file (JPEG, PNG, etc.)

Response

{
  "faceQuality": 0.856
}

The faceQuality field returns a face quality index where:

  • 0.0 = Lowest quality face detection
  • 1.0 = Highest quality face detection
  • 0.5 = Default value when no face is detected

Example Request

curl "http://localhost:8000/?url=https://example.com/photo.jpg"

Local Development

Prerequisites

  • Python 3.11+
  • Virtual environment (recommended)

Installation

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run the server
python app/main.py

The API will be available at http://localhost:8000

Docker Deployment

# Build the image
docker build -t face-quality-api .

# Run the container
docker run -p 7860:7860 face-quality-api

Technology Stack

  • FastAPI: Modern, fast web framework
  • InsightFace: State-of-the-art face analysis library
  • ONNX Runtime: Optimized inference engine
  • OpenCV: Image processing
  • Docker: Containerized deployment