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.
Automatically identify and locate objects in images using YOLOX object
detection models.
Problem
You have images that need object detection—identifying what objects are
present and where they’re located. Manual labeling is slow and
expensive.
Solution
What’s in this recipe:
- Detect objects using YOLOX models (runs locally, no API needed)
- Get bounding boxes and class labels
- Filter detections by confidence threshold
You add a computed column that runs YOLOX on each image. Detection
happens automatically when you insert new images.
Setup
Load images
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘detection_demo’.
<pixeltable.catalog.dir.Dir at 0x1413e9ed0>
Created table ‘images’.
Inserting rows into `images`: 0 rows [00:00, ? rows/s]
Inserting rows into `images`: 3 rows [00:00, 523.85 rows/s]
Inserted 3 rows with 0 errors.
3 rows inserted, 6 values computed.
Run object detection
Add a computed column that runs YOLOX on each image:
Added 3 column values with 0 errors.
3 rows updated, 3 values computed.
Parse the detection output to get object counts and classes:
Added 3 column values with 0 errors.
3 rows updated, 6 values computed.
Added 3 column values with 0 errors.
3 rows updated, 3 values computed.
Explanation
YOLOX model sizes:
Detection output format:
The detections dictionary contains:
labels: List of class names (e.g., “person”, “car”, “dog”)
boxes: Bounding box coordinates [x1, y1, x2, y2]
scores: Confidence scores (0-1)
Adjusting threshold:
- Higher threshold (0.7-0.9): Fewer detections, higher confidence
- Lower threshold (0.3-0.5): More detections, may include false
positives
See also