This documentation page is also available as an interactive notebook. You can launch the notebook in
Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the
above links.
This notebook demonstrates how to use Black Forest Labs (BFL) FLUX
models for image generation and editing through Pixeltable.
BFL FLUX offers state-of-the-art text-to-image
generation with models like FLUX.2 and FLUX 1.1, featuring:
- High-fidelity image generation with accurate hands, faces, and
textures
- Multi-reference image editing
- Precise hex color control
- Typography and text rendering
Prerequisites
- A BFL API key from dashboard.bfl.ai
- Pixeltable installed
Setup
First, install Pixeltable and set up your API key:
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘bfl_demo’.
<pixeltable.catalog.dir.Dir at 0x1527b9d90>
Text-to-Image Generation
Generate images from text prompts using FLUX models. FLUX 1.1 [pro]
offers fast, reliable results.
Created table ‘prompts’.
Added 0 column values with 0 errors.
No rows affected.
Inserting rows into `prompts`: 2 rows [00:00, 442.18 rows/s]
Inserted 2 rows with 0 errors.
2 rows inserted, 6 values computed.
Image Editing
Edit existing images with text prompts using FLUX models. This is
powerful for:
- Changing backgrounds
- Adding or removing objects
- Style transfer
- Multi-reference editing
Created table ‘edits’.
Added 0 column values with 0 errors.
No rows affected.
Inserting rows into `edits`: 1 rows [00:00, 600.99 rows/s]
Inserted 1 row with 0 errors.
1 row inserted, 4 values computed.
Using Seeds for Reproducibility
Use the seed parameter to get reproducible results:
Created table ‘seeded’.
Added 0 column values with 0 errors.
Inserting rows into `seeded`: 3 rows [00:00, 1211.18 rows/s]
Inserted 3 rows with 0 errors.
3 rows inserted, 6 values computed.
Image Expansion (Outpainting)
Expand an image beyond its original boundaries using bfl.expand().
This is perfect for:
- Making images wider or taller
- Adapting content for different aspect ratios
- Extending scenes naturally
Created table ‘expanded’.
Added 0 column values with 0 errors.
No rows affected.
Inserting rows into `expanded`: 1 rows [00:00, 379.78 rows/s]
Inserted 1 row with 0 errors.
1 row inserted, 4 values computed.
Inpainting with Fill
bfl.fill() allows you to inpaint specific regions of an image using a
mask:
- Black areas in the mask are preserved
- White areas in the mask are inpainted based on the prompt
Use cases: remove unwanted objects, replace backgrounds, edit text in
images, restore damaged areas.
Created table ‘filled’.
Added 0 column values with 0 errors.
No rows affected.
Inserting rows into `filled`: 1 rows [00:00, 531.87 rows/s]
Inserted 1 row with 0 errors.
1 row inserted, 6 values computed.
Best Practices
- Use specific prompts: Include details about style, lighting,
composition, and subject
- Start with flux-pro-1.1: Fast and reliable for most use cases
- Use seeds for reproducibility: When you need consistent results
- Resolution: Minimum 64x64, max 4MP (2048x2048), dimensions must
be multiples of 16
- Input image limits: Max 20MP for editing/expand/fill operations
- Safety tolerance: Default is 2; lower = stricter moderation (0-6
scale)
Learn More