YOLOX

Streamline Object Detection with Pixeltable and YOLOX

Overview

This tutorial demonstrates how to leverage Pixeltable's intuitive data manipulation and built-in video handling to perform object detection using the powerful YOLOX models. You'll learn to:

  • Import and process videos seamlessly
  • Apply YOLOX models for object detection
  • Visualize results with bounding boxes
  • Compare model performance and export detections

Prerequisites

πŸ“˜

Basic understanding of Python and object detection concepts

Step 1: Setup

%pip install pixeltable git+<https://github.com/Megvii-BaseDetection/YOLOX@ac58e0a>
import pixeltable as pxt

Step 2: Create Namespace, Tables, and Views:

pxt.create_dir('video_tutorial', ignore_errors=True)  # Create a working directory

videos_table = pxt.create_table('video_tutorial.videos', {'video': pxt.VideoType()})
# Table to store video references

frames_view = pxt.create_view(
    'video_tutorial.frames', videos_table, 
    iterator_class=pxt.iterators.FrameIterator, 
    iterator_args={'video': videos_table.video, 'fps': 0} 
)
# Automatically extract frames on-demand

Step 3: Load Your Video(s)

videos_table.insert([{'video': 'https://raw.github.com/pixeltable/pixeltable/master/docs/source/data/bangkok.mp4'}])
# Or, reference a video file from your local system or cloud storage

Step 4: Apply YOLOX Object Detection

Choose a YOLOX Model: Select the model size that fits your accuracy vs. speed needs.

  • yolox_nano: Fastest, smallest model
  • yolox_tiny
  • yolox_s
  • yolox_m
  • yolox_l
  • yolox_x: Most accurate, largest model
from pixeltable.ext.functions.yolox import yolox

Apply the Model:

model_choice = 'yolox_tiny'  # Adjust as needed  
frames_view\['detect_' + model_choice] = yolox(frames_view.frame, model_id=model_choice, threshold=0.25)

Step 4: Visualize Result

frames_view
Column NameTypeComputed With
posint
frame_idxint
pos_msecfloat
pos_framefloat
frameinage
detect_yolo_tinyjsonpixeltable.ext.functions.yolox.yolox(frame, threshold=0.25, model_id='yolox_tiny')
videovideo

Learn More

You can learn more with the Object Detection in Videos tutorial to demonstrate how to use Pixeltable to do frame-by-frame object detection.