インストール |ドキュメント | API リファレンス |コードサンプル |コンピュータビジョン | LLM
Pixeltable は、マルチモーダル データ (テキスト、画像、オーディオ、ビデオ) の宣言型インターフェイスを提供する Python ライブラリです。組み込みのバージョニング、リネージ追跡、増分更新機能を備えており、ユーザーは ML ワークフローのデータを保存、変換、インデックス付け、反復処理できるようになります。
データ変換、モデル推論、カスタム ロジックは、計算列として埋め込まれます。
pip install pixeltable
Pixeltable は永続的です。 Pandas などのインメモリ Python ライブラリとは異なり、Pixeltable はデータベースです。
テーブルを作成し、テーブルにデータを入力し、組み込みまたはユーザー定義の変換でテーブルを拡張する方法を学びます。
トピック | ノート | トピック | ノート |
---|---|---|---|
Pixeltable の 10 分間ツアー | テーブルとデータ操作 | ||
ユーザー定義関数 (UDF) | 物体検出モデル | ||
インクリメンタル プロンプト エンジニアリング | 外部ファイルの操作 | ||
Label Studio との統合 | オーディオ/ビデオのトランスクリプトのインデックス作成 | ||
マルチモーダルなアプリケーション | ドキュメントのインデックス作成と RAG | ||
コンテキスト認識型 Discord ボット | 画像/テキスト類似検索 |
import pixeltable as pxt
v = pxt . create_table ( 'external_data.videos' , { 'video' : pxt . Video })
prefix = 's3://multimedia-commons/'
paths = [
'data/videos/mp4/ffe/ffb/ffeffbef41bbc269810b2a1a888de.mp4' ,
'data/videos/mp4/ffe/feb/ffefebb41485539f964760e6115fbc44.mp4' ,
'data/videos/mp4/ffe/f73/ffef7384d698b5f70d411c696247169.mp4'
]
v . insert ({ 'video' : prefix + p } for p in paths )
Pixeltable でデータを操作する方法を学びます。
import pixeltable as pxt
from pixeltable . functions import huggingface
# Create a table to store data persistently
t = pxt . create_table ( 'image' , { 'image' : pxt . Image })
# Insert some images
prefix = 'https://upload.wikimedia.org/wikipedia/commons'
paths = [
'/1/15/Cat_August_2010-4.jpg' ,
'/e/e1/Example_of_a_Dog.jpg' ,
'/thumb/b/bf/Bird_Diversity_2013.png/300px-Bird_Diversity_2013.png'
]
t . insert ({ 'image' : prefix + p } for p in paths )
# Add a computed column for image classification
t . add_computed_column ( classification = huggingface . detr_for_object_detection (
t . image ,
model_id = 'facebook/detr-resnet-50'
))
# Retrieve the rows where cats have been identified
t . select ( animal = t . image ,
classification = t . classification . label_text [ 0 ])
. where ( t . classification . label_text [ 0 ] == 'cat' ). head ()
計算列とオブジェクト検出について学習します: オブジェクト検出モデルの比較。
@ pxt . udf
def draw_boxes ( img : PIL . Image . Image , boxes : list [ list [ float ]]) -> PIL . Image . Image :
result = img . copy () # Create a copy of `img`
d = PIL . ImageDraw . Draw ( result )
for box in boxes :
d . rectangle ( box , width = 3 ) # Draw bounding box rectangles on the copied image
return result
ユーザー定義関数の詳細については、Pixeltable の UDF をご覧ください。
# In this example, the view is defined by iteration over the chunks of a DocumentSplitter
chunks_table = pxt . create_view (
'rag_demo.chunks' ,
documents_table ,
iterator = DocumentSplitter . create (
document = documents_table . document ,
separators = 'token_limit' , limit = 300 )
)
ビューを活用して RAG ワークフローを構築する方法を学びます。
# The computation of the mAP metric can become a query over the evaluation output
frames_view . select ( mean_ap ( frames_view . eval_yolox_tiny ), mean_ap ( frames_view . eval_yolox_m )). show ()
Pixeltable をモデル分析に活用する方法を学びます。
chat_table = pxt . create_table ( 'together_demo.chat' , { 'input' : pxt . String })
# The chat-completions API expects JSON-formatted input:
messages = [{ 'role' : 'user' , 'content' : chat_table . input }]
# This example shows how additional parameters from the Together API can be used in Pixeltable
chat_table . add_computed_column (
output = chat_completions (
messages = messages ,
model = 'mistralai/Mixtral-8x7B-Instruct-v0.1' ,
max_tokens = 300 ,
stop = [ ' n ' ],
temperature = 0.7 ,
top_p = 0.9 ,
top_k = 40 ,
repetition_penalty = 1.1 ,
logprobs = 1 ,
echo = True
)
)
chat_table . add_computed_column (
response = chat_table . output . choices [ 0 ]. message . content
)
# Start a conversation
chat_table . insert ([
{ 'input' : 'How many species of felids have been classified?' },
{ 'input' : 'Can you make me a coffee?' }
])
chat_table . select ( chat_table . input , chat_table . response ). head ()
Pixeltable で Together AI などの推論サービスを操作する方法を学びます。
import pixeltable as pxt
from pixeltable . functions . huggingface import clip_image , clip_text
from pixeltable . iterators import FrameIterator
import PIL . Image
video_table = pxt . create_table ( 'videos' , { 'video' : pxt . Video })
video_table . insert ([{ 'video' : '/video.mp4' }])
frames_view = pxt . create_view (
'frames' , video_table , iterator = FrameIterator . create ( video = video_table . video ))
@ pxt . expr_udf
def embed_image ( img : PIL . Image . Image ):
return clip_image ( img , model_id = 'openai/clip-vit-base-patch32' )
@ pxt . expr_udf
def str_embed ( s : str ):
return clip_text ( s , model_id = 'openai/clip-vit-base-patch32' )
# Create an index on the 'frame' column that allows text and image search
frames_view . add_embedding_index ( 'frame' , string_embed = str_embed , image_embed = embed_image )
# Now we will retrieve images based on a sample image
sample_image = '/image.jpeg'
sim = frames_view . frame . similarity ( sample_image )
frames_view . order_by ( sim , asc = False ). limit ( 5 ). select ( frames_view . frame , sim = sim ). collect ()
# Now we will retrieve images based on a string
sample_text = 'red truck'
sim = frames_view . frame . similarity ( sample_text )
frames_view . order_by ( sim , asc = False ). limit ( 5 ). select ( frames_view . frame , sim = sim ). collect ()
埋め込みインデックスとベクトルインデックスの操作方法を学びます。
要件 | 伝統的 | ピクセルテーブル |
---|---|---|
フレーム抽出 | ffmpeg + カスタムコード | FrameIterator による自動 |
物体検出 | 複数のスクリプト + キャッシュ | 単一の計算列 |
ビデオのインデックス作成 | カスタムパイプライン + Vector DB | ネイティブ類似性検索 |
注釈管理 | 個別のツール + カスタム コード | ラベルスタジオの統合 |
モデルの評価 | カスタムメトリクスパイプライン | 内蔵のmAP計算 |
要件 | 伝統的 | ピクセルテーブル |
---|---|---|
ドキュメントのチャンク化 | ツール + カスタムコード | ネイティブ ドキュメントスプリッター |
埋め込み生成 | 個別のパイプライン + キャッシュ | 計算列 |
ベクトル検索 | 外部ベクトルDB | 組み込みのベクトルインデックス作成 |
迅速な管理 | カスタム追跡ソリューション | バージョン管理された列 |
チェーン管理 | ツール + カスタムコード | 計算された列 DAG |
要件 | 伝統的 | ピクセルテーブル |
---|---|---|
データ型 | 複数のストレージ システム | 統合されたテーブルインターフェイス |
クロスモーダル検索 | 複雑な統合 | ネイティブ類似性サポート |
パイプライン オーケストレーション | 複数のツール (エアフローなど) | 単一の宣言型インターフェイス |
資産運用管理 | カスタム追跡システム | 自動系統 |
品質管理 | 複数の検証ツール | 計算された検証列 |
Pixeltable は、変換、モデル推論、計算列として表されるカスタム ロジックを使用して、データ ストレージ、バージョン管理、インデックス作成を、宣言型テーブル インターフェイスの下でオーケストレーションとモデルのバージョン管理と統合します。
AI アプリ開発のための今日のソリューションには、広範なカスタム コーディングとインフラストラクチャの配管が必要です。データ変換、モデル、デプロイメント間およびデータ変換、モデル、デプロイメント間での系統とバージョンの追跡は面倒です。 Pixeltable を使用すると、ML エンジニアとデータ サイエンティストは、通常のデータ配管に取り組むことなく、探索、モデリング、アプリ開発に集中できます。
ヒント
「統合」セクションを確認し、追加の統合のリクエストを遠慮なく送信してください。
コミュニティからの貢献をお待ちしております。参加方法は次のとおりです。
このライブラリは、Apache 2.0 ライセンスに基づいてライセンスされています。