0.0.0-05092022-1208-169dbb41c • Published 4 years ago

react-native-pytorch-core v0.0.0-05092022-1208-169dbb41c

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

PyTorch core library for React Native

The PyTorch core library for React Native is part of the PyTorch Live project. Please follow the instructions provided on the PyTorch Live website as outlined below!

🎉 Building your first PyTorch Live app

Follow the Getting Started guide. PyTorch Live offers a CLI with convenient commands to install development dependencies and initialize new projects. We also have a few tutorials for you to keep going after getting started:

📖 Documentation

The full documentation for PyTorch Live can be found on our website.

Example Usage

import * as React from 'react';
import {Button, StyleSheet, Text, View} from 'react-native';

import {MobileModel, ImageUtil} from 'react-native-pytorch-core';

// Have a look at how to prepare a model for PyTorch Live
// https://pytorch.org/live/docs/tutorials/prepare-custom-model/
const model = require('./mobilenet_v3_small.ptl');

// JSON array of classes that map the max idx to a class label
const IMAGE_CLASSES = require('./image_classes.json');

type ImageClassificationResult = {
  maxIdx: number;
  confidence: number;
};

export default function ImageClassificaion() {
  const [topClass, setTopClass] = React.useState<string>('');
  async function classifyImage() {
    const image = await ImageUtil.fromURL('https://pytorch.org/example.jpg');
    const {metrics, result} =
      await MobileModel.execute<ImageClassificationResult>(model, {
        image,
      });

    console.log(metrics);
    if (result.confidence > 0.7) {
      setTopClass(IMAGE_CLASSES[result.maxIdx]);
    } else {
      setTopClass('low confidence');
    }
  }

  return (
    <View style={StyleSheet.absoluteFill}>
      <Button title="Classify Image" onPress={classifyImage} />
      <Text>{topClass}</Text>
    </View>
  );
}

👏 How to Contribute

The main purpose of this repository is to continue evolving PyTorch Live. We want to make contributing to this project as easy and transparent as possible, and we are grateful to the community for contributing bug fixes and improvements. Read below to learn how you can take part in improving PyTorch Live.

Code of Conduct

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

Read our Contributing Guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to PyTorch Live.

License

PyTorch Live is MIT licensed, as found in the LICENSE file.

0.2.3

3 years ago

0.2.4

3 years ago

0.2.2

3 years ago

0.2.0-rc.3

3 years ago

0.2.0-rc.2

3 years ago

0.2.0-rc.1

3 years ago

0.2.0-rc.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.0.4-alpha.9

4 years ago

0.0.4-alpha.10

4 years ago

0.1.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.3

4 years ago

0.0.4-alpha.5

4 years ago

0.0.4-alpha.6

4 years ago

0.0.4-alpha.7

4 years ago

0.0.4-alpha.8

4 years ago

0.0.2-alpha.22

4 years ago

0.0.2-alpha.23

4 years ago

0.0.2-alpha.24

4 years ago

0.0.2-alpha.25

4 years ago

0.0.2-alpha.26

4 years ago

0.0.2-alpha.27

4 years ago

0.0.2-alpha.28

4 years ago

0.0.2-alpha.14

4 years ago

0.0.2-alpha.15

4 years ago

0.0.2-alpha.16

4 years ago

0.0.2-alpha.17

4 years ago

0.0.2-alpha.18

4 years ago

0.0.2-alpha.19

4 years ago

0.0.2-alpha.20

4 years ago

0.0.2-alpha.21

4 years ago

0.0.2-alpha.13

4 years ago

0.0.2-alpha.12

4 years ago

0.0.2-alpha.11

4 years ago

0.0.2-alpha.10

4 years ago

0.0.2-alpha.9

4 years ago

0.0.2-alpha.8

4 years ago

0.0.2-alpha.7

4 years ago

0.0.2-alpha.6

4 years ago

0.0.2-alpha.5

4 years ago

0.0.2-alpha.4

4 years ago

0.0.2-alpha.3

5 years ago

0.0.2-alpha.2

5 years ago

0.0.2-alpha.1

5 years ago

0.0.2-alpha.0

5 years ago

0.0.1

5 years ago