Giter Site home page Giter Site logo

redisai-node-example's Introduction

Getting Started with RedisAI for JavaScript

This tool loads a Mobilenet image classification model into RedisAI, takes a bunch of images that you provide on the command line and classifies them with it.

Installation

  1. First and foremost, you need to have Redis and RedisAI installed. You can build this all from source, but I find it a lot easier to just use Docker. In the root of this project, I have a start-redis.sh file. It will download the needed image, make sure RedisAI is configured, and have you up and running in a jiffy (or is that giphy).

    $ ./start-redis.sh

  2. Also, make sure you have Node installed. I like to use Node Version Manager but do it how you like.

  3. Clone this repo.

    $ git clone [email protected]:redislabs-training/redisai-node-example.git

  4. Install all of the dependencies.

    $ npm install

  5. There is no step, five. You're all set!

Usage

This is a simple example that uses the CLI. Everythign you need should be included in the repo. The model is in the model folder. There are even some images to play with in the img folder.

To user the tool to classify an images, just run:

$ npm start img/panda.jpg

It'll return the top 5 most likely classes for the images, including their scores:

┌─────────┬──────────────────────────────────┬───────────────────────┐
│ (index) │              label               │         score         │
├─────────┼──────────────────────────────────┼───────────────────────┤
│    0    │          'giant panda'           │  0.9475338459014893   │
│    1    │   'Staffordshire bullterrier'    │ 0.0028441373724490404 │
│    2    │ 'American Staffordshire terrier' │ 0.0027995011769235134 │
│    3    │         'French bulldog'         │ 0.002384455408900976  │
│    4    │             'badger'             │ 0.0011667307699099183 │
└─────────┴──────────────────────────────────┴───────────────────────┘
img/panda.jpg

The CLI is variadic, so you can add multiple images as well:

$ npm start img/panda.jpg img/sample_dog.jpg img/sample_computer.jpg

┌─────────┬──────────────────────────────────┬───────────────────────┐
│ (index) │              label               │         score         │
├─────────┼──────────────────────────────────┼───────────────────────┤
│    0    │          'giant panda'           │  0.9475339651107788   │
│    1    │   'Staffordshire bullterrier'    │ 0.002844122936949134  │
│    2    │ 'American Staffordshire terrier' │ 0.002799485344439745  │
│    3    │         'French bulldog'         │ 0.0023844465613365173 │
│    4    │             'badger'             │ 0.0011667292565107346 │
└─────────┴──────────────────────────────────┴───────────────────────┘
img/panda.jpg

┌─────────┬───────────────────┬─────────────────────┐
│ (index) │       label       │        score        │
├─────────┼───────────────────┼─────────────────────┤
│    0    │    'malamute'     │ 0.3466069996356964  │
│    1    │   'Eskimo dog'    │ 0.24618299305438995 │
│    2    │ 'Siberian husky'  │ 0.15509867668151855 │
│    3    │     'dogsled'     │ 0.03109908662736416 │
│    4    │ 'German shepherd' │ 0.00960743147879839 │
└─────────┴───────────────────┴─────────────────────┘
img/sample_dog.jpg

┌─────────┬─────────────────────┬─────────────────────┐
│ (index) │        label        │        score        │
├─────────┼─────────────────────┼─────────────────────┤
│    0    │      'screen'       │ 0.29382583498954773 │
│    1    │ 'desktop computer'  │  0.164292573928833  │
│    2    │ 'computer keyboard' │ 0.08968286216259003 │
│    3    │       'mouse'       │ 0.06009386107325554 │
│    4    │      'monitor'      │ 0.05255772918462753 │
└─────────┴─────────────────────┴─────────────────────┘
img/sample_computer.jpg

And, it will even take a URL to an image, like this rando I grabbed off the Internet:

$ npm start http://guyroyse.com/guy-royse-papis-global-2018.jpg

Apparently, I'm a fur coat.

┌─────────┬──────────────────────┬──────────────────────┐
│ (index) │        label         │        score         │
├─────────┼──────────────────────┼──────────────────────┤
│    0    │      'fur coat'      │  0.3993118405342102  │
│    1    │ 'cellular telephone' │ 0.049747321754693985 │
│    2    │       'stole'        │ 0.03721235692501068  │
│    3    │        'wool'        │ 0.03711461275815964  │
│    4    │        'wig'         │ 0.02954762428998947  │
└─────────┴──────────────────────┴──────────────────────┘
http://guyroyse.com/guy-royse-papis-global-2018.jpg

redisai-node-example's People

Contributors

guyroyse avatar joecianflone avatar

Stargazers

 avatar  avatar

Watchers

 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.