YOLOv8Seg<T>

Models & Types · AiDotNet.ComputerVision.Segmentation.InstanceSegmentation

YOLOv8-Seg: Ultralytics real-time instance segmentation.

Inheritance: NeuralNetworkBase<T> → SegmentationModelBase<T> → InstanceSegmentationBase<T> → YOLOv8Seg<T>

For Beginners

YOLOv8-Seg is a fast, accurate instance segmentation model that detects individual objects and produces per-pixel masks for each. It builds on the YOLO family’s anchor-free detection with a YOLACT-style prototype mask generation branch.

Common use cases:

  • Real-time instance segmentation in video streams
  • Object counting and measurement
  • Autonomous driving perception
  • Industrial quality inspection

How It Works

Technical Details:

  • CSPDarknet backbone with C2f (Cross-Stage Partial with 2 convolutions) blocks
  • Anchor-free decoupled detection head
  • YOLACT-style prototype masks with 32 coefficients
  • Available in 5 sizes: N (3.4M), S (11.8M), M (27.3M), L (46.0M), X (71.8M)
  • Input resolution: 640x640 by default

Reference: Ultralytics, “YOLOv8”, 2023.

Example

// Create a YOLOv8-Seg model for real-time instance segmentation
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.ThreeDimensional,
    taskType: NeuralNetworkTaskType.MultiClassClassification,
    inputHeight: 640, inputWidth: 640, inputDepth: 3, outputSize: 80);
var model = new YOLOv8Seg<double>(architecture);
// Every tunable is now set through the options object; these are the defaults:
var custom = new YOLOv8Seg<double>(architecture,
    options: new YOLOv8SegOptions { NumClasses = 80, DropRate = 0, ModelSize = YOLOv8SegModelSize.N });
            
// Or load a pre-trained ONNX model for video stream processing
var onnxModel = new YOLOv8Seg<double>(architecture, "yolov8n-seg.onnx");

Constructors

Constructor Summary
YOLOv8Seg(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, YOLOv8SegOptions options) Initializes YOLOv8Seg in native (trainable) mode.
YOLOv8Seg(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, YOLOv8SegOptions options) Initializes YOLOv8Seg in ONNX (inference-only) mode.

Methods

Method Summary
InstanceSegmentationResult<T> DetectInstances(Tensor<T> image)
ModelMetadata<T> GetModelMetadata() Collects metadata describing this model’s configuration.