forked from watson-developer-cloud/node-red-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavr_classify_image_flow.json
90 lines (90 loc) · 3.54 KB
/
avr_classify_image_flow.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
[
{ "id":"fdfac57e.3a6c48",
"type":"http in",
"name":"",
"url":"/recognize",
"method":"get",
"swaggerDoc":"",
"x":133,"y":104,"z":"b8faba5a.41017",
"wires":[["faa4232c.af7478"]]
},
{ "id":"f41b5f2e.e7538",
"type":"http response",
"name":"HTTP Response",
"x":990,"y":203,"z":"b8faba5a.41017",
"wires":[]
},
{ "id":"faa4232c.af7478",
"type":"switch",
"name":"Check image param",
"property":"payload.url",
"rules":[{"t":"null"},{"t":"else"}],
"checkall":"false",
"outputs":2,
"x":218,"y":186,"z":"b8faba5a.41017",
"wires":[["89b54f88.f3a598"],["58db18d2.a95f8"]]
},
{ "id":"89b54f88.f3a598",
"type":"template",
"name":"HTML Input Form",
"field":"payload",
"format":"html",
"template":"<h1>Visual Recognition Demo on Node-RED</h1>\n<h2>Type a image URL</h2>\n<form action=\"{{req._parsedUrl.pathname}}\">\n Url: <input type=\"text\" name=\"url\"/><br/>\n Classifier id: <input type=\"text\" name=\"classifier_id\"/><br/>\n <input type=\"submit\" value=\"Classify\"/>\n</form>\n",
"x":681,"y":181,"z":"b8faba5a.41017",
"wires":[["f41b5f2e.e7538"]]
},
{ "id":"58db18d2.a95f8",
"type":"function",
"name":"Classify",
"func":"msg.imageurl = encodeURI(msg.payload.url)\nmsg.url=\"https://visual-recognition-moscow.mybluemix.net/api/classify?url=\" + encodeURI(msg.payload.url)+\"&classifier_id=\" + encodeURI(msg.payload.classifier_id);\nreturn msg;",
"outputs":1,
"noerr":0,
"x":338,"y":288,"z":"b8faba5a.41017",
"wires":[["e7f50db3.0886c8"]]
},
{ "id":"e7f50db3.0886c8",
"type":"http request",
"name":"",
"method":"GET",
"ret":"obj",
"url":"",
"x":339,"y":394,"z":"b8faba5a.41017",
"wires":[["7966fc0e.fa67bc","2d0a233d.c0b494"]]
},
{ "id":"2d0a233d.c0b494",
"type":"debug",
"name":"JSON RESULT",
"active":true,
"console":"false",
"complete":"true",
"x":533.5,"y":430,"z":"b8faba5a.41017",
"wires":[]
},
{ "id":"7966fc0e.fa67bc",
"type":"function",
"name":"Set Header for HTML",
"func":"msg.imageclasses = msg.payload;\nmsg.headers = {'Content-Type' : 'text/html'};\nreturn msg;",
"outputs":1,
"noerr":0,
"x":523,"y":333,"z":"b8faba5a.41017",
"wires":[["8684d0ae.77d9f8","7f468394.20f70c"]]
},
{ "id":"8684d0ae.77d9f8",
"type":"debug",
"name":"Image Data",
"active":true,
"console":"false",
"complete":"imageclasses",
"x":722,"y":377,"z":"b8faba5a.41017",
"wires":[]
},
{ "id":"7f468394.20f70c",
"type":"template",
"name":"HTML Classification Response",
"field":"payload",
"format":"handlebars",
"template":"<h1>Visual Recognition on Node-RED</h1>\n{{#imageclasses}}\n {{#images}}\n <div><img src=\"{{imageurl}}\" height='100'/></div>\n <div>{{image}}</div>\n <br/>\n <table border='1'>\n <thead>\n <tr><th>Classifier</th><th>Score</th></tr>\n </thead>\n <tbody>\n {{#scores}}\n <tr>\n <td>\n {{name}}\n </td>\n <td>\n {{score}}\n </td>\n </tr>\n {{/scores}} \n {{^scores}}\n <tr>\n <td colspan=\"2\">\n No match to classification\n </td>\n </tr>\n {{/scores}} \n </tbody>\n </table>\n {{/images}} \n{{/imageclasses}}\n",
"x":718,"y":253,"z":"b8faba5a.41017",
"wires":[["f41b5f2e.e7538"]]
}
]