This guide will help you spin up a functioning AI workload in 5 minutes.
1
Install Required Packages
Pixeltable requires only a minimal set of Python packages by default. To use AI models, you’ll need to install
additional dependencies.
Copy
Ask AI
pip install torch transformers openai
2
Create a Table
Copy
Ask AI
import pixeltable as pxt# Create a namespace and tablepxt.create_dir('quickstart', if_exists='replace_force')t = pxt.create_table('quickstart/images', {'image': pxt.Image})
Tables are persistent: your data survives restarts and can be queried anytime.
3
Add AI Object Detection
Copy
Ask AI
from pixeltable.functions import huggingface# Add DETR object detection as a computed columnt.add_computed_column( detections=huggingface.detr_for_object_detection( t.image, model_id='facebook/detr-resnet-50' ))# Extract labels from detectionst.add_computed_column(labels=t.detections.label_text)
Computed columns run automatically whenever new data is inserted.
4
Insert Data
Copy
Ask AI
# Insert a few imagest.insert([ {'image': 'https://raw.githubusercontent.com/pixeltable/pixeltable/release/docs/resources/images/000000000001.jpg'}, {'image': 'https://raw.githubusercontent.com/pixeltable/pixeltable/release/docs/resources/images/000000000025.jpg'}])
You can insert images from URLs and/or local paths in any combination.
You’ll need an OpenAI API key to use this step. If you don’t have one, you can
safely skip this step.
Copy
Ask AI
import osfrom pixeltable.functions import openai# Set your API keyos.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.labels, t.description).collect()
Copy
Ask AI
# See the full text of the description in row 0t.select(t.description).collect()[0]
Pixeltable orchestrates LLM calls for optimized throughput, handling
rate limiting, retries, and caching automatically.