# THE BAKER — Flux.2 LoRA Training Execution Plan

**Date:** 2026-05-13  
**Goal:** Fine-tune Flux.2 to generate deck visuals and concept art in THE BAKER's visual language  
**Hardware:** NVIDIA RTX 6000 Ada (48GB VRAM)  
**Estimated Time:** 4-6 hours total

---

## Executive Summary

We're creating a custom LoRA (Low-Rank Adaptation) for Flux.2 that captures THE BAKER's "grandeur with decay" aesthetic. This model will generate:

- Pitch deck visuals (16:9 format)
- Character concept art
- Location references (estate, church, club, Lebanon)
- Symbolic imagery (crucifix, bread/blood, family crest)
- Mood boards for Cannes pitch

**Output:** A reusable model that generates on-brand visuals from text prompts.

---

## Phase 1: Dataset Generation (30-60 minutes)

### What happens:
- 54 images generated from curated captions
- Each image matches a specific visual concept
- Captions use trigger word: "the baker film style"

### Files created:
```
training/dataset/images/     (54 PNG files, 1024x1024)
training/dataset/captions/   (54 TXT files)
```

### Command:
```bash
cd /home/workspaces/thebaker/training
source /home/workspaces/cultguard-agents/.devenv/state/venv/bin/activate
python generate_dataset.py --config config.json
```

### Review criteria:
- Do images capture "grandeur with decay"?
- Is chiaroscuro lighting present?
- Are Baroque + Phoenician elements visible?
- Any artifacts or distortions?

**If quality is poor:** Adjust captions in `generate_dataset.py` and regenerate.

---

## Phase 2: LoRA Training (2-4 hours)

### What happens:
- Flux.2-dev base model loaded
- LoRA adapters (rank 16) trained on 54 images
- Checkpoints saved every 500 steps
- Final weights exported as `.safetensors`

### Files created:
```
training/outputs/checkpoint-500/
training/outputs/checkpoint-1000/
training/outputs/checkpoint-1500/
training/outputs/checkpoint-2000/
training/outputs/lora_weights.safetensors  ← Final model
training/outputs/logs/                      ← Training metrics
```

### Command:
```bash
python train_flux_lora.py --config config.json
```

### Monitoring:
- Watch loss curve (should decrease steadily)
- Check validation images at steps 250, 500, 750...
- VRAM usage: ~20-24GB (well within 48GB limit)

**If training fails:**
- OOM error → reduce rank to 8 or batch_size to 1
- Loss not decreasing → check captions, increase learning rate
- Artifacts in output → reduce rank or increase training steps

---

## Phase 3: Deck Visual Generation (15-30 minutes)

### What happens:
- Trained LoRA loaded with base Flux.2 model
- 13 preset deck visuals generated (one per slide)
- Images saved as PNG, ready for Typst deck

### Files created:
```
training/assets/decks/visuals/
├── 01_cover.png
├── 02_the_bargain.png
├── 03_the_story.png
├── 04_fault_line.png
├── 05_opening_wound.png
├── 06_fredric.png
├── 07_magda.png
├── 08_billy.png
├── 09_communion.png
├── 10_lebanon.png
├── 11_theme.png
├── 12_audience.png
└── 13_closing.png
```

### Command:
```bash
python generate_deck_visual.py --batch --lora outputs/lora_weights.safetensors
```

### Custom prompts:
```bash
python generate_deck_visual.py \
  --prompt "the baker film style, nightclub interior, opulence with emptiness" \
  --output club_visual.png \
  --lora outputs/lora_weights.safetensors
```

---

## Phase 4: Integration with Typst Deck

### Option A: Manual image insertion

Edit `assets/decks/THE_BAKER_Cannes_Deck.typ`:

```typst
// After slide title, before body copy
#image("../training/assets/decks/visuals/02_the_bargain.png", width: 100%, fit: "cover")
```

### Option B: Create visual reference cards

Add new card type to Typst deck:

```typst
#let visual_card(image_path, caption) = block(
  width: 100%,
  inset: 0pt,
  stroke: 1pt + c_line,
  radius: 9pt,
)[
  #image(image_path, width: 100%, fit: "cover")
  #v(6pt)
  #align(center)[#note(caption)]
]
```

### Option C: Generate background textures

Use LoRA for subtle backgrounds:

```bash
python generate_deck_visual.py \
  --prompt "the baker film style, deep black background #121212, subtle texture, gold line accent" \
  --output background_texture.png \
  --lora outputs/lora_weights.safetensors
```

---

## Quality Assurance Checklist

### Dataset Review (Phase 1)
- [ ] All 54 images generated
- [ ] No obvious artifacts or distortions
- [ ] Chiaroscuro lighting visible
- [ ] "Grandeur with decay" aesthetic present
- [ ] Captions accurately describe images

### Training Review (Phase 2)
- [ ] Loss decreased from start to end
- [ ] No NaN/Inf errors in logs
- [ ] Checkpoints saved successfully
- [ ] Final LoRA weights file exists (< 200MB)

### Output Review (Phase 3)
- [ ] All 13 deck visuals generated
- [ ] Images match slide content
- [ ] Resolution appropriate for deck (1024x576 or 1024x1024)
- [ ] Style consistent across all images

### Deck Integration (Phase 4)
- [ ] Images inserted in Typst deck
- [ ] Deck compiles without errors
- [ ] Visuals enhance (not distract from) copy
- [ ] PDF output looks professional

---

## Troubleshooting Guide

### Problem: Out of Memory during training
**Solution:**
```json
{
  "training": {
    "rank": 8,
    "batch_size": 1,
    "gradient_accumulation_steps": 8
  }
}
```

### Problem: Images don't match "grandeur with decay"
**Solution:**
- Add more emphasis in captions: "STRONG chiaroscuro", "HEAVY decay"
- Increase training steps to 3000
- Regenerate dataset with refined prompts

### Problem: LoRA not loading
**Solution:**
```python
# Check file exists
import os
os.path.exists("outputs/lora_weights.safetensors")

# Try alternative loading
pipeline.load_lora_weights("outputs/", weight_name="lora_weights.safetensors")
```

### Problem: Deck visuals too dark
**Solution:**
- Add "brighter lighting" to prompts
- Reduce guidance scale to 2.5-3.0
- Adjust Typst deck background from #121212 to #1a1a1a

---

## Success Metrics

### Quantitative:
- Training loss < 0.1 by step 2000
- All 54 dataset images generated successfully
- All 13 deck visuals generated
- LoRA file size < 200MB (efficient adaptation)

### Qualitative:
- Visuals clearly identifiable as THE BAKER aesthetic
- Deck reviewers comment positively on visual cohesion
- Images support (not overwhelm) screenplay-first messaging
- Model reusable for future marketing materials

---

## Next Steps After Training

1. **Generate marketing assets:**
   - Social media tiles
   - Email headers
   - One-sheets

2. **Create character lookbook:**
   - Fredric, Magda, Billy, Vincent, Aida
   - Cast wish-list integration

3. **Location scouting references:**
   - Estate interiors (Sydney)
   - Church locations (Maronite Catholic)
   - Lebanon references (Byblos, cemeteries)

4. **Iterate on weak concepts:**
   - Identify categories with poor outputs
   - Add 10-20 more training images
   - Retrain for 500-1000 additional steps

5. **Share with team:**
   - Ronny (creative validation)
   - Nicholas (visual direction check)
   - Tracey (PR/marketing use)

---

## File Reference

| File | Purpose | Size |
|------|---------|------|
| `config.json` | Training configuration | 2 KB |
| `generate_dataset.py` | Dataset generation script | 19 KB |
| `train_flux_lora.py` | LoRA training script | 14 KB |
| `generate_deck_visual.py` | Deck visual generator | 9 KB |
| `visual_concepts.md` | Concept documentation | 8 KB |
| `README.md` | User guide | 6 KB |
| `00_quickstart.sh` | Interactive workflow | 5 KB |
| `lora_weights.safetensors` | Trained model (output) | ~100-200 MB |

**Total disk space needed:** ~25 GB (base model) + ~500 MB (dataset + outputs)

---

## Contact & Support

**Training issues:** Check logs in `training/outputs/logs/`  
**Visual direction:** Reference `notes/OLD_DECK_CREATIVE_VISUAL_DIRECTION_REVIEW_2026-05-08.md`  
**Deck integration:** See `assets/decks/THE_BAKER_Cannes_Deck.typ`

---

**Ready to begin?** Run:
```bash
cd /home/workspaces/thebaker/training
./00_quickstart.sh
```
