# HTTP Request for Tensorflow COCO SSD

**URL:** https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721
**Category:** General
**Created:** [27 February 2021 16:02 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721 "2021-02-27T16:02:02Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Gerry-it](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gerry-it](https://discourse.nodered.org/u/Gerry-it)
#### Post date: [27 February 2021 16:02 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/1 "2021-02-27T16:02:02Z")

</div>

Hello

following different discussions here in this forum (very helpful) I was able to set up the object detection within the IP cam pictures getting from the HTTP request node. The RETURN of the HTTP request node is "a binary buffer". But it takes about 7-9 seconds to create this...

If i put the return setting to "UTF-8 string" the request is much faster, but the tf coco ssd node does not accept this and quits with this error message msg.error: "TypeError: The argument 'path' must be a string or Uint8Array without null bytes. Received '����\x00�\x00\x0B\x07\b\n' +↵ '\b\x07\x0B\n' +↵ '\t\n' +↵ "\f\f\x0B\r\x10\x1B\x12\x10\x0F\x0F\x10!\x18\x19\x14\x1B'#))'#&%,1..."

Could someone help me to find the correct setting to decrease the http-request time...otherwise the complete project does not make sense...

Thank you, BR

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [27 February 2021 16:32 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/2 "2021-02-27T16:32:15Z")

</div>

> [@Gerry-it](#):
>
> return setting to "UTF-8 string"

Hi,  
You cannot use utf-8 because then image becomes corrupt.

> [@Gerry-it](#):
>
> the request is much faster,

So for the same url, the http-request node is faster when you use utf8 instead of buffer. That sounds very strange because the utf8 is extra conversion work...

Are you sure your url is referring to an image and not to something els (e.g. an entire html page)?  
Bart

---

<div class="post-metadata">

### Author: ![Gerry-it](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gerry-it](https://discourse.nodered.org/u/Gerry-it)
#### Post date: [27 February 2021 17:32 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/3 "2021-02-27T17:32:07Z")

</div>

Hi, good question. I use this http link given from the camera supplier - of course with my settings of IP, user and password :-).

**[http://192.168.2.119/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=123456](http://192.168.2.119/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=123456)**

> **[How to Capture Live JPEG Image of Reolink Cameras via Web Browsers](https://support.reolink.com/hc/en-us/articles/360007011233-How-to-Capture-Live-JPEG-Image-of-Reolink-Cameras-via-Web-Browsers)**
>
> Applies to: All Reolink IP cameras ( B800, B400, D800, D400, Reolink battery-powered cameras, Reolink Lumus, Reolink E1, and Reolink E1 pro excluded ).
> You may capture live images of your cameras b...

BR

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [27 February 2021 17:46 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/4 "2021-02-27T17:46:46Z")

</div>

And when you enter that url in your browser, what do you see then?

---

<div class="post-metadata">

### Author: ![Gerry-it](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gerry-it](https://discourse.nodered.org/u/Gerry-it)
#### Post date: [27 February 2021 17:49 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/5 "2021-02-27T17:49:14Z")

</div>

I see the current pic from the camera in my browser...everytime i refresh i get the new one...within milliseconds...

update: now I've tried different scenarios. Strange: if I disconnect the HTTP request from the following GATE node (this one followed by the TS COCO node) the request is fast, even with buffer. If I connect it again the request is very slow...?

---

<div class="post-metadata">

### Author: ![Gerry-it](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gerry-it](https://discourse.nodered.org/u/Gerry-it)
#### Post date: [27 February 2021 18:53 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/6 "2021-02-27T18:53:53Z")

</div>

Here is the code with the connection between HTTP REQUEST and GATE node. You will see that the request will take longer compared to the case the CONNECTION is disconnected...  
Instead of my URL from the CAM I used a picture from the internet.

```auto
[{"id":"81112407.19761","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a4ed9580.a498c8","type":"http request","z":"81112407.19761","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"http://placekitten.com/300/300","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":100,"wires":[["c2976493.81c34","a8218af0.7d98c8","48319a06.09efe4"]]},{"id":"229b825b.37cb5e","type":"tensorflowCoco","z":"81112407.19761","name":"","modelUrl":"http://localhost:1880/coco/model.json","scoreThreshold":"1","passthru":"bbox","lineColour":"yellow","x":810,"y":100,"wires":[["3ef574b6.30ae5c","34f8ab62.de17a4"]]},{"id":"3ef574b6.30ae5c","type":"image","z":"81112407.19761","name":"","width":"500","data":"image","dataType":"msg","thumbnail":false,"active":false,"pass":false,"outputs":0,"x":1000,"y":160,"wires":[]},{"id":"34f8ab62.de17a4","type":"change","z":"81112407.19761","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"cars\":$count(payload[class=\"car\"]\t),\"person\":$count(payload[class=\"person\"]\t),\"umbrella\":$count(payload[class=\"umbrella\"]\t),\"bicycle\":$count(payload[class=\"bicycle\"]\t),\"motorcycle\":$count(payload[class=\"motorcycle\"]\t)}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":100,"wires":[["6cd0d21a.672f34"]]},{"id":"7500d0ba.c45608","type":"debug","z":"81112407.19761","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1330,"y":100,"wires":[]},{"id":"6cd0d21a.672f34","type":"json","z":"81112407.19761","name":"","property":"payload","action":"str","pretty":false,"x":1170,"y":100,"wires":[["7500d0ba.c45608"]]},{"id":"5b195891.b91fb","type":"change","z":"81112407.19761","name":"START","rules":[{"t":"set","p":"command","pt":"msg","to":"stop","tot":"str"},{"t":"set","p":"command","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":440,"wires":[["b5526ad2.e5be78","9a9c3c01.8e3c7"]]},{"id":"a8218af0.7d98c8","type":"change","z":"81112407.19761","name":"STOP","rules":[{"t":"set","p":"command","pt":"msg","to":"stop","tot":"str"},{"t":"set","p":"command","pt":"msg","to":"status","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":480,"wires":[["b5526ad2.e5be78","9a9c3c01.8e3c7"]]},{"id":"b5526ad2.e5be78","type":"hourglass","z":"81112407.19761","name":"Hourglas","persistId":"","humanizeLocale":"","x":900,"y":420,"wires":[["956b81b6.cc7518"]]},{"id":"956b81b6.cc7518","type":"debug","z":"81112407.19761","name":"MS","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"elapsed.millis","targetType":"msg","statusVal":"elapsed.millis","statusType":"auto","x":1050,"y":420,"wires":[]},{"id":"9a9c3c01.8e3c7","type":"debug","z":"81112407.19761","name":"last command","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"command","targetType":"msg","statusVal":"command","statusType":"auto","x":940,"y":480,"wires":[]},{"id":"311583b7.031d5c","type":"complete","z":"81112407.19761","name":"","scope":["6cd0d21a.672f34"],"uncaught":false,"x":130,"y":140,"wires":[["474f92d6.2da634","5b195891.b91fb"]]},{"id":"474f92d6.2da634","type":"delay","z":"81112407.19761","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":300,"y":140,"wires":[["a4ed9580.a498c8"]]},{"id":"48319a06.09efe4","type":"gate","z":"81112407.19761","name":"GATE","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"","persist":false,"x":650,"y":100,"wires":[["229b825b.37cb5e"]]},{"id":"857820fb.e0137","type":"change","z":"81112407.19761","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":60,"wires":[["48319a06.09efe4"]]},{"id":"3abed264.c60e26","type":"change","z":"81112407.19761","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":220,"wires":[["48319a06.09efe4"]]},{"id":"693514f1.aa38d4","type":"inject","z":"81112407.19761","name":"Start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":100,"wires":[["a4ed9580.a498c8","857820fb.e0137","5b195891.b91fb"]]},{"id":"b5953c49.daa09","type":"inject","z":"81112407.19761","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":220,"wires":[["3abed264.c60e26"]]},{"id":"c2976493.81c34","type":"image","z":"81112407.19761","name":"","width":"200","data":"payload","dataType":"msg","thumbnail":false,"active":true,"pass":false,"outputs":0,"x":680,"y":160,"wires":[]}]

```

---

<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: [27 February 2021 19:21 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/7 "2021-02-27T19:21:01Z")

</div>

What about not using a gate and using a normal switch instead ? seems quick to me. (on my Mac). Are you sure it's just not the actual recognition (coco) taking a long time ?

```auto
[{"id":"a4ed9580.a498c8","type":"http request","z":"81112407.19761","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"http://placekitten.com/300/300","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":100,"wires":[["c2976493.81c34","a8218af0.7d98c8","a740110c.49a97"]]},{"id":"229b825b.37cb5e","type":"tensorflowCoco","z":"81112407.19761","name":"","modelUrl":"http://localhost:1880/coco/model.json","scoreThreshold":"1","passthru":"bbox","lineColour":"yellow","x":810,"y":100,"wires":[["3ef574b6.30ae5c","34f8ab62.de17a4"]]},{"id":"311583b7.031d5c","type":"complete","z":"81112407.19761","name":"","scope":["6cd0d21a.672f34"],"uncaught":false,"x":130,"y":140,"wires":[["474f92d6.2da634","5b195891.b91fb"]]},{"id":"474f92d6.2da634","type":"delay","z":"81112407.19761","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":300,"y":140,"wires":[["a4ed9580.a498c8"]]},{"id":"857820fb.e0137","type":"change","z":"81112407.19761","name":"","rules":[{"t":"set","p":"gate","pt":"flow","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":60,"wires":[[]]},{"id":"3abed264.c60e26","type":"change","z":"81112407.19761","name":"","rules":[{"t":"set","p":"gate","pt":"flow","to":"close","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":220,"wires":[[]]},{"id":"693514f1.aa38d4","type":"inject","z":"81112407.19761","name":"Start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":100,"wires":[["a4ed9580.a498c8","857820fb.e0137","5b195891.b91fb"]]},{"id":"b5953c49.daa09","type":"inject","z":"81112407.19761","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":220,"wires":[["3abed264.c60e26"]]},{"id":"c2976493.81c34","type":"image","z":"81112407.19761","name":"","width":"200","data":"payload","dataType":"msg","thumbnail":false,"active":true,"pass":false,"outputs":0,"x":680,"y":160,"wires":[]},{"id":"a740110c.49a97","type":"switch","z":"81112407.19761","name":"","property":"gate","propertyType":"flow","rules":[{"t":"eq","v":"open","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":650,"y":100,"wires":[["229b825b.37cb5e"]]}]

```

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [27 February 2021 19:52 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/8 "2021-02-27T19:52:25Z")

</div>

Like Dave says, without gate node in between the image loads incredable fast on Windows too:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b677642620c0ca6d18aa8832632325819709b8dc.png)

Cannot load the gate node. Which node is that?

---

<div class="post-metadata">

### Author: ![Gerry-it](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gerry-it](https://discourse.nodered.org/u/Gerry-it)
#### Post date: [27 February 2021 19:52 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/9 "2021-02-27T19:52:30Z")

</div>

This was also my first thought, that the coco uses most of the time, but measuring with hourglass node between input and output of the coco node did not confirmed this hypothesis... Instead the tf-model is very fast....

---

<div class="post-metadata">

### Author: ![Gerry-it](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gerry-it](https://discourse.nodered.org/u/Gerry-it)
#### Post date: [27 February 2021 19:56 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/10 "2021-02-27T19:56:36Z")

</div>

Its this one: [node-red-contrib-simple-gate (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-simple-gate)

For me its just strange that the blue requesting text below the http request node stays a lot longer in the case the gate node is connected. The same if i connect directly to the tf model...

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [27 February 2021 20:00 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/11 "2021-02-27T20:00:10Z")

</div>

Still working fine ...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/3783dcde49cb89df33d4b7b332a2e47b72c3efa8.png)

---

<div class="post-metadata">

### Author: ![Gerry-it](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gerry-it](https://discourse.nodered.org/u/Gerry-it)
#### Post date: [27 February 2021 20:24 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/12 "2021-02-27T20:24:45Z")

</div>

Its working also on my side, there is just this huge runtime difference when i take the http from the cam, depending if i connect the http request with the following node or not... Hmmm

This means that you see absolutely no difference between the runtime of the http request independent from the connection with the gate node? Have you ever tried with a bigger picture? And did you measured with the hourglass too? T ank you

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [27 February 2021 21:09 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/13 "2021-02-27T21:09:15Z")

</div>

Have used a bigger [picture](https://images.unsplash.com/photo-1516918656725-e9b3ae9ee7a4?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1650&q=80) (1650x1100) but still very fast with the gate node attached:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3ee941afe13a3938e00513544fb132d83582e80e.png)

But of course:

- I'm not running the coco-ssd node after the gate node, since I got some installation errors on tensorflow.
- I'm running on a decent Windows portable. If you run this e.g. on a Raspberry, adding extra nodes to the output of the http-request node might have impact: if you have N wires at an output, the image will be copied N-1 times (which uses both RAM and CPU).

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [27 February 2021 21:24 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/14 "2021-02-27T21:24:34Z")

</div>

Are you saying it is slow if you have the gate but don't connect it to the coco node?

Edit. You have to be careful with timer nodes. If a node hogs the processor for some and it gets the processor before the start message has got to the timer then the timer may not even get started until the node you are trying to time has finished. To check for this add a 100ms delay node in front of the coco node and time from before that. The 100ms will make sure the timer gets started before the coco node grabs the processor.

---

<div class="post-metadata">

### Author: ![Gerry-it](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gerry-it](https://discourse.nodered.org/u/Gerry-it)
#### Post date: [28 February 2021 08:36 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/15 "2021-02-28T08:36:29Z")

</div>

Hi Colin, you are right, now with the correct timer setting it is clear that the COCO node consumes the time and not the http request. I'm still wondering why the "blue request text" below the http request stays there for all the time while the flow is running but anyway.

So I need to modify my question: is there a possibility to accelerate the COCO node? For example I'm only interested in detection of persons, cars and biycles...?

--\> move to this thread: [How fast is your Tensorflow COCO SSD](https://discourse.nodered.org/t/how-fast-is-your-tensorflow-coco-ssd/41747)

Thank you, BR

---

<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: [29 April 2021 08:36 UTC](https://discourse.nodered.org/t/http-request-for-tensorflow-coco-ssd/41721/16 "2021-04-29T08:36:45Z")

</div>

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