Coder Social home page Coder Social logo

pytorch_mobile_clone's Introduction

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('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]

pytorch_mobile_clone's People

Contributors

battlecook avatar cdxker avatar elb3k avatar fbelderink avatar leovinsen avatar

Watchers

 avatar  avatar

Forkers

zmongol

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.