PierreBrunelle commited on
Commit
d1f8ddb
·
verified ·
1 Parent(s): 396398d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +219 -1
README.md CHANGED
@@ -7,4 +7,222 @@ sdk: static
7
  pinned: false
8
  ---
9
 
10
- Edit this `README.md` markdown file to author your organization card.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  pinned: false
8
  ---
9
 
10
+ <div align="center">
11
+ <img src="https://raw.githubusercontent.com/pixeltable/pixeltable/main/docs/source/data/pixeltable-logo-large.png" alt="Pixeltable" width="20%" />
12
+ <br></br>
13
+
14
+ [![License](https://img.shields.io/badge/License-Apache%202.0-0530AD.svg)](https://opensource.org/licenses/Apache-2.0)
15
+ [Installation](https://pixeltable.github.io/pixeltable/getting-started/) | [Documentation](https://pixeltable.readme.io/) | [API Reference](https://pixeltable.github.io/pixeltable/) | [Code Samples](https://github.com/pixeltable/pixeltable?tab=readme-ov-file#-code-samples) | [Computer Vision](https://docs.pixeltable.com/docs/object-detection-in-videos) | [LLM](https://docs.pixeltable.com/docs/document-indexing-and-rag)
16
+ </div>
17
+
18
+ Pixeltable is a Python library providing a declarative interface for multimodal data (text, images, audio, video). It features built-in versioning, lineage tracking, and incremental updates, enabling users to **store**, **transform**, **index**, and **iterate** on data for their ML workflows.
19
+
20
+ Data transformations, model inference, and custom logic are embedded as **computed columns**.
21
+ - **Load/Query all data types**: Interact with [video data](https://github.com/pixeltable/pixeltable?tab=readme-ov-file#import-media-data-into-pixeltable-videos-images-audio) at the [frame level](https://github.com/pixeltable/pixeltable?tab=readme-ov-file#text-and-image-similarity-search-on-video-frames-with-embedding-indexes) and documents at the [chunk level](https://github.com/pixeltable/pixeltable?tab=readme-ov-file#automate-data-operations-with-views-eg-split-documents-into-chunks)
22
+ - **Incremental updates for data transformation**: Maintain an [embedding index](https://docs.pixeltable.com/docs/embedding-vector-indexes) colocated with your data
23
+ - **Lazy evaluation and cache management**: Eliminates the need for [manual frame extraction](https://docs.pixeltable.com/docs/object-detection-in-videos)
24
+ - **Integrates with any Python libraries**: Use [built-in and custom functions (UDFs)](https://docs.pixeltable.com/docs/user-defined-functions-udfs) without complex pipelines
25
+ - **Data format agnostic and extensibility**: Access tables as Parquet files, [PyTorch datasets](https://pixeltable.github.io/pixeltable/api/data-frame/#pixeltable.DataFrame.to_pytorch_dataset), or [COCO annotations](https://pixeltable.github.io/pixeltable/api/table/#pixeltable.Table.to_coco_dataset)
26
+
27
+ ## 💾 Installation
28
+
29
+ ```python
30
+ pip install pixeltable
31
+ ```
32
+ **Pixeltable is persistent. Unlike in-memory Python libraries such as Pandas, Pixeltable is a database.**
33
+
34
+ ## 🧱 Code Samples
35
+
36
+ ### Import media data into Pixeltable (videos, images, audio...)
37
+ ```python
38
+ import pixeltable as pxt
39
+
40
+ v = pxt.create_table('external_data.videos', {'video': pxt.VideoType()})
41
+
42
+ prefix = 's3://multimedia-commons/'
43
+ paths = [
44
+ 'data/videos/mp4/ffe/ffb/ffeffbef41bbc269810b2a1a888de.mp4',
45
+ 'data/videos/mp4/ffe/feb/ffefebb41485539f964760e6115fbc44.mp4',
46
+ 'data/videos/mp4/ffe/f73/ffef7384d698b5f70d411c696247169.mp4'
47
+ ]
48
+ v.insert({'video': prefix + p} for p in paths)
49
+ ```
50
+ Learn how to [work with data in Pixeltable](https://pixeltable.readme.io/docs/working-with-external-files).
51
+
52
+ ### Object detection in images using DETR model
53
+ ```python
54
+ import pixeltable as pxt
55
+ from pixeltable.functions import huggingface
56
+
57
+ # Create a table to store data persistently
58
+ t = pxt.create_table('image', {'image': pxt.ImageType()})
59
+
60
+ # Insert some images
61
+ prefix = 'https://upload.wikimedia.org/wikipedia/commons'
62
+ paths = [
63
+ '/1/15/Cat_August_2010-4.jpg',
64
+ '/e/e1/Example_of_a_Dog.jpg',
65
+ '/thumb/b/bf/Bird_Diversity_2013.png/300px-Bird_Diversity_2013.png'
66
+ ]
67
+ t.insert({'image': prefix + p} for p in paths)
68
+
69
+ # Add a computed column for image classification
70
+ t['classification'] = huggingface.detr_for_object_detection(
71
+ (t.image), model_id='facebook/detr-resnet-50'
72
+ )
73
+
74
+ # Retrieve the rows where cats have been identified
75
+ t.select(animal = t.image,
76
+ classification = t.classification.label_text[0]) \
77
+ .where(t.classification.label_text[0]=='cat').head()
78
+ ```
79
+ Learn about computed columns and object detection: [Comparing object detection models](https://pixeltable.readme.io/docs/object-detection-in-videos).
80
+
81
+ ### Extend Pixeltable's capabilities with user-defined functions
82
+ ```python
83
+ @pxt.udf
84
+ def draw_boxes(img: PIL.Image.Image, boxes: list[list[float]]) -> PIL.Image.Image:
85
+ result = img.copy() # Create a copy of `img`
86
+ d = PIL.ImageDraw.Draw(result)
87
+ for box in boxes:
88
+ d.rectangle(box, width=3) # Draw bounding box rectangles on the copied image
89
+ return result
90
+ ```
91
+ Learn more about user-defined functions: [UDFs in Pixeltable](https://pixeltable.readme.io/docs/user-defined-functions-udfs).
92
+
93
+ ### Automate data operations with views, e.g., split documents into chunks
94
+ ```python
95
+ # In this example, the view is defined by iteration over the chunks of a DocumentSplitter
96
+ chunks_table = pxt.create_view(
97
+ 'rag_demo.chunks',
98
+ documents_table,
99
+ iterator=DocumentSplitter.create(
100
+ document=documents_table.document,
101
+ separators='token_limit', limit=300)
102
+ )
103
+ ```
104
+ Learn how to leverage views to build your [RAG workflow](https://pixeltable.readme.io/docs/document-indexing-and-rag).
105
+
106
+ ### Evaluate model performance
107
+ ```python
108
+ # The computation of the mAP metric can become a query over the evaluation output
109
+ frames_view.select(mean_ap(frames_view.eval_yolox_tiny), mean_ap(frames_view.eval_yolox_m)).show()
110
+ ```
111
+ Learn how to leverage Pixeltable for [Model analytics](https://pixeltable.readme.io/docs/object-detection-in-videos).
112
+
113
+ ### Working with inference services
114
+ ```python
115
+ chat_table = pxt.create_table('together_demo.chat', {'input': pxt.StringType()})
116
+
117
+ # The chat-completions API expects JSON-formatted input:
118
+ messages = [{'role': 'user', 'content': chat_table.input}]
119
+
120
+ # This example shows how additional parameters from the Together API can be used in Pixeltable
121
+ chat_table['output'] = chat_completions(
122
+ messages=messages,
123
+ model='mistralai/Mixtral-8x7B-Instruct-v0.1',
124
+ max_tokens=300,
125
+ stop=['\n'],
126
+ temperature=0.7,
127
+ top_p=0.9,
128
+ top_k=40,
129
+ repetition_penalty=1.1,
130
+ logprobs=1,
131
+ echo=True
132
+ )
133
+ chat_table['response'] = chat_table.output.choices[0].message.content
134
+
135
+ # Start a conversation
136
+ chat_table.insert([
137
+ {'input': 'How many species of felids have been classified?'},
138
+ {'input': 'Can you make me a coffee?'}
139
+ ])
140
+ chat_table.select(chat_table.input, chat_table.response).head()
141
+ ```
142
+ Learn how to interact with inference services such as [Together AI](https://pixeltable.readme.io/docs/together-ai) in Pixeltable.
143
+
144
+ ### Text and image similarity search on video frames with embedding indexes
145
+ ```python
146
+ import pixeltable as pxt
147
+ from pixeltable.functions.huggingface import clip_image, clip_text
148
+ from pixeltable.iterators import FrameIterator
149
+ import PIL.Image
150
+
151
+ video_table = pxt.create_table('videos', {'video': pxt.VideoType()})
152
+
153
+ video_table.insert([{'video': '/video.mp4'}])
154
+
155
+ frames_view = pxt.create_view(
156
+ 'frames', video_table, iterator=FrameIterator.create(video=video_table.video))
157
+
158
+ @pxt.expr_udf
159
+ def embed_image(img: PIL.Image.Image):
160
+ return clip_image(img, model_id='openai/clip-vit-base-patch32')
161
+
162
+ @pxt.expr_udf
163
+ def str_embed(s: str):
164
+ return clip_text(s, model_id='openai/clip-vit-base-patch32')
165
+
166
+ # Create an index on the 'frame' column that allows text and image search
167
+ frames_view.add_embedding_index('frame', string_embed=str_embed, image_embed=embed_image)
168
+
169
+ # Now we will retrieve images based on a sample image
170
+ sample_image = '/image.jpeg'
171
+ sim = frames_view.frame.similarity(sample_image)
172
+ frames_view.order_by(sim, asc=False).limit(5).select(frames_view.frame, sim=sim).collect()
173
+
174
+ # Now we will retrieve images based on a string
175
+ sample_text = 'red truck'
176
+ sim = frames_view.frame.similarity(sample_text)
177
+ frames_view.order_by(sim, asc=False).limit(5).select(frames_view.frame, sim=sim).collect()
178
+
179
+ ```
180
+ Learn how to work with [Embedding and Vector Indexes](https://docs.pixeltable.com/docs/embedding-vector-indexes).
181
+
182
+ ## ❓ FAQ
183
+
184
+ ### What is Pixeltable?
185
+
186
+ Pixeltable unifies data storage, versioning, and indexing with orchestration and model versioning under a declarative table interface, with transformations, model inference, and custom logic represented as computed columns.
187
+
188
+ ### What problems does Pixeltable solve?
189
+
190
+ Today's solutions for AI app development require extensive custom coding and infrastructure plumbing. Tracking lineage and versions between and across data transformations, models, and deployments is cumbersome. Pixeltable lets ML Engineers and Data Scientists focus on exploration, modeling, and app development without dealing with the customary data plumbing.
191
+
192
+ ### What does Pixeltable provide me with? Pixeltable provides:
193
+
194
+ - Data storage and versioning
195
+ - Combined Data and Model Lineage
196
+ - Indexing (e.g. embedding vectors) and Data Retrieval
197
+ - Orchestration of multimodal workloads
198
+ - Incremental updates
199
+ - Code is automatically production-ready
200
+
201
+ ### Why should you use Pixeltable?
202
+
203
+ - **It gives you transparency and reproducibility**
204
+ - All generated data is automatically recorded and versioned
205
+ - You will never need to re-run a workload because you lost track of the input data
206
+ - **It saves you money**
207
+ - All data changes are automatically incremental
208
+ - You never need to re-run pipelines from scratch because you’re adding data
209
+ - **It integrates with any existing Python code or libraries**
210
+ - Bring your ever-changing code and workloads
211
+ - You choose the models, tools, and AI practices (e.g., your embedding model for a vector index); Pixeltable orchestrates the data
212
+
213
+ ### What is Pixeltable not providing?
214
+
215
+ - Pixeltable is not a low-code, prescriptive AI solution. We empower you to use the best frameworks and techniques for your specific needs.
216
+ - We do not aim to replace your existing AI toolkit, but rather enhance it by streamlining the underlying data infrastructure and orchestration.
217
+
218
+ > [!TIP]
219
+ > Check out the [Integrations](https://pixeltable.readme.io/docs/working-with-openai) section, and feel free to submit a request for additional ones.
220
+
221
+ ## 🐛 Contributions & Feedback
222
+
223
+ Are you experiencing issues or bugs with Pixeltable? File an [Issue](https://github.com/pixeltable/pixeltable/issues).
224
+ </br>Do you want to contribute? Feel free to open a [PR](https://github.com/pixeltable/pixeltable/pulls).
225
+
226
+ ## :classical_building: License
227
+
228
+ This library is licensed under the Apache 2.0 License.