Skip to content

kamero-ai/face-count-api-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face Count API Lite

A lightweight, fast face counting API using OpenCV DNN. Returns the number of faces detected in an image.

Built for speed and low resource usage - ideal for serverless deployments.

Features

  • 🚀 Fast inference (~50ms per image)
  • 💾 Low memory footprint (~200MB)
  • 🐳 Docker ready
  • ☁️ DigitalOcean Functions compatible
  • 🔧 Simple JSON API

Quick Start

Using Docker

# Build
docker build -t face-count-api-lite .

# Run
docker run -p 8000:8000 face-count-api-lite

# Test
curl -X POST http://localhost:8000/count-faces -F "file=@photo.jpg"
# {"face_count": 2}

Local Development

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload

API

POST /count-faces

Upload an image and get the face count.

curl -X POST http://localhost:8000/count-faces \
  -F "file=@image.jpg"

Response:

{"face_count": 3}

GET /health

curl http://localhost:8000/health

Response:

{
  "status": "healthy",
  "model": "opencv-dnn-resnet10-ssd",
  "model_loaded": true
}

Deployment

DigitalOcean App Platform

  1. Fork this repo
  2. Connect to DO App Platform
  3. Deploy from Dockerfile

DigitalOcean Functions

doctl serverless install
doctl serverless connect
doctl serverless deploy .

Model

Uses OpenCV's pre-trained face detector:

  • Architecture: ResNet-10 SSD
  • Input size: 300x300
  • Model size: ~10MB

Performance

Metric Value
Inference time ~50ms
Memory usage ~200MB
Cold start ~2s

Limitations

  • Optimized for frontal faces
  • May miss small or distant faces in group photos
  • For higher accuracy with complex scenes, consider MTCNN-based solutions

License

MIT

Contributing

Contributions welcome! Please open an issue or PR.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors