{ "cells": [ { "cell_type": "markdown", "id": "c7f0f404-3929-4c42-a70a-34dc32d92640", "metadata": {}, "source": [ "# 10-Minute Tour\n", "\n", "Welcome to Pixeltable! In this tutorial, we'll survey how to create tables, populate them with data, and enhance them with built-in and user-defined transformations and AI operations.\n", "\n", "## Install Python packages\n", "\n", "First run the following command to install Pixeltable and related libraries needed for this tutorial." ] }, { "cell_type": "code", "execution_count": null, "id": "5115179a-2c88-48ef-b46c-dcebe82ed2de", "metadata": { "scrolled": true }, "outputs": [], "source": [ "%pip install -qU torch transformers openai pixeltable" ] }, { "cell_type": "markdown", "id": "3c265fc3-1a33-4d4d-be35-c49c668514b3", "metadata": {}, "source": [ "## Creating a table\n", "\n", "Let's begin by creating a `demo` directory (if it doesn't already exist) and a table that can hold image data, `demo/first`. The table will initially have just a single column to hold our input images, which we'll call `input_image`. We also need to specify a type for the column: `pxt.Image`." ] }, { "cell_type": "code", "execution_count": 1, "id": "e926b5c8-16bc-4d4d-8384-32f62fedac28", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/asiegel/.pixeltable/pgdata\n", "Created directory 'demo'.\n", "Created table 'first'.\n" ] } ], "source": [ "import pixeltable as pxt\n", "\n", "# Create the directory `demo`, dropping it first (if it exists)\n", "# to ensure a clean environment.\n", "pxt.drop_dir('demo', force=True)\n", "pxt.create_dir('demo')\n", "\n", "# Create the table `demo/first` with a single column `input_image`\n", "t = pxt.create_table('demo/first', {'input_image': pxt.Image})" ] }, { "cell_type": "markdown", "id": "2e5ec663-261a-4bb9-a8b8-dfb1ec2633f0", "metadata": {}, "source": [ "We can use `t.describe()` to examine the table schema. We see that it now contains a single column, as expected." ] }, { "cell_type": "code", "execution_count": 2, "id": "00e1bdde-8f5b-438d-b2b2-0fd6193c9831", "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "\n", "
| table 'demo/first' | \n", "
| Column Name | \n", "Type | \n", "Computed With | \n", "
|---|---|---|
| input_image | \n", "Image | \n", "\n", " |
| input_image | \n", "
|---|
\n",
" | \n",
"
| table 'demo/first' | \n", "
| Column Name | \n", "Type | \n", "Computed With | \n", "
|---|---|---|
| input_image | \n", "Image | \n", "\n", " |
| detections | \n", "Json | \n", "detr_for_object_detection(input_image, model_id='facebook/detr-resnet-50') | \n", "
| detections_text | \n", "Json | \n", "detections.label_text | \n", "
| input_image | \n", "detections_text | \n", "
|---|---|
\n",
" | \n",
" ["giraffe", "giraffe"] | \n", "
\n",
" | \n",
" ["vase", "potted plant"] | \n", "
\n",
" | \n",
" ["zebra"] | \n", "
\n",
" | \n",
" ["dog", "dog"] | \n", "
\n",
" | \n",
" ["person", "person", "bench", "person", "elephant", "elephant", "person"] | \n", "
| detections_text | \n", "top | \n", "
|---|---|
| ["person", "person", "bench", "person", "elephant", "elephant", "person"] | \n", "elephant | \n", "
| ["zebra"] | \n", "zebra | \n", "
| ["giraffe", "giraffe"] | \n", "giraffe | \n", "
| ["dog", "dog"] | \n", "dog | \n", "
| ["vase", "potted plant"] | \n", "vase | \n", "