--- 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 1. Install dependencies: ```bash pip install -r requirements.txt ``` 2. Run the app: ```bash python app.py ``` 3. 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 1. Build the image: ```bash docker build -t facegen-api . ``` 2. Run the container: ```bash 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 ```bash curl http://localhost:8002/ ``` ### GET `/health` Detailed health status ```bash curl http://localhost:8002/health ``` ### POST `/generate` Generate face images (returns PNG image) Request body: ```json { "n_samples": 4, "seed": 42 } ``` Example: ```bash # 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: ```bash # 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