# THE BAKER — Flux.2 LoRA Training

**Quick Start Guide**

---

## What We Built

A complete fine-tuning pipeline for Flux.2 that generates deck visuals and concept art in THE BAKER's "grandeur with decay" aesthetic.

**Files created:**
- `config.json` — Training configuration
- `generate_dataset.py` — Creates 54 training images
- `train_flux_lora.py` — Trains the LoRA model
- `generate_deck_visual.py` — Generates deck visuals
- `visual_concepts.md` — 8 visual categories documented
- `TRAINING_PLAN.md` — Complete execution plan
- `00_quickstart.sh` — Interactive workflow script

---

## 3-Step Workflow

### Step 1: Generate Dataset (30-60 min)
```bash
cd /home/workspaces/thebaker/training
source /home/workspaces/cultguard-agents/.devenv/state/venv/bin/activate
python generate_dataset.py --config config.json
```

**Creates:** 54 images + captions in `dataset/`

---

### Step 2: Train LoRA (2-4 hours)
```bash
python train_flux_lora.py --config config.json
```

**Creates:** `outputs/lora_weights.safetensors`

---

### Step 3: Generate Deck Visuals (15-30 min)
```bash
python generate_deck_visual.py --batch --lora outputs/lora_weights.safetensors
```

**Creates:** 13 deck visuals in `assets/decks/visuals/`

---

## OR: Use Interactive Script

```bash
./00_quickstart.sh
```

Choose from:
1. Generate dataset only
2. Train LoRA
3. Generate deck visuals
4. Full pipeline (all 3 steps)
5. Custom prompt generation

---

## What You'll Get

**13 Deck Visuals:**
1. Cover slide (THE BAKER title)
2. The Bargain (estate interior)
3. The Story (family dinner)
4. Fault Line (family crest symbolic)
5. Opening Wound (Byblos port)
6. Fredric portrait
7. Magda portrait
8. Billy portrait
9. Communion ceremony
10. Lebanon cemetery
11. Theme (bread and blood)
12. Audience (diaspora)
13. Closing (THE END)

**Plus:**
- Reusable LoRA model for future marketing
- 54-image training dataset
- Custom prompt generation capability

---

## Hardware Requirements

**GPU:** NVIDIA with 24GB+ VRAM  
**Your system:** RTX 6000 Ada (48GB) ✓

**Disk space:** ~25 GB (base model download)

**Time:** 4-6 hours total

---

## Visual Style

The trained model captures:
- **Grandeur with decay** — Beauty and rot in same frame
- **Chiaroscuro lighting** — Moral pressure through light
- **Baroque Catholic weight** — Ornate, ceremonial
- **Phoenician memory** — Lebanese heritage elements
- **Cinematic composition** — Pitch-ready quality

**Trigger word:** `the baker film style`

---

## Example Prompts

```
the baker film style, fredric barakat portrait, aging patriarch, 
grandeur with decay, chiaroscuro lighting, cinematic
```

```
the baker film style, barakat estate interior, baroque catholic weight, 
phoenician memory, grandeur with decay, chiaroscuro lighting
```

```
the baker film style, holy communion ceremony, maronite church, 
family gathering, grandeur with decay, cinematic
```

---

## Integration with Typst Deck

Once visuals are generated, add to `assets/decks/THE_BAKER_Cannes_Deck.typ`:

```typst
#image("../training/assets/decks/visuals/02_the_bargain.png", 
       width: 100%, fit: "cover")
```

Or use as reference cards in new slides.

---

## Quality Control

**After dataset generation:**
- Review all 54 images
- Check for artifacts
- Verify "grandeur with decay" aesthetic
- Refine captions if needed

**After training:**
- Check loss curve (should decrease)
- Test LoRA with sample prompts
- Compare outputs to deck copy

**After deck visual generation:**
- Insert into Typst deck
- Compile to PDF
- Review visual cohesion

---

## Troubleshooting

**Out of Memory:**
```json
{"training": {"rank": 8, "batch_size": 1}}
```

**Poor quality:**
- Increase training steps to 3000
- Refine dataset captions
- Add more training images

**Model not loading:**
- Check file exists: `ls outputs/lora_weights.safetensors`
- Verify safetensors package: `pip install safetensors`

---

## Documentation

| File | Use |
|------|-----|
| `README.md` | Full user guide |
| `TRAINING_PLAN.md` | Detailed execution plan |
| `visual_concepts.md` | 8 visual categories |
| `config.json` | Training parameters |

---

## Ready to Start?

```bash
cd /home/workspaces/thebaker/training
./00_quickstart.sh
```

**Recommended:** Choose option 4 (Full pipeline) for first run.

---

**Questions?** Check `TRAINING_PLAN.md` for detailed troubleshooting.
