A simple Flask-based API that extracts the highest-confidence face from an image
596
A simple Flask-based API that extracts the highest-confidence face from an image, expands its bounding box by 20%, and returns the cropped image as a downloadable JPEG file without saving it on the server. The API supports two methods of image input: providing an image URL or uploading an image file.
Clone this repository:
git clone https://github.com/your_username/face-extraction-api.git
cd face-extraction-api
Install the required dependencies:
pip install -r requirements.txt
Run the Flask application:
python app.py
The API will be available at http://localhost:5000.
Build the Docker image:
docker build -t face-extraction-api .
Run the Docker container:
docker run -p 5000:5000 face-extraction-api
Docker compose file:
version: '3.8'
services:
face-extraction-api:
image: blazordevlab/face-extraction-api:latest
container_name: faceextraction
ports:
- "5000:5000"
labels:
- "traefik.enable=true"
# Replace 'faceextraction.example.com' with your actual domain
- "traefik.http.routers.faceextraction.rule=Host(`faceextraction.example.com`)"
- "traefik.http.routers.faceextraction.tls=true"
- "traefik.http.routers.faceextraction.entrypoints=https"
- "traefik.http.services.faceextraction.loadbalancer.server.port=5000"
- "traefik.docker.network=proxy"
networks:
proxy:
security_opt:
- no-new-privileges:true
networks:
proxy:
external: true
Endpoint: /extract_face
Method: POST
Payload: JSON object containing the image_url key.
Example JSON Payload:
{
"image_url": "https://example.com/your_image.jpg"
}
Response: Returns the cropped face image as a downloadable JPEG file.
Endpoint: /upload_extract_face
Method: POST
Payload: Form-data with an image file in the file field.
Example using curl:
curl -X POST -F "file=@/path/to/your_image.jpg" http://localhost:5000/upload_extract_face --output extracted_face.jpg
Response: Returns the cropped face image as a downloadable JPEG file.
This project is licensed under the MIT License.
Content type
Image
Digest
sha256:127baec73…
Size
1.7 GB
Last updated
9 months ago
docker pull blazordevlab/face-extraction-api