tflite_web 0.3.1 copy "tflite_web: ^0.3.1" to clipboard
tflite_web: ^0.3.1 copied to clipboard

Platformweb

Run Tensorflow Lite models using TFLite JS and WebAssembly on browser

TFLite Web #

Run TFLite models on Dart. It is packaged in a WebAssembly binary that runs in a browser

Getting Started #

  • Unpack tflite (link) into your web folder.
    Result structure:
    -- Web
    ├── tflite
    ──────├── tf-backend-cpu.js
    ──────├── tf-core.js
    ──────├── tf-tflite.min.js
    ──────├── tflite_web_...

  • Initialize TFLite:

await TFLiteWeb.initialize();

This may take a couple of seconds

  • Either Load Model from Url:
final model = await TFLiteModel.fromUrl(modelUrl);
  • Or load from memory:
final model = await TFLiteModel.fromMemory(modelBytes);
  • If you need to access the model from the assets in Flutter, you can either:
final url = AssetManager().getAssetUrl(asset);
final model = await TFLiteModel.fromUrl(url);
  • Or:
final byteData = await rootBundle.load(asset);
final bytes = byteData.buffer.asUint8List();
model = await TFLiteModel.fromMemory(bytes);
  • Create a tensor:
final input = Tensor(data, shape, dataType);
  • Run the model:
final outputs = model.predict(input);

Depending on the model, the input can be a Tensor, a list of Tensors, or a Tensor map

Flutter #

If you're wondering how to use this package with tflite_flutter, please refer to this article (link)

Current Version: #

  • TF-JS: 4.11.0
  • TF-JS TFLite: 0.0.1-alpha.10
15
likes
160
points
209
downloads

Publisher

verified publisherappgozar.com

Weekly Downloads

Run Tensorflow Lite models using TFLite JS and WebAssembly on browser

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

web

More

Packages that depend on tflite_web