FLUTTER ECOSYSTEM

gtbluesky/onnxruntime_flutter

OnnxRuntime용 플러터 플러그인은 모바일 및 데스크톱 플랫폼에서 플러터 앱에 Onnx 모델을 통합하기 위한 간편하고 유연하며 빠른 Dart API를 제공합니다.

onnxruntime_flutter 프로젝트 이미지
Stars
130
Forks
73
최근 푸시(UTC)
2024. 12. 23.
프로젝트 상태
활성
gtbluesky GitHub avatar
GITHUB User

gtbluesky ↗

Interesting in Android、iOS、HarmonyOS、Flutter、AI...

NanJing, China
언어C++DartCMakeCRubySwiftKotlinMakefileObjective-C

기술 주제

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 5 개
  • flutter{"sdk":"flutter"}
  • ffi^2.0.1
  • ffigen개발 의존성^7.2.11
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^2.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

https://github.com/microsoft/onnxruntime/raw/main/docs/images/ONNX_Runtime_logo_dark.png

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();