This folder contains a dev-only script that generates 2D “studio” images (single plant, side view, white background) from the raw photos in images/.
-
Ensure your repo root
.envcontains:GOOG_API_KEY=...
-
Create a virtualenv and install deps:
cd pa-wildflower-selector
python -m venv .venv
.venv\Scripts\activate
pip install -r scripts/studio_images/requirements.txtGenerate studio images into images/studio_full (skips ones already present):
python scripts/studio_images/generate_studio_images.py --input-dir images --output-dir images/studio_fullHigher quality (still fast model) tips:
- Preserve model output format (often PNG) to avoid extra compression:
python scripts/studio_images/generate_studio_images.py --output-format keep- If using WebP, bump quality (bigger files):
python scripts/studio_images/generate_studio_images.py --webp-quality 96By default, outputs are written as .webp (smaller + modern for web). You can change this:
python scripts/studio_images/generate_studio_images.py --output-format jpgDry-run (no API calls, no writes):
python scripts/studio_images/generate_studio_images.py --dry-run --limit 10Use a custom prompt without editing the script:
python scripts/studio_images/generate_studio_images.py --prompt-file scripts/studio_images/prompt.txtBy default the script auto-crops the generated image by trimming near-white margins, then adds a small padding.
- Disable:
--no-autocrop - Crop algorithm:
--crop-mode bg-diff(default) or--crop-mode near-white - Tune aggressiveness:
--crop-mode bg-diff:--crop-threshold 8(tighter) or--crop-threshold 16(looser)--crop-mode near-white:--crop-threshold 245(looser) or--crop-threshold 252(tighter)
- Tune padding:
--crop-padding 12
Example:
python scripts/studio_images/generate_studio_images.py --overwrite --crop-threshold 252 --crop-padding 12- Inputs:
*.jpg,*.jpeg,*.pnginimages/. - Skips:
*.preview.jpg(unless you pass--no-skip-preview) and anything already generated inimages/studio_full/. - Output format defaults to
.webp. Use--output-format keepto preserve the model output type.