HTTP Request for Tensorflow COCO SSD

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

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

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

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

BR

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

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...?

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.

[{"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":[]}]

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 ?

[{"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"]]}]

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

image

Cannot load the gate node. Which node is that?

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....

Its this one: node-red-contrib-simple-gate (node) - Node-RED

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...

Still working fine ...
image

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

Have used a bigger picture (1650x1100) but still very fast with the gate node attached:

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).

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.

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

Thank you, BR

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