Image classification¶
final classifier = await ImageClassifier.load(location);
final results = await classifier.classify(jpegBytes, topK: 5);
classifytakes encoded bytes (JPEG, PNG, WebP). Withmodelport_flutter, decoding uses the Flutter engine's native codecs and applies EXIF orientation.classifyImagetakes an already decodedRgbImage.- Decoding and preprocessing run in a background isolate, so the UI stays smooth.
- Each
Classificationhasindex,label, andscore. Scores are probabilities when the manifest's activation issoftmaxorsigmoid.
Choosing an engine¶
On the test phone, ExecuTorch ran MobileNetV3 in 17 ms and ONNX Runtime in 77 ms. See Performance.
Bring your own model¶
Any Hugging Face image classifier whose image processor uses a fixed size, or a shortest edge plus a center crop, is supported, including the ConvNext crop_pct rule.