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.
pip install torch transformers openai
2
Create a Table
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
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
# 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.