File size: 2,350 Bytes
961e88e
 
 
 
 
 
 
 
 
06e799e
961e88e
 
 
06e799e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55ed626
 
 
961e88e
06e799e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55ed626
 
 
 
06e799e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d26d42
06e799e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
961e88e
06e799e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
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