modelport_flutter 0.1.0
modelport_flutter: ^0.1.0 copied to clipboard
Flutter setup for ModelPort: app cache folder, asset bundles, and device RAM for picking model variants.
modelport_flutter #
Flutter setup for ModelPort. One call configures the model cache, asset:// bundles, native image decoding, and device RAM.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await ModelPortFlutter.init(adapters: [OnnxAdapter()]);
runApp(const MyApp());
}
What init does:
- Cache folder. Models are kept in the app support folder under
modelport/, verified once, and reused offline. - Native image decoding. JPEG and PNG are decoded by the Flutter engine instead of pure Dart. On the test phone a 1546x1213 JPEG went from 717 ms to 302 ms. EXIF orientation is applied, like Pillow does in Python. Pass
nativeImageDecoding: falseto opt out. - Assets.
asset://assets/models/<name>bundles load from your app's assets and are copied into the cache. - Device RAM. Read with
device_info_plus, so variants that need more memory than the device has are skipped.
This package re-exports package:modelport/modelport.dart, so one import is enough.
Engines #
Add the engines you need and pass them to init:
| Package | Engine |
|---|---|
modelport_onnx |
ONNX Runtime |
modelport_executorch |
PyTorch ExecuTorch |
modelport_llamacpp |
llama.cpp for GGUF language models |
See the documentation and the demo app.
License #
Apache-2.0