Skip to content

A Node.js API for Image Object Detection with Tensorflow.js & COCO SSD pretrained model

License

Notifications You must be signed in to change notification settings

gnurgeldiyev/object-detection-api

Repository files navigation

Building an Image Object Detection API with Tensorflow.js & COCO SSD pretrained model

Basic API for posting images and getting the result of detection. Uses COCO SSD pretrained model to detect objects in 300x300 px images. List of object names

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Installed local Node.js environment
  • Package manager to install packages. Yarn or npm

Clone the repo in your environment

git clone https://github.com/gnurgeldiyev/object-detection-api.git

Installing

# move into project folder
cd object-detection-api

# install the dependencies
yarn install

# rename the .env.sample
mv .env.sample .env

# add your variables
nano .env

Running the server

yarn start

Example

# POST - /detection
curl -H "Content-Type: application/octet-stream" --data-binary "@image/bicycle 300x300.jpg" "http://localhost:3000/detection"
Response
{
  "duration": 171,
  "result": [
    {
      "bbox": [
        5.610904097557068,
        85.95118224620819,
        295.6936866044998,
        171.45759165287018
      ],
      "class": "bicycle",
      "score": 0.9325430393218994
    }
  ]
}

Running the tests

yarn test

Built With

License

This project is licensed under the MIT License - see the LICENSE file for details