How to get the scores of each class detected , while performing a image classification using a custom ibm visual recognition model in node red?

cI am using a custom IBM visual recognition classifier in node red.But while getting the result for a image, the debug window only shows no of classes detected i.e 'custom_classes: 7'. How can i get the indivisual scores for different classes detected from the visual recognition node in node-red?
I will be glad to get any solution .

What does a debug node set to show complete message” show ?

Thanks for ur reply.Initailly ,debug node was set to 'complete msg object'.Now I set it to 'msg.result', then i got the class scores.Now , I want to display the photo, its class n class score values in separate webpage using http response node n template node, but the http response node always give -"No response object" in debug window

the template i used is-

Watson Visual Recognition on Node-RED

Node-RED Watson Visual Recognition output

Analyzed image: {{payload}}

{{#result.images.0.classifiers.0.classes}} {{/result.images.0.classifiers.0.classes}}
Name Score
{{class}} {{score}}

please suggest me about where things r getting wrong.

can you paste a snapshot of the flow itself ? - generally that suggests what it says - that there is no http response object on the msg you are trying to send back to the http rresponse node , so you must have stripped it off the msg at some point.

error

OK - - hmm I don't know enough about the Visual Reco node to know why it would do that...
(I was thinking it may have come from the lower path you have there - but that doesn't seem to be the case...)

@mst you get the "No response object" message because you are triggering the flow from the Camera node - not the HTTP In node. So when the message reaches the HTTP Response node, there is no HTTP request waiting for it to respond to.

I assume you want to be able to load the page /swp to access the result of the VR node.

You have two options.

  1. Change the flow so the HTTP In node first triggers a Camera node (you'd need to use a different node that can be triggered by a flow), so that when the message arrives at the HTTP Response node it can respond to the request.

  2. Stick with the existing camera node and have it store its results in Context - breaking the link to the HTTP Response node. Then change the HTTP In flow to get the most recent results from context and pass them to the Template/HTTP Response nodes. The down side of this approach is you have to still manually trigger the camera from the Node-RED Dashboard.

In your flow, you start with the Camera node that passes through the VR node, then to the template node and the HTTP Response node.... but when the message arrives at the Response node, there is no HTTP request for it to respond to - your flow started with the Camera node.

thanks for ur response, Sir

@knolleary sir ,Is there any node available for node-red that can be injected?

@knolleary sir ,as u said i tried to create a flow variable to store the value given by the VR node, still am unable to get the scores in the web page .Even the context,flow data dialog boxes are showing empty. Please, suggest me the right way code to store the msg.payload values.

The code you currently have gets the local context variable called 'msg.payload' - this doesn't exist.

What it should be doing is just storing the value of msg.payload into a flow Context variables.

The code to do that with a Function node is:

flow.set('m', msg.payload);
return msg;

But you can also do that with a Change node configured to set flow.m to the value of msg.payload.

Then you will need to add another Change node before the template node in your second flow to do the reverse - set msg.payload to the value of flow.m.

1 Like

Thank u very much @knolleary sir, your solution worked.
Sir , I have one more issue. I am running node-red on IBM cloud account. I want to upload live webcam images to node red at regular interval from my laptop bcoz the camera node I am using now can only be injected manually. Or if there is any way i can run javascript or python scripts on node red, that will take webcam images n upload to node red. Please, suggest me something on this....

@knolleary sir , as I have mentioned want earlier that am using node-red from ibm cloud to & want to access a file/image from local storage at regular interval automaticaly..using file-in node,etc.
Is there any way I can add path of a local directry ,so that node-red can access it at regular interval through a file-in type of node?
Please suggest me something....

HI @mst

If you want to share a file from a local device to Node-RED running in the cloud, you'll need to run something on the local device that sends the file up - perhaps as an HTTP Post.

@knolleary sir, u mean i will send a http post request to the node-red url and receive the request using a http-in node ?

@knolleary , i ran a python script to send a http post request to node red.

I got status code = 200 .Then in node red editor, i used the flow to receive the request -receive

Now , when open the url for the http-in node i get a message- 'Cannot GET /mns', but the debug node showed the msg-deb

I also saved the msg.payload of the hhtp-in node as flow variable n passed it to the visual recognition node n i got a error msg- "TypeError: The "url" argument must be of type string. Received an instance of Buffer
Iam unable to know , where am going wrong. Please guide me on this.

It is not clear from your latest post what you have done.

You show a flow with the HTTP In/Response node, you then show the output of a Debug node. What is that Debug node connected to?

Which node is logging the error about the 'url' argument?


I hope this pic will give u bttr info. :smiley:

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