Spaces:
Running
Running
metadata
title: Face Generator
emoji: 🎨
colorFrom: purple
colorTo: pink
sdk: docker
app_port: 8002
pinned: false
Face Generator Flask API
Flask service for the GAN-based face generation model.
Setup
Local Development
- Install dependencies:
pip install -r requirements.txt
- Run the app:
python app.py
- Access the application:
- Web Interface: http://localhost:8002 (Try it directly in your browser!)
- API Info: http://localhost:8002/api
- Health check: http://localhost:8002/health
Docker
- Build the image:
docker build -t facegen-api .
- Run the container:
docker run -p 8002:8002 facegen-api
API Endpoints
Web Interface
Visit the root URL to access the interactive web interface where you can generate faces with a user-friendly UI.
GET /api
Health check and info
curl http://localhost:8002/
GET /health
Detailed health status
curl http://localhost:8002/health
POST /generate
Generate face images (returns PNG image)
Request body:
{
"n_samples": 4,
"seed": 42
}
Example:
# Generate single face
curl -X POST http://localhost:8002/generate \
-H "Content-Type: application/json" \
-d '{"n_samples": 1, "seed": 42}' \
--output face.png
# Generate 4 faces in a grid
curl -X POST http://localhost:8002/generate \
-H "Content-Type: application/json" \
-d '{"n_samples": 4, "seed": 123}' \
--output faces_grid.png
GET /generate-single
Quick endpoint to generate a single face
Example:
# Random face
curl http://localhost:8002/generate-single --output face.png
# With seed
curl "http://localhost:8002/generate-single?seed=42" --output face.png
Model
- Model: Face Generation GAN
- Location:
./models/face-gen-gan/generator_model_100.h5 - Type: Generative Adversarial Network
- Port: 8002
Parameters
- n_samples: Number of faces to generate (1-16, default: 1)
- seed: Random seed for reproducibility (optional)
Response Format
- Returns PNG image
- Single face: Original resolution
- Multiple faces: Grid layout (auto-calculated)
Features
- CORS enabled for all origins
- Returns images as PNG
- Grid layout for multiple faces
- Reproducible generation with seeds
- Simple Flask API
- Health check endpoints