搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。