The YOLO OBB Blueprint is for oriented object detection using Ultralytics YOLO. This Blueprint wraps the YOLO v8 model to train models that can detect non-axis aligned objects (oriented bounding boxes).
This Blueprint provides a complete training pipeline for oriented object detection tasks. It integrates with the Blueprint Toolkit to locally manage Training Runs, checkpoints, metrics, and datasets.
- Oriented Object Detection: Train YOLO models to detect rotated objects using oriented bounding boxes
- Checkpoint Management: Automatic checkpoint saving and resuming
- Metrics Tracking: Integration with training metrics and evaluation
- Model Export: Exports trained models in TorchServe format for deployment
The main training module that:
- Initializes and configures YOLO OBB models
- Manages training loops with custom callbacks
- Handles dataset fetching and conversion
- Saves checkpoints and models
- Tracks metrics and progress
Key classes:
CallbackYOLO: Extended YOLO class withrun_contextintegrationOBBTrainerWithCallbacks: Custom trainer withrun_contextcallbacksCallbacks:run_contextcallbacks for checkpoint saving and metric tracking
Pydantic-based configuration management:
Config: Main configuration model with validation
Supports configuration options including:
- Model initialization (from checkpoint or pretrained model)
- Training hyperparameters (epochs, batch size, image size)
- Class mappings
data/util.py: Converts YOLO results to standardized oriented bounding box formatyolo_yaml.py: Generates YOLO dataset configurationyamlfiles
This Blueprint is designed to be run as part of a training system that provides a RunContext. The main entry point is the train() function that accepts a RunContext and executes the training loop. This library leverages a local run context but can be extended with custom RunContext implementations.
The following example demonstrates how to start training from a local_run_context
where config is the training run configuration expected by the blueprint below:
with open(config_path) as fp:
config = json.load(fp)
run_context = local_run_context(
run_id=<your Run ID>, config=config, base_dir=<your base dir>
)
with run_context:
train(run_context)Example configuration structure:
{
"datasets": {
"train_data": [
{
"snapshot_id": 123,
"split": "train"
}
],
"val_data": [
{
"snapshot_id": 123,
"split": "val"
}
]
},
"class_to_idx": null,
"idx_to_class": null,
"start_model": null,
"ckpt_epoch_period": 5,
"log_level": "INFO",
"epochs": 100,
"batch_size": 16,
"resize_to": 640
}