Package Exports
- kaia.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (kaia.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Kaia.js
Kaia.ai platform's JS client library
Usage
TfMobile
- Sample app
- Sample app source code
- Sample app source code, built with node.js and webpack
let tfMobile = await createTfMobile(model); // load model
...
let result = await tfMobile.run([img], // classify image
{feed: [
{width: size,
height: size,
inputName: 'input',
imageMean: 128.0,
imageStd: 128.0,
feedType: 'colorBitmapAsFloat'
}],
run: {enableStats: false},
fetch: {outputNames: ['MobilenetV1/Predictions/Softmax'], outputTypes: ['float']}
});
let probabilities = result.output[0];
...
tfMobile.close(); // optional
TfLite
- Sample app
- Sample app source code
- Sample app source code, built with node.js and webpack
let tfLite = await createTfLite(model); // load model
...
let result = await tfLite.run([img], // classify image
{input: [
{width: size,
height: size,
channels: 4,
batchSize: 1,
imageMean: 128.0,
imageStd: 128.0,
type: 'colorBitmapAsFloat'
}],
output: [
{type: 'float',
size: [1, 1001],
}]
});
let probabilities = result.output[0][0];
...
tfLite.close(); // optional
Installing
Via npm + webpack/rollup
npm install kaia.js
Now you can require/import kaia.js
:
import { TfMobile, TfLite } from 'kaia.js';
Via <script>
dist/kaia.mjs
is a valid JS module.dist/kaia-iife.js
can be used in browsers that don't support modules.idbKeyval
is created as a global.dist/kaia-iife.min.js
As above, but minified.dist/kaia-iife-compat.min.js
As above, but works in older browsers such as IE 10.dist/kaia-amd.js
is an AMD module.dist/kaia-amd.min.js
As above, but minified.
These built versions are also available on jsDelivr, e.g.:
<script src="https://cdn.jsdelivr.net/npm/kaia.js/dist/kaia-iife.min.js"></script>
<!-- Or in modern browsers: -->
<script type="module">
import { createTfMobile, createTfLite } from 'https://cdn.jsdelivr.net/npm/kaia.js';
</script>
and unpkg
<script src="https://unpkg.com/kaia.js/dist/kaia-iife.min.js"></script>
<!-- Or in modern browsers: -->
<script type="module">
import { createTfMobile, createTfLite } from 'https://unpkg.com/kaia.js';
</script>
Customizing NN Model
- To make a custom TfMobile model please follow a detailed Google Codelabs TFMobile tutorial
- To make a custom TfLite model please follow a detailed Google Codelabs TFLite tutorial