This comprehensive tutorial will guide you through running inference with the Hailo Toolbox framework. The toolbox supports both Hailo (.hef) and ONNX models with various input sources and customizable processing pipelines.
- Installation and Configuration
- Basic Usage
- Command Line Arguments
- Inference Command
- Input Source Types
- Callback Functions
- Practical Usage Examples
Ensure you have installed the Hailo Toolbox:
pip install -e .Check version information:
hailo-toolbox --versionHailo Toolbox CLI uses a subcommand structure:
hailo-toolbox <subcommand> [arguments]Supported subcommands:
infer: Model inferenceconvert: Model conversion
Run inference on a video file:
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source sources/test.mp4--version/-v/-V: Display version information and exithailo-toolbox --version
hailo-toolbox infer <model_path> -c <callback> --source <input_source> [OPTIONS]- Purpose: Specify the path to the model file
- Type: String
- Supported formats: .hef and .onnx formats
- Examples:
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4 hailo-toolbox infer models/yolov8n.onnx -c yolov8det --source video.mp4
- Purpose: Specify callback function name for custom processing and visualization
- Type: String
- Required: Yes
- Common values:
yolov8det,yolov8seg,yolov8pose - Examples:
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4 hailo-toolbox infer models/yolov8n_seg.hef -c yolov8seg --source video.mp4
- Purpose: Specify input source (video file, image file, folder, or camera)
- Type: String
- Required: Yes
- Supported formats:
- Video files:
.mp4,.avi,.mov,.mkv, etc. - Image files:
.jpg,.png,.bmp,.tiff, etc. - Image folders: Directory containing image files
- Cameras:
0,1(device ID) - IP cameras:
rtsp://...
- Video files:
- Examples:
# Video file hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4 # Image file hailo-toolbox infer models/yolov8n.hef -c yolov8det --source image.jpg # Image folder hailo-toolbox infer models/yolov8n.hef -c yolov8det --source images/ # Webcam hailo-toolbox infer models/yolov8n.hef -c yolov8det --source 0
- Purpose: Save output video (flag parameter)
- Type: Boolean flag
- Default: False
- Example:
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4 --save
- Purpose: Specify path to save output video
- Type: String
- Default: Auto-generated
- Example:
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4 --save --save-path output/result.mp4
- Purpose: Display output video in real-time (flag parameter)
- Type: Boolean flag
- Default: False
- Example:
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4 --show
-
Video Files
- Formats: MP4, AVI, MOV, MKV, WMV, etc.
- Example:
--source video.mp4
-
Image Files
- Formats: JPG, PNG, BMP, TIFF, WEBP, etc.
- Example:
--source image.jpg
-
Image Folders
- Format: Directory path containing image files
- Example:
--source images/ - Processes all supported image files in the directory
-
USB Cameras
- Format: Device ID (integer)
- Example:
--source 0(default camera)
-
IP Cameras
- Format: RTSP stream address
- Example:
--source rtsp://username:password@ip:port/stream
yolov8det: YOLOv8 object detectionyolov8seg: YOLOv8 semantic segmentationyolov8pose: YOLOv8 pose estimation
Callback functions handle:
- Preprocessing: Input data preparation
- Postprocessing: Model output processing
- Visualization: Result rendering and display
# Basic detection
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4
# Detection with saved results
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4 --save --save-path output/detection_result.mp4
# Real-time display of detection results
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source video.mp4 --show# Process single image
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source image.jpg --save
# Process image folder
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source images/ --save
# Batch process with custom output path
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source images/ --save --save-path output/# Segmentation task
hailo-toolbox infer models/yolov8n_seg.hef -c yolov8seg --source video.mp4 --show
# Save segmentation results
hailo-toolbox infer models/yolov8n_seg.hef -c yolov8seg --source video.mp4 --save --save-path output/segmentation_result.mp4
# Process image folder for segmentation
hailo-toolbox infer models/yolov8n_seg.hef -c yolov8seg --source images/ --save# Pose detection
hailo-toolbox infer models/yolov8s_pose.hef -c yolov8pose --source video.mp4 --show
# Save pose detection results
hailo-toolbox infer models/yolov8s_pose.hef -c yolov8pose --source video.mp4 --save --save-path output/pose_result.mp4
# Process image folder for pose estimation
hailo-toolbox infer models/yolov8s_pose.hef -c yolov8pose --source images/ --save# Use default camera for real-time detection
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source 0 --show
# Use secondary camera
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source 1 --show# Process RTSP stream
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source rtsp://192.168.1.100:554/stream --show# Use ONNX model
hailo-toolbox infer models/yolov8n.onnx -c yolov8det --source video.mp4 --saveCreate a batch processing script for multiple files:
#!/bin/bash
# batch_inference.sh
MODEL="models/yolov8n.hef"
CALLBACK="yolov8det"
INPUT_DIR="input_videos"
OUTPUT_DIR="output_results"
mkdir -p "$OUTPUT_DIR"
for video in "$INPUT_DIR"/*.mp4; do
filename=$(basename "$video" .mp4)
echo "Processing $filename..."
hailo-toolbox infer "$MODEL" \
-c "$CALLBACK" \
--source "$video" \
--save \
--save-path "$OUTPUT_DIR/${filename}_result.mp4"
done
echo "Batch processing completed!"# Process all images in a folder
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source dataset/images/ --save
# Process folder with custom output directory
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source dataset/test/ --save --save-path results/
# Process folder and display results
hailo-toolbox infer models/yolov8n.hef -c yolov8det --source dataset/demo/ --show- Use smaller models (yolov8n) for real-time applications
- Use larger models (yolov8s, yolov8m) for higher accuracy requirements
- Choose task-specific models (detection, segmentation, pose)
- Adjust input size to match model input dimensions
- Use appropriate color space (RGB/BGR)
- Maintain consistent input data normalization
- Regularly clean output directories
- Use appropriate compression for saved videos
- Consider storage limitations for long-running processes
- Monitor system resources during inference
- Use appropriate batch sizes
- Properly clean up resources after processing
This tutorial covers the comprehensive usage of the Hailo Toolbox inference system with the latest parameter requirements. The framework provides flexible, high-performance inference capabilities for various deep learning tasks. By following these guidelines and examples, you can effectively leverage the toolbox for your specific use cases.
Note that both --callback and --source parameters are now required for the inference command, ensuring proper configuration for all inference operations.
This project uses the MIT license. See the LICENSE file for details.