Skip to main content
This guide gets you from zero to a working AI application quickly. For deeper learning, see Pixeltable Basics and Tables & Data Operations.

Installation

pip install pixeltable torch transformers
Add openai to the install if you want to use OpenAI Vision in Step 3.

Build an Image Analysis App

1

Create a Table

import pixeltable as pxt

# Create a namespace and table
pxt.drop_dir('quickstart', force=True)
pxt.create_dir('quickstart')

t = pxt.create_table('quickstart.images', {'image': pxt.Image})
Tables are persistent—your data survives restarts and can be queried anytime.
2

Add AI Object Detection

from pixeltable.functions import huggingface

# Add DETR object detection as a computed column
t.add_computed_column(
    detections=huggingface.detr_for_object_detection(
        t.image,
        model_id='facebook/detr-resnet-50'
    )
)

# Extract labels from detections
t.add_computed_column(labels=t.detections.label_text)
Computed columns run automatically whenever new data is inserted.
3

Insert Data and See Results

# Insert an image
t.insert(image='https://raw.githubusercontent.com/pixeltable/pixeltable/release/docs/resources/images/000000000025.jpg')

# View results
t.select(t.image, t.labels).collect()
Expected output:
| image      | labels              |
|------------|---------------------|
| [Image]    | ['giraffe', 'giraffe'] |
4

Add Custom Logic with UDFs

@pxt.udf
def top_label(detections: dict) -> str:
    """Return the highest-confidence detection label."""
    if not detections['scores']:
        return 'none'
    best_idx = detections['scores'].index(max(detections['scores']))
    return detections['label_text'][best_idx]

t.add_computed_column(best=top_label(t.detections))

# Now every row has the top detection
t.select(t.image, t.best).collect()
UDFs let you add any Python logic as computed columns.
5

(Optional) Add LLM Vision

import os
from pixeltable.functions import openai

# Set your API key (or use config.toml)
os.environ['OPENAI_API_KEY'] = 'your-key-here'

t.add_computed_column(
    description=openai.vision(
        prompt="Describe this image in one sentence.",
        image=t.image,
        model='gpt-4o-mini'
    )
)

t.select(t.image, t.best, t.description).collect()
Pixeltable handles rate limiting, retries, and caching automatically.
Pixeltable automatically:
  1. Created a persistent multimodal table
  2. Downloaded and cached the DETR model
  3. Ran inference on your image
  4. Stored all results (including computed columns) for instant retrieval
  5. Will incrementally process any new images you insert

Key Concepts

Next Steps