搜索插件、代码仓与 APP 分类

插件详情v1.4.1

onnxruntime

OnnxRuntime 的 Flutter 插件为在跨移动和桌面平台的 Flutter 应用中集成 Onnx 模型提供了一个简单、灵活且快速的 Dart API。

AndroidiOSmacOSWindowsLinux
近 30 天下载
1.6万
喜欢数
73
Pub 分数
150

安装插件

flutter pub add onnxruntime

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

onnxruntime Flutter 插件可实现 ONNX(开放神经网络交换)模型在 Android、iOS、macOS、Windows 和 Linux 上的无缝集成。它提供了一个快速、灵活且易于使用的 Dart API,可在应用程序中直接运行机器学习推理。非常适合以最小开销部署预训练模型,支持广泛的机器学习任务,包括图像识别、目标检测和自然语言处理。该插件利用底层 ONNX Runtime 引擎的性能,同时保持跨平台兼容性。

适合场景

  • 图像分类
  • 目标检测
  • 自然语言处理
  • 移动应用中的实时推理
  • 桌面机器学习应用

主要特点

  • 跨平台支持
  • 高性能推理
  • 简单的 Dart API
  • ONNX 模型兼容性
  • 轻量级集成

适合对象

  • 开发基于机器学习的 Flutter 应用程序的开发者
  • 使用 ONNX 模型的团队
  • 需要实时推理的应用程序
  • 移动和桌面机器学习部署
  • 需要跨平台机器学习的项目

使用建议

  • 需要 ONNX 模型转换
  • 仅限 ONNX 兼容模型
  • 模型大小影响应用包
  • 无内置模型训练
  • 平台特定的运行时依赖项

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

OnnxRuntime Plugin

pub package

Overview

Flutter plugin for OnnxRuntime via dart:ffi provides an easy, flexible, and fast Dart API to integrate Onnx models in flutter apps across mobile and desktop platforms.

Platform Android iOS Linux macOS Windows
Compatibility API level 21+ * * * *
Architecture arm32/arm64 * * * *

*: Consistent with Flutter

Key Features

  • Multi-platform Support for Android, iOS, Linux, macOS, Windows, and Web(Coming soon).
  • Flexibility to use any Onnx Model.
  • Acceleration using multi-threading.
  • Similar structure as OnnxRuntime Java and C# API.
  • Inference speed is not slower than native Android/iOS Apps built using the Java/Objective-C API.
  • Run inference in different isolates to prevent jank in UI thread.

Getting Started

In your flutter project add the dependency:

dependencies:
  ...
  onnxruntime: x.y.z

Usage example

Import
import 'package:onnxruntime/onnxruntime.dart';
Initializing environment
OrtEnv.instance.init();
Creating the Session
final sessionOptions = OrtSessionOptions();
const assetFileName = 'assets/models/test.onnx';
final rawAssetFile = await rootBundle.load(assetFileName);
final bytes = rawAssetFile.buffer.asUint8List();
final session = OrtSession.fromBuffer(bytes, sessionOptions!);
Performing inference
final shape = [1, 2, 3];
final inputOrt = OrtValueTensor.createTensorWithDataList(data, shape);
final inputs = {'input': inputOrt};
final runOptions = OrtRunOptions();
final outputs = await _session?.runAsync(runOptions, inputs);
inputOrt.release();
runOptions.release();
outputs?.forEach((element) {
  element?.release();
});
Releasing environment
OrtEnv.instance.release();

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。