Giter Club home page Giter Club logo

darknet.js's Introduction

Darknet.JS

A Node wrapper of pjreddie's open source neural network framework Darknet, using the Foreign Function Interface Library. Read: YOLOv3 in JavaScript.

Prerequisites

  • Linux, Windows (Linux sub-system),
  • Node
  • Build tools (make, gcc, etc.)

Examples

To run the examples, run the following commands:

# Clone the repositorys
git clone https://github.com/bennetthardwick/darknet.js.git darknet && cd darknet
# Install dependencies and build Darknet
npm install
# Compile Darknet.js library
npx tsc
# Run examples
./examples/example

Note: The example weights are quite large, the download might take some time

Installation

You can install darknet with npm using the following command:

npm install darknet

If you'd like to enable CUDA and/or CUDANN, export the flags DARKNET_BUILD_WITH_GPU=1 for CUDA, and DARKNET_BUILD_WITH_CUDNN=1 for CUDANN, and rebuild:

export DARKNET_BUILD_WITH_GPU=1
export DARKNET_BUILD_WITH_CUDNN=1
npm rebuild darknet

You can enable OpenMP by also exporting the flag DARKNET_BUILD_WITH_OPENMP=1;

You can also build for a different architecture by using the DARKNET_BUILD_WITH_ARCH flag.

Usage

To create an instance of darknet.js, you need a three things. The trained weights, the configuration file they were trained with and a list of the names of all the classes.

import { Darknet } from "darknet";

// Init
let darknet = new Darknet({
  weights: "./cats.weights",
  config: "./cats.cfg",
  names: ["dog", "cat"],
});

// Detect
console.log(darknet.detect("/image/of/a/dog.jpg"));

In conjuction with opencv4nodejs, Darknet.js can also be used to detect objects inside videos.

const fs = require("fs");
const cv = require("opencv4nodejs");
const { Darknet } = require("darknet");

const darknet = new Darknet({
  weights: "yolov3.weights",
  config: "cfg/yolov3.cfg",
  namefile: "data/coco.names",
});

const cap = new cv.VideoCapture("video.mp4");

let frame;
let index = 0;
do {
  frame = cap.read().cvtColor(cv.COLOR_BGR2RGB);
  console.log(darknet.detect(frame));
} while (!frame.empty);

Example Configuration

You can download pre-trained weights and configuration from pjreddie's website. The latest version (yolov3-tiny) is linked below:

If you don't want to download that stuff manually, navigate to the examples directory and issue the ./example command. This will download the necessary files and run some detections.

Built-With

darknet.js's People

Contributors

alexnodex avatar bennett-microsoft avatar bennetthardwick avatar dependabot[bot] avatar kossolax avatar legraphista avatar ngoan98tv avatar teisd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

darknet.js's Issues

Multiple async calls causes incorrect results

When I make multiple calls to detectAsync consecutively with different images I get very different results than I do when I run the model with a single call.

For a particular image, a single call to detectAsync with no other consecutive calls gives the expected results that match what the darknet command line detect command gives for the same image.

But when I add a second call to detectAsync immediately after this call, the first and second calls return different and entirely incorrect JSON objects. Not surprisingly, this holds true for the third, fourth, and consecutive concurrent calls.

If there is some kind of workaround or fix for this that would be great. Otherwise I will just use the synchronous version.

Support Windows

AlexeyAB's fork of darknet works with Windows. The install script and binding.gyp files will need to be updated for Windows so that it will fetch and build from there.

Changes to the darknet makefile can cause for the install script to fail

2 days ago the owner of the darknet repository pushed a change to the makefile in which he changed OPENCV=0 to OPENCV=1. For those of us that do not have OpenCV installed and configured, npm install does not work. Adding the following lines to install-script.sh lines fixes the problem.

sed -i -e "s/OPENCV=[01]/OPENCV=0/g" ./Makefile
sed -i -e "s/OPENMP=[01]/OPENMP=0/g" ./Makefile

It would be nice for this library to add the options for compiling with OpenCV and OpenMP in the same way that it has the options to compile with GPU and CUDNN.

Dependencie node-ffi is not working on ARM64

Hi,

I'm trying to install the project on a jetson tx2 (arm64). I get that the dependence node-ffi can't be install.

After testing a lot of things, I was able to install https://github.com/zsmweb/node-ffi-aarch64. I know it's not made for my architecture and I was not really surprise when darknet didn't work with it. (If you want the error I get I can give it to you)

I know it's not the issue of this project, but I would like to know if it's possible to replace the node-ffi with something else or a previous version that would work on my architecture.

Usually I would have ask the node-ffi community to help me with that but the issue have been known for more then a year and nothing really happen.

Thank you

output image with boxes

will it be possible to output an image, which I can return to call (I am calling this API via an express based web service) along with the predictions json?

feature request: mask

can we provide mask in terms of set points for a polygon to be able to mask of part of the image that can be ignored when doing the detection.

For example I have an image of my driveway and walkway, I would like it ignore the road, neighbours house etc for object detection. what are you thoughts.

Memory Leak

Hi,
First of all, thanks a lot for the great work and continued support for this wrapper.
It works very well from what I used it for albeit it is slower than the original.
However, I have been using it on long videos and rtsp streams and noticed that the ram usage keeps going up and up until the computer just crashes from having all its memory hogged up.

Is this only happening to me or is this known?

"sh: 1: tsc: not found" at install

According to the documentation here, npm prepare is run before publishing but also while installing the project, resulting in tsc: not found if typescript is not installed globally.

I suggest using prepublishOnly if possible to circumvent the issue. I could open a PR for it if you'd like.

Error while trying to install with GPU and CUDNN support

It installs fine without gpu and cudnn support but fails when i try to install it with it.

Part of the log with error:

mkdir -p obj
mkdir -p backup
mkdir -p results
gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -fopenmp -Ofast -DOPENCV -DGPU -DCUDNN -c ./src/gemm.c -o obj/gemm.o
/bin/sh: 1: pkg-config: not found
In file included from ./src/utils.h:5:0,
                 from ./src/gemm.c:2:
include/darknet.h:11:30: fatal error: cuda_runtime.h: No such file or directory
compilation terminated.
Makefile:89: recipe for target 'obj/gemm.o' failed
make: *** [obj/gemm.o] Error 1
Could not compile darknet
npm WARN enoent ENOENT: no such file or directory, open '/mnt/c/node_yolo/package.json'
npm WARN node_yolo No description
npm WARN node_yolo No repository field.
npm WARN node_yolo No README data
npm WARN node_yolo No license field.
npm ERR! Linux 4.4.0-17763-Microsoft
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "darknet"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `./install-script.sh`
npm ERR! Exit status 2
npm ERR!

Seems like its missing cuda_runtime.h from somewhere.

Error ./install-script.sh installing npm

Hello,
On Windows 10 I´m getting this error on npm install:

./install-script.sh
The command "." is either misspelled or could not be found.

I think the problem is with the first "." in the comand. Does anyone know how to avoid or solve that?

thank you

cant assign gpu and cudnn

I cant enable gpu and cudnn.when I tried to export cudnn and gpu it show me 'fatal: destination path 'darknet' already exists and is not an empty directory.' this error

how to generate IBufferImage in pure javascript ?

As in your readme, there is an example like this:

const fs = require('fs');
const cv = require('opencv4nodejs');
const { Darknet } = require('darknet');

const darknet = new Darknet({
  weights: 'yolov3.weights',
  config: 'cfg/yolov3.cfg',
  namefile: 'data/coco.names'
});
const cap = new cv.VideoCapture('video.mp4');
let frame;
let index = 0;
do {
  frame = cap.read().cvtColor(cv.COLOR_BGR2RGB);
  console.log('frame', index++); 
  console.log(darknet.detect({
    b: frame.getData(),
    w: frame.cols,
    h: frame.rows,
    c: frame.channels
  }));
} while(!frame.empty);

Now, I want to detect a single image ,but for some reason , I don't have opencv4nodejs installed, I just want to pass a IBufferImage to Darknet, the question is, how can I generate IBufferImage in pure javascript ?

Less accurate detection compare to darknet project

Hi,

I trained some darknet weights to detect a specific object. When I use the darknet project with my camera the detection is really great.

./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights

But when I use those same weights and config within my nodejs project, I have difficulty detecting the same object. It work if the object is close to the camera, but when it's a little bit far it doesn't detect anything. I use the node opencv4nodejs to capture the picture from my camera. I tested with the example with opencv4nodejs.

Do you have an idea of what could cause that issue?

beta: error when trying to process image with OPENNMP

Not sure if this is an issue w/ my build or with the beta code not supporting OPENMP

node: symbol lookup error: /server/node_modules/darknet/build/Release/darknet.node: undefined symbol: GOMP_parallel

when I try and process an image.

I am running it from ny node/express server

root@1bad14f639cf:/server# node server.js
layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   608 x 608 x   3   ->   608 x 608 x  32  0.639 BFLOPs
    1 conv     64  3 x 3 / 2   608 x 608 x  32   ->   304 x 304 x  64  3.407 BFLOPs
    2 conv     32  1 x 1 / 1   304 x 304 x  64   ->   304 x 304 x  32  0.379 BFLOPs
    3 conv     64  3 x 3 / 1   304 x 304 x  32   ->   304 x 304 x  64  3.407 BFLOPs
    4 res    1                 304 x 304 x  64   ->   304 x 304 x  64
    5 conv    128  3 x 3 / 2   304 x 304 x  64   ->   152 x 152 x 128  3.407 BFLOPs
    6 conv     64  1 x 1 / 1   152 x 152 x 128   ->   152 x 152 x  64  0.379 BFLOPs
    7 conv    128  3 x 3 / 1   152 x 152 x  64   ->   152 x 152 x 128  3.407 BFLOPs
    8 res    5                 152 x 152 x 128   ->   152 x 152 x 128
    9 conv     64  1 x 1 / 1   152 x 152 x 128   ->   152 x 152 x  64  0.379 BFLOPs
   10 conv    128  3 x 3 / 1   152 x 152 x  64   ->   152 x 152 x 128  3.407 BFLOPs
   11 res    8                 152 x 152 x 128   ->   152 x 152 x 128
   12 conv    256  3 x 3 / 2   152 x 152 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   13 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
   14 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   15 res   12                  76 x  76 x 256   ->    76 x  76 x 256
   16 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
   17 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   18 res   15                  76 x  76 x 256   ->    76 x  76 x 256
   19 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
   20 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   21 res   18                  76 x  76 x 256   ->    76 x  76 x 256
   22 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
   23 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   24 res   21                  76 x  76 x 256   ->    76 x  76 x 256
   25 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
   26 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   27 res   24                  76 x  76 x 256   ->    76 x  76 x 256
   28 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
   29 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   30 res   27                  76 x  76 x 256   ->    76 x  76 x 256
   31 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
   32 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   33 res   30                  76 x  76 x 256   ->    76 x  76 x 256
   34 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
   35 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
   36 res   33                  76 x  76 x 256   ->    76 x  76 x 256
   37 conv    512  3 x 3 / 2    76 x  76 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   38 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   39 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   40 res   37                  38 x  38 x 512   ->    38 x  38 x 512
   41 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   42 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   43 res   40                  38 x  38 x 512   ->    38 x  38 x 512
   44 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   45 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   46 res   43                  38 x  38 x 512   ->    38 x  38 x 512
   47 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   48 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   49 res   46                  38 x  38 x 512   ->    38 x  38 x 512
   50 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   51 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   52 res   49                  38 x  38 x 512   ->    38 x  38 x 512
   53 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   54 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   55 res   52                  38 x  38 x 512   ->    38 x  38 x 512
   56 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   57 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   58 res   55                  38 x  38 x 512   ->    38 x  38 x 512
   59 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   60 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   61 res   58                  38 x  38 x 512   ->    38 x  38 x 512
   62 conv   1024  3 x 3 / 2    38 x  38 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   63 conv    512  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 512  0.379 BFLOPs
   64 conv   1024  3 x 3 / 1    19 x  19 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   65 res   62                  19 x  19 x1024   ->    19 x  19 x1024
   66 conv    512  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 512  0.379 BFLOPs
   67 conv   1024  3 x 3 / 1    19 x  19 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   68 res   65                  19 x  19 x1024   ->    19 x  19 x1024
   69 conv    512  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 512  0.379 BFLOPs
   70 conv   1024  3 x 3 / 1    19 x  19 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   71 res   68                  19 x  19 x1024   ->    19 x  19 x1024
   72 conv    512  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 512  0.379 BFLOPs
   73 conv   1024  3 x 3 / 1    19 x  19 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   74 res   71                  19 x  19 x1024   ->    19 x  19 x1024
   75 conv    512  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 512  0.379 BFLOPs
   76 conv   1024  3 x 3 / 1    19 x  19 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   77 conv    512  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 512  0.379 BFLOPs
   78 conv   1024  3 x 3 / 1    19 x  19 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   79 conv    512  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 512  0.379 BFLOPs
   80 conv   1024  3 x 3 / 1    19 x  19 x 512   ->    19 x  19 x1024  3.407 BFLOPs
   81 conv    255  1 x 1 / 1    19 x  19 x1024   ->    19 x  19 x 255  0.189 BFLOPs
   82 yolo
   83 route  79
   84 conv    256  1 x 1 / 1    19 x  19 x 512   ->    19 x  19 x 256  0.095 BFLOPs
   85 upsample            2x    19 x  19 x 256   ->    38 x  38 x 256
   86 route  85 61
   87 conv    256  1 x 1 / 1    38 x  38 x 768   ->    38 x  38 x 256  0.568 BFLOPs
   88 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   89 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   90 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   91 conv    256  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 256  0.379 BFLOPs
   92 conv    512  3 x 3 / 1    38 x  38 x 256   ->    38 x  38 x 512  3.407 BFLOPs
   93 conv    255  1 x 1 / 1    38 x  38 x 512   ->    38 x  38 x 255  0.377 BFLOPs
   94 yolo
   95 route  91
   96 conv    128  1 x 1 / 1    38 x  38 x 256   ->    38 x  38 x 128  0.095 BFLOPs
   97 upsample            2x    38 x  38 x 128   ->    76 x  76 x 128
   98 route  97 36
   99 conv    128  1 x 1 / 1    76 x  76 x 384   ->    76 x  76 x 128  0.568 BFLOPs
  100 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
  101 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
  102 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
  103 conv    128  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 128  0.379 BFLOPs
  104 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
  105 conv    255  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 255  0.754 BFLOPs
  106 yolo
Loading weights from yolov3.weights...Done!
layer     filters    size              input                output
    0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  16  0.150 BFLOPs
    1 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  16
    2 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  32  0.399 BFLOPs
    3 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  32
    4 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  64  0.399 BFLOPs
    5 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  64
    6 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 128  0.399 BFLOPs
    7 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 128
    8 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 256  0.399 BFLOPs
    9 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 256
   10 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
   11 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 512
   12 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   13 conv    256  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 256  0.089 BFLOPs
   14 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
   15 conv    255  1 x 1 / 1    13 x  13 x 512   ->    13 x  13 x 255  0.044 BFLOPs
   16 yolo
   17 route  13
   18 conv    128  1 x 1 / 1    13 x  13 x 256   ->    13 x  13 x 128  0.011 BFLOPs
   19 upsample            2x    13 x  13 x 128   ->    26 x  26 x 128
   20 route  19 8
   21 conv    256  3 x 3 / 1    26 x  26 x 384   ->    26 x  26 x 256  1.196 BFLOPs
   22 conv    255  1 x 1 / 1    26 x  26 x 256   ->    26 x  26 x 255  0.088 BFLOPs
   23 yolo
Loading weights from yolov3-tiny.weights...Done!
[2019-07-23T11:46:30.368Z] darknet app listening on port :3000
[2019-07-23T11:46:34.549Z] -- yolo received --: ./uploads/f64de5faefee75946fb2a85674d0ac26
node: symbol lookup error: /server/node_modules/darknet/build/Release/darknet.node: undefined symbol: GOMP_parallel

v1.3.9 on npm

I tried to install darknet.js with opencv enabled, and found that DARKNET_BUILD_WITH_OPENCV didn't work in v1.3.8 which is the latest version published on npm. The issue has already been fixed by #16, and I was able to install it with opencv from the repo.

Do you plan to release v1.3.9 to npm anytime soon?

need to modifly ARCH= in darknet Makefile

@bennetthardwick I finally got a GPU and while comping darknet for GPU, I found that I need to be able to specify the ARCH= for my GPU in the darknet makefile. Can you please add a DARKNET_ARCH enviroment variable I can set to be able to override the ARCH= setting in the darknet makefile.

it seems that some arch's have been deprecated and cause compile issues on darknet.

box is off

The values the wrapper is returning differs from what happens when I run the same weights directly off darknet

Cannot find module darknet.node

When executing a fresh install on ubuntu, (using WSL), I get the following exception:

`drew@DESKTOP-LEGTF2V:/mnt/c/Users/Drew/WebstormProjects/project1$ node index.js
internal/modules/cjs/loader.js:883
throw err;
^

Error: Cannot find module './build/Release/darknet.node'
Require stack:

  • /mnt/c/Users/Drew/WebstormProjects/project1/node_modules/darknet/darknet.js
  • /mnt/c/Users/Drew/WebstormProjectsproject1/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object. (/mnt/c/Users/Drew/WebstormProjects/project1/node_modules/darknet/darknet.js:5:22)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/mnt/c/Users/Drew/WebstormProjects/project1/node_modules/darknet/darknet.js',
    '/mnt/c/Users/Drew/WebstormProjects/project1/index.js'
    ]
    }
    `

It appears that the native node module that should have been compiled wasn't compiled, or it is not in the correct directory. Any advice on the matter would be much appreciated.

Example for using direct buffer

Hi, I am trying to directly use a buffer, but I am not sure how I call the .detect method. I am using multer with in memory storage

my question is about predictions = darknet.detect(req.file.buffer);, I can see that detect(input: string | IBufferImage | IOpenCVFrame, config: IConfig = {}):, How can I send it IBufferImage, I have the code I am using below, which results in a throw new Error('Could not get valid image from input!');

Writing it to a file and read it back works, but I was hoping to not need that step.

app.post('/yolo', upload.single('photo'), function (req, res, next) {
  if (req.file.buffer.length < 100)  {
    console.log(`-- invalid file`);
    res.json({});
    return;      
  }
  
  var predictions = "";
  try {
    console.time("Detection");
    predictions = darknet.detect(req.file.buffer);
    console.timeEnd("Detection");

Still no support for Windows?

Hello!,

when trying to instal darknet, I am getting this error:

`C:\Users\hussj\Desktop\MLTest>npm i darknet
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: this library is no longer supported

[email protected] install C:\Users\hussj\Desktop\MLTest\node_modules\darknet
./install-script.sh && node-gyp rebuild

'.' is not recognized as an internal or external command,
operable program or batch file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: ./install-script.sh && node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hussj\AppData\Roaming\npm-cache_logs\2021-09-07T18_09_13_373Z-debug.log`

It seems it does not want run node-gyp command... Is it because I am on W10?

Thank you!

Error: ../libdarknet.so: cannot open shared object file: No such file or directory

Hi,
I compiled darknet with cuda, cudnn and cudnn_half successfully.
However when I try to run a simple script using the module I get this error:

`internal/modules/cjs/loader.js:1122
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: ../libdarknet.so: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (/home/user/test/node_modules/darknet/darknet.js:5:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)`

I'm running Ubuntu 18.04 and I have tried on different cuda versions with the same error.
This error occurs with the latest version of darknet.js with the alexeyab fork.
Any idea where this could be coming from?

Unable to install v3 on mac

Trying to install the latest version (v3) on macOS Mojave results in an error:

ld: library not found for -l:libdarknet.so
clang: fatal error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [uselib] Error 1
Could not compile darknet
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] install: `./install-script.sh && node-gyp rebuild`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Installing the previous version (v2.0.17) works just fine.

Memory leak

This wrapper works brilliantly but seems to eat up my computers ram under prolonged use.
I can't seem to find where this problem is coming from but it looks like the memory used by the images never seems to be released to the OS.
Am I the only one encountering this problem?

Typo in your docs

In your docs you have /image/of/a/dog/.jpg

Shouldn't it say /image/of/a/dog.jpg ?

Performance

First of all thank you for your hard work!!!!

Let's talk about performance:
I did some tests and on my hardware (Nvidia Jetson Nano) performance are quite low.

If I use Darknet (AlexeyAB) in order to open an IP camera with RTSP protocol I'm able to reach 13-15 FPS but if I do the same with your wrapper, using opencv4nodejs to grep RTSP data, I get only 5.5 FPS.

Darknet run command: ./darknet detector demo ./cfg/coco.data ./cfg/yolov2-tiny.cfg ./yolov2-tiny.weights "rtsp://admin:[email protected]:554"

In order to understand if the difference is Darknet fork, I also tested Darknet (pjreddie) opening webcam and the result is always 13-15 FPS.
Testing your wrapper with a MP4 video file doesn't change... 4-5 FPS.

Have you any suggestion how to reach darknet performace? I will reach at least 13-15 fps in my project.

PS: I compiled both Darknet with GPU and CUDNN support.

Thanks

No way to get example working

Hi,
I'm trying to run the example but I get an error:

`File ‘giraffe.jpg’ already there; not retrieving.

internal/modules/cjs/loader.js:638
throw err;
^

Error: Cannot find module '../darknet'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/viper/darknetjs/darknet/examples/yolov3-tiny.js:1:21)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
`
Node version: v10.16.3
Node-gyp: v5.0.3
Hardware: Nvidia Jetson Nano

Darknet is compiled corretly, also if is not the AlexeyAB fork which has better performances.

Any idea?
Thanks

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.