darknode
A micro HTTP service that runs darknet / yolo on provided images/video's. This
allows you to easily offload this heavy computing to a cloud server that has
support for GPU.
Table of Contents
Installation
The package is published to npm and can be installed by running:
npm install --save darknode
Configuration
{
"port": 8080,
"NODE_ENV": 'development',
"name": "secret-username",
"password": "secret-password",
"timeout": "20 minutes",
"retries": 3,
"concurrency": 10,
"expiree": "30 minutes"
}
API Client
The library ships a Node.js Client that can be used to interact with the
created server.
const DarkNode = require('darknode/client');
const api = new DarkNode({
username: 'matching username of what is specified in config',
password: 'matching password of what is specified in config',
api: 'http://address-of-server.here/'
})
The client expects 3 options:
username The basic auth username that you configured on teh server.
password The password for the basic auth username.
api The actual address of your DarkNode HTTP server.
There are 2 different ways to receive the data from the DarkNode server, but
they both assume the same options as arguments:
payload URL of where the asset is hosted, and requires detection.
record Record the DarkNode detection.
bgr24 Use bgr24 instead of rgb24 for color encoding.
stream
Asks the server to respond with an EventSource / ServerSentEvent response
which will receive the detections of your uploaded asset in near real-time.
const stream = client.stream({
payload: 'https://aws.cloud.server/video.mp4'
});
stream.on('data', (detection) => {
console.log('detection')
});
fetch
Waits until the all the detections is done to return the response from the
server.
client.fetch({
payload: 'https://aws.cloud.server/video.mp4'
}, function (err, payload) {
if (err) throw err;
console.log(payload);
});