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 tutorial demonstrates how to configure Pixeltable to use
Tigris for storage. This lets you store
unlimited amounts of images in Tigris’ global data plane, allowing your
images to load fast everywhere.
import pixeltable as pxtfrom datasets import load_dataset# Create directory for this demopxt.drop_dir('tigris', force=True)pxt.create_dir('tigris', if_exists='replace')# Load the datasetds = load_dataset('XeIaso/botw-screenshots-captioned')# Import it to pixeltable with the name screenshotspxt.drop_table('tigris/screenshots', force=True)screenshots = pxt.create_table( 'tigris/screenshots', source=ds, if_exists='replace')
Created directory ‘tigris’.
Created table ‘screenshots’.
Inserting rows into `screenshots`: 100 rows [00:01, 51.72 rows/s]
Inserting rows into `screenshots`: 100 rows [00:01, 55.57 rows/s]
Inserting rows into `screenshots`: 100 rows [00:01, 52.74 rows/s]
Inserting rows into `screenshots`: 100 rows [00:02, 33.96 rows/s]
Inserting rows into `screenshots`: 100 rows [00:02, 42.64 rows/s]
Inserting rows into `screenshots`: 100 rows [00:02, 39.65 rows/s]
Inserting rows into `screenshots`: 100 rows [00:02, 47.36 rows/s]
Inserting rows into `screenshots`: 28 rows [00:00, 6786.12 rows/s]
Inserted 728 rows with 0 errors.
Once the import is done, you can create thumbnails with a computed
column:
# Add a computed column for thumbnails# Uses output_media_dest by default, or specify a custom destinationscreenshots.add_computed_column( thumbnail=screenshots.image.resize((256, 256)), destination=f'https://t3.storage.dev/{bucket_name}/botw-screenshots/thumbnails/',)
When your files are in object storage, you can get URLs that point
directly to them. These URLs work in HTML, APIs, or any application you
need to serve media with. Fetch them with the .fileurl property:
For private buckets or when you need time-limited access to files, use
presigned URLs. These are temporary, authenticated URLs that allow
anyone to access your files for a limited time without needing
credentials.Use the presigned_url function from pixeltable.functions.net: