-
Notifications
You must be signed in to change notification settings - Fork 1
/
Classifier Test.json
executable file
·1 lines (1 loc) · 22.8 KB
/
Classifier Test.json
1
[{"id":"9e895548.30768","type":"tab","label":"TestFE","disabled":false,"info":""},{"id":"1ba787b5.aa3dd8","type":"tab","label":"testPy","disabled":false,"info":""},{"id":"741fb921.e27498","type":"tab","label":"Classifier Training","disabled":false,"info":""},{"id":"52fac848.9ba85","type":"websocket-listener","path":"/ws/chat","wholemsg":"false"},{"id":"7b523b84.421194","type":"dropbox-config","z":"","name":"Missing Maps"},{"id":"e44c4d3d.5350a","type":"http in","z":"9e895548.30768","name":"","url":"/","method":"get","upload":false,"swaggerDoc":"","x":230,"y":100,"wires":[["53855993.f7e898"]]},{"id":"53855993.f7e898","type":"template","z":"9e895548.30768","name":"Drag and Drop","field":"dragAndDrop","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<script>\n /////////////////////////////////\n // The Drag Drop Box Component //\n /////////////////////////////////\n // reference: https://serversideup.net/drag-and-drop-file-uploads-with-vuejs-and-axios/\n Vue.component('drag-drop-box', {\n delimiters: ['{(', ')}'],\n props: {files: Array, alert: Function},\n data: function () {\n return {\n dragAndDropCapable: false,\n }\n },\n mounted: function() {\n Vue.use(Vuetify, { options: { customProperties: true } })\n\n var div = document.createElement('div');\n\n this.dragAndDropCapable = ( ( 'draggable' in div )\n || ( 'ondragstart' in div && 'ondrop' in div ) )\n && 'FormData' in window\n && 'FileReader' in window;\n\n console.log(\"dragAndDropCapable is \" + this.dragAndDropCapable);\n\n let fileInput = this.$refs.fileform.querySelector( 'input[type=\"file\"]' )\n fileInput.addEventListener( 'change', function(e) {\n this.addFiles(fileInput.files)\n this.$refs.fileform.reset()\n }.bind(this))\n\n if (this.dragAndDropCapable) {\n ['drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop'].forEach( function( evt ) {\n this.$refs.fileform.addEventListener(evt, function(e){\n e.preventDefault();\n e.stopPropagation();\n }.bind(this), false);\n }.bind(this));\n\n this.$refs.fileform.addEventListener('drop', function(e){\n this.addFiles(e.dataTransfer.files)\n }.bind(this));\n\n dragoverClasses = [\"is-dragover\",]\n // drag over\n this.$refs.fileform.addEventListener('dragover', function(e){\n dragoverClasses.forEach(className =>\n this.$refs.fileform.classList.add( className )\n )\n }.bind(this));\n\n // leave\n [ 'dragend', 'dragleave', 'drop'].forEach( function( evt ) {\n this.$refs.fileform.addEventListener(evt, function(e){\n dragoverClasses.forEach(className =>\n this.$refs.fileform.classList.remove( className )\n )\n }.bind(this), false);\n }.bind(this));\n }\n\n },\n methods: {\n dismissFile: function(fileName) { return },\n addFiles: function(files) {\n let fileArr = this.files;\n files = [...files];\n let filtered = files.filter(file => file.type.split(\"/\")[0] == 'image')\n let invalidFile = files.length - filtered.length;\n if (invalidFile)\n this.alert(invalidFile + \" of \" + files.length + \" file(s) are invalid and ignored!\");\n filtered.forEach(file => fileArr.push({file:file, result: {}}))\n }\n },\n template: `\n <form ref=\"fileform\" style=\"height:500px;\" :class=\"'box mt-auto align-center d-flex grey lighten-4 elevation-3'\">\n <div class=\"box__input\" style=\"align-item: center\">\n <input class=\"box__file\" type=\"file\" name=\"files[]\" id=\"file\" data-multiple-caption=\"{count} files selected\" multiple />\n <label for=\"file\" class=\"md-headline\" style=\"display: inline\">\n <strong>Choose a file <i class=\"material-icons\" style=\"display:inline; vertical-align: bottom\">folder</i></strong>\n <span class=\"box__dragndrop\"> or drag it here</span>.\n </label>\n </div>\n </form>\n `\n })\n</script>\n","output":"str","x":420,"y":100,"wires":[["92727dea.320d7"]]},{"id":"92727dea.320d7","type":"template","z":"9e895548.30768","name":"Image Card","field":"imageCard","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<script>\n\n\n //////////////////////////////\n // The Image Card Component //\n //////////////////////////////\n Vue.component('img-card', {\n delimiters: ['{(', ')}'],\n props: {upload: Boolean, img: Object, imgs: Array},\n data: function () {\n return {\n show: false,\n data: \"hello vue\",\n }\n },\n methods:{\n dismiss: function() {\n for (let i = 0; i < this.imgs.length; i++) {\n if (this.imgs[i].file === this.img.file) {\n this.imgs.splice(i, 1)\n }\n }\n },\n download: function() {\n let link = document.createElement(\"a\");\n link.download = this.img.file.name;\n link.href = this.imgUrl;\n link.click();\n }\n },\n computed: {\n fileSize: function() {\n let kb = this.img.file.size / 1024\n if (kb < 100) {\n return kb.toFixed(2) + \" KB\"\n } else {\n let mb = kb / 1024\n return mb.toFixed(2) + \" MB\"\n }\n },\n imgUrl: function () {\n return window.URL.createObjectURL(this.img.file)\n },\n reportInfo: function() {\n // every line is an element in the returned list\n console.log(this.img.result.images);\n if (!this.img.result.images) {\n return [\n `Here should be the report details. Some random stuff here now`,\n `Name: ${this.img.file.name}`,\n `LastModifiedDate: ${this.img.file.lastModifiedDate}`,\n `Type: ${this.img.file.type}\\n`,\n ];\n } else {\n let classifier = this.img.result.images[0].classifiers[0]\n return [\n `classifier_id: ${classifier.classifier_id}`,\n ].concat(classifier.classes.map(oneClass => `${oneClass.class}: \\t ${oneClass.score}` + \n (oneClass.type_hierarchy ? ` from \\t ${oneClass.type_hierarchy}` : \"\")))\n }\n }\n },\n\n template: `\n <v-layout>\n <v-flex>\n <v-card>\n <v-card-title primary-title>\n <v-flex xs6>\n <v-img :src=\"imgUrl\"></v-img>\n </v-flex>\n <v-spacer />\n <div>\n <h3 class=\"headline mb-0\" >{(img.file.name)}</h3>\n <div>{(upload ? this.fileSize : this.fileSize)}</div>\n </div>\n </v-card-title>\n\n\n <v-card-actions>\n <v-btn v-if=\"!upload\" flat color=\"primary\" v-on:click=\"download()\">\n Download\n </v-btn>\n <v-spacer />\n <v-btn v-if=\"upload\" flat color=\"primary\" v-on:click=\"dismiss()\">\n dismiss\n </v-btn>\n <v-btn v-else flat color=\"primary\" @click = \"show = !show\">\n {(show ? \"Collapse\" : \"Details\")}\n </v-btn>\n </v-card-actions>\n <v-slide-y-transition>\n <v-card-text v-show = \"show\">\n <div v-for=\"line in reportInfo\" style=\"margin-bottom: 10px\">{(line)}</div>\n </v-card-text>\n </v-slide-y-transition>\n </v-card>\n </v-flex>\n </v-layout>\n `\n })\n\n\n</script>","output":"str","x":590,"y":100,"wires":[["f969922d.f98dc"]]},{"id":"f969922d.f98dc","type":"template","z":"9e895548.30768","name":"Main Vue Instance","field":"mainVueInstance","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<script>\n\n ///////////////////////////\n // The main Vue Instance //\n ///////////////////////////\n new Vue({\n el: '#app',\n delimiters: ['{(', ')}'],\n data: {\n uploadingPage: true,\n imgs: [],\n alert: false,\n alertMsg: \"\",\n uploading: false,\n },\n methods: {\n submitImg: function (event) {\n if (this.imgs.length) {\n // TODO: the real uploading things\n let postURL = \"testFE2\"\n var formData = new FormData();\n this.imgs.forEach(img => formData.append(\"images\", img.file));\n this.uploading = true;\n axios.post(postURL, formData, {\n timeoutL:1000000,\n }).then(function(res) {\n console.log(res);\n let results = res.data\n if (results.length != this.imgs.length) {\n console.log(\"results.length != this.imgs.length, this should never happens\");\n } else {\n for (let i = 0; i < results.length; i++) {\n this.imgs[i].result = results[i]\n }\n }\n\n // end of processing\n this.uploading = false;\n this.uploadingPage = false; // switch page\n }.bind(this))\n } else {\n this.raiseAlert(\"No images to submit\");\n }\n },\n raiseAlert: function (msg) {\n if (!this.alert) {\n this.alert = true;\n this.alertMsg = msg;\n } else {\n this.alert = false;\n setTimeout(function() {\n this.alert = true;\n this.alertMsg = msg;\n }.bind(this), 100)\n }\n },\n goHome: function() {\n this.uploadingPage = true\n this.imgs = []\n },\n expend_all: function (expend) {\n [...this.$refs.report_card].forEach(function(child) {child.show = expend})\n }\n },\n computed:{\n cardsData: function() {return {}} // TODO\n }\n })\n\n </script>","output":"str","x":770,"y":100,"wires":[["75404bbd.39bbdc"]]},{"id":"75404bbd.39bbdc","type":"template","z":"9e895548.30768","name":"CSS","field":"style","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<style>\n .box {\n outline: 2px dashed #BDBDBD;\n outline-offset: -10px;\n text-align: center;\n padding: 200px 20px;\n transition: outline-offset .15s ease-in-out, background-color .15s linear;\n }\n \n .box__dragndrop {\n display: inline;\n }\n .is-dragover {\n outline-offset: -20px;\n outline-color: #82B1FF; /* default accent */\n color: #82B1FF; /* default accent */\n }\n .box__file {\n display: none;\n }\n .box label {\n cursor: pointer;\n }\n </style>","output":"str","x":930,"y":100,"wires":[["7007b2f1.332cc4"]]},{"id":"7007b2f1.332cc4","type":"template","z":"9e895548.30768","name":"HTML","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n<html>\n<head>\n <link href=\"https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons\" rel=\"stylesheet\">\n <link href=\"https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css\" rel=\"stylesheet\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui\">\n{{{style}}}\n</head>\n<body>\n <div id=\"app\">\n <v-app>\n <v-content>\n <v-layout row wrap>\n\n <!-- The top tool bar -->\n <v-card>\n <v-toolbar fixed>\n <v-btn icon v-on:click=\"goHome()\">\n <v-icon>home</v-icon>\n </v-btn>\n <v-toolbar-title>Missing Maps</v-toolbar-title>\n </v-toolbar>\n </v-card>\n\n <v-flex xs12> <!-- take the space of the floatting toolbar -->\n <div style=\"height: 70px\"> </div>\n </v-flex>\n\n <!-- uploading page content -->\n <template v-if=\"uploadingPage\">\n <!-- drag drop box -->\n <v-flex xs6>\n <v-flex>\n <drag-drop-box :files=\"imgs\" :alert=\"raiseAlert\" style=\"position:fixed; top:94px ;margin: 2%; width:45%\"/>\n </v-flex>\n\n <!-- Alert window -->\n <v-flex>\n <v-toolbar flat fixed class=\"transparent\" style=\"left: 230px\">\n <v-alert\n dismissible\n v-model=\"alert\"\n type=\"error\"\n icon=\"new_releases\"\n transition=\"scale-transition\"\n >\n {(alertMsg)}\n </v-alert>\n </v-toolbar>\n </v-flex>\n\n <!-- Bottom submit button -->\n <v-flex>\n <v-btn\n class=\"text-none\"\n color=\"primary\"\n fixed style=\"margin:2%; bottom:0px; left:0px\"\n v-on:click=\"submitImg\"\n :loading=\"uploading\"\n >\n Submit\n </v-btn>\n </v-flex>\n </v-flex>\n\n <!-- Right part -->\n <v-flex xs6>\n <v-container fluid grid-list-xl>\n <v-layout row wrap>\n <v-flex d-flex xs6 v-for=\"file in imgs\">\n <img-card upload :img=\"file\" :imgs=\"imgs\"/>\n </v-flex>\n </v-layout>\n </v-container>\n </v-flex>\n </template>\n\n <!-- report page content -->\n <template v-else>\n <v-container fluid grid-list-xl>\n <v-toolbar floatting flat style=\"position: fixed; z-index: 2; left: 30px;bottom: 30px; width: auto\" class=\"transparent\">\n <v-btn color=\"info\" v-on:click=\"expend_all(true)\">\n <v-icon>unfold_more</v-icon>\n Expend All\n </v-btn>\n <v-btn color=\"info\" v-on:click=\"expend_all(false)\">\n <v-icon>unfold_less</v-icon>\n Collapse All\n </v-btn>\n <v-btn color=\"info\">\n <v-icon>arrow_downward</v-icon>\n Download All\n </v-btn>\n </v-toolbar>\n <v-layout row wrap>\n <v-flex d-flex xs4 v-for=\"img in imgs\">\n <img-card ref=\"report_card\" :img=\"img\" :imgs=\"imgs\"/>\n </v-flex>\n </v-layout>\n </v-container>\n\n\n </template>\n </v-layout>\n </v-content>\n </v-app>\n </div>\n\n <script src=\"https://unpkg.com/axios/dist/axios.min.js\"></script>\n <script src=\"https://vuejs.org/js/vue.js\"></script>\n <script src=\"https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.js\"></script>\n {{{dragAndDrop}}}\n {{{imageCard}}}\n {{{mainVueInstance}}}\n \n</body>\n</html>\n","x":1050,"y":100,"wires":[["3f175dc0.9a8c42"]]},{"id":"3f175dc0.9a8c42","type":"http response","z":"9e895548.30768","name":"","statusCode":"","headers":{},"x":1170,"y":100,"wires":[]},{"id":"d874874d.2c1aa","type":"function","z":"9e895548.30768","name":" Determine File Path","func":"msg.payload = msg.req.files.images.map(function(file){\n return file.path\n})\n\nreturn msg\n","outputs":1,"noerr":0,"x":480,"y":260,"wires":[["bf73323c.cf8f1"]]},{"id":"e8368514.77eb88","type":"visual-recognition-v3","z":"9e895548.30768","name":"","vr-service-endpoint":"https://gateway.watsonplatform.net/visual-recognition/api","image-feature":"classifyImage","lang":"en","x":270,"y":380,"wires":[["34910d3b.ecdc9a"]]},{"id":"cb80719.69b5c9","type":"http response","z":"9e895548.30768","name":"","statusCode":"","headers":{},"x":1170,"y":380,"wires":[]},{"id":"2a146fc4.ac7fc8","type":"json","z":"9e895548.30768","name":"","property":"payload","action":"str","pretty":false,"x":970,"y":380,"wires":[["cb80719.69b5c9","77cd2d94.c4cfc4"]]},{"id":"34910d3b.ecdc9a","type":"change","z":"9e895548.30768","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":380,"wires":[["6efb2459.6144ac"]]},{"id":"6efb2459.6144ac","type":"change","z":"9e895548.30768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"result","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":380,"wires":[["d99ee4e5.dd37d8"]]},{"id":"d99ee4e5.dd37d8","type":"join","z":"9e895548.30768","name":"","mode":"auto","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":850,"y":380,"wires":[["2a146fc4.ac7fc8"]]},{"id":"bf73323c.cf8f1","type":"split","z":"9e895548.30768","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":670,"y":260,"wires":[["55b3819.abef48"]]},{"id":"77cd2d94.c4cfc4","type":"debug","z":"9e895548.30768","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1170,"y":440,"wires":[]},{"id":"55b3819.abef48","type":"file-buffer","z":"9e895548.30768","name":"","x":820,"y":260,"wires":[["e8368514.77eb88"]]},{"id":"e4370099.550c2","type":"httpInMultipart","z":"9e895548.30768","name":"","url":"/testFE2","method":"post","fields":"[{ \"name\":\"images\"}]","swaggerDoc":"","x":260,"y":260,"wires":[["d874874d.2c1aa"]]},{"id":"a26c250c.d73828","type":"comment","z":"1ba787b5.aa3dd8","name":"!!! Note that only python itself is accessible","info":"","x":940,"y":140,"wires":[]},{"id":"3c57374b.340168","type":"pythonshell in","z":"1ba787b5.aa3dd8","name":"","pyfile":"/app/public/testPythonNode.py","virtualenv":"","continuous":false,"stdInData":false,"x":920,"y":260,"wires":[["a58c0655.d7e9f8"]]},{"id":"aff1fa44.c20a38","type":"inject","z":"1ba787b5.aa3dd8","name":"","topic":"","payload":"{\"1\":\"2\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":730,"y":260,"wires":[["3c57374b.340168","bc333988.492478"]]},{"id":"a58c0655.d7e9f8","type":"debug","z":"1ba787b5.aa3dd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1110,"y":260,"wires":[]},{"id":"bc333988.492478","type":"debug","z":"1ba787b5.aa3dd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":910,"y":200,"wires":[]},{"id":"f3ca7b3b.f79498","type":"visual-recognition-util-v3","z":"741fb921.e27498","name":"Classifier","vr-service-endpoint":"https://gateway.watsonplatform.net/visual-recognition/api","image-feature":"createClassifier","x":807,"y":447,"wires":[["6073ca70.9ff0a4"]]},{"id":"7c2f0ad6.2c5524","type":"change","z":"741fb921.e27498","name":"Set Positives","rules":[{"t":"set","p":"params.inhabited_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":617,"y":367,"wires":[["67afd05e.4a1b"]]},{"id":"7beef768.fe5738","type":"change","z":"741fb921.e27498","name":"Set Name","rules":[{"t":"set","p":"params","pt":"msg","to":"{'name':'inhabited'}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":327,"y":367,"wires":[["4f3a2928.c3db28"]]},{"id":"4f3a2928.c3db28","type":"dropbox","z":"741fb921.e27498","dropbox":"7b523b84.421194","filename":"postest.zip","name":"Inhabited","x":467,"y":367,"wires":[["7c2f0ad6.2c5524"]]},{"id":"67afd05e.4a1b","type":"dropbox","z":"741fb921.e27498","dropbox":"7b523b84.421194","filename":"negtest.zip","name":"Uninhabited","x":477,"y":447,"wires":[["ecb95ff3.38546"]]},{"id":"ecb95ff3.38546","type":"change","z":"741fb921.e27498","name":"Set Negatives","rules":[{"t":"set","p":"params.negative_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":647,"y":447,"wires":[["f3ca7b3b.f79498"]]},{"id":"6073ca70.9ff0a4","type":"debug","z":"741fb921.e27498","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"result","x":797,"y":507,"wires":[]},{"id":"a9fdab8f.fd8348","type":"inject","z":"741fb921.e27498","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":327,"y":307,"wires":[["7beef768.fe5738"]]},{"id":"e31327e9.2219d8","type":"function","z":"741fb921.e27498","name":"Set Classifier IDs","func":"msg.params={\"classifier_ids\":[\"inhabited_1729809335\"],\"threshold\":0};\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":280,"wires":[["f8e2424b.b086a"]]},{"id":"f8e2424b.b086a","type":"visual-recognition-v3","z":"741fb921.e27498","name":"","vr-service-endpoint":"https://gateway.watsonplatform.net/visual-recognition/api","image-feature":"classifyImage","lang":"en","x":1110,"y":340,"wires":[["ed26578a.7d02f8"]]},{"id":"ed26578a.7d02f8","type":"debug","z":"741fb921.e27498","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"result","x":1150,"y":400,"wires":[]},{"id":"20981950.257b56","type":"inject","z":"741fb921.e27498","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":360,"y":640,"wires":[["201847c0.dcca38"]]},{"id":"201847c0.dcca38","type":"visual-recognition-util-v3","z":"741fb921.e27498","name":"List Classifiers","vr-service-endpoint":"https://gateway.watsonplatform.net/visual-recognition/api","image-feature":"retrieveClassifiersList","x":520,"y":640,"wires":[["f559de5a.11608"]]},{"id":"f559de5a.11608","type":"debug","z":"741fb921.e27498","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"result","x":690,"y":640,"wires":[]},{"id":"30efddd7.2d6d52","type":"visual-recognition-util-v3","z":"741fb921.e27498","name":"Delete All Custom Classifiers","vr-service-endpoint":"https://gateway.watsonplatform.net/visual-recognition/api","image-feature":"deleteAllClassifiers","x":560,"y":700,"wires":[["b4c4f05d.bd4c1"]]},{"id":"ca43169d.06aef8","type":"inject","z":"741fb921.e27498","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":360,"y":700,"wires":[["30efddd7.2d6d52"]]},{"id":"b4c4f05d.bd4c1","type":"debug","z":"741fb921.e27498","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"result","x":770,"y":700,"wires":[]},{"id":"b04814b.28242e8","type":"fileinject","z":"741fb921.e27498","name":"","x":1020,"y":200,"wires":[["e31327e9.2219d8"]]}]