Skip to content

Instantly share code, notes, and snippets.

@apischdo
Created March 18, 2016 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apischdo/1af9a0c7fb970dc5e0d7 to your computer and use it in GitHub Desktop.
Save apischdo/1af9a0c7fb970dc5e0d7 to your computer and use it in GitHub Desktop.
Build a face detection app usig AlchemyAPI service on Bluemix

This lab will show you how to build a Bluemix application that uses the Alchemy Vision service analyzing the contents of an image and extract features from it. The Face Detection service is able to identify multiple faces within the image, and determine their gender and age with a confidence score, and identify celebrities.

[{"id":"8da9511c.20566","type":"change","z":"bfafde67.102e78","name":"Extract image URL","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.imageurl","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":348,"y":255.5,"wires":[["eae444de.e7596"]]},{"id":"478112c5.2ebaac","type":"switch","z":"bfafde67.102e78","name":"Check image url","property":"payload.imageurl","propertyType":"msg","rules":[{"t":"null"},{"t":"else"}],"checkall":"true","outputs":2,"x":232,"y":183.5,"wires":[["dab93b42.b803b8"],["8da9511c.20566"]]},{"id":"eae444de.e7596","type":"alchemy-image-analysis","z":"bfafde67.102e78","name":"","apikey":"__PWRD__","image-feature":"imageFaces","x":565,"y":325,"wires":[["5c2b082e.7f1a4"]]},{"id":"ba4093d0.b572d8","type":"http in","z":"bfafde67.102e78","name":"","url":"/people","method":"get","swaggerDoc":"","x":108,"y":116.5,"wires":[["478112c5.2ebaac"]]},{"id":"dab93b42.b803b8","type":"template","z":"bfafde67.102e78","name":"Prompt images","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h1>Welcome to my Face Detection app</h1>\n<H2>Recognize anyone? (Is he wearing the same dark blue jacket again?)</H2>\n<form action=\"{{req._parsedUrl.pathname}}\">\n <img src=\"http://asbarez.com/wp-content/uploads/2016/02/ibmwatson.jpg\" height='200'/>\n <img src=\"http://www.awaken.com/wp-content/uploads/2015/05/forbes.jpg\" height='200'/>\n <img src=\"https://www.commerce.gov/sites/commerce.gov/files/styles/scale_250w/public/media/images/profile/elizabethholmes.jpg?itok=DHmvdC-1\" height='200'/>\n <br/>Right-click one of the above images and select Copy image location and paste the URL in the box below.<br>Do an image search for faces, try multiple faces. After you click on an image, to the right it usually says \"View image\" click that to get the URL.<br/>\n <br>Image URL: <input type=\"text\" name=\"imageurl\"/>\n <input type=\"submit\" value=\"Analyze\"/>\n</form>","x":544,"y":124.5,"wires":[["38a9423e.12c4be"]]},{"id":"5c2b082e.7f1a4","type":"template","z":"bfafde67.102e78","name":"Report faces","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<h1>Alchemy Image Analysis</h1>\n <p>Analyzed image: {{payload}}<br/><img id=\"alchemy_image\" src=\"{{payload}}\" height=\"200\"/></p>\n {{^result}}\n <P>No Face detected</P>\n {{/result}}\n <table border='1'>\n <thead><tr><th>Age Range</th><th>Confidence</th><th>Gender</th><th>Confidence</th><th>Name</th></tr></thead>\n {{#result}}<tr>\n <td><b>{{age.ageRange}}</b></td><td><i>{{age.score}}</i></td>\n <td>{{gender.gender}}</td><td>{{gender.score}}</td>\n {{#identity}}<td>{{identity.name}} ({{identity.score}})</td>{{/identity}}\n </tr>{{/result}}\n </table>\n <form action=\"{{req._parsedUrl.pathname}}\">\n <br><input type=\"submit\" value=\"Try again or go back to the home page\"/>\n </form>","x":738,"y":237.5,"wires":[["38a9423e.12c4be"]]},{"id":"38a9423e.12c4be","type":"http response","z":"bfafde67.102e78","name":"","x":859,"y":127,"wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment