GithubHelp home page GithubHelp logo

maxmarcospayne / kaia.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaiaai/kaia.js

0.0 1.0 0.0 176 KB

Kaia.ai platform's JS client library

License: Apache License 2.0

JavaScript 1.25% TypeScript 98.75%

kaia.js's Introduction

Kaia.js

Kaia.ai platform's JS client library

Usage

TfMobile

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

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

kaia.js's People

Contributors

kaiaai avatar

Watchers

James Cloos avatar

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.