0.1.3 • Published 2 years ago

@hotg-ai/react-native-runevm v0.1.3

Weekly downloads
-
License
MIT OR Apache-2.0
Repository
github
Last release
2 years ago

react-native-runevm

Run Rune container in React Native (iOS & Android)

Getting started

$ npm install @hotg-ai/react-native-runevm --save

Mostly automatic installation

$ react-native link @hotg-ai/react-native-runevm

Usage

Since RN does not support transferring TypedArrays to native, data is transferred in base64 over the RN-bridge. We recommend using 'react-native-base64' package for this:

$ npm install react-native-base64 --save

import Runevm, { TensorType } from '@hotg-ai/react-native-runevm';
import base64 from 'react-native-base64';

//init the Rune 

const b64encoded = base64.encodeFromByteArray(runeBytes); //bytes is a Uint8Array containing the rune
let message = await Runevm.loadWasm(b64encoded, (message) => {
  //json formatted manifest file
  console.log(message);
});

//add input before running inference (eg image data)

const b64encoded = base64.encodeFromByteArray(inputBytes);
await Runevm.addInput(1, b64encoded, [width, width, 3], TensorType.U8, (response) => {
  console.log(response);
});

//Run model

await Runevm.runRune((message) => {
  this.setState(() => {
    return { message: message };
  });
});

//Retrieve logs of inference

await Runevm.getRuneLogs((logs) => {
  console.log(logs);
});
      

A working example can be found here: example/App.js

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago