pytorch_mobile 0.0.2
pytorch_mobile: ^0.0.2

Flutter Android iOS

A flutter plugin for pytorch model inference. Supports image models as well as custom models.

pytorch_mobile #

A flutter plugin for pytorch model inference. Since this is still being developed, the plugin is only supported for Android. An iOS version is going to come soon

Usage #

Installation #

To use this plugin, add pytorch_mobile as a dependency in your pubspec.yaml file.

Create a assets folder with your pytorch model and labels if needed. Modify pubspec.yaml accoringly.

assets:
 - assets/models/model.pt
 - assets/labels.csv

Run flutter pub get

Import the library #

import 'package:pytorch_mobile/pytorch_mobile.dart';

Load model #

Either custom model:

Model customModel = await PyTorchMobile
        .loadModel(model: 'assets/models/custom_model.pt');

Or image model:

Model imageModel = await PyTorchMobile
        .loadModel(model: 'assets/models/resnet18.pt');

Get custom prediction #

List prediction = await customModel
        .getPrediction([1, 2, 3, 4], [1, 2, 2], DType.float32);

Get prediction for an image #

String prediction = await _imageModel
        .getImagePrediction(image, 224, 224, "assets/labels/labels.csv");

Contact #

fynnmaarten.business@gmail.com

7
likes
90
pub points
58%
popularity

A flutter plugin for pytorch model inference. Supports image models as well as custom models.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

fynnmaarten.business@gmail.com

License

BSD (LICENSE)

Dependencies

flutter, path, path_provider

More

Packages that depend on pytorch_mobile