-
Notifications
You must be signed in to change notification settings - Fork 2
/
image-classifier.json
1 lines (1 loc) · 3.42 KB
/
image-classifier.json
1
[{"id":"86a23f17.b0cfd","type":"http response","z":"c635c760.a7d8d8","name":"","x":906,"y":335,"wires":[]},{"id":"93239a49.b36f08","type":"function","z":"c635c760.a7d8d8","name":"Classify","func":"msg.imageurl = encodeURI(msg.payload.url)\nmsg.url=\"https://watson-api-explorer.mybluemix.net/visual-recognition/api/v3/classify?api_key=\" + encodeURI(msg.payload.apikey)+\"&url=\" + encodeURI(msg.payload.url)+\"&classifier_ids=\" + encodeURI(msg.payload.classifier_id)+\"&version=\" + encodeURI(msg.payload.version);\nreturn msg;","outputs":1,"noerr":0,"x":239,"y":260,"wires":[["249fd963.2bd146"]]},{"id":"249fd963.2bd146","type":"http request","z":"c635c760.a7d8d8","name":"","method":"GET","ret":"obj","url":"","tls":"","x":315,"y":335,"wires":[["49064ef.bd205b"]]},{"id":"49064ef.bd205b","type":"function","z":"c635c760.a7d8d8","name":"set the headers for HTML","func":"msg.imageclasses = msg.payload;\nmsg.headers = {'Content-Type' : 'text/html'};\nreturn msg;","outputs":1,"noerr":0,"x":422,"y":404,"wires":[["99276e75.88078","b905c41c.8bd4b8"]]},{"id":"99276e75.88078","type":"template","z":"c635c760.a7d8d8","name":"HTML Classification Response","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h1>Nike Finder</h1>\n<div><img src=\"{{imageurl}}\" height='100'/></div>\n{{#payload}}\n{{#images}}\n <div>{{resolved_url}}</div>\n {{#classifiers}}\n\n <br/>\n <table border='1'>\n <thead>\n <tr><th>Classifier</th><th>Score</th></tr>\n </thead>\n <tbody>\n {{#classes}}\n <tr>\n <td>\n {{class}}\n </td>\n <td>\n {{score}}\n </td>\n </tr>\n {{/classes}} \n {{^classes}}\n <tr>\n <td colspan=\"2\">\n No match to classification\n </td>\n </tr>\n {{/classes}} \n </tbody>\n </table>\n {{/classifiers}}\n{{/images}}\n{{/payload}} \n","x":533,"y":481,"wires":[["86a23f17.b0cfd"]]},{"id":"b905c41c.8bd4b8","type":"debug","z":"c635c760.a7d8d8","name":"","active":true,"console":"false","complete":"payload","x":650,"y":312,"wires":[]},{"id":"22788b0b.b9aad4","type":"switch","z":"c635c760.a7d8d8","name":"Check image param","property":"payload.url","propertyType":"msg","rules":[{"t":"null"},{"t":"else"}],"checkall":"false","outputs":2,"x":279,"y":155,"wires":[["92c7b120.9f64c"],["93239a49.b36f08"]]},{"id":"92c7b120.9f64c","type":"template","z":"c635c760.a7d8d8","name":"HTML Input Form","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h1>Find Nike shoe</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 version: <input type=\"text\" name=\"version\"/><br/>\n Api Key: <input type=\"text\" name=\"apikey\"/><br/>\n <input type=\"submit\" value=\"Classify\"/>\n</form>","x":669,"y":171,"wires":[["86a23f17.b0cfd"]]},{"id":"4eae6178.27ea8","type":"http in","z":"c635c760.a7d8d8","name":"","url":"/recognise_nike","method":"get","swaggerDoc":"","x":203,"y":87,"wires":[["22788b0b.b9aad4"]]}]