Skip to main content

WildTrain Detection Training Configuration

Detailed reference for detection training, evaluation, and sweep YAML configuration files.

Overview

WildTrain supports YOLO-based object detection via Ultralytics. Training configs define the model, data, training hyperparameters, and MLflow tracking.

Usage:

# Train
wildtrain train detector -c configs/detection/yolo_configs/yolo.yaml

# Evaluate
wildtrain evaluate detector -c configs/detection/yolo_configs/yolo_eval.yaml

# Hyperparameter sweep
wildtrain pipeline detection -c configs/detection/detection_sweep.yaml

Training Config (yolo.yaml)

The YOLO training config follows the Ultralytics configuration format with additional WildTrain fields.

Key Fields

FieldTypeDescription
modelstrPath to YOLO model config or pretrained weights
datastrPath to YOLO data YAML file
epochsintNumber of training epochs
imgszintInput image size
batchintBatch size
devicestr/intDevice: 0 (GPU 0), cpu, etc.
lr0floatInitial learning rate
lrffloatFinal learning rate factor
optimizerstrOptimizer: SGD, Adam, AdamW
weight_decayfloatWeight decay for regularization

Data YAML Format

The data field points to a standard YOLO data config:

train: ./images/train
val: ./images/val
nc: 3
names: ['elephant', 'giraffe', 'zebra']

Evaluation Config (yolo_eval.yaml)

Used with wildtrain evaluate detector -c CONFIG.

FieldTypeDescription
modelstrPath to trained YOLO weights
datastrPath to YOLO data YAML
imgszintInput image size
batchintBatch size
devicestr/intDevice for evaluation

Hyperparameter Sweep Config

Used with wildtrain pipeline detection -c CONFIG for Optuna-based hyperparameter optimization.

Sweep Structure

# Base config used as template
base_config: configs/detection/yolo_configs/yolo.yaml

# Search space
parameters:
model: null # Model variants (optional)
train:
lr0: [0.0001, 0.001, 0.01]
lrf: [0.01, 0.1, 0.5]
batch: [8, 16, 32]
epochs: [10, 20, 30]
imgsz: [640, 1280]
optimizer: [SGD, AdamW, Adam]
weight_decay: [0.0001, 0.0005, 0.001]

Sweep Settings

FieldTypeDefaultDescription
base_configstrPath to base training config
sweep_namestrName for the sweep experiment
n_trialsint20Number of Optuna trials
seedint42Random seed
objectivestrmap_50Metric to optimize: precision, recall, f1_score, map, map_50, map_50_95, fitness
directionstrmaximizeOptimization direction: minimize or maximize
timeoutint/nullnullMaximum optimization time in seconds

Output Settings

FieldTypeDefaultDescription
output.directorystrresults/sweeps/{name}Results output directory
output.save_resultsbooltrueSave trial results
output.save_plotsbooltrueSave optimization plots
output.formatstrbothOutput format: json, csv, or both
output.include_optimization_historybooltrueInclude full optimization history

Complete Training Example

# Model
model: yolo12n.pt
data: configs/detection/yolo_configs/data/wildlife.yaml

# Training
epochs: 100
imgsz: 800
batch: 16
device: 0

# Learning rate
lr0: 0.001
lrf: 0.01
optimizer: AdamW
weight_decay: 0.0005

# Augmentation (built into Ultralytics)
augment: true
mosaic: 1.0
mixup: 0.0

See also: