# Object Detection using node-red-contrib-tfjs-coco-ssd

**URL:** <https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931>\
**Category:** General\
**Created:** [10 March 2020 14:41 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931 "2020-03-10T14:41:53Z")\
**Posts on this page:** 19\
**Page:** 7

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [23 April 2020 06:48 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/122 "2020-04-23T06:48:32Z")

</div>

the update by the Palette went well :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6e81aa14ac2c6adf369f532582ba271891a94953.png)  
I came back with 1920x1080 FHD images, and I see a nice improvement. I turn around the 82-84% of memory occupation (1GB RAM), remaining \<90% during the work of detections. The RPI's Swap memory is not used even when spamming images. 🤩

The update looks promising. Wait and see in the long term ...

Thanks @dceejay

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 April 2020 07:21 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/123 "2020-04-23T07:21:46Z")

</div>

As I said above, smaller images would also help.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [23 April 2020 08:25 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/124 "2020-04-23T08:25:58Z")

</div>

I did also make some tests, added some lines to the tfjs.js file

```
        node.send(m);
        node.warn(tf.memory());
        tf.dispose(img);
        node.warn(tf.memory());
        tf.disposeVariables();
        node.warn(tf.memory());

```

The result:  
tf.dispose(img) seems to clear correctly, in my case, when analyzing going up to 787 and then always returning to 786 when finished. Adding tf.disposeVariables() seems not necessary, at least seems not make any additional difference on memory  
Also total memory seems to be freed up (from 111 free before analyze and 142 after when finished)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/44d1038e92856c6b8182e1a9de30a10e8755ee5e.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/69bc355172f9a6c8ba6bbaa31c7ca86d5e6272f9.png)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 April 2020 09:03 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/125 "2020-04-23T09:03:12Z")

</div>

so I got lucky first time ! yay !

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [23 April 2020 09:17 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/126 "2020-04-23T09:17:41Z")

</div>

@dceejay  
yes, very good!!!

I have another "thing" I would like to ask about. As I wrote [earlier](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/116), there is a problem on certain platforms, like arm64. I managed to solve this with a fix but as soon as I update the node, my "fix" is of course overwritten and I have to do the delete-copy-paste of folders again in the @tensorflow module

This particular problem is obviously related to some platforms like the arm64. Don't know if the RPi4 is affected as well or if your node works out of the box?

I'm just thinking out loud here, could it be possible to have some kind of platform identification when installing the node? It is the dependency of @tensorflow I think is the part that would need this

First workaround could be not to touch @tensorflow at all if it is arm64 and maybe just present a note that this has to be installed separately. Ultimate solution is of course to detect the platform and then select the proper procedure

Just my thoughts

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [23 April 2020 09:52 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/127 "2020-04-23T09:52:52Z")

</div>

Actually, installing another node (using in this case the palette manager) also messed up the things. I installed the _node-red-contrib-bool-gate_ and afterwards, the _node-red-contrib-tfjs-coco-ssd_ did not work. I found that the tfjs\_binding.node file in "/home/user/.node-red/node\_modules/node-red-contrib-tfjs-coco-ssd/node\_modules/@tensorflow/tfjs-node/lib/napi-v5" had been removed during the install

Copied it back from my saved folder and restarted the flow helped, all working again

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [23 April 2020 12:58 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/128 "2020-04-23T12:58:36Z")

</div>

Sometimes luck makes it work the first time, it's nice when it happens 🤭

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [23 April 2020 13:05 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/129 "2020-04-23T13:05:25Z")

</div>

HI @wiredquill,  
can you try to update :

> [@Object Detection using node-red-contrib-tfjs-coco-ssd](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/121):
>
> worth a try - pushed a version 0.4.1 not sure if I've implemented it correctly - so any help / advice gratefully received...

At this time it resolve memory leak on RPI3 and ARM64 devices  
Let us know if RPI 4 consumme memory again ?

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [23 April 2020 15:14 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/131 "2020-04-23T15:14:32Z")

</div>

@dceejay Merci for the correction!  
And @SuperNinja Thanks for the info.  
I just updated and YES, memory remains stable. To be continued in the coming days.  
But clearly that's better. See the graph below.  
At each detection, there's a CPU and memory spike, it's normal.  
But now the memory goes down with each detection. Cool.

![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/4/841277656850ac0f2abe39210a76e3aec25fac08.png)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 April 2020 08:47 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/132 "2020-04-24T08:47:07Z")

</div>

Hi @krambriw  
I did in fact raise this with the tfjs guys - [https://github.com/yhwang/node-red-contrib-tf-model/issues/7](https://github.com/yhwang/node-red-contrib-tf-model/issues/7)  
so hopefully they will think about it. In theory it may be possible for "us" to do it - but really it should be part of that project. (I'm happy for any PR if anyone wants to do it of course)

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [24 April 2020 10:29 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/133 "2020-04-24T10:29:14Z")

</div>

Hello @dceejay  
Thank you, I read what you raised, I think also, as recommended, it is better they add something on their side. Until then, I know how to "repair" with the simple fix I already have

Just wondering, did your "standard" node install work out of the box on the RPi4 or is it necessary to use the dedicated fix as they explained?

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [24 April 2020 11:17 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/134 "2020-04-24T11:17:29Z")

</div>

Hi @krambriw,

> [@Object Detection using node-red-contrib-tfjs-coco-ssd](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/129):
>
> HI @wiredquill, can you try to update : At this time it resolve memory leak on RPI3 and ARM64 devices Let us know if RPI 4 consumme memory again ?

apparently @wiredquill tested with RPI4, he also had memory leak problems. It would be nice if he could answer us about it.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 April 2020 11:26 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/135 "2020-04-24T11:26:31Z")

</div>

> [@krambriw](#):
>
> did your "standard" node install work out of the box on the RPi4

no idea - I don't have a Pi4 - will let you folk tell me.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [24 April 2020 11:40 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/136 "2020-04-24T11:40:57Z")

</div>

Yes, maybe it worked since there is still no 64-bit kernel running in the RPi4 if you go for Raspbian. But one day maybe...

---

<div class="post-metadata">

**Author:** ![wiredquill](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wiredquill/32/19765_2.png) [@wiredquill](https://discourse.nodered.org/u/wiredquill)\
**Post date:** [24 April 2020 20:31 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/137 "2020-04-24T20:31:23Z")

</div>

sorry for the delay, Emergency at work.

I update to 4.1 a day and a half ago and it system has not had to reboot since.  
I'm currently sitting at around 25% men utilization on 4 Gig Raspberry Pi.

I was not downsizing the images, I was sending it 1920x1080 images directly from my security cameras.

I'll keep an eye on it over the weekend.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [25 April 2020 04:40 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/138 "2020-04-25T04:40:55Z")

</div>

@wiredquill

Hello,  
when you installed this node on your Raspberry Pi 4, did it work right away or did you have to apply the fix described [here](https://github.com/yhwang/node-red-contrib-tf-model#note)?

For the Raspberry Pi 4, you need to provide a file named `custom-binary.json` under the `scripts` directory with the following contents:

```auto
{
  "tf-lib": "https://s3.us.cloud-object-storage.appdomain.cloud/tfjs-cos/libtensorflow-cpu-linux-arm-1.15.0.tar.gz"
}

```

---

<div class="post-metadata">

**Author:** ![wiredquill](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wiredquill/32/19765_2.png) [@wiredquill](https://discourse.nodered.org/u/wiredquill)\
**Post date:** [25 April 2020 16:00 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/139 "2020-04-25T16:00:17Z")

</div>

I manualy installed @tensorflow/tfjs-node. The Flow worded fine the first time I tried it installing via the GUI. The only reason I ran the manual install was to get ride of the error msg below.

I did not need to manually create custom-binary.json

However, do receive get this error in my node-red-log

# ============================ Hi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit [https://github.com/tensorflow/tfjs-node](https://github.com/tensorflow/tfjs-node) for more details.

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [26 April 2020 06:23 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/140 "2020-04-26T06:23:24Z")

</div>

Yes I also have this message on RPI 3B. Is it interesting to do it?  
Someone tried?  
Is the gain visible?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 May 2020 06:23 UTC](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931/141 "2020-05-10T06:23:33Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/object-detection-using-node-red-contrib-tfjs-coco-ssd/22931.md?page=6)
