# Need help to speed up my flow

**URL:** <https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685>\
**Category:** General\
**Created:** [18 January 2024 10:26 UTC](https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685 "2024-01-18T10:26:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)\
**Post date:** [18 January 2024 10:26 UTC](https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685/1 "2024-01-18T10:26:12Z")

</div>

Hi all!

I´ve been playing around with the picamera and tensorflow recently. Technically it works fine but is pretty slow. The whole procedure (Taking image, saving image, reading back the image, evaluation) takes around 20-30s. I tried decreasing the camera-resolution but I think the bottleneck is saving the image to the sd-card and then read that file again into tensorflow.

Any ideas on how I could decrease the processing time?

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/2179f429c9f40a0f6fa76b40ca0e4f2b598e0e49.png)

```auto
[
    {
        "id": "f4b1c46ead32be2d",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "0cdf4353160d5b6b",
        "type": "image viewer",
        "z": "f4b1c46ead32be2d",
        "name": "",
        "width": "320",
        "data": "payload",
        "dataType": "msg",
        "active": true,
        "x": 750,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "306b36debe375050",
        "type": "inject",
        "z": "f4b1c46ead32be2d",
        "name": "trigger photo",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 110,
        "y": 20,
        "wires": [
            [
                "d2e26697e0fa52d4"
            ]
        ]
    },
    {
        "id": "d2e26697e0fa52d4",
        "type": "exec",
        "z": "f4b1c46ead32be2d",
        "command": "libcamera-still --width 1536 --height 1024 -q 80 -o newtest.JPEG",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "capture setting",
        "x": 120,
        "y": 120,
        "wires": [
            [
                "3689dbb728c6e8ec"
            ],
            [],
            []
        ]
    },
    {
        "id": "4847c7c7a3402623",
        "type": "jimp-image",
        "z": "f4b1c46ead32be2d",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "ret": "img",
        "parameter1": "",
        "parameter1Type": "msg",
        "parameter2": "",
        "parameter2Type": "msg",
        "parameter3": "",
        "parameter3Type": "msg",
        "parameter4": "",
        "parameter4Type": "msg",
        "parameter5": "",
        "parameter5Type": "msg",
        "parameter6": "",
        "parameter6Type": "msg",
        "parameter7": "",
        "parameter7Type": "msg",
        "parameter8": "",
        "parameter8Type": "msg",
        "sendProperty": "payload",
        "sendPropertyType": "msg",
        "parameterCount": 0,
        "jimpFunction": "none",
        "selectedJimpFunction": {
            "name": "none",
            "fn": "none",
            "description": "Just loads the image.",
            "parameters": []
        },
        "x": 610,
        "y": 80,
        "wires": [
            [
                "0cdf4353160d5b6b"
            ]
        ]
    },
    {
        "id": "497e047f9db6eb7c",
        "type": "debug",
        "z": "f4b1c46ead32be2d",
        "name": "Result",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 630,
        "y": 340,
        "wires": []
    },
    {
        "id": "3689dbb728c6e8ec",
        "type": "change",
        "z": "f4b1c46ead32be2d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "/home/pi/newtest.JPEG",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 430,
        "y": 80,
        "wires": [
            [
                "4847c7c7a3402623",
                "db8542bf22386caf"
            ]
        ]
    },
    {
        "id": "b4c71952e3216ba8",
        "type": "teachable machine",
        "z": "f4b1c46ead32be2d",
        "name": "",
        "mode": "local",
        "modelUri": "/home/pi/Pictures/tm-my-image-model/",
        "localModel": "teachable_model",
        "output": "best",
        "activeThreshold": false,
        "threshold": 80,
        "activeMaxResults": false,
        "maxResults": 3,
        "passThrough": false,
        "x": 390,
        "y": 340,
        "wires": [
            [
                "497e047f9db6eb7c"
            ]
        ]
    },
    {
        "id": "dadfc08cdd5e1b27",
        "type": "inject",
        "z": "f4b1c46ead32be2d",
        "name": "retest",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 170,
        "y": 220,
        "wires": [
            [
                "3689dbb728c6e8ec"
            ]
        ]
    },
    {
        "id": "db8542bf22386caf",
        "type": "file in",
        "z": "f4b1c46ead32be2d",
        "name": "",
        "filename": "payload",
        "filenameType": "msg",
        "format": "",
        "chunk": false,
        "sendError": false,
        "encoding": "base64",
        "allProps": false,
        "x": 440,
        "y": 160,
        "wires": [
            [
                "b4c71952e3216ba8"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [18 January 2024 11:21 UTC](https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685/2 "2024-01-18T11:21:36Z")

</div>

Sorry, but:

You may need to share more information:

What machine? Raspi ......?????

Which O/S?

Just that your flow can't just be looked at as many/most people won't have those nodes/hardware.

---

<div class="post-metadata">

**Author:** ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)\
**Post date:** [18 January 2024 11:56 UTC](https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685/3 "2024-01-18T11:56:01Z")

</div>

I am using a pi4 2gb ram version running Raspberry Pi OS(bullseye).  
I was hoping that somebody played around with this aswell 🙂  
Basically it would already help, if someone could explain to me how to output a buffer object of the taken picture from the execute-node. This way I could get rid of saving and then parsing the file to the tensorflow node.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [18 January 2024 12:14 UTC](https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685/4 "2024-01-18T12:14:49Z")

</div>

> [@nico25](#):
>
> `libcamera-still --width 1536 --height 1024 -q 80 -o newtest.JPEG`

Try this...

```auto
libcamera-still --width 1536 --height 1024 -q 80 -o -

```

This should send the output to `stdout` of the `exec` node.  
meaning you can plug the image viewer/tensorflow directly after it, and skip the IO involved with the SD Card

Dsiclaimer.  
This is just from searching

---

<div class="post-metadata">

**Author:** ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)\
**Post date:** [18 January 2024 12:28 UTC](https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685/5 "2024-01-18T12:28:27Z")

</div>

Works like a charm! Thank you 😁

---

<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:** [18 January 2024 18:39 UTC](https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685/6 "2024-01-18T18:39:28Z")

</div>

Also you may find reducing the image size helps as most models are trained on smaller images anyway.

---

<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:** [1 February 2024 18:39 UTC](https://discourse.nodered.org/t/need-help-to-speed-up-my-flow/84685/7 "2024-02-01T18:39:45Z")

</div>

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