Melange
API ReferenceFlutter

ZeticMLangeModel

API reference for general model inference in Flutter.

This page reflects zetic_mlange 1.9.1.

ZeticMLangeModel loads a general on-device model from the Melange registry and runs tensor inference from Dart.

Import

import 'package:zetic_mlange/zetic_mlange.dart';

create

static Future<ZeticMLangeModel> create({
  required String personalKey,
  required String name,
  int? version,
  ModelMode modelMode = ModelMode.runAuto,
  QuantType? quantType,
  Target? target,
  APType apType = APType.na,
  MlangeProgressCallback? onProgress,
  ZeticMLangeCacheHandlingPolicy cacheHandlingPolicy =
      CacheHandlingPolicy.removeOverlapping,
})
ParameterTypeDefaultDescription
personalKeyString-Personal key for accessing the model.
nameString-Model name in account_name/project_name format.
versionint?nullModel version. null loads the latest version.
modelModeModelModerunAutoBackend selection strategy.
quantTypeQuantType?nullOptional precision filter.
targetTarget?nullOptional backend target filter.
apTypeAPTypenaOptional processor filter.
onProgressMlangeProgressCallback?nullDownload progress callback from 0.0 to 1.0.
cacheHandlingPolicyZeticMLangeCacheHandlingPolicyremoveOverlappingManaged artifact cache cleanup policy.
final model = await ZeticMLangeModel.create(
  personalKey: personalKey,
  name: 'account_name/project_name',
);

run

Runs inference with tensors matching the model input order.

List<Tensor> run([List<Tensor> inputs = const []])
ParameterTypeDescription
inputsList<Tensor>Input tensors matching the model's expected shapes and data types.

Returns: output tensors in model output order.

final outputs = model.run([inputTensor]);
final firstOutput = outputs.first;

Lifecycle

bool get isClosed
void close()

Call close() when the model is no longer needed.

model.close();

On this page