YOLO constructor

YOLO({
  1. required String modelPath,
  2. YOLOTask? task,
  3. bool useGpu = true,
  4. bool useMultiInstance = false,
  5. Map<String, dynamic>? classifierOptions,
  6. int? numItemsThreshold,
})

Creates a new YOLO instance with the specified model path and task.

The modelPath can refer to an official model ID, asset, internal storage, remote URL, or absolute file path. The task is optional when the exported model metadata already includes it. The useGpu parameter controls whether to use GPU acceleration (default: true).

If useMultiInstance is true, each YOLO instance gets a unique ID and its own channel. If false, uses the default channel for backward compatibility.

Implementation

YOLO({
  required this.modelPath,
  this.task,
  this.useGpu = true,
  bool useMultiInstance = false,
  this.classifierOptions,
  int? numItemsThreshold,
}) {
  if (useMultiInstance) {
    _instanceId = 'yolo_${DateTime.now().millisecondsSinceEpoch}_$hashCode';

    YOLOInstanceManager.registerInstance(_instanceId, this);
  } else {
    _instanceId = 'default';
  }

  this.numItemsThreshold = numItemsThreshold ?? 30;
  _channel = ChannelConfig.createSingleImageChannel(instanceId: _instanceId);
}