Train an Object Detector


Before training an object detector, you'll need a properly prepared dataset. If you haven't created one yet, follow our Building a Dataset: Object Detection guide first.

Quick Start

If you're looking to get up and running quickly, follow these essential steps:

You need a properly formatted dataset with images and annotations in COCO JSON format. If you don't have one yet, you can download our sample dataset:

Plane Dataset

Basic Training Steps

  1. Create a new Canvas

  2. Drag the Object Detection Trainer element onto your Canvas

  3. Open the settings panel by clicking the ... button in the top right corner

  4. Configure the essential settings:

    • Give your model and training execution a descriptive name
    • Click Select Directory and choose the folder containing your images and annotations
  5. Close the settings panel

  6. Click the Run button at the top right to start training

The first time you run this flow, dependencies will be installed automatically, which may take several minutes.

Once training completes, you can use your model with the Object Detector element.

Comprehensive Training Guide

For optimal results with your object detector, understanding and configuring the training parameters is essential.

  1. Training Data Configuration

    Dataset Selection

    Configure your training data:

    • Training Data Path: Select the folder containing your training images and annotations
    • Validation Split: Percentage of training data used for validation (recommended: 20%)

    Your annotations must be in COCO JSON format in an "annotations" folder within your training data folder.

    Class Configuration

    Set up your model classes:

    • Model Classes: Verify that all classes from your annotations are correctly listed
    • Number of Classes: Should automatically match your annotation data
  2. Model Parameters

    Model Architecture

    Choose your model configuration:

    • Base Model: Choose from available architectures (YOLOv5, YOLOv8, etc.)
    • Model Size: Select based on your performance needs:
      • Nano: Fastest but least accurate (best for resource-constrained environments)
      • Small: Good balance for many applications
      • Medium: Better accuracy with moderate speed
      • Large: High accuracy with slower performance
      • XL: Highest accuracy but requires significant resources

    Training Hyperparameters

    Configure training parameters:

    • Batch Size: Number of images processed together (higher values require more memory)
    • Learning Rate: Controls how quickly the model adapts (default is usually optimal)
    • Epochs: Number of complete passes through the training dataset

    Data Augmentation

    Data augmentation artificially expands your training dataset by creating variations of your images:

    • Horizontal Flip: Mirrors images horizontally
    • Vertical Flip: Mirrors images vertically
    • Rotation: Rotates images by random angles
    • Color Jitter: Randomly adjusts brightness, contrast, and saturation

    Enable augmentations that match real-world variations your model will encounter.

  3. Monitoring Training Progress

    During training, you can monitor several key metrics:

    Loss Curves

    Shows how well the model is learning:

    • Training Loss: Should decrease steadily
    • Validation Loss: Should follow a similar pattern without significant divergence

    Precision and Recall

    Measures detection accuracy:

    • Precision: Percentage of detections that are correct
    • Recall: Percentage of actual objects that are detected

    mAP (mean Average Precision)

    Overall accuracy metric:

    • Higher values: Indicate better performance
    • IoU Thresholds: Values are calculated at different Intersection over Union thresholds

    You can expand the trainer element during training to view these metrics in real-time.

  4. Using Your Trained Model

    Once training completes, your model is ready to use:

    • Setup: Create a new Canvas with an Object Detector element
    • Configuration: Configure the detector to use your newly trained model
    • Connection: Connect input sources (camera or media) and output displays

    See our Object Detector guide for detailed instructions on configuring and using your trained model.

  5. Troubleshooting Training Issues

    If you encounter issues during training:

    • Poor Detection: Try increasing epochs or adjusting learning rate
    • Stalled Training: Check your dataset for annotation errors
    • Memory Issues: Reduce batch size or use a smaller model
    • Low Accuracy: Ensure your training dataset has sufficient variety and accurately represents your target environment

Next Steps