i8i-ky's picture
Add README.md
8dc647e verified
|
Raw History Blame Contribute Delete
3.2 kB
# FLUX.1-dev + PuLID Handler
High-quality image generation with optional character consistency using FLUX.1-dev and PuLID.
## Features
- **FLUX.1-dev**: Higher quality than schnell (28 steps vs 4)
- **PuLID Integration**: Character consistency across images via face embeddings
- **Dual Mode**: Normal generation or ID-consistent generation
- **Memory Optimization**: FP8 quantization and CPU offload for smaller GPUs
## GPU Requirements
| GPU | Mode | Features |
|-----|------|----------|
| A100 80GB | Full GPU | Best quality, PuLID, batch processing |
| L40S 48GB | CPU Offload + FP8 | Good quality, PuLID, single inference |
## API Modes
### 1. Normal Generation
```json
{
"inputs": "A professional portrait of a business person",
"parameters": {
"mode": "generate",
"width": 1344,
"height": 768,
"num_inference_steps": 28,
"guidance_scale": 3.5
}
}
```
### 2. Register Character Face
```json
{
"inputs": "",
"parameters": {
"mode": "register",
"face_image": "data:image/png;base64,...",
"character_name": "Hero_A"
}
}
```
Response:
```json
{
"success": true,
"character_id": "uuid-xxx",
"character_name": "Hero_A",
"embedding_cached": true
}
```
### 3. Generate with Character Consistency
```json
{
"inputs": "Hero_A sitting in a coffee shop, morning light",
"parameters": {
"mode": "generate_with_ids",
"character_ids": ["uuid-xxx"],
"id_weight": 0.8,
"width": 1344,
"height": 768
}
}
```
### 4. Check Cache
```json
{
"inputs": "",
"parameters": {
"mode": "check_cache",
"character_ids": ["uuid-xxx", "uuid-yyy"]
}
}
```
### 5. Clear Cache
```json
{
"inputs": "",
"parameters": {
"mode": "clear_cache",
"character_ids": ["uuid-xxx"]
}
}
```
## Parameters
| Parameter | Default | Description |
|-----------|---------|-------------|
| `num_inference_steps` | 28 | More steps = higher quality (25-50) |
| `guidance_scale` | 3.5 | Prompt adherence (3.0-7.0) |
| `width` | 1344 | Image width |
| `height` | 768 | Image height |
| `id_weight` | 0.8 | PuLID identity strength (0.0-1.0) |
| `max_batch_size` | 4 | Max images per batch |
## Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `ENABLE_PULID` | true | Enable PuLID character consistency |
| `ENABLE_FP8` | auto | FP8 quantization (auto/true/false) |
| `NUM_INFERENCE_STEPS` | 28 | Default inference steps |
## Deployment
1. Create a new model repository on Hugging Face Hub
2. Upload `handler.py` and `requirements.txt`
3. Create a Dedicated Endpoint (A100 80GB recommended)
4. Set Task type to "Custom"
## Cost Comparison (vs schnell)
| Model | Steps | Time/Image | Quality |
|-------|-------|------------|---------|
| schnell | 4 | ~1.5s | Good |
| dev | 28 | ~8s | Excellent |
| dev + PuLID | 28 | ~10s | Excellent + Consistent |
## References
- [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev)
- [PuLID](https://github.com/ToTheBeginning/PuLID)
- [PuLID-FLUX v0.9.1](https://huggingface.co/guozinan/PuLID)