Skip to content

Library of components for TensorFlow.js in web frameworks.

License

Notifications You must be signed in to change notification settings

infinitered/ai-lab

Repository files navigation

Docs Working CodeQL

AI-Lab Bring the power of AI to Web easily. (currently in ALPHA).

This project wires together frameworks for Artificial Intelligence on the edge. The current focus is popular computer vision models in TensorFlow.js on React. The goal is to support React Native, and multiple web frameworks.

Quick Look

To play with AI-Lab, check out the latest storybook build.

React Native (broken for now) React
app example web example

Install

yarn add ai-lab @tensorflow/tfjs

Then add it

import React from 'react';
import { AILabImage } from 'ai-lab';

Dev Requirements

The packages in this repository require Node v14+ and pnpm.

Examples

📷 AILabImage

The following code automatically runs the SSD model and places bounding boxes for detections.

  <AILabImage
    model={SSD_MODEL_HERE}
    modelConfig={{
      modelType: 'ssd'
    }}
    src={require('./cat.jpeg')}
    visual
  />  

📺 AILabLocalVideo

This code runs the model on the supplied video and logs the results

  <AILabLocalVideo
    model={ClassificationModel}
    onInference={console.log}
    modelConfig={{
      modelType: 'classification',
    }}
    src={theVideo}
  />

🕸🎥 AILabWebCam

This code runs the model on the webcam feed and logs the results

    <AILabWebCam
      model={BlazePoseModel}
      onInference={console.log}
      modelConfig={{
        modelType: 'pose',
      }}
    />

Installation

Check Requirements

Assure Node > v14 Installed

node -v

Assure TypeScript Installed

tsc -v

Assure/Install PNPM

npm install -g pnpm

If you ran yarn/npm - delete all node_modules from those and start fresh.

Install project code at project root

pnpm install

Windows Users: The package tsconfig files are symlinks. If you're looking for a quick fix, you can copy the contents of the shared/tsconfig.json to these files as a temporary fix. These should not be committed like this, and should be reverted or linked in Windows.

pnpm build

Now you can run example projects that are depending on

E.G. of running the ai-lab-example example

cd examples/ai-lab-example
pnpm start

Contributing

Working within this repository requires Node v14. A Node Version Manager is recommended, such as nvm.

This repository is a monorepo, and managed by pnpm. To install it, run:

$ npm install pnpm -g

From the repository root directory, run the following command to install all dependencies:

$ pnpm install

Once install completes, development can begin.

Stacks we use :

tsdx

storybook

pnpm


⁉️ If you run into problems, first search the issues in this repository. Otherwise you can report the bug.