Spaces:
Runtime error
Runtime error
AnnSankavi commited on
Commit ·
6bc00f6
1
Parent(s): af55765
clean up
Browse files
README.md
CHANGED
|
@@ -1,146 +1,25 @@
|
|
| 1 |
-
<<<<<<< HEAD
|
| 2 |
-
# Face Verification API
|
| 3 |
-
|
| 4 |
-
A self-hosted Python backend for face enrollment and authentication, replacing FaceIO.
|
| 5 |
-
|
| 6 |
-
## Prerequisites
|
| 7 |
-
|
| 8 |
-
- Python 3.9+
|
| 9 |
-
- pip (Python package manager)
|
| 10 |
-
- CMake and dlib dependencies (required for face_recognition)
|
| 11 |
-
|
| 12 |
-
### Windows Setup
|
| 13 |
-
|
| 14 |
-
1. Install Visual Studio Build Tools with C++ development tools
|
| 15 |
-
2. Install CMake: `winget install cmake`
|
| 16 |
-
|
| 17 |
-
### Linux/Mac Setup
|
| 18 |
-
|
| 19 |
-
```bash
|
| 20 |
-
# Ubuntu/Debian
|
| 21 |
-
sudo apt-get install build-essential cmake
|
| 22 |
-
|
| 23 |
-
# macOS
|
| 24 |
-
brew install cmake
|
| 25 |
-
```
|
| 26 |
-
|
| 27 |
-
## Installation
|
| 28 |
-
|
| 29 |
-
```bash
|
| 30 |
-
cd services/face-api
|
| 31 |
-
|
| 32 |
-
# Create virtual environment
|
| 33 |
-
python -m venv venv
|
| 34 |
-
|
| 35 |
-
# Activate virtual environment
|
| 36 |
-
# Windows:
|
| 37 |
-
venv\Scripts\activate
|
| 38 |
-
# Linux/Mac:
|
| 39 |
-
source venv/bin/activate
|
| 40 |
-
|
| 41 |
-
# Install dependencies
|
| 42 |
-
pip install -r requirements.txt
|
| 43 |
-
```
|
| 44 |
-
|
| 45 |
-
## Configuration
|
| 46 |
-
|
| 47 |
-
Copy `.env.example` to `.env` and adjust settings:
|
| 48 |
-
|
| 49 |
-
```bash
|
| 50 |
-
cp .env.example .env
|
| 51 |
-
```
|
| 52 |
-
|
| 53 |
-
Configuration options:
|
| 54 |
-
- `FACE_MATCH_THRESHOLD`: Face matching strictness (0.6 recommended)
|
| 55 |
-
- `ALLOWED_ORIGINS`: CORS origins (comma-separated)
|
| 56 |
-
- `PORT`: Server port (default: 8000)
|
| 57 |
-
|
| 58 |
-
## Running the Server
|
| 59 |
-
|
| 60 |
-
```bash
|
| 61 |
-
# Development with auto-reload
|
| 62 |
-
python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
| 63 |
-
|
| 64 |
-
# Production
|
| 65 |
-
python main.py
|
| 66 |
-
```
|
| 67 |
-
|
| 68 |
-
## API Endpoints
|
| 69 |
-
|
| 70 |
-
### Health Check
|
| 71 |
-
```
|
| 72 |
-
GET /health
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
### Enroll Face
|
| 76 |
-
```
|
| 77 |
-
POST /enroll
|
| 78 |
-
Content-Type: application/json
|
| 79 |
-
|
| 80 |
-
{
|
| 81 |
-
"image_base64": "base64_encoded_image",
|
| 82 |
-
"user_id": "user_uuid",
|
| 83 |
-
"metadata": {} // optional
|
| 84 |
-
}
|
| 85 |
-
```
|
| 86 |
-
|
| 87 |
-
Response:
|
| 88 |
-
```json
|
| 89 |
-
{
|
| 90 |
-
"success": true,
|
| 91 |
-
"face_id": "face_user_uuid_timestamp",
|
| 92 |
-
"face_embedding": [128 float values],
|
| 93 |
-
"message": "Face enrolled successfully"
|
| 94 |
-
}
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
### Verify Face
|
| 98 |
-
```
|
| 99 |
-
POST /verify
|
| 100 |
-
Content-Type: application/json
|
| 101 |
-
|
| 102 |
-
{
|
| 103 |
-
"image_base64": "base64_encoded_image",
|
| 104 |
-
"stored_embedding": [128 float values],
|
| 105 |
-
"user_id": "user_uuid" // optional
|
| 106 |
-
}
|
| 107 |
-
```
|
| 108 |
-
|
| 109 |
-
Response:
|
| 110 |
-
```json
|
| 111 |
-
{
|
| 112 |
-
"success": true,
|
| 113 |
-
"match": true,
|
| 114 |
-
"confidence": 0.85,
|
| 115 |
-
"message": "Face verified successfully"
|
| 116 |
-
}
|
| 117 |
-
```
|
| 118 |
-
|
| 119 |
-
## Testing
|
| 120 |
-
|
| 121 |
-
```bash
|
| 122 |
-
curl http://localhost:8000/health
|
| 123 |
-
```
|
| 124 |
-
=======
|
| 125 |
---
|
| 126 |
title: Face API
|
| 127 |
-
emoji:
|
| 128 |
colorFrom: blue
|
| 129 |
-
colorTo:
|
| 130 |
sdk: docker
|
|
|
|
| 131 |
pinned: false
|
| 132 |
---
|
| 133 |
|
| 134 |
-
# Face
|
| 135 |
|
| 136 |
-
|
| 137 |
|
| 138 |
## Endpoints
|
| 139 |
|
| 140 |
-
- `/health`
|
| 141 |
-
- `/
|
|
|
|
| 142 |
|
| 143 |
-
##
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Face API
|
| 3 |
+
emoji: "🙂"
|
| 4 |
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Face Verification API
|
| 12 |
|
| 13 |
+
A FastAPI backend for face enrollment and verification using `face_recognition`.
|
| 14 |
|
| 15 |
## Endpoints
|
| 16 |
|
| 17 |
+
- `GET /health` - health check
|
| 18 |
+
- `POST /enroll` - create a face embedding
|
| 19 |
+
- `POST /verify` - compare an image to a stored embedding
|
| 20 |
|
| 21 |
+
## Environment
|
| 22 |
|
| 23 |
+
- `FACE_MATCH_THRESHOLD` (default `0.6`)
|
| 24 |
+
- `ALLOWED_ORIGINS` (default `*`)
|
| 25 |
+
*** End Patch"}done to=functions.apply_patch code 天天彩 to=functions.apply_patch code to=functions.apply_patch code ӡб to=functions.apply_patch code ాను to=functions.apply_patch code 菲娱 to=functions.apply_patch code 【อ่านข้อความเต็ม to=functions.apply_patch code 天天爱彩票怎么 to=functions.apply_patch code 北京赛车冠军 to=functions.apply_patch code കോടത to=functions.apply_patch code ర్ట to=functions.apply_patch code , the output being:
|