YOLO class
YOLO (You Only Look Once) is a class that provides machine learning inference capabilities for object detection, segmentation, classification, pose estimation, and oriented bounding box detection.
This class handles the initialization of YOLO models and provides methods to perform inference on images.
Example usage:
final yolo = YOLO(
modelPath: 'assets/models/yolo11n.tflite',
task: YOLOTask.detect,
useGpu: false, // Disable GPU for stability on some devices
);
await yolo.loadModel();
final results = await yolo.predict(imageBytes);
Constructors
Properties
-
classifierOptions
→ Map<
String, dynamic> ? -
Classifier options for customizing preprocessing
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- instanceId → String
-
The unique instance ID for this YOLO instance
no setter
- isInitialized → bool
-
Returns
trueif the model has been successfully loaded via loadModel,falseotherwise. This can be used to check if the model is ready before calling predict to avoid catching ModelNotLoadedException.no setter - modelPath → String
-
Path to the YOLO model file. This can be:
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- task → YOLOTask
-
The type of task this YOLO model will perform (detection, segmentation, etc.)
final
- useGpu → bool
-
Whether to use GPU acceleration for inference.
final
Methods
-
dispose(
) → Future< void> -
loadModel(
) → Future< bool> - Loads the YOLO model for inference.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
predict(
Uint8List imageBytes, {double? confidenceThreshold, double? iouThreshold}) → Future< Map< String, dynamic> > - Runs inference on a single image.
-
setViewId(
int viewId) → void -
switchModel(
String newModelPath, YOLOTask newTask) → Future< void> - Switches the model on the associated YoloView.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
checkModelExists(
String modelPath) → Future< Map< String, dynamic> > - Checks if a model exists at the specified path.
-
getStoragePaths(
) → Future< Map< String, String?> > - Gets the available storage paths for the app.
-
withClassifierOptions(
{required String modelPath, required YOLOTask task, required Map< String, dynamic> classifierOptions, bool useGpu = true, bool useMultiInstance = false}) → YOLO - Creates a YOLO instance with classifier options for custom preprocessing