runevm_fl

Creator: coderz1093

Last updated:

0 purchases

runevm_fl Image
runevm_fl Images
Add to Cart

Description:

runevm fl

runevm_fl #
RuneVM plugin for Flutter
Example app is the game 2048 with voice control
Getting Started #
Add the RuneVM plugin to your pubspec.yaml file #
dependencies:
flutter:
sdk: flutter
runevm_fl: ^0.3.0

copied to clipboard
Load and run your rune file #
Load and run your rune file in three steps:
Deploy
Future<bool> RunevmFl.load(Uint8List runeBytes)
copied to clipboard
Read manifest
Future<dynamic> RunevmFl.manifest
copied to clipboard
Run rune with input bytes
Future<String> RunevmFl.runRune(Uint8List input)
copied to clipboard
Rune Bindings Implementation
Full implementation in main.dart

import 'package:runevm_fl/runevm_fl.dart';

class RunMyRune {

double _input = 0;
String? _output;

Future<void> _loadRune() async {
try {
//Load Rune from assets into memory;
ByteData bytes = await rootBundle.load('assets/sine.rune');
bool loaded =
await RunevmFl.load(bytes.buffer.asUint8List()) ?? false;
print("Rune deployed:");
if (loaded) {
//Read Manifest with capabilities
String manifest = (await RunevmFl.manifest).toString();
print("Manifest loaded: $manifest");
}
} on Exception {
print('Failed to init rune');
}
setState(() {
_loaded = true;
});
}

void _runRune() async {
try {
Random rand = Random();
_input = rand.nextDouble() * 2 * pi;
//convert input to 4 bytes representing a Float32 (See assets/Runefile)
Uint8List inputBytes = Uint8List(4)
..buffer.asByteData().setFloat32(0, _input, Endian.little);
//Run rune with the inputBytes
_output = await RunevmFl.runRune(inputBytes);
setState(() {});
} on Exception {
print('Failed to run rune');
}
}

}

copied to clipboard
Forge Deployment Implementation
First step is to initialise Forge and deploy model

import 'package:runevm_fl/runevm_fl.dart';

void loadForge() async {
final answer = await Forge.forge({
"deploymentId": "26", //insert deploymentId here
"apiKey": "{apiKey from forge}", //insert apiKey here
"baseURL": "https://dev-forge.hotg.ai", //insert url here
"telemetry": {
"baseURL": "https://dev-telemetry.hotg.ai", //insert url here
}
});
setState(() {
_capabilities = answer;
});
}

copied to clipboard
To run inference imply provide to output to Forge.predict(Uint8List input)

void _runInference() async {
Uint8List inputData = getInputData();
final data = await Forge.predict([inputData]);
final out = (data is String) ? json.decode(data) : data;
doSomethingWithOutput(out);
}

copied to clipboard
Android #
No extra config needed
iOS #
If you are creating a new app, first run :
foo@bar:~$ flutter run
copied to clipboard
to generate the podfile.
Minimum iOS version should be at least 12.1 to be compatible with the plugin:
Set this in XCode > Runner > General > Deployment info
For version <0.3.0 Bitcode needs to be disabled either for the runevm_fl target:
XCode > Pods > Targets > runevm_fl > Build Settings > Enable Bitcode > Set to 'No'
or directly in the Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
## Add these 3 lines to your podfile
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end

end
end
copied to clipboard
Run it #
foo@bar:~$ flutter run
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.

Related Products

More From This Creator