Coder Social home page Coder Social logo

hsvdo / flutter_pytorch_mobile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fbelderink/flutter_pytorch_mobile

0.0 0.0 0.0 41.67 MB

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

Home Page: https://pub.dev/packages/pytorch_mobile

License: Other

Ruby 7.55% Python 1.71% Objective-C 10.81% Java 31.45% Dart 26.46% Objective-C++ 22.01%

flutter_pytorch_mobile's Introduction

pytorch_mobile

A flutter plugin for pytorch model inference, supported both for Android and iOS.

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('assets/models/custom_model.pt');

Or image model:

Model imageModel = await PyTorchMobile
        .loadModel('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");

Image prediction for an image with custom mean and std

final mean = [0.5, 0.5, 0.5];
final std = [0.5, 0.5, 0.5];
String prediction = await _imageModel
        .getImagePrediction(image, 224, 224, "assets/labels/labels.csv", mean: mean, std: std);

Contact

[email protected]

flutter_pytorch_mobile's People

Contributors

fbelderink avatar elb3k avatar hsvdo avatar battlecook avatar cdxker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.