# Node red+ raspberry pi\_push\_button+image classification

**URL:** <https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344>\
**Category:** General\
**Created:** [13 July 2021 04:06 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344 "2021-07-13T04:06:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MK1992](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@MK1992](https://discourse.nodered.org/u/MK1992)\
**Post date:** [13 July 2021 04:06 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344/1 "2021-07-13T04:06:23Z")

</div>

![mobilenet1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/9537bb139bf93e1bcc3a10c995af5007debfdd5c.png)  
[flows.json](https://discourse.nodered.org/uploads/short-url/613ulqMbEPN7WlviBt3LGKeu0Ej.json) (3.0 KB)  
So once I press the button, it will capture image and classify the image based on the model. I have used the model that nodered already provides. But I think there is sth wrong from usbcamera portion to mobilenet. That's why I cannot get the image classification result. But I don't know how. I am not sure if I am asking the basic question. Meanwhile I will try to get the result as much as I can but much appreciate for help. Thank 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:** [13 July 2021 05:52 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344/2 "2021-07-13T05:52:02Z")

</div>

Hi @MK1992 ,

As you can see in the first debug message, the msg.payload of the mobilenet output message contains an array with the names of the detected object.  
But you also send that array of names to the image preview node, so it is very normal that your image preview node cannot show it.  
You should wire your image preview node to the output of the usbcamera node I assume ...  
Bart

---

<div class="post-metadata">

**Author:** ![MK1992](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@MK1992](https://discourse.nodered.org/u/MK1992)\
**Post date:** [13 July 2021 07:38 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344/3 "2021-07-13T07:38:54Z")

</div>

Hi although I have made changes, the problem still persists.  
[flows (1).json](https://discourse.nodered.org/uploads/short-url/6xOMEHuUBrPaNr0wLskgVcqeocd.json) (2.0 KB)

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [13 July 2021 08:03 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344/4 "2021-07-13T08:03:32Z")

</div>

It would be better (and more traditional) to post your flow between the triple backticks (use the \</\> icon in the editor) so we don't have to deal with download links.

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [13 July 2021 08:10 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344/5 "2021-07-13T08:10:12Z")

</div>

> [@MK1992](#):
>
> I cannot get the image classification result

In my testing, the classifications came from a debug node set to `msg.classes`, not `msg.payload`.

---

<div class="post-metadata">

**Author:** ![MK1992](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@MK1992](https://discourse.nodered.org/u/MK1992)\
**Post date:** [14 July 2021 11:25 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344/6 "2021-07-14T11:25:59Z")

</div>

```auto
[{"id":"1da9c43d.77184c","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"b1428df3.67c61","type":"usbcamera","z":"1da9c43d.77184c","filemode":"1","filename":"image01.jpg","filedefpath":"1","filepath":"","fileformat":"jpeg","resolution":"5","name":"","x":330,"y":100,"wires":[["ae8b99d3.4c8418","eef158a4.21dce8"]]},{"id":"bbd793a1.7a082","type":"rpi-gpio in","z":"1da9c43d.77184c","name":"Button","pin":"11","intype":"down","debounce":"25","read":false,"x":110,"y":240,"wires":[["3bec5dde.56dd12"]]},{"id":"3bec5dde.56dd12","type":"function","z":"1da9c43d.77184c","name":"","func":"if (msg.payload == 1){\nvar now = new Date().toLocaleString(\"en-US\");\nnow = now.replace(\",\",\"\"); // clear out comma\nnow = now.replace(/\\//g,\"-\"); // replace all slashes\nnow = now.replace(/ /g,\"_\"); // replace all spaces\nmsg.filename = \"image_\" + now;\nreturn msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":300,"wires":[["b1428df3.67c61"]]},{"id":"eef158a4.21dce8","type":"mobilenet","z":"1da9c43d.77184c","name":"","x":520,"y":100,"wires":[["1c235fd7.997f3"]]},{"id":"1c235fd7.997f3","type":"debug","z":"1da9c43d.77184c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":140,"wires":[]},{"id":"4524ba7d.a66544","type":"inject","z":"1da9c43d.77184c","name":"Take Photo","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Take Photo","payloadType":"str","x":120,"y":160,"wires":[["b1428df3.67c61"]]},{"id":"ae8b99d3.4c8418","type":"image","z":"1da9c43d.77184c","name":"","width":160,"data":"payload","dataType":"msg","thumbnail":false,"active":false,"pass":false,"outputs":0,"x":580,"y":220,"wires":[]}]

```

I have got the classification with mobilenet which is default model when i install tensorflow in nodered, and I want to do deep learning with custom dataset with the model I have trained in nodered. is that possible to do that? Thank you.

---

<div class="post-metadata">

**Author:** ![MK1992](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@MK1992](https://discourse.nodered.org/u/MK1992)\
**Post date:** [15 July 2021 03:30 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344/7 "2021-07-15T03:30:26Z")

</div>

Just now I saw that we can convert tensoflow to tensorflow.js model for custom image classification but the problem is how we gonna define this as a node in nodered?

---

<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:** [13 September 2021 03:30 UTC](https://discourse.nodered.org/t/node-red-raspberry-pi-push-button-image-classification/48344/8 "2021-09-13T03:30:30Z")

</div>

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