Skip to main content

Documentation Index

Fetch the complete documentation index at: https://wb-21fd5541-style-guide-models-integrations-20260527-015516.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Ultralytics provides computer vision models for tasks like image classification, object detection, image segmentation, and pose estimation. It hosts YOLOv8, an iteration in the YOLO series of real-time object detection models, along with other computer vision models such as SAM (Segment Anything Model), RT-DETR, and YOLO-NAS. Ultralytics also provides ready-to-use workflows for training, fine-tuning, and applying these models through an API. This page shows computer vision practitioners how to integrate W&B with Ultralytics so that W&B automatically tracks and visualizes experiment metrics, model checkpoints, and predictions on validation or inference images. It covers installation, a training and validation workflow, and an inference-only workflow.

Get started

To use the integration, you must first install both ultralytics and wandb and confirm you’re using a supported version of ultralytics. Install ultralytics and wandb:
pip install --upgrade ultralytics==8.0.238 wandb

# or
# conda install ultralytics
The development team tested the integration with ultralytics v8.0.238 and below. To report any issues with the integration, create a GitHub issue with the tag yolov8.
With both packages installed, you can move on to instrumenting an Ultralytics workflow with W&B.

Track experiments and visualize validation results

This section demonstrates a typical workflow that uses an Ultralytics model for training, fine-tuning, and validation, and that performs experiment tracking, model checkpointing, and visualization of the model’s performance using W&B. For more information about the integration, see Supercharging Ultralytics with W&B. To use the W&B integration with Ultralytics, import the wandb.integration.ultralytics.add_wandb_callback function. This callback is the entry point that registers W&B logging with the Ultralytics model.
import wandb
from wandb.integration.ultralytics import add_wandb_callback

from ultralytics import YOLO
Next, initialize the YOLO model of your choice, and invoke the add_wandb_callback function on it before performing inference with the model. Attaching the callback before training enables automatic logging during each epoch. This ensures that when you perform training, fine-tuning, validation, or inference, W&B automatically saves the experiment logs and the images, overlaid with both ground-truth and the respective prediction results using the interactive overlays for computer vision tasks, along with additional insights in a wandb.Table.
with wandb.init(project="ultralytics", job_type="train") as run:

    # Initialize YOLO Model
    model = YOLO("yolov8n.pt")

    # Add W&B callback for Ultralytics
    add_wandb_callback(model, enable_model_checkpointing=True)

    # Train/fine-tune your model
    # At the end of each epoch, predictions on validation batches are logged
    # to a W&B table with insightful and interactive overlays for
    # computer vision tasks
    model.train(project="ultralytics", data="coco128.yaml", epochs=5, imgsz=640)
With the callback attached and training started, your run now streams training metrics, model checkpoints, and per-epoch validation visualizations to your W&B project. Here’s how experiments tracked using W&B for an Ultralytics training or fine-tuning workflow look: Here’s how epoch-wise validation results are visualized using a W&B Table:

Visualize prediction results

This section demonstrates a typical workflow that uses an Ultralytics model for inference and visualizes the results using W&B. You can try out the code in Google Colab: Open in Colab. As with the training workflow, to use the W&B integration with Ultralytics, import the wandb.integration.ultralytics.add_wandb_callback function.
import wandb
from wandb.integration.ultralytics import add_wandb_callback

from ultralytics.engine.model import YOLO
Next, download a few images to test the integration on. You can use still images, videos, or camera sources. For more information about inference sources, see the Ultralytics docs.
!wget https://raw.githubusercontent.com/wandb/examples/ultralytics/colabs/ultralytics/assets/img1.png
!wget https://raw.githubusercontent.com/wandb/examples/ultralytics/colabs/ultralytics/assets/img2.png
!wget https://raw.githubusercontent.com/wandb/examples/ultralytics/colabs/ultralytics/assets/img4.png
!wget https://raw.githubusercontent.com/wandb/examples/ultralytics/colabs/ultralytics/assets/img5.png
With the test images in place, initialize a W&B run using wandb.init(). Next, initialize your desired YOLO model and invoke the add_wandb_callback function on it before you perform inference with the model. This ensures that when you perform inference, W&B automatically logs the images overlaid with your interactive overlays for computer vision tasks, along with additional insights in a wandb.Table.
# Initialize W&B Run
with wandb.init(project="ultralytics", job_type="inference") as run:
    # Initialize YOLO Model
    model = YOLO("yolov8n.pt")

    # Add W&B callback for Ultralytics
    add_wandb_callback(model, enable_model_checkpointing=True)

    # Perform prediction which automatically logs to a W&B Table
    # with interactive overlays for bounding boxes, segmentation masks
    model(
        [
            "./assets/img1.jpeg",
            "./assets/img3.png",
            "./assets/img4.jpeg",
            "./assets/img5.jpeg",
        ]
    )
You don’t need to explicitly initialize a run using wandb.init() for a training or fine-tuning workflow. However, if the code involves only prediction, you must explicitly create a run.
After you run inference, W&B logs the predicted bounding boxes and segmentation masks to your W&B run as interactive overlays. Here’s how the interactive bounding box overlay looks: For more information, see the W&B image overlays guide.

More resources