From 45773c0c80aa3883fb6fbcb7deb11cdeb7d04457 Mon Sep 17 00:00:00 2001 From: joeyklee Date: Tue, 28 Jan 2020 17:37:17 -0500 Subject: [PATCH 1/8] initial commit of universal sentence encoder --- package-lock.json | 189 +++++++++++++++------ package.json | 3 +- src/UniversalSentenceEncoder/index.js | 41 +++++ src/UniversalSentenceEncoder/index_test.js | 0 4 files changed, 178 insertions(+), 55 deletions(-) create mode 100644 src/UniversalSentenceEncoder/index.js create mode 100644 src/UniversalSentenceEncoder/index_test.js diff --git a/package-lock.json b/package-lock.json index 790a07849..917e82b57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1070,21 +1070,46 @@ "resolved": "https://registry.npmjs.org/@tensorflow-models/speech-commands/-/speech-commands-0.3.9.tgz", "integrity": "sha512-MrMlDEDHkZPKuZawQb1E2Hof1m2ojZrOW1EAVnvZ1Jn+cPmDJz+X3hokYLC3P+UBUq+tAYq1vU0Byt9SbyGWbg==" }, - "@tensorflow/tfjs": { + "@tensorflow-models/universal-sentence-encoder": { "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-1.2.2.tgz", - "integrity": "sha512-HfhSzL2eTWhlT0r/A5wmo+u3bHe+an16p5wsnFH3ujn21fQ8QtGpSfDHQZjWx1kVFaQnV6KBG+17MOrRHoHlLA==", - "requires": { - "@tensorflow/tfjs-converter": "1.2.2", - "@tensorflow/tfjs-core": "1.2.2", - "@tensorflow/tfjs-data": "1.2.2", - "@tensorflow/tfjs-layers": "1.2.2" + "resolved": "https://registry.npmjs.org/@tensorflow-models/universal-sentence-encoder/-/universal-sentence-encoder-1.2.2.tgz", + "integrity": "sha512-fGCl/gwB7jmKCRI2FhgIBeIa/LCSUcjlEcckH2Bc2dIjhJ+2nspp+22lubxcseN6jjrmP42kkXt/reAPe+KJkQ==" + }, + "@tensorflow/tfjs": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-1.2.11.tgz", + "integrity": "sha512-q1SIEMiR+Vqq8Fnmt/YGBC5tNq97LXDvUEl8SwWedhLtK1GJCpLMJXQA54JrkFXGLv5hK4dEb+1dx28TJUET2g==", + "requires": { + "@tensorflow/tfjs-converter": "1.2.11", + "@tensorflow/tfjs-core": "1.2.11", + "@tensorflow/tfjs-data": "1.2.11", + "@tensorflow/tfjs-layers": "1.2.11" + }, + "dependencies": { + "@tensorflow/tfjs-core": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-1.2.11.tgz", + "integrity": "sha512-guqqD5bb5BTaTvUVWhG1xCXB0NuA5rv0indSEEOpMfqqBvtSwKp02heDGDcPOSUnmdB8V/HJbcyX2wRBXztQpA==", + "requires": { + "@types/offscreencanvas": "~2019.3.0", + "@types/seedrandom": "2.4.27", + "@types/webgl-ext": "0.0.30", + "@types/webgl2": "0.0.4", + "node-fetch": "~2.1.2", + "seedrandom": "2.4.3" + } + }, + "node-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", + "integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=" + } } }, "@tensorflow/tfjs-converter": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-1.2.2.tgz", - "integrity": "sha512-NM2NcPRHpCNeJdBxHcYpmW9ZHTQ2lJFJgmgGpQ8CxSC9CtQB05bFONs3SKcwMNDE/69QBRVom5DYqLCVUg+A+g==" + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-1.2.11.tgz", + "integrity": "sha512-3Qg3k6x9ZbAFSCJTSC2anaM40Fs04+PGFw/uRvupWHmns6D5ni9RzTH2thef9hzBT2V/UHnlnHs7RYJqQNTThA==" }, "@tensorflow/tfjs-core": { "version": "1.2.2", @@ -1108,9 +1133,9 @@ } }, "@tensorflow/tfjs-data": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-1.2.2.tgz", - "integrity": "sha512-oHGBoGdnCl2RyouLKplQqo+iil0iJgPbi/aoHizhpO77UBuJXlKMblH8w5GbxVAw3hKxWlqzYpxPo6rVRgehNA==", + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-data/-/tfjs-data-1.2.11.tgz", + "integrity": "sha512-xrRekVbwWgW1Cyaqh+1x0Tq3CQkePm/G94eGLcH6IbcoBp0syKKUCD0vHkaGn7GkUGFJkej5yHXsh0ujrbxd+A==", "requires": { "@types/node-fetch": "^2.1.2", "node-fetch": "~2.1.2" @@ -1124,9 +1149,9 @@ } }, "@tensorflow/tfjs-layers": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-1.2.2.tgz", - "integrity": "sha512-yzWZaZrCVpEyTkSrzMe4OOP4aGUfaaROE/zR9fPsPGGF8wLlbLNZUJjeYUmjy3G3pXGaM0mQUbLR5Vd707CVtQ==" + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-1.2.11.tgz", + "integrity": "sha512-Ye/b0pwB9KVW5IbRP9UNSXPUvizP8VdaKVFzT2C6JJpUE97LznItbYDJjO60ND/Cl0uj7ttvxPwlYb7HYo+e6g==" }, "@tensorflow/tfjs-vis": { "version": "1.1.0", @@ -1175,9 +1200,9 @@ "integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==" }, "@types/node-fetch": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.0.tgz", - "integrity": "sha512-TLFRywthBgL68auWj+ziWu+vnmmcHCDFC/sqCOQf1xTz4hRq8cu79z8CtHU9lncExGBsB8fXA4TiLDLt6xvMzw==", + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.4.tgz", + "integrity": "sha512-Oz6id++2qAOFuOlE1j0ouk1dzl3mmI1+qINPNBhi9nt/gVOz0G+13Ao6qjhdF0Ys+eOkhu6JnFmt38bR3H0POQ==", "requires": { "@types/node": "*" } @@ -3139,6 +3164,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true, + "optional": true, "requires": { "hoek": "2.x.x" } @@ -3573,7 +3599,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-1.0.0.tgz", "integrity": "sha512-EMetuGFz5SLsT0QTnXzINh4Ksr+oo4i+UGTXEshiGCQWnsgSs7ZhJ8fzlwQ+OzEMs0MpDAMr1hxnblp5a4vcHg==", - "dev": true + "dev": true, + "optional": true }, "buffer-xor": { "version": "1.0.3", @@ -8285,7 +8312,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -8306,12 +8334,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8326,17 +8356,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -8453,7 +8486,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -8465,6 +8499,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -8479,6 +8514,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -8486,12 +8522,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -8510,6 +8548,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -8590,7 +8629,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -8602,6 +8642,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -8687,7 +8728,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -8723,6 +8765,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -8742,6 +8785,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -8785,12 +8829,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -9500,7 +9546,8 @@ "version": "2.16.3", "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true + "dev": true, + "optional": true }, "home-or-tmp": { "version": "2.0.0", @@ -10043,6 +10090,7 @@ "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.6.1.tgz", "integrity": "sha1-rQFScUOi6Hc8+uapb1hla7UqNLI=", "dev": true, + "optional": true, "requires": { "httpreq": ">=0.4.22", "underscore": "~1.7.0" @@ -10052,7 +10100,8 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz", "integrity": "sha1-QzX/2CzZaWaKOUZckprGHWOTYn8=", - "dev": true + "dev": true, + "optional": true }, "https-browserify": { "version": "1.0.0", @@ -10702,7 +10751,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", - "dev": true + "dev": true, + "optional": true }, "is-redirect": { "version": "1.0.0", @@ -11364,13 +11414,15 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-0.1.0.tgz", "integrity": "sha1-YjUag5VjrF/1vSbxL2Dpgwu3UeY=", - "dev": true + "dev": true, + "optional": true }, "libmime": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/libmime/-/libmime-3.0.0.tgz", "integrity": "sha1-UaGp50SOy9Ms2lRCFnW7IbwJPaY=", "dev": true, + "optional": true, "requires": { "iconv-lite": "0.4.15", "libbase64": "0.1.0", @@ -11381,7 +11433,8 @@ "version": "0.4.15", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=", - "dev": true + "dev": true, + "optional": true } } }, @@ -11389,7 +11442,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/libqp/-/libqp-1.1.0.tgz", "integrity": "sha1-9ebgatdLeU+1tbZpiL9yjvHe2+g=", - "dev": true + "dev": true, + "optional": true }, "lines-and-columns": { "version": "1.1.6", @@ -12963,13 +13017,15 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz", "integrity": "sha1-ecSQihwPXzdbc/6IjamCj23JY6Q=", - "dev": true + "dev": true, + "optional": true }, "nodemailer-shared": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/nodemailer-shared/-/nodemailer-shared-1.1.0.tgz", "integrity": "sha1-z1mU4v0mjQD1zw+nZ6CBae2wfsA=", "dev": true, + "optional": true, "requires": { "nodemailer-fetch": "1.6.0" } @@ -13002,7 +13058,8 @@ "version": "0.1.10", "resolved": "https://registry.npmjs.org/nodemailer-wellknown/-/nodemailer-wellknown-0.1.10.tgz", "integrity": "sha1-WG24EB2zDLRDjrVGc3pBqtDPE9U=", - "dev": true + "dev": true, + "optional": true }, "nomnom": { "version": "1.8.1", @@ -19616,13 +19673,15 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.0.1.tgz", "integrity": "sha512-RFqinRVJVcCAL9Uh1oVqE6FZkqsyLiVOYEZ20TqIOjuX7iFVJ+zsbs4RIghnw/pTs7mZvt8ZHhvm1ZUrR4fykg==", - "dev": true + "dev": true, + "optional": true }, "smtp-connection": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/smtp-connection/-/smtp-connection-2.12.0.tgz", "integrity": "sha1-1275EnyyPCJZ7bHoNJwujV4tdME=", "dev": true, + "optional": true, "requires": { "httpntlm": "1.6.1", "nodemailer-shared": "1.1.0" @@ -19870,6 +19929,7 @@ "resolved": "https://registry.npmjs.org/socks/-/socks-2.2.2.tgz", "integrity": "sha512-g6wjBnnMOZpE0ym6e0uHSddz9p3a+WsBaaYQaBaSCJYvrC4IXykQR9MNGjLQf38e9iIIhp3b1/Zk8YZI3KGJ0Q==", "dev": true, + "optional": true, "requires": { "ip": "^1.1.5", "smart-buffer": "^4.0.1" @@ -19880,6 +19940,7 @@ "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-4.0.1.tgz", "integrity": "sha512-Kezx6/VBguXOsEe5oU3lXYyKMi4+gva72TwJ7pQY5JfqUx2nMk7NXA6z/mpNqIlfQjWYVfeuNvQjexiTaTn6Nw==", "dev": true, + "optional": true, "requires": { "agent-base": "~4.2.0", "socks": "~2.2.0" @@ -20970,7 +21031,8 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", - "dev": true + "dev": true, + "optional": true }, "union-value": { "version": "1.0.1", @@ -22679,7 +22741,7 @@ "webpack-addons": "^1.1.5", "yargs": "9.0.1", "yeoman-environment": "^2.0.0", - "yeoman-generator": "github:ev1stensberg/generator#9e24fa31c85302ca1145ae34fc68b4f133251ca0" + "yeoman-generator": "github:ev1stensberg/generator#Feature-getArgument" }, "dependencies": { "ansi-escapes": { @@ -23384,7 +23446,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -23405,12 +23468,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -23425,17 +23490,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -23552,7 +23620,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -23564,6 +23633,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -23578,6 +23648,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -23585,12 +23656,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -23609,6 +23682,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -23689,7 +23763,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -23701,6 +23776,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -23786,7 +23862,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -23822,6 +23899,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -23841,6 +23919,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -23884,12 +23963,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, diff --git a/package.json b/package.json index d2588a096..ec54b06bb 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,8 @@ "@tensorflow-models/mobilenet": "2.0.3", "@tensorflow-models/posenet": "2.1.3", "@tensorflow-models/speech-commands": "0.3.9", - "@tensorflow/tfjs": "~1.2.1", + "@tensorflow-models/universal-sentence-encoder": "^1.2.2", + "@tensorflow/tfjs": "^1.2.11", "@tensorflow/tfjs-vis": "^1.1.0", "events": "^3.0.0", "face-api.js": "0.20.1" diff --git a/src/UniversalSentenceEncoder/index.js b/src/UniversalSentenceEncoder/index.js new file mode 100644 index 000000000..b2c431d19 --- /dev/null +++ b/src/UniversalSentenceEncoder/index.js @@ -0,0 +1,41 @@ +// import * as tf from '@tensorflow/tfjs'; +// import callCallback from '../utils/callcallback'; +import * as USE from '@tensorflow-models/universal-sentence-encoder'; + +class UniversalSentenceEncoder { + constructor(){ + this.model = null; + this.config = {}; + } + + /** + * load model + */ + async loadModel(){ + this.model = await USE.load(); + return this; + } + + + +} + +const universalSentenceEncoder = (optionsOr, cb) => { + let options = {}; + let callback = cb; + + if (typeof optionsOr === 'function') { + callback = optionsOr; + } else if (typeof optionsOr === 'object') { + options = optionsOr; + } + + if (typeof optionsOr === 'object') { + options = optionsOr; + } else if (typeof optionsOr === 'function') { + callback = optionsOr; + } + return new UniversalSentenceEncoder(options, callback); +}; + +export default universalSentenceEncoder; \ No newline at end of file diff --git a/src/UniversalSentenceEncoder/index_test.js b/src/UniversalSentenceEncoder/index_test.js new file mode 100644 index 000000000..e69de29bb From 71e4631c1fb41d15a9ec5c47fb8f634ec92e8365 Mon Sep 17 00:00:00 2001 From: joeyklee Date: Tue, 28 Jan 2020 17:42:52 -0500 Subject: [PATCH 2/8] adds predict function --- src/UniversalSentenceEncoder/index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/UniversalSentenceEncoder/index.js b/src/UniversalSentenceEncoder/index.js index b2c431d19..7d2b5febd 100644 --- a/src/UniversalSentenceEncoder/index.js +++ b/src/UniversalSentenceEncoder/index.js @@ -1,5 +1,5 @@ // import * as tf from '@tensorflow/tfjs'; -// import callCallback from '../utils/callcallback'; +import callCallback from '../utils/callcallback'; import * as USE from '@tensorflow-models/universal-sentence-encoder'; class UniversalSentenceEncoder { @@ -16,7 +16,20 @@ class UniversalSentenceEncoder { return this; } - + predict(textArray, callback){ + return callCallback(this.predictInternal(textArray), callback); + } + + async predictInternal(textArray){ + try{ + const embeddings = await this.model.embed(textArray); + const results = await embeddings.toArray(); + embeddings.dispose(); + return results; + } catch(err){ + throw new Error(err); + } + } } From d12b050b203e845aef567fb2dc9f13896f6c862b Mon Sep 17 00:00:00 2001 From: joeyklee Date: Tue, 28 Jan 2020 17:51:33 -0500 Subject: [PATCH 3/8] adds USE to index --- src/UniversalSentenceEncoder/index.js | 2 +- src/index.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/UniversalSentenceEncoder/index.js b/src/UniversalSentenceEncoder/index.js index 7d2b5febd..80b6aa6be 100644 --- a/src/UniversalSentenceEncoder/index.js +++ b/src/UniversalSentenceEncoder/index.js @@ -1,6 +1,6 @@ // import * as tf from '@tensorflow/tfjs'; -import callCallback from '../utils/callcallback'; import * as USE from '@tensorflow-models/universal-sentence-encoder'; +import callCallback from '../utils/callcallback'; class UniversalSentenceEncoder { constructor(){ diff --git a/src/index.js b/src/index.js index 9be1e57c7..d841da3b4 100644 --- a/src/index.js +++ b/src/index.js @@ -29,6 +29,7 @@ import bodyPix from './BodyPix'; import neuralNetwork from './NeuralNetwork'; import faceApi from './FaceApi'; import kmeans from './KMeans'; +import universalSentenceEncoder from './UniversalSentenceEncoder'; import p5Utils from './utils/p5Utils'; const withPreload = { @@ -51,6 +52,7 @@ const withPreload = { sentiment, bodyPix, faceApi, + universalSentenceEncoder }; module.exports = Object.assign({p5Utils}, preloadRegister(withPreload), { From e0597345a676037ac626c61c7e9344e69ac6e5a4 Mon Sep 17 00:00:00 2001 From: joeyklee Date: Tue, 28 Jan 2020 18:10:50 -0500 Subject: [PATCH 4/8] adds predict function --- package-lock.json | 26 ++++++++++++++++++++++---- package.json | 4 ++++ src/UniversalSentenceEncoder/index.js | 6 ++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 917e82b57..3c8a73d8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1112,16 +1112,15 @@ "integrity": "sha512-3Qg3k6x9ZbAFSCJTSC2anaM40Fs04+PGFw/uRvupWHmns6D5ni9RzTH2thef9hzBT2V/UHnlnHs7RYJqQNTThA==" }, "@tensorflow/tfjs-core": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-1.2.2.tgz", - "integrity": "sha512-2hCHMKjh3UNpLEjbAEaurrTGJyj/KpLtMSAraWgHA1vGY0kmk50BBSbgCDmXWUVm7lyh/SkCq4/GrGDZktEs3g==", + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-1.2.11.tgz", + "integrity": "sha512-guqqD5bb5BTaTvUVWhG1xCXB0NuA5rv0indSEEOpMfqqBvtSwKp02heDGDcPOSUnmdB8V/HJbcyX2wRBXztQpA==", "requires": { "@types/offscreencanvas": "~2019.3.0", "@types/seedrandom": "2.4.27", "@types/webgl-ext": "0.0.30", "@types/webgl2": "0.0.4", "node-fetch": "~2.1.2", - "rollup-plugin-visualizer": "~1.1.1", "seedrandom": "2.4.3" }, "dependencies": { @@ -7266,6 +7265,25 @@ "tslib": "^1.10.0" }, "dependencies": { + "@tensorflow/tfjs-core": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-core/-/tfjs-core-1.2.2.tgz", + "integrity": "sha512-2hCHMKjh3UNpLEjbAEaurrTGJyj/KpLtMSAraWgHA1vGY0kmk50BBSbgCDmXWUVm7lyh/SkCq4/GrGDZktEs3g==", + "requires": { + "@types/offscreencanvas": "~2019.3.0", + "@types/seedrandom": "2.4.27", + "@types/webgl-ext": "0.0.30", + "@types/webgl2": "0.0.4", + "node-fetch": "~2.1.2", + "rollup-plugin-visualizer": "~1.1.1", + "seedrandom": "2.4.3" + } + }, + "node-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", + "integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=" + }, "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", diff --git a/package.json b/package.json index ec54b06bb..91d362f96 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,10 @@ "transform-object-rest-spread" ] }, + "peerDependencies": { + "@tensorflow/tfjs-core": "^1.2.9", + "@tensorflow/tfjs-converter": "^1.2.9" + }, "dependencies": { "@magenta/sketch": "0.2.0", "@tensorflow-models/body-pix": "1.1.2", diff --git a/src/UniversalSentenceEncoder/index.js b/src/UniversalSentenceEncoder/index.js index 80b6aa6be..7574b788c 100644 --- a/src/UniversalSentenceEncoder/index.js +++ b/src/UniversalSentenceEncoder/index.js @@ -3,9 +3,11 @@ import * as USE from '@tensorflow-models/universal-sentence-encoder'; import callCallback from '../utils/callcallback'; class UniversalSentenceEncoder { - constructor(){ + constructor(options, callback){ this.model = null; this.config = {}; + + callCallback(this.loadModel(),callback); } /** @@ -23,7 +25,7 @@ class UniversalSentenceEncoder { async predictInternal(textArray){ try{ const embeddings = await this.model.embed(textArray); - const results = await embeddings.toArray(); + const results = await embeddings.array(); embeddings.dispose(); return results; } catch(err){ From 875f86f8c60b0b5352247e2bcccf415af85de2ae Mon Sep 17 00:00:00 2001 From: joeyklee Date: Thu, 30 Jan 2020 11:17:49 -0500 Subject: [PATCH 5/8] cleans up code via feedback from henrmota --- src/UniversalSentenceEncoder/index.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/UniversalSentenceEncoder/index.js b/src/UniversalSentenceEncoder/index.js index 7574b788c..93630d752 100644 --- a/src/UniversalSentenceEncoder/index.js +++ b/src/UniversalSentenceEncoder/index.js @@ -29,27 +29,17 @@ class UniversalSentenceEncoder { embeddings.dispose(); return results; } catch(err){ - throw new Error(err); + console.error(err); + return err; } } } const universalSentenceEncoder = (optionsOr, cb) => { - let options = {}; - let callback = cb; + const options = (typeof optionsOr === 'object') ? optionsOr : {}; + const callback = (typeof optionsOr === 'function') ? optionsOr : cb; - if (typeof optionsOr === 'function') { - callback = optionsOr; - } else if (typeof optionsOr === 'object') { - options = optionsOr; - } - - if (typeof optionsOr === 'object') { - options = optionsOr; - } else if (typeof optionsOr === 'function') { - callback = optionsOr; - } return new UniversalSentenceEncoder(options, callback); }; From 177bd61edd1c663c14342257e94bd6a18ef647b3 Mon Sep 17 00:00:00 2001 From: joeyklee Date: Wed, 8 Apr 2020 09:52:04 -0400 Subject: [PATCH 6/8] adds example and adds lib --- .../UniversalSentenceEncoder_Basic/index.html | 13 ++++++ .../UniversalSentenceEncoder_Basic/sketch.js | 42 +++++++++++++++++++ package-lock.json | 5 +++ package.json | 3 +- 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/index.html create mode 100644 examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/sketch.js diff --git a/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/index.html b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/index.html new file mode 100644 index 000000000..d089c391c --- /dev/null +++ b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/index.html @@ -0,0 +1,13 @@ + + + + Universal Sentence Encoder + + + + + +

Universal Sentence Encoder

+ + + \ No newline at end of file diff --git a/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/sketch.js b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/sketch.js new file mode 100644 index 000000000..566085c5b --- /dev/null +++ b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/sketch.js @@ -0,0 +1,42 @@ +let sentenceEncoder; +const sentences = [ + 'I love rainbows', + 'I love rainbows too', + 'I love cupcakes', + 'I love bagels more' +] + +function setup(){ + createCanvas(512, 512); + // background(220); + colorMode(HSB, 360, 100, 100); + sentenceEncoder = ml5.universalSentenceEncoder(modelLoaded) +} + +function modelLoaded(){ + + predict(); +} + +function predict(){ + + sentenceEncoder.predict(sentences, gotResults); +} + +function gotResults(err, result){ + if(err){ + return err; + } + console.log(result); + + result.forEach( (item, y) => { + // console.log(item); + item.forEach( (val, x) => { + const l = map(val, -1, 1, 0, 100); + noStroke(); + fill(360, 100, l); + rect(x, y * (height/result.length) , 1, (height/result.length)); + }) + }) + +} diff --git a/package-lock.json b/package-lock.json index 1a9410e20..09d2db907 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1079,6 +1079,11 @@ "resolved": "https://registry.npmjs.org/@tensorflow-models/speech-commands/-/speech-commands-0.3.9.tgz", "integrity": "sha512-MrMlDEDHkZPKuZawQb1E2Hof1m2ojZrOW1EAVnvZ1Jn+cPmDJz+X3hokYLC3P+UBUq+tAYq1vU0Byt9SbyGWbg==" }, + "@tensorflow-models/universal-sentence-encoder": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@tensorflow-models/universal-sentence-encoder/-/universal-sentence-encoder-1.2.2.tgz", + "integrity": "sha512-fGCl/gwB7jmKCRI2FhgIBeIa/LCSUcjlEcckH2Bc2dIjhJ+2nspp+22lubxcseN6jjrmP42kkXt/reAPe+KJkQ==" + }, "@tensorflow/tfjs": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-1.7.0.tgz", diff --git a/package.json b/package.json index 74953d288..57d948a93 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,8 @@ "@tensorflow-models/mobilenet": "2.0.3", "@tensorflow-models/posenet": "2.1.3", "@tensorflow-models/speech-commands": "0.3.9", - "@tensorflow/tfjs": "1.7.0", + "@tensorflow-models/universal-sentence-encoder": "^1.2.2", + "@tensorflow/tfjs": "^1.7.0", "@tensorflow/tfjs-vis": "^1.1.0", "events": "^3.0.0", "face-api.js": "~0.22.2", From e429fef70efe288a4fcab5380be38ba32f966222 Mon Sep 17 00:00:00 2001 From: joeyklee Date: Wed, 8 Apr 2020 09:54:13 -0400 Subject: [PATCH 7/8] updates example json --- examples/examples.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/examples.json b/examples/examples.json index 2c2001ae5..066ad7f1e 100644 --- a/examples/examples.json +++ b/examples/examples.json @@ -1 +1 @@ -{"BodyPix":{"p5js":[{"name":"BodyPix_Image","url":"../p5js/BodyPix/BodyPix_Image"},{"name":"BodyPix_Preload","url":"../p5js/BodyPix/BodyPix_Preload"},{"name":"BodyPix_Webcam","url":"../p5js/BodyPix/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"../p5js/BodyPix/BodyPix_Webcam_Parts"},{"name":"BodyPix_p5Instance","url":"../p5js/BodyPix/BodyPix_p5Instance"}],"p5webeditor":[{"name":"BodyPix_Image","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Image"},{"name":"BodyPix_Preload","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Preload"},{"name":"BodyPix_Webcam","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Webcam_Parts"},{"name":"BodyPix_p5Instance","url":"https://editor.p5js.org/ml5/sketches/BodyPix_p5Instance"}],"javascript":[{"name":"BodyPix_Image","url":"../javascript/BodyPix/BodyPix_Image"},{"name":"BodyPix_Webcam","url":"../javascript/BodyPix/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"../javascript/BodyPix/BodyPix_Webcam_Parts"}]},"CVAE":{"p5js":[{"name":"CVAE_QuickDraw","url":"../p5js/CVAE/CVAE_QuickDraw"}],"p5webeditor":[{"name":"CVAE_QuickDraw","url":"https://editor.p5js.org/ml5/sketches/CVAE_QuickDraw"}],"javascript":[{"name":"CVAE_QuickDraw","url":"../javascript/CVAE/CVAE_QuickDraw"}]},"CharRNN":{"p5js":[{"name":"CharRNN_Interactive","url":"../p5js/CharRNN/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"../p5js/CharRNN/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"../p5js/CharRNN/CharRNN_Text_Stateful"}],"p5webeditor":[{"name":"CharRNN_Interactive","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Text_Stateful"}],"javascript":[{"name":"CharRNN_Interactive","url":"../javascript/CharRNN/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"../javascript/CharRNN/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"../javascript/CharRNN/CharRNN_Text_Stateful"}]},"DCGAN":{"p5js":[{"name":"DCGAN_LatentVector_RandomWalk","url":"../p5js/DCGAN/DCGAN_LatentVector_RandomWalk"},{"name":"DCGAN_LatentVector_Slider","url":"../p5js/DCGAN/DCGAN_LatentVector_Slider"},{"name":"DCGAN_Random","url":"../p5js/DCGAN/DCGAN_Random"},{"name":"model","url":"../p5js/DCGAN/model"}],"p5webeditor":[{"name":"DCGAN_LatentVector_RandomWalk","url":"https://editor.p5js.org/ml5/sketches/DCGAN_LatentVector_RandomWalk"},{"name":"DCGAN_LatentVector_Slider","url":"https://editor.p5js.org/ml5/sketches/DCGAN_LatentVector_Slider"},{"name":"DCGAN_Random","url":"https://editor.p5js.org/ml5/sketches/DCGAN_Random"},{"name":"model","url":"https://editor.p5js.org/ml5/sketches/model"}],"javascript":[{"name":"DCGAN_Random","url":"../javascript/DCGAN/DCGAN_Random"}]},"FaceApi":{"p5js":[{"name":"FaceApi_Image_Landmarks","url":"../p5js/FaceApi/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"../p5js/FaceApi/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"../p5js/FaceApi/FaceApi_Video_Landmarks_LocalModels"}],"p5webeditor":[{"name":"FaceApi_Image_Landmarks","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Video_Landmarks_LocalModels"}],"javascript":[{"name":"FaceApi_Image_Landmarks","url":"../javascript/FaceApi/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"../javascript/FaceApi/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"../javascript/FaceApi/FaceApi_Video_Landmarks_LocalModels"}]},"FeatureExtractor":{"p5js":[{"name":"FeatureExtractor_Image_Classification","url":"../p5js/FeatureExtractor/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"../p5js/FeatureExtractor/FeatureExtractor_Image_Regression"}],"p5webeditor":[{"name":"FeatureExtractor_Image_Classification","url":"https://editor.p5js.org/ml5/sketches/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"https://editor.p5js.org/ml5/sketches/FeatureExtractor_Image_Regression"}],"javascript":[{"name":"FeatureExtractor_Image_Classification","url":"../javascript/FeatureExtractor/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"../javascript/FeatureExtractor/FeatureExtractor_Image_Regression"}]},"ImageClassification":{"p5js":[{"name":"ImageClassification","url":"../p5js/ImageClassification/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"../p5js/ImageClassification/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"../p5js/ImageClassification/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"../p5js/ImageClassification/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"../p5js/ImageClassification/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"../p5js/ImageClassification/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"../p5js/ImageClassification/ImageClassification_VideoSound"},{"name":"ImageClassification_VideoSoundTranslate","url":"../p5js/ImageClassification/ImageClassification_VideoSoundTranslate"},{"name":"ImageClassification_Video_Load","url":"../p5js/ImageClassification/ImageClassification_Video_Load"}],"p5webeditor":[{"name":"ImageClassification","url":"https://editor.p5js.org/ml5/sketches/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoSound"},{"name":"ImageClassification_VideoSoundTranslate","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoSoundTranslate"},{"name":"ImageClassification_Video_Load","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_Video_Load"}],"javascript":[{"name":"ImageClassification","url":"../javascript/ImageClassification/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"../javascript/ImageClassification/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"../javascript/ImageClassification/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"../javascript/ImageClassification/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"../javascript/ImageClassification/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"../javascript/ImageClassification/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"../javascript/ImageClassification/ImageClassification_VideoSound"},{"name":"ImageClassification_Video_Load","url":"../javascript/ImageClassification/ImageClassification_Video_Load"}]},"KMeans":{"p5js":[{"name":"KMeans_imageSegmentation","url":"../p5js/KMeans/KMeans_imageSegmentation"}],"p5webeditor":[{"name":"KMeans_imageSegmentation","url":"https://editor.p5js.org/ml5/sketches/KMeans_imageSegmentation"}],"d3":[{"name":"KMeans_GaussianClusterDemo","url":"../d3/KMeans/KMeans_GaussianClusterDemo"}]},"KNNClassification":{"p5js":[{"name":"KNNClassification_PoseNet","url":"../p5js/KNNClassification/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"../p5js/KNNClassification/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"../p5js/KNNClassification/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"../p5js/KNNClassification/KNNClassification_VideoSquare"}],"p5webeditor":[{"name":"KNNClassification_PoseNet","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_VideoSquare"}],"javascript":[{"name":"KNNClassification_PoseNet","url":"../javascript/KNNClassification/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"../javascript/KNNClassification/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"../javascript/KNNClassification/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"../javascript/KNNClassification/KNNClassification_VideoSquare"}]},"NeuralNetwork":{"p5js":[{"name":"NeuralNetwork_ImageClassifier_Colors","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Colors"},{"name":"NeuralNetwork_ImageClassifier_Letters","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Letters"},{"name":"NeuralNetwork_ImageClassifier_Letters2","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Letters2"},{"name":"NeuralNetwork_ImageClassifier_Video","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Video"},{"name":"NeuralNetwork_Simple_AorB","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_AorB"},{"name":"NeuralNetwork_Simple_Classification","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_Classification"},{"name":"NeuralNetwork_Simple_Regression","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_Regression"},{"name":"NeuralNetwork_XOR","url":"../p5js/NeuralNetwork/NeuralNetwork_XOR"},{"name":"NeuralNetwork_basics","url":"../p5js/NeuralNetwork/NeuralNetwork_basics"},{"name":"NeuralNetwork_co2net","url":"../p5js/NeuralNetwork/NeuralNetwork_co2net"},{"name":"NeuralNetwork_color_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_color_classifier"},{"name":"NeuralNetwork_load_model","url":"../p5js/NeuralNetwork/NeuralNetwork_load_model"},{"name":"NeuralNetwork_load_saved_data","url":"../p5js/NeuralNetwork/NeuralNetwork_load_saved_data"},{"name":"NeuralNetwork_lowres_pixels","url":"../p5js/NeuralNetwork/NeuralNetwork_lowres_pixels"},{"name":"NeuralNetwork_multiple_layers","url":"../p5js/NeuralNetwork/NeuralNetwork_multiple_layers"},{"name":"NeuralNetwork_musical_face","url":"../p5js/NeuralNetwork/NeuralNetwork_musical_face"},{"name":"NeuralNetwork_musical_mouse","url":"../p5js/NeuralNetwork/NeuralNetwork_musical_mouse"},{"name":"NeuralNetwork_pose_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_pose_classifier"},{"name":"NeuralNetwork_titanic","url":"../p5js/NeuralNetwork/NeuralNetwork_titanic"},{"name":"NeuralNetwork_xy_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_xy_classifier"}],"p5webeditor":[{"name":"NeuralNetwork_ImageClassifier_Colors","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Colors"},{"name":"NeuralNetwork_ImageClassifier_Letters","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Letters"},{"name":"NeuralNetwork_ImageClassifier_Letters2","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Letters2"},{"name":"NeuralNetwork_ImageClassifier_Video","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Video"},{"name":"NeuralNetwork_Simple_AorB","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_AorB"},{"name":"NeuralNetwork_Simple_Classification","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_Classification"},{"name":"NeuralNetwork_Simple_Regression","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_Regression"},{"name":"NeuralNetwork_XOR","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_XOR"},{"name":"NeuralNetwork_basics","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_basics"},{"name":"NeuralNetwork_co2net","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_co2net"},{"name":"NeuralNetwork_color_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_color_classifier"},{"name":"NeuralNetwork_load_model","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_load_model"},{"name":"NeuralNetwork_load_saved_data","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_load_saved_data"},{"name":"NeuralNetwork_lowres_pixels","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_lowres_pixels"},{"name":"NeuralNetwork_multiple_layers","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_multiple_layers"},{"name":"NeuralNetwork_musical_face","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_musical_face"},{"name":"NeuralNetwork_musical_mouse","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_musical_mouse"},{"name":"NeuralNetwork_pose_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_pose_classifier"},{"name":"NeuralNetwork_titanic","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_titanic"},{"name":"NeuralNetwork_xy_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_xy_classifier"}]},"ObjectDetector":{"p5js":[{"name":"ObjectDetector_COCOSSD_Video","url":"../p5js/ObjectDetector/ObjectDetector_COCOSSD_Video"},{"name":"ObjectDetector_COCOSSD_single_image","url":"../p5js/ObjectDetector/ObjectDetector_COCOSSD_single_image"},{"name":"ObjectDetector_YOLO_Video","url":"../p5js/ObjectDetector/ObjectDetector_YOLO_Video"},{"name":"ObjectDetector_YOLO_single_image","url":"../p5js/ObjectDetector/ObjectDetector_YOLO_single_image"}],"p5webeditor":[{"name":"ObjectDetector_COCOSSD_Video","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_COCOSSD_Video"},{"name":"ObjectDetector_COCOSSD_single_image","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_COCOSSD_single_image"},{"name":"ObjectDetector_YOLO_Video","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_YOLO_Video"},{"name":"ObjectDetector_YOLO_single_image","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_YOLO_single_image"}],"javascript":[{"name":"COCOSSD_single_image","url":"../javascript/ObjectDetector/COCOSSD_single_image"},{"name":"COCOSSD_webcam","url":"../javascript/ObjectDetector/COCOSSD_webcam"},{"name":"YOLO_single_image","url":"../javascript/ObjectDetector/YOLO_single_image"},{"name":"YOLO_webcam","url":"../javascript/ObjectDetector/YOLO_webcam"}]},"PitchDetection":{"p5js":[{"name":"PitchDetection","url":"../p5js/PitchDetection/PitchDetection"},{"name":"PitchDetection_Game","url":"../p5js/PitchDetection/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"../p5js/PitchDetection/PitchDetection_Piano"}],"p5webeditor":[{"name":"PitchDetection","url":"https://editor.p5js.org/ml5/sketches/PitchDetection"},{"name":"PitchDetection_Game","url":"https://editor.p5js.org/ml5/sketches/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"https://editor.p5js.org/ml5/sketches/PitchDetection_Piano"}],"javascript":[{"name":"PitchDetection","url":"../javascript/PitchDetection/PitchDetection"},{"name":"PitchDetection_Game","url":"../javascript/PitchDetection/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"../javascript/PitchDetection/PitchDetection_Piano"}]},"Pix2Pix":{"p5js":[{"name":"Pix2Pix_callback","url":"../p5js/Pix2Pix/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"../p5js/Pix2Pix/Pix2Pix_promise"}],"p5webeditor":[{"name":"Pix2Pix_callback","url":"https://editor.p5js.org/ml5/sketches/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"https://editor.p5js.org/ml5/sketches/Pix2Pix_promise"}],"javascript":[{"name":"Pix2Pix_callback","url":"../javascript/Pix2Pix/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"../javascript/Pix2Pix/Pix2Pix_promise"}]},"PoseNet":{"p5js":[{"name":"PoseNet_image_single","url":"../p5js/PoseNet/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"../p5js/PoseNet/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"../p5js/PoseNet/PoseNet_webcam"}],"p5webeditor":[{"name":"PoseNet_image_single","url":"https://editor.p5js.org/ml5/sketches/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"https://editor.p5js.org/ml5/sketches/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"https://editor.p5js.org/ml5/sketches/PoseNet_webcam"}],"javascript":[{"name":"PoseNet_image_single","url":"../javascript/PoseNet/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"../javascript/PoseNet/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"../javascript/PoseNet/PoseNet_webcam"}]},"Sentiment":{"p5js":[{"name":"Sentiment_Interactive","url":"../p5js/Sentiment/Sentiment_Interactive"}],"p5webeditor":[{"name":"Sentiment_Interactive","url":"https://editor.p5js.org/ml5/sketches/Sentiment_Interactive"}],"javascript":[{"name":"Sentiment_Interactive","url":"../javascript/Sentiment/Sentiment_Interactive"}]},"SketchRNN":{"p5js":[{"name":"SketchRNN_basic","url":"../p5js/SketchRNN/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"../p5js/SketchRNN/SketchRNN_interactive"}],"p5webeditor":[{"name":"SketchRNN_basic","url":"https://editor.p5js.org/ml5/sketches/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"https://editor.p5js.org/ml5/sketches/SketchRNN_interactive"}],"javascript":[{"name":"SketchRNN_basic","url":"../javascript/SketchRNN/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"../javascript/SketchRNN/SketchRNN_interactive"}]},"SoundClassification":{"p5js":[{"name":"SoundClassification_speechcommand","url":"../p5js/SoundClassification/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"../p5js/SoundClassification/SoundClassification_speechcommand_load"}],"p5webeditor":[{"name":"SoundClassification_speechcommand","url":"https://editor.p5js.org/ml5/sketches/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"https://editor.p5js.org/ml5/sketches/SoundClassification_speechcommand_load"}],"javascript":[{"name":"SoundClassification_speechcommand","url":"../javascript/SoundClassification/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"../javascript/SoundClassification/SoundClassification_speechcommand_load"}]},"StyleTransfer":{"p5js":[{"name":"StyleTransfer_Image","url":"../p5js/StyleTransfer/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"../p5js/StyleTransfer/StyleTransfer_Video"}],"p5webeditor":[{"name":"StyleTransfer_Image","url":"https://editor.p5js.org/ml5/sketches/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"https://editor.p5js.org/ml5/sketches/StyleTransfer_Video"}],"javascript":[{"name":"StyleTransfer_Image","url":"../javascript/StyleTransfer/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"../javascript/StyleTransfer/StyleTransfer_Video"}]},"TeachableMachine":{"p5js":[{"name":"ImageModel_TM","url":"../p5js/TeachableMachine/ImageModel_TM"},{"name":"SoundModel_TM","url":"../p5js/TeachableMachine/SoundModel_TM"}],"p5webeditor":[{"name":"ImageModel_TM","url":"https://editor.p5js.org/ml5/sketches/ImageModel_TM"},{"name":"SoundModel_TM","url":"https://editor.p5js.org/ml5/sketches/SoundModel_TM"}]},"UNET":{"p5js":[{"name":"UNET_webcam","url":"../p5js/UNET/UNET_webcam"}],"p5webeditor":[{"name":"UNET_webcam","url":"https://editor.p5js.org/ml5/sketches/UNET_webcam"}],"javascript":[{"name":"UNET_webcam","url":"../javascript/UNET/UNET_webcam"}]},"Word2Vec":{"p5js":[{"name":"Word2Vec_Interactive","url":"../p5js/Word2Vec/Word2Vec_Interactive"}],"p5webeditor":[{"name":"Word2Vec_Interactive","url":"https://editor.p5js.org/ml5/sketches/Word2Vec_Interactive"}],"javascript":[{"name":"Word2Vec_Interactive","url":"../javascript/Word2Vec/Word2Vec_Interactive"}]},"YOLO":{"p5js":[{"name":"YOLO_single_image","url":"../p5js/YOLO/YOLO_single_image"},{"name":"YOLO_webcam","url":"../p5js/YOLO/YOLO_webcam"}],"p5webeditor":[{"name":"YOLO_single_image","url":"https://editor.p5js.org/ml5/sketches/YOLO_single_image"},{"name":"YOLO_webcam","url":"https://editor.p5js.org/ml5/sketches/YOLO_webcam"}],"javascript":[{"name":"YOLO_single_image","url":"../javascript/YOLO/YOLO_single_image"},{"name":"YOLO_webcam","url":"../javascript/YOLO/YOLO_webcam"}]},"ml5_boilerplate":{"p5js":[],"p5webeditor":[],"javascript":[]}} \ No newline at end of file +{"BodyPix":{"p5js":[{"name":"BodyPix_Image","url":"../p5js/BodyPix/BodyPix_Image"},{"name":"BodyPix_Preload","url":"../p5js/BodyPix/BodyPix_Preload"},{"name":"BodyPix_Webcam","url":"../p5js/BodyPix/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"../p5js/BodyPix/BodyPix_Webcam_Parts"},{"name":"BodyPix_p5Instance","url":"../p5js/BodyPix/BodyPix_p5Instance"}],"p5webeditor":[{"name":"BodyPix_Image","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Image"},{"name":"BodyPix_Preload","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Preload"},{"name":"BodyPix_Webcam","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Webcam_Parts"},{"name":"BodyPix_p5Instance","url":"https://editor.p5js.org/ml5/sketches/BodyPix_p5Instance"}],"javascript":[{"name":"BodyPix_Image","url":"../javascript/BodyPix/BodyPix_Image"},{"name":"BodyPix_Webcam","url":"../javascript/BodyPix/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"../javascript/BodyPix/BodyPix_Webcam_Parts"}]},"CVAE":{"p5js":[{"name":"CVAE_QuickDraw","url":"../p5js/CVAE/CVAE_QuickDraw"}],"p5webeditor":[{"name":"CVAE_QuickDraw","url":"https://editor.p5js.org/ml5/sketches/CVAE_QuickDraw"}],"javascript":[{"name":"CVAE_QuickDraw","url":"../javascript/CVAE/CVAE_QuickDraw"}]},"CharRNN":{"p5js":[{"name":"CharRNN_Interactive","url":"../p5js/CharRNN/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"../p5js/CharRNN/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"../p5js/CharRNN/CharRNN_Text_Stateful"}],"p5webeditor":[{"name":"CharRNN_Interactive","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Text_Stateful"}],"javascript":[{"name":"CharRNN_Interactive","url":"../javascript/CharRNN/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"../javascript/CharRNN/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"../javascript/CharRNN/CharRNN_Text_Stateful"}]},"DCGAN":{"p5js":[{"name":"DCGAN_LatentVector_RandomWalk","url":"../p5js/DCGAN/DCGAN_LatentVector_RandomWalk"},{"name":"DCGAN_LatentVector_Slider","url":"../p5js/DCGAN/DCGAN_LatentVector_Slider"},{"name":"DCGAN_Random","url":"../p5js/DCGAN/DCGAN_Random"},{"name":"model","url":"../p5js/DCGAN/model"}],"p5webeditor":[{"name":"DCGAN_LatentVector_RandomWalk","url":"https://editor.p5js.org/ml5/sketches/DCGAN_LatentVector_RandomWalk"},{"name":"DCGAN_LatentVector_Slider","url":"https://editor.p5js.org/ml5/sketches/DCGAN_LatentVector_Slider"},{"name":"DCGAN_Random","url":"https://editor.p5js.org/ml5/sketches/DCGAN_Random"},{"name":"model","url":"https://editor.p5js.org/ml5/sketches/model"}],"javascript":[{"name":"DCGAN_Random","url":"../javascript/DCGAN/DCGAN_Random"}]},"FaceApi":{"p5js":[{"name":"FaceApi_Image_Landmarks","url":"../p5js/FaceApi/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"../p5js/FaceApi/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"../p5js/FaceApi/FaceApi_Video_Landmarks_LocalModels"}],"p5webeditor":[{"name":"FaceApi_Image_Landmarks","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Video_Landmarks_LocalModels"}],"javascript":[{"name":"FaceApi_Image_Landmarks","url":"../javascript/FaceApi/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"../javascript/FaceApi/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"../javascript/FaceApi/FaceApi_Video_Landmarks_LocalModels"}]},"FeatureExtractor":{"p5js":[{"name":"FeatureExtractor_Image_Classification","url":"../p5js/FeatureExtractor/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"../p5js/FeatureExtractor/FeatureExtractor_Image_Regression"}],"p5webeditor":[{"name":"FeatureExtractor_Image_Classification","url":"https://editor.p5js.org/ml5/sketches/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"https://editor.p5js.org/ml5/sketches/FeatureExtractor_Image_Regression"}],"javascript":[{"name":"FeatureExtractor_Image_Classification","url":"../javascript/FeatureExtractor/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"../javascript/FeatureExtractor/FeatureExtractor_Image_Regression"}]},"ImageClassification":{"p5js":[{"name":"ImageClassification","url":"../p5js/ImageClassification/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"../p5js/ImageClassification/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"../p5js/ImageClassification/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"../p5js/ImageClassification/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"../p5js/ImageClassification/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"../p5js/ImageClassification/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"../p5js/ImageClassification/ImageClassification_VideoSound"},{"name":"ImageClassification_VideoSoundTranslate","url":"../p5js/ImageClassification/ImageClassification_VideoSoundTranslate"},{"name":"ImageClassification_Video_Load","url":"../p5js/ImageClassification/ImageClassification_Video_Load"}],"p5webeditor":[{"name":"ImageClassification","url":"https://editor.p5js.org/ml5/sketches/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoSound"},{"name":"ImageClassification_VideoSoundTranslate","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoSoundTranslate"},{"name":"ImageClassification_Video_Load","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_Video_Load"}],"javascript":[{"name":"ImageClassification","url":"../javascript/ImageClassification/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"../javascript/ImageClassification/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"../javascript/ImageClassification/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"../javascript/ImageClassification/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"../javascript/ImageClassification/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"../javascript/ImageClassification/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"../javascript/ImageClassification/ImageClassification_VideoSound"},{"name":"ImageClassification_Video_Load","url":"../javascript/ImageClassification/ImageClassification_Video_Load"}]},"KMeans":{"p5js":[{"name":"KMeans_imageSegmentation","url":"../p5js/KMeans/KMeans_imageSegmentation"}],"p5webeditor":[{"name":"KMeans_imageSegmentation","url":"https://editor.p5js.org/ml5/sketches/KMeans_imageSegmentation"}],"d3":[{"name":"KMeans_GaussianClusterDemo","url":"../d3/KMeans/KMeans_GaussianClusterDemo"}]},"KNNClassification":{"p5js":[{"name":"KNNClassification_PoseNet","url":"../p5js/KNNClassification/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"../p5js/KNNClassification/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"../p5js/KNNClassification/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"../p5js/KNNClassification/KNNClassification_VideoSquare"}],"p5webeditor":[{"name":"KNNClassification_PoseNet","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_VideoSquare"}],"javascript":[{"name":"KNNClassification_PoseNet","url":"../javascript/KNNClassification/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"../javascript/KNNClassification/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"../javascript/KNNClassification/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"../javascript/KNNClassification/KNNClassification_VideoSquare"}]},"NeuralNetwork":{"p5js":[{"name":"NeuralNetwork_ImageClassifier_Colors","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Colors"},{"name":"NeuralNetwork_ImageClassifier_Letters","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Letters"},{"name":"NeuralNetwork_ImageClassifier_Letters2","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Letters2"},{"name":"NeuralNetwork_ImageClassifier_Video","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Video"},{"name":"NeuralNetwork_Simple_AorB","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_AorB"},{"name":"NeuralNetwork_Simple_Classification","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_Classification"},{"name":"NeuralNetwork_Simple_Regression","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_Regression"},{"name":"NeuralNetwork_XOR","url":"../p5js/NeuralNetwork/NeuralNetwork_XOR"},{"name":"NeuralNetwork_basics","url":"../p5js/NeuralNetwork/NeuralNetwork_basics"},{"name":"NeuralNetwork_co2net","url":"../p5js/NeuralNetwork/NeuralNetwork_co2net"},{"name":"NeuralNetwork_color_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_color_classifier"},{"name":"NeuralNetwork_load_model","url":"../p5js/NeuralNetwork/NeuralNetwork_load_model"},{"name":"NeuralNetwork_load_saved_data","url":"../p5js/NeuralNetwork/NeuralNetwork_load_saved_data"},{"name":"NeuralNetwork_lowres_pixels","url":"../p5js/NeuralNetwork/NeuralNetwork_lowres_pixels"},{"name":"NeuralNetwork_multiple_layers","url":"../p5js/NeuralNetwork/NeuralNetwork_multiple_layers"},{"name":"NeuralNetwork_musical_face","url":"../p5js/NeuralNetwork/NeuralNetwork_musical_face"},{"name":"NeuralNetwork_musical_mouse","url":"../p5js/NeuralNetwork/NeuralNetwork_musical_mouse"},{"name":"NeuralNetwork_pose_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_pose_classifier"},{"name":"NeuralNetwork_titanic","url":"../p5js/NeuralNetwork/NeuralNetwork_titanic"},{"name":"NeuralNetwork_xy_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_xy_classifier"}],"p5webeditor":[{"name":"NeuralNetwork_ImageClassifier_Colors","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Colors"},{"name":"NeuralNetwork_ImageClassifier_Letters","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Letters"},{"name":"NeuralNetwork_ImageClassifier_Letters2","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Letters2"},{"name":"NeuralNetwork_ImageClassifier_Video","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Video"},{"name":"NeuralNetwork_Simple_AorB","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_AorB"},{"name":"NeuralNetwork_Simple_Classification","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_Classification"},{"name":"NeuralNetwork_Simple_Regression","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_Regression"},{"name":"NeuralNetwork_XOR","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_XOR"},{"name":"NeuralNetwork_basics","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_basics"},{"name":"NeuralNetwork_co2net","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_co2net"},{"name":"NeuralNetwork_color_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_color_classifier"},{"name":"NeuralNetwork_load_model","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_load_model"},{"name":"NeuralNetwork_load_saved_data","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_load_saved_data"},{"name":"NeuralNetwork_lowres_pixels","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_lowres_pixels"},{"name":"NeuralNetwork_multiple_layers","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_multiple_layers"},{"name":"NeuralNetwork_musical_face","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_musical_face"},{"name":"NeuralNetwork_musical_mouse","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_musical_mouse"},{"name":"NeuralNetwork_pose_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_pose_classifier"},{"name":"NeuralNetwork_titanic","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_titanic"},{"name":"NeuralNetwork_xy_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_xy_classifier"}]},"ObjectDetector":{"p5js":[{"name":"ObjectDetector_COCOSSD_Video","url":"../p5js/ObjectDetector/ObjectDetector_COCOSSD_Video"},{"name":"ObjectDetector_COCOSSD_single_image","url":"../p5js/ObjectDetector/ObjectDetector_COCOSSD_single_image"},{"name":"ObjectDetector_YOLO_Video","url":"../p5js/ObjectDetector/ObjectDetector_YOLO_Video"},{"name":"ObjectDetector_YOLO_single_image","url":"../p5js/ObjectDetector/ObjectDetector_YOLO_single_image"}],"p5webeditor":[{"name":"ObjectDetector_COCOSSD_Video","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_COCOSSD_Video"},{"name":"ObjectDetector_COCOSSD_single_image","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_COCOSSD_single_image"},{"name":"ObjectDetector_YOLO_Video","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_YOLO_Video"},{"name":"ObjectDetector_YOLO_single_image","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_YOLO_single_image"}],"javascript":[{"name":"COCOSSD_single_image","url":"../javascript/ObjectDetector/COCOSSD_single_image"},{"name":"COCOSSD_webcam","url":"../javascript/ObjectDetector/COCOSSD_webcam"},{"name":"YOLO_single_image","url":"../javascript/ObjectDetector/YOLO_single_image"},{"name":"YOLO_webcam","url":"../javascript/ObjectDetector/YOLO_webcam"}]},"PitchDetection":{"p5js":[{"name":"PitchDetection","url":"../p5js/PitchDetection/PitchDetection"},{"name":"PitchDetection_Game","url":"../p5js/PitchDetection/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"../p5js/PitchDetection/PitchDetection_Piano"}],"p5webeditor":[{"name":"PitchDetection","url":"https://editor.p5js.org/ml5/sketches/PitchDetection"},{"name":"PitchDetection_Game","url":"https://editor.p5js.org/ml5/sketches/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"https://editor.p5js.org/ml5/sketches/PitchDetection_Piano"}],"javascript":[{"name":"PitchDetection","url":"../javascript/PitchDetection/PitchDetection"},{"name":"PitchDetection_Game","url":"../javascript/PitchDetection/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"../javascript/PitchDetection/PitchDetection_Piano"}]},"Pix2Pix":{"p5js":[{"name":"Pix2Pix_callback","url":"../p5js/Pix2Pix/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"../p5js/Pix2Pix/Pix2Pix_promise"}],"p5webeditor":[{"name":"Pix2Pix_callback","url":"https://editor.p5js.org/ml5/sketches/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"https://editor.p5js.org/ml5/sketches/Pix2Pix_promise"}],"javascript":[{"name":"Pix2Pix_callback","url":"../javascript/Pix2Pix/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"../javascript/Pix2Pix/Pix2Pix_promise"}]},"PoseNet":{"p5js":[{"name":"PoseNet_image_single","url":"../p5js/PoseNet/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"../p5js/PoseNet/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"../p5js/PoseNet/PoseNet_webcam"}],"p5webeditor":[{"name":"PoseNet_image_single","url":"https://editor.p5js.org/ml5/sketches/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"https://editor.p5js.org/ml5/sketches/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"https://editor.p5js.org/ml5/sketches/PoseNet_webcam"}],"javascript":[{"name":"PoseNet_image_single","url":"../javascript/PoseNet/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"../javascript/PoseNet/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"../javascript/PoseNet/PoseNet_webcam"}]},"Sentiment":{"p5js":[{"name":"Sentiment_Interactive","url":"../p5js/Sentiment/Sentiment_Interactive"}],"p5webeditor":[{"name":"Sentiment_Interactive","url":"https://editor.p5js.org/ml5/sketches/Sentiment_Interactive"}],"javascript":[{"name":"Sentiment_Interactive","url":"../javascript/Sentiment/Sentiment_Interactive"}]},"SketchRNN":{"p5js":[{"name":"SketchRNN_basic","url":"../p5js/SketchRNN/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"../p5js/SketchRNN/SketchRNN_interactive"}],"p5webeditor":[{"name":"SketchRNN_basic","url":"https://editor.p5js.org/ml5/sketches/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"https://editor.p5js.org/ml5/sketches/SketchRNN_interactive"}],"javascript":[{"name":"SketchRNN_basic","url":"../javascript/SketchRNN/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"../javascript/SketchRNN/SketchRNN_interactive"}]},"SoundClassification":{"p5js":[{"name":"SoundClassification_speechcommand","url":"../p5js/SoundClassification/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"../p5js/SoundClassification/SoundClassification_speechcommand_load"}],"p5webeditor":[{"name":"SoundClassification_speechcommand","url":"https://editor.p5js.org/ml5/sketches/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"https://editor.p5js.org/ml5/sketches/SoundClassification_speechcommand_load"}],"javascript":[{"name":"SoundClassification_speechcommand","url":"../javascript/SoundClassification/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"../javascript/SoundClassification/SoundClassification_speechcommand_load"}]},"StyleTransfer":{"p5js":[{"name":"StyleTransfer_Image","url":"../p5js/StyleTransfer/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"../p5js/StyleTransfer/StyleTransfer_Video"}],"p5webeditor":[{"name":"StyleTransfer_Image","url":"https://editor.p5js.org/ml5/sketches/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"https://editor.p5js.org/ml5/sketches/StyleTransfer_Video"}],"javascript":[{"name":"StyleTransfer_Image","url":"../javascript/StyleTransfer/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"../javascript/StyleTransfer/StyleTransfer_Video"}]},"TeachableMachine":{"p5js":[{"name":"ImageModel_TM","url":"../p5js/TeachableMachine/ImageModel_TM"},{"name":"SoundModel_TM","url":"../p5js/TeachableMachine/SoundModel_TM"}],"p5webeditor":[{"name":"ImageModel_TM","url":"https://editor.p5js.org/ml5/sketches/ImageModel_TM"},{"name":"SoundModel_TM","url":"https://editor.p5js.org/ml5/sketches/SoundModel_TM"}]},"UNET":{"p5js":[{"name":"UNET_webcam","url":"../p5js/UNET/UNET_webcam"}],"p5webeditor":[{"name":"UNET_webcam","url":"https://editor.p5js.org/ml5/sketches/UNET_webcam"}],"javascript":[{"name":"UNET_webcam","url":"../javascript/UNET/UNET_webcam"}]},"UniversalSentenceEncoder":{"p5js":[{"name":"UniversalSentenceEncoder_Basic","url":"../p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic"}],"p5webeditor":[{"name":"UniversalSentenceEncoder_Basic","url":"https://editor.p5js.org/ml5/sketches/UniversalSentenceEncoder_Basic"}]},"Word2Vec":{"p5js":[{"name":"Word2Vec_Interactive","url":"../p5js/Word2Vec/Word2Vec_Interactive"}],"p5webeditor":[{"name":"Word2Vec_Interactive","url":"https://editor.p5js.org/ml5/sketches/Word2Vec_Interactive"}],"javascript":[{"name":"Word2Vec_Interactive","url":"../javascript/Word2Vec/Word2Vec_Interactive"}]},"YOLO":{"p5js":[{"name":"YOLO_single_image","url":"../p5js/YOLO/YOLO_single_image"},{"name":"YOLO_webcam","url":"../p5js/YOLO/YOLO_webcam"}],"p5webeditor":[{"name":"YOLO_single_image","url":"https://editor.p5js.org/ml5/sketches/YOLO_single_image"},{"name":"YOLO_webcam","url":"https://editor.p5js.org/ml5/sketches/YOLO_webcam"}],"javascript":[{"name":"YOLO_single_image","url":"../javascript/YOLO/YOLO_single_image"},{"name":"YOLO_webcam","url":"../javascript/YOLO/YOLO_webcam"}]},"ml5_boilerplate":{"p5js":[],"p5webeditor":[],"javascript":[]}} \ No newline at end of file From e876c2d04b23e26de940d45a56f31f22f500250f Mon Sep 17 00:00:00 2001 From: joeyklee Date: Wed, 8 Apr 2020 12:56:47 -0400 Subject: [PATCH 8/8] adds tokenizer --- examples/examples.json | 2 +- .../UniversalSentenceEncoder_Basic/index.html | 4 +- .../index.html | 13 +++++++ .../sketch.js | 37 +++++++++++++++++++ src/UniversalSentenceEncoder/index.js | 36 +++++++++++++++++- 5 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer/index.html create mode 100644 examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer/sketch.js diff --git a/examples/examples.json b/examples/examples.json index 066ad7f1e..84c93a74e 100644 --- a/examples/examples.json +++ b/examples/examples.json @@ -1 +1 @@ -{"BodyPix":{"p5js":[{"name":"BodyPix_Image","url":"../p5js/BodyPix/BodyPix_Image"},{"name":"BodyPix_Preload","url":"../p5js/BodyPix/BodyPix_Preload"},{"name":"BodyPix_Webcam","url":"../p5js/BodyPix/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"../p5js/BodyPix/BodyPix_Webcam_Parts"},{"name":"BodyPix_p5Instance","url":"../p5js/BodyPix/BodyPix_p5Instance"}],"p5webeditor":[{"name":"BodyPix_Image","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Image"},{"name":"BodyPix_Preload","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Preload"},{"name":"BodyPix_Webcam","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Webcam_Parts"},{"name":"BodyPix_p5Instance","url":"https://editor.p5js.org/ml5/sketches/BodyPix_p5Instance"}],"javascript":[{"name":"BodyPix_Image","url":"../javascript/BodyPix/BodyPix_Image"},{"name":"BodyPix_Webcam","url":"../javascript/BodyPix/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"../javascript/BodyPix/BodyPix_Webcam_Parts"}]},"CVAE":{"p5js":[{"name":"CVAE_QuickDraw","url":"../p5js/CVAE/CVAE_QuickDraw"}],"p5webeditor":[{"name":"CVAE_QuickDraw","url":"https://editor.p5js.org/ml5/sketches/CVAE_QuickDraw"}],"javascript":[{"name":"CVAE_QuickDraw","url":"../javascript/CVAE/CVAE_QuickDraw"}]},"CharRNN":{"p5js":[{"name":"CharRNN_Interactive","url":"../p5js/CharRNN/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"../p5js/CharRNN/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"../p5js/CharRNN/CharRNN_Text_Stateful"}],"p5webeditor":[{"name":"CharRNN_Interactive","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Text_Stateful"}],"javascript":[{"name":"CharRNN_Interactive","url":"../javascript/CharRNN/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"../javascript/CharRNN/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"../javascript/CharRNN/CharRNN_Text_Stateful"}]},"DCGAN":{"p5js":[{"name":"DCGAN_LatentVector_RandomWalk","url":"../p5js/DCGAN/DCGAN_LatentVector_RandomWalk"},{"name":"DCGAN_LatentVector_Slider","url":"../p5js/DCGAN/DCGAN_LatentVector_Slider"},{"name":"DCGAN_Random","url":"../p5js/DCGAN/DCGAN_Random"},{"name":"model","url":"../p5js/DCGAN/model"}],"p5webeditor":[{"name":"DCGAN_LatentVector_RandomWalk","url":"https://editor.p5js.org/ml5/sketches/DCGAN_LatentVector_RandomWalk"},{"name":"DCGAN_LatentVector_Slider","url":"https://editor.p5js.org/ml5/sketches/DCGAN_LatentVector_Slider"},{"name":"DCGAN_Random","url":"https://editor.p5js.org/ml5/sketches/DCGAN_Random"},{"name":"model","url":"https://editor.p5js.org/ml5/sketches/model"}],"javascript":[{"name":"DCGAN_Random","url":"../javascript/DCGAN/DCGAN_Random"}]},"FaceApi":{"p5js":[{"name":"FaceApi_Image_Landmarks","url":"../p5js/FaceApi/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"../p5js/FaceApi/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"../p5js/FaceApi/FaceApi_Video_Landmarks_LocalModels"}],"p5webeditor":[{"name":"FaceApi_Image_Landmarks","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Video_Landmarks_LocalModels"}],"javascript":[{"name":"FaceApi_Image_Landmarks","url":"../javascript/FaceApi/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"../javascript/FaceApi/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"../javascript/FaceApi/FaceApi_Video_Landmarks_LocalModels"}]},"FeatureExtractor":{"p5js":[{"name":"FeatureExtractor_Image_Classification","url":"../p5js/FeatureExtractor/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"../p5js/FeatureExtractor/FeatureExtractor_Image_Regression"}],"p5webeditor":[{"name":"FeatureExtractor_Image_Classification","url":"https://editor.p5js.org/ml5/sketches/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"https://editor.p5js.org/ml5/sketches/FeatureExtractor_Image_Regression"}],"javascript":[{"name":"FeatureExtractor_Image_Classification","url":"../javascript/FeatureExtractor/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"../javascript/FeatureExtractor/FeatureExtractor_Image_Regression"}]},"ImageClassification":{"p5js":[{"name":"ImageClassification","url":"../p5js/ImageClassification/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"../p5js/ImageClassification/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"../p5js/ImageClassification/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"../p5js/ImageClassification/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"../p5js/ImageClassification/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"../p5js/ImageClassification/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"../p5js/ImageClassification/ImageClassification_VideoSound"},{"name":"ImageClassification_VideoSoundTranslate","url":"../p5js/ImageClassification/ImageClassification_VideoSoundTranslate"},{"name":"ImageClassification_Video_Load","url":"../p5js/ImageClassification/ImageClassification_Video_Load"}],"p5webeditor":[{"name":"ImageClassification","url":"https://editor.p5js.org/ml5/sketches/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoSound"},{"name":"ImageClassification_VideoSoundTranslate","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoSoundTranslate"},{"name":"ImageClassification_Video_Load","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_Video_Load"}],"javascript":[{"name":"ImageClassification","url":"../javascript/ImageClassification/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"../javascript/ImageClassification/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"../javascript/ImageClassification/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"../javascript/ImageClassification/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"../javascript/ImageClassification/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"../javascript/ImageClassification/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"../javascript/ImageClassification/ImageClassification_VideoSound"},{"name":"ImageClassification_Video_Load","url":"../javascript/ImageClassification/ImageClassification_Video_Load"}]},"KMeans":{"p5js":[{"name":"KMeans_imageSegmentation","url":"../p5js/KMeans/KMeans_imageSegmentation"}],"p5webeditor":[{"name":"KMeans_imageSegmentation","url":"https://editor.p5js.org/ml5/sketches/KMeans_imageSegmentation"}],"d3":[{"name":"KMeans_GaussianClusterDemo","url":"../d3/KMeans/KMeans_GaussianClusterDemo"}]},"KNNClassification":{"p5js":[{"name":"KNNClassification_PoseNet","url":"../p5js/KNNClassification/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"../p5js/KNNClassification/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"../p5js/KNNClassification/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"../p5js/KNNClassification/KNNClassification_VideoSquare"}],"p5webeditor":[{"name":"KNNClassification_PoseNet","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_VideoSquare"}],"javascript":[{"name":"KNNClassification_PoseNet","url":"../javascript/KNNClassification/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"../javascript/KNNClassification/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"../javascript/KNNClassification/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"../javascript/KNNClassification/KNNClassification_VideoSquare"}]},"NeuralNetwork":{"p5js":[{"name":"NeuralNetwork_ImageClassifier_Colors","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Colors"},{"name":"NeuralNetwork_ImageClassifier_Letters","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Letters"},{"name":"NeuralNetwork_ImageClassifier_Letters2","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Letters2"},{"name":"NeuralNetwork_ImageClassifier_Video","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Video"},{"name":"NeuralNetwork_Simple_AorB","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_AorB"},{"name":"NeuralNetwork_Simple_Classification","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_Classification"},{"name":"NeuralNetwork_Simple_Regression","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_Regression"},{"name":"NeuralNetwork_XOR","url":"../p5js/NeuralNetwork/NeuralNetwork_XOR"},{"name":"NeuralNetwork_basics","url":"../p5js/NeuralNetwork/NeuralNetwork_basics"},{"name":"NeuralNetwork_co2net","url":"../p5js/NeuralNetwork/NeuralNetwork_co2net"},{"name":"NeuralNetwork_color_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_color_classifier"},{"name":"NeuralNetwork_load_model","url":"../p5js/NeuralNetwork/NeuralNetwork_load_model"},{"name":"NeuralNetwork_load_saved_data","url":"../p5js/NeuralNetwork/NeuralNetwork_load_saved_data"},{"name":"NeuralNetwork_lowres_pixels","url":"../p5js/NeuralNetwork/NeuralNetwork_lowres_pixels"},{"name":"NeuralNetwork_multiple_layers","url":"../p5js/NeuralNetwork/NeuralNetwork_multiple_layers"},{"name":"NeuralNetwork_musical_face","url":"../p5js/NeuralNetwork/NeuralNetwork_musical_face"},{"name":"NeuralNetwork_musical_mouse","url":"../p5js/NeuralNetwork/NeuralNetwork_musical_mouse"},{"name":"NeuralNetwork_pose_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_pose_classifier"},{"name":"NeuralNetwork_titanic","url":"../p5js/NeuralNetwork/NeuralNetwork_titanic"},{"name":"NeuralNetwork_xy_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_xy_classifier"}],"p5webeditor":[{"name":"NeuralNetwork_ImageClassifier_Colors","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Colors"},{"name":"NeuralNetwork_ImageClassifier_Letters","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Letters"},{"name":"NeuralNetwork_ImageClassifier_Letters2","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Letters2"},{"name":"NeuralNetwork_ImageClassifier_Video","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Video"},{"name":"NeuralNetwork_Simple_AorB","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_AorB"},{"name":"NeuralNetwork_Simple_Classification","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_Classification"},{"name":"NeuralNetwork_Simple_Regression","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_Regression"},{"name":"NeuralNetwork_XOR","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_XOR"},{"name":"NeuralNetwork_basics","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_basics"},{"name":"NeuralNetwork_co2net","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_co2net"},{"name":"NeuralNetwork_color_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_color_classifier"},{"name":"NeuralNetwork_load_model","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_load_model"},{"name":"NeuralNetwork_load_saved_data","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_load_saved_data"},{"name":"NeuralNetwork_lowres_pixels","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_lowres_pixels"},{"name":"NeuralNetwork_multiple_layers","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_multiple_layers"},{"name":"NeuralNetwork_musical_face","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_musical_face"},{"name":"NeuralNetwork_musical_mouse","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_musical_mouse"},{"name":"NeuralNetwork_pose_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_pose_classifier"},{"name":"NeuralNetwork_titanic","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_titanic"},{"name":"NeuralNetwork_xy_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_xy_classifier"}]},"ObjectDetector":{"p5js":[{"name":"ObjectDetector_COCOSSD_Video","url":"../p5js/ObjectDetector/ObjectDetector_COCOSSD_Video"},{"name":"ObjectDetector_COCOSSD_single_image","url":"../p5js/ObjectDetector/ObjectDetector_COCOSSD_single_image"},{"name":"ObjectDetector_YOLO_Video","url":"../p5js/ObjectDetector/ObjectDetector_YOLO_Video"},{"name":"ObjectDetector_YOLO_single_image","url":"../p5js/ObjectDetector/ObjectDetector_YOLO_single_image"}],"p5webeditor":[{"name":"ObjectDetector_COCOSSD_Video","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_COCOSSD_Video"},{"name":"ObjectDetector_COCOSSD_single_image","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_COCOSSD_single_image"},{"name":"ObjectDetector_YOLO_Video","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_YOLO_Video"},{"name":"ObjectDetector_YOLO_single_image","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_YOLO_single_image"}],"javascript":[{"name":"COCOSSD_single_image","url":"../javascript/ObjectDetector/COCOSSD_single_image"},{"name":"COCOSSD_webcam","url":"../javascript/ObjectDetector/COCOSSD_webcam"},{"name":"YOLO_single_image","url":"../javascript/ObjectDetector/YOLO_single_image"},{"name":"YOLO_webcam","url":"../javascript/ObjectDetector/YOLO_webcam"}]},"PitchDetection":{"p5js":[{"name":"PitchDetection","url":"../p5js/PitchDetection/PitchDetection"},{"name":"PitchDetection_Game","url":"../p5js/PitchDetection/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"../p5js/PitchDetection/PitchDetection_Piano"}],"p5webeditor":[{"name":"PitchDetection","url":"https://editor.p5js.org/ml5/sketches/PitchDetection"},{"name":"PitchDetection_Game","url":"https://editor.p5js.org/ml5/sketches/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"https://editor.p5js.org/ml5/sketches/PitchDetection_Piano"}],"javascript":[{"name":"PitchDetection","url":"../javascript/PitchDetection/PitchDetection"},{"name":"PitchDetection_Game","url":"../javascript/PitchDetection/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"../javascript/PitchDetection/PitchDetection_Piano"}]},"Pix2Pix":{"p5js":[{"name":"Pix2Pix_callback","url":"../p5js/Pix2Pix/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"../p5js/Pix2Pix/Pix2Pix_promise"}],"p5webeditor":[{"name":"Pix2Pix_callback","url":"https://editor.p5js.org/ml5/sketches/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"https://editor.p5js.org/ml5/sketches/Pix2Pix_promise"}],"javascript":[{"name":"Pix2Pix_callback","url":"../javascript/Pix2Pix/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"../javascript/Pix2Pix/Pix2Pix_promise"}]},"PoseNet":{"p5js":[{"name":"PoseNet_image_single","url":"../p5js/PoseNet/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"../p5js/PoseNet/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"../p5js/PoseNet/PoseNet_webcam"}],"p5webeditor":[{"name":"PoseNet_image_single","url":"https://editor.p5js.org/ml5/sketches/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"https://editor.p5js.org/ml5/sketches/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"https://editor.p5js.org/ml5/sketches/PoseNet_webcam"}],"javascript":[{"name":"PoseNet_image_single","url":"../javascript/PoseNet/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"../javascript/PoseNet/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"../javascript/PoseNet/PoseNet_webcam"}]},"Sentiment":{"p5js":[{"name":"Sentiment_Interactive","url":"../p5js/Sentiment/Sentiment_Interactive"}],"p5webeditor":[{"name":"Sentiment_Interactive","url":"https://editor.p5js.org/ml5/sketches/Sentiment_Interactive"}],"javascript":[{"name":"Sentiment_Interactive","url":"../javascript/Sentiment/Sentiment_Interactive"}]},"SketchRNN":{"p5js":[{"name":"SketchRNN_basic","url":"../p5js/SketchRNN/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"../p5js/SketchRNN/SketchRNN_interactive"}],"p5webeditor":[{"name":"SketchRNN_basic","url":"https://editor.p5js.org/ml5/sketches/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"https://editor.p5js.org/ml5/sketches/SketchRNN_interactive"}],"javascript":[{"name":"SketchRNN_basic","url":"../javascript/SketchRNN/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"../javascript/SketchRNN/SketchRNN_interactive"}]},"SoundClassification":{"p5js":[{"name":"SoundClassification_speechcommand","url":"../p5js/SoundClassification/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"../p5js/SoundClassification/SoundClassification_speechcommand_load"}],"p5webeditor":[{"name":"SoundClassification_speechcommand","url":"https://editor.p5js.org/ml5/sketches/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"https://editor.p5js.org/ml5/sketches/SoundClassification_speechcommand_load"}],"javascript":[{"name":"SoundClassification_speechcommand","url":"../javascript/SoundClassification/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"../javascript/SoundClassification/SoundClassification_speechcommand_load"}]},"StyleTransfer":{"p5js":[{"name":"StyleTransfer_Image","url":"../p5js/StyleTransfer/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"../p5js/StyleTransfer/StyleTransfer_Video"}],"p5webeditor":[{"name":"StyleTransfer_Image","url":"https://editor.p5js.org/ml5/sketches/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"https://editor.p5js.org/ml5/sketches/StyleTransfer_Video"}],"javascript":[{"name":"StyleTransfer_Image","url":"../javascript/StyleTransfer/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"../javascript/StyleTransfer/StyleTransfer_Video"}]},"TeachableMachine":{"p5js":[{"name":"ImageModel_TM","url":"../p5js/TeachableMachine/ImageModel_TM"},{"name":"SoundModel_TM","url":"../p5js/TeachableMachine/SoundModel_TM"}],"p5webeditor":[{"name":"ImageModel_TM","url":"https://editor.p5js.org/ml5/sketches/ImageModel_TM"},{"name":"SoundModel_TM","url":"https://editor.p5js.org/ml5/sketches/SoundModel_TM"}]},"UNET":{"p5js":[{"name":"UNET_webcam","url":"../p5js/UNET/UNET_webcam"}],"p5webeditor":[{"name":"UNET_webcam","url":"https://editor.p5js.org/ml5/sketches/UNET_webcam"}],"javascript":[{"name":"UNET_webcam","url":"../javascript/UNET/UNET_webcam"}]},"UniversalSentenceEncoder":{"p5js":[{"name":"UniversalSentenceEncoder_Basic","url":"../p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic"}],"p5webeditor":[{"name":"UniversalSentenceEncoder_Basic","url":"https://editor.p5js.org/ml5/sketches/UniversalSentenceEncoder_Basic"}]},"Word2Vec":{"p5js":[{"name":"Word2Vec_Interactive","url":"../p5js/Word2Vec/Word2Vec_Interactive"}],"p5webeditor":[{"name":"Word2Vec_Interactive","url":"https://editor.p5js.org/ml5/sketches/Word2Vec_Interactive"}],"javascript":[{"name":"Word2Vec_Interactive","url":"../javascript/Word2Vec/Word2Vec_Interactive"}]},"YOLO":{"p5js":[{"name":"YOLO_single_image","url":"../p5js/YOLO/YOLO_single_image"},{"name":"YOLO_webcam","url":"../p5js/YOLO/YOLO_webcam"}],"p5webeditor":[{"name":"YOLO_single_image","url":"https://editor.p5js.org/ml5/sketches/YOLO_single_image"},{"name":"YOLO_webcam","url":"https://editor.p5js.org/ml5/sketches/YOLO_webcam"}],"javascript":[{"name":"YOLO_single_image","url":"../javascript/YOLO/YOLO_single_image"},{"name":"YOLO_webcam","url":"../javascript/YOLO/YOLO_webcam"}]},"ml5_boilerplate":{"p5js":[],"p5webeditor":[],"javascript":[]}} \ No newline at end of file +{"BodyPix":{"p5js":[{"name":"BodyPix_Image","url":"../p5js/BodyPix/BodyPix_Image"},{"name":"BodyPix_Preload","url":"../p5js/BodyPix/BodyPix_Preload"},{"name":"BodyPix_Webcam","url":"../p5js/BodyPix/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"../p5js/BodyPix/BodyPix_Webcam_Parts"},{"name":"BodyPix_p5Instance","url":"../p5js/BodyPix/BodyPix_p5Instance"}],"p5webeditor":[{"name":"BodyPix_Image","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Image"},{"name":"BodyPix_Preload","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Preload"},{"name":"BodyPix_Webcam","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"https://editor.p5js.org/ml5/sketches/BodyPix_Webcam_Parts"},{"name":"BodyPix_p5Instance","url":"https://editor.p5js.org/ml5/sketches/BodyPix_p5Instance"}],"javascript":[{"name":"BodyPix_Image","url":"../javascript/BodyPix/BodyPix_Image"},{"name":"BodyPix_Webcam","url":"../javascript/BodyPix/BodyPix_Webcam"},{"name":"BodyPix_Webcam_Parts","url":"../javascript/BodyPix/BodyPix_Webcam_Parts"}]},"CVAE":{"p5js":[{"name":"CVAE_QuickDraw","url":"../p5js/CVAE/CVAE_QuickDraw"}],"p5webeditor":[{"name":"CVAE_QuickDraw","url":"https://editor.p5js.org/ml5/sketches/CVAE_QuickDraw"}],"javascript":[{"name":"CVAE_QuickDraw","url":"../javascript/CVAE/CVAE_QuickDraw"}]},"CharRNN":{"p5js":[{"name":"CharRNN_Interactive","url":"../p5js/CharRNN/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"../p5js/CharRNN/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"../p5js/CharRNN/CharRNN_Text_Stateful"}],"p5webeditor":[{"name":"CharRNN_Interactive","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"https://editor.p5js.org/ml5/sketches/CharRNN_Text_Stateful"}],"javascript":[{"name":"CharRNN_Interactive","url":"../javascript/CharRNN/CharRNN_Interactive"},{"name":"CharRNN_Text","url":"../javascript/CharRNN/CharRNN_Text"},{"name":"CharRNN_Text_Stateful","url":"../javascript/CharRNN/CharRNN_Text_Stateful"}]},"DCGAN":{"p5js":[{"name":"DCGAN_LatentVector_RandomWalk","url":"../p5js/DCGAN/DCGAN_LatentVector_RandomWalk"},{"name":"DCGAN_LatentVector_Slider","url":"../p5js/DCGAN/DCGAN_LatentVector_Slider"},{"name":"DCGAN_Random","url":"../p5js/DCGAN/DCGAN_Random"},{"name":"model","url":"../p5js/DCGAN/model"}],"p5webeditor":[{"name":"DCGAN_LatentVector_RandomWalk","url":"https://editor.p5js.org/ml5/sketches/DCGAN_LatentVector_RandomWalk"},{"name":"DCGAN_LatentVector_Slider","url":"https://editor.p5js.org/ml5/sketches/DCGAN_LatentVector_Slider"},{"name":"DCGAN_Random","url":"https://editor.p5js.org/ml5/sketches/DCGAN_Random"},{"name":"model","url":"https://editor.p5js.org/ml5/sketches/model"}],"javascript":[{"name":"DCGAN_Random","url":"../javascript/DCGAN/DCGAN_Random"}]},"FaceApi":{"p5js":[{"name":"FaceApi_Image_Landmarks","url":"../p5js/FaceApi/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"../p5js/FaceApi/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"../p5js/FaceApi/FaceApi_Video_Landmarks_LocalModels"}],"p5webeditor":[{"name":"FaceApi_Image_Landmarks","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"https://editor.p5js.org/ml5/sketches/FaceApi_Video_Landmarks_LocalModels"}],"javascript":[{"name":"FaceApi_Image_Landmarks","url":"../javascript/FaceApi/FaceApi_Image_Landmarks"},{"name":"FaceApi_Video_Landmarks","url":"../javascript/FaceApi/FaceApi_Video_Landmarks"},{"name":"FaceApi_Video_Landmarks_LocalModels","url":"../javascript/FaceApi/FaceApi_Video_Landmarks_LocalModels"}]},"FeatureExtractor":{"p5js":[{"name":"FeatureExtractor_Image_Classification","url":"../p5js/FeatureExtractor/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"../p5js/FeatureExtractor/FeatureExtractor_Image_Regression"}],"p5webeditor":[{"name":"FeatureExtractor_Image_Classification","url":"https://editor.p5js.org/ml5/sketches/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"https://editor.p5js.org/ml5/sketches/FeatureExtractor_Image_Regression"}],"javascript":[{"name":"FeatureExtractor_Image_Classification","url":"../javascript/FeatureExtractor/FeatureExtractor_Image_Classification"},{"name":"FeatureExtractor_Image_Regression","url":"../javascript/FeatureExtractor/FeatureExtractor_Image_Regression"}]},"ImageClassification":{"p5js":[{"name":"ImageClassification","url":"../p5js/ImageClassification/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"../p5js/ImageClassification/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"../p5js/ImageClassification/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"../p5js/ImageClassification/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"../p5js/ImageClassification/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"../p5js/ImageClassification/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"../p5js/ImageClassification/ImageClassification_VideoSound"},{"name":"ImageClassification_VideoSoundTranslate","url":"../p5js/ImageClassification/ImageClassification_VideoSoundTranslate"},{"name":"ImageClassification_Video_Load","url":"../p5js/ImageClassification/ImageClassification_Video_Load"}],"p5webeditor":[{"name":"ImageClassification","url":"https://editor.p5js.org/ml5/sketches/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoSound"},{"name":"ImageClassification_VideoSoundTranslate","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_VideoSoundTranslate"},{"name":"ImageClassification_Video_Load","url":"https://editor.p5js.org/ml5/sketches/ImageClassification_Video_Load"}],"javascript":[{"name":"ImageClassification","url":"../javascript/ImageClassification/ImageClassification"},{"name":"ImageClassification_DoodleNet_Canvas","url":"../javascript/ImageClassification/ImageClassification_DoodleNet_Canvas"},{"name":"ImageClassification_DoodleNet_Video","url":"../javascript/ImageClassification/ImageClassification_DoodleNet_Video"},{"name":"ImageClassification_MultipleImages","url":"../javascript/ImageClassification/ImageClassification_MultipleImages"},{"name":"ImageClassification_Video","url":"../javascript/ImageClassification/ImageClassification_Video"},{"name":"ImageClassification_VideoScavengerHunt","url":"../javascript/ImageClassification/ImageClassification_VideoScavengerHunt"},{"name":"ImageClassification_VideoSound","url":"../javascript/ImageClassification/ImageClassification_VideoSound"},{"name":"ImageClassification_Video_Load","url":"../javascript/ImageClassification/ImageClassification_Video_Load"}]},"KMeans":{"p5js":[{"name":"KMeans_imageSegmentation","url":"../p5js/KMeans/KMeans_imageSegmentation"}],"p5webeditor":[{"name":"KMeans_imageSegmentation","url":"https://editor.p5js.org/ml5/sketches/KMeans_imageSegmentation"}],"d3":[{"name":"KMeans_GaussianClusterDemo","url":"../d3/KMeans/KMeans_GaussianClusterDemo"}]},"KNNClassification":{"p5js":[{"name":"KNNClassification_PoseNet","url":"../p5js/KNNClassification/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"../p5js/KNNClassification/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"../p5js/KNNClassification/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"../p5js/KNNClassification/KNNClassification_VideoSquare"}],"p5webeditor":[{"name":"KNNClassification_PoseNet","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"https://editor.p5js.org/ml5/sketches/KNNClassification_VideoSquare"}],"javascript":[{"name":"KNNClassification_PoseNet","url":"../javascript/KNNClassification/KNNClassification_PoseNet"},{"name":"KNNClassification_Video","url":"../javascript/KNNClassification/KNNClassification_Video"},{"name":"KNNClassification_VideoSound","url":"../javascript/KNNClassification/KNNClassification_VideoSound"},{"name":"KNNClassification_VideoSquare","url":"../javascript/KNNClassification/KNNClassification_VideoSquare"}]},"NeuralNetwork":{"p5js":[{"name":"NeuralNetwork_ImageClassifier_Colors","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Colors"},{"name":"NeuralNetwork_ImageClassifier_Letters","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Letters"},{"name":"NeuralNetwork_ImageClassifier_Letters2","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Letters2"},{"name":"NeuralNetwork_ImageClassifier_Video","url":"../p5js/NeuralNetwork/NeuralNetwork_ImageClassifier_Video"},{"name":"NeuralNetwork_Simple_AorB","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_AorB"},{"name":"NeuralNetwork_Simple_Classification","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_Classification"},{"name":"NeuralNetwork_Simple_Regression","url":"../p5js/NeuralNetwork/NeuralNetwork_Simple_Regression"},{"name":"NeuralNetwork_XOR","url":"../p5js/NeuralNetwork/NeuralNetwork_XOR"},{"name":"NeuralNetwork_basics","url":"../p5js/NeuralNetwork/NeuralNetwork_basics"},{"name":"NeuralNetwork_co2net","url":"../p5js/NeuralNetwork/NeuralNetwork_co2net"},{"name":"NeuralNetwork_color_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_color_classifier"},{"name":"NeuralNetwork_load_model","url":"../p5js/NeuralNetwork/NeuralNetwork_load_model"},{"name":"NeuralNetwork_load_saved_data","url":"../p5js/NeuralNetwork/NeuralNetwork_load_saved_data"},{"name":"NeuralNetwork_lowres_pixels","url":"../p5js/NeuralNetwork/NeuralNetwork_lowres_pixels"},{"name":"NeuralNetwork_multiple_layers","url":"../p5js/NeuralNetwork/NeuralNetwork_multiple_layers"},{"name":"NeuralNetwork_musical_face","url":"../p5js/NeuralNetwork/NeuralNetwork_musical_face"},{"name":"NeuralNetwork_musical_mouse","url":"../p5js/NeuralNetwork/NeuralNetwork_musical_mouse"},{"name":"NeuralNetwork_pose_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_pose_classifier"},{"name":"NeuralNetwork_titanic","url":"../p5js/NeuralNetwork/NeuralNetwork_titanic"},{"name":"NeuralNetwork_xy_classifier","url":"../p5js/NeuralNetwork/NeuralNetwork_xy_classifier"}],"p5webeditor":[{"name":"NeuralNetwork_ImageClassifier_Colors","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Colors"},{"name":"NeuralNetwork_ImageClassifier_Letters","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Letters"},{"name":"NeuralNetwork_ImageClassifier_Letters2","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Letters2"},{"name":"NeuralNetwork_ImageClassifier_Video","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_ImageClassifier_Video"},{"name":"NeuralNetwork_Simple_AorB","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_AorB"},{"name":"NeuralNetwork_Simple_Classification","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_Classification"},{"name":"NeuralNetwork_Simple_Regression","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_Simple_Regression"},{"name":"NeuralNetwork_XOR","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_XOR"},{"name":"NeuralNetwork_basics","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_basics"},{"name":"NeuralNetwork_co2net","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_co2net"},{"name":"NeuralNetwork_color_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_color_classifier"},{"name":"NeuralNetwork_load_model","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_load_model"},{"name":"NeuralNetwork_load_saved_data","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_load_saved_data"},{"name":"NeuralNetwork_lowres_pixels","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_lowres_pixels"},{"name":"NeuralNetwork_multiple_layers","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_multiple_layers"},{"name":"NeuralNetwork_musical_face","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_musical_face"},{"name":"NeuralNetwork_musical_mouse","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_musical_mouse"},{"name":"NeuralNetwork_pose_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_pose_classifier"},{"name":"NeuralNetwork_titanic","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_titanic"},{"name":"NeuralNetwork_xy_classifier","url":"https://editor.p5js.org/ml5/sketches/NeuralNetwork_xy_classifier"}]},"ObjectDetector":{"p5js":[{"name":"ObjectDetector_COCOSSD_Video","url":"../p5js/ObjectDetector/ObjectDetector_COCOSSD_Video"},{"name":"ObjectDetector_COCOSSD_single_image","url":"../p5js/ObjectDetector/ObjectDetector_COCOSSD_single_image"},{"name":"ObjectDetector_YOLO_Video","url":"../p5js/ObjectDetector/ObjectDetector_YOLO_Video"},{"name":"ObjectDetector_YOLO_single_image","url":"../p5js/ObjectDetector/ObjectDetector_YOLO_single_image"}],"p5webeditor":[{"name":"ObjectDetector_COCOSSD_Video","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_COCOSSD_Video"},{"name":"ObjectDetector_COCOSSD_single_image","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_COCOSSD_single_image"},{"name":"ObjectDetector_YOLO_Video","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_YOLO_Video"},{"name":"ObjectDetector_YOLO_single_image","url":"https://editor.p5js.org/ml5/sketches/ObjectDetector_YOLO_single_image"}],"javascript":[{"name":"COCOSSD_single_image","url":"../javascript/ObjectDetector/COCOSSD_single_image"},{"name":"COCOSSD_webcam","url":"../javascript/ObjectDetector/COCOSSD_webcam"},{"name":"YOLO_single_image","url":"../javascript/ObjectDetector/YOLO_single_image"},{"name":"YOLO_webcam","url":"../javascript/ObjectDetector/YOLO_webcam"}]},"PitchDetection":{"p5js":[{"name":"PitchDetection","url":"../p5js/PitchDetection/PitchDetection"},{"name":"PitchDetection_Game","url":"../p5js/PitchDetection/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"../p5js/PitchDetection/PitchDetection_Piano"}],"p5webeditor":[{"name":"PitchDetection","url":"https://editor.p5js.org/ml5/sketches/PitchDetection"},{"name":"PitchDetection_Game","url":"https://editor.p5js.org/ml5/sketches/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"https://editor.p5js.org/ml5/sketches/PitchDetection_Piano"}],"javascript":[{"name":"PitchDetection","url":"../javascript/PitchDetection/PitchDetection"},{"name":"PitchDetection_Game","url":"../javascript/PitchDetection/PitchDetection_Game"},{"name":"PitchDetection_Piano","url":"../javascript/PitchDetection/PitchDetection_Piano"}]},"Pix2Pix":{"p5js":[{"name":"Pix2Pix_callback","url":"../p5js/Pix2Pix/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"../p5js/Pix2Pix/Pix2Pix_promise"}],"p5webeditor":[{"name":"Pix2Pix_callback","url":"https://editor.p5js.org/ml5/sketches/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"https://editor.p5js.org/ml5/sketches/Pix2Pix_promise"}],"javascript":[{"name":"Pix2Pix_callback","url":"../javascript/Pix2Pix/Pix2Pix_callback"},{"name":"Pix2Pix_promise","url":"../javascript/Pix2Pix/Pix2Pix_promise"}]},"PoseNet":{"p5js":[{"name":"PoseNet_image_single","url":"../p5js/PoseNet/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"../p5js/PoseNet/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"../p5js/PoseNet/PoseNet_webcam"}],"p5webeditor":[{"name":"PoseNet_image_single","url":"https://editor.p5js.org/ml5/sketches/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"https://editor.p5js.org/ml5/sketches/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"https://editor.p5js.org/ml5/sketches/PoseNet_webcam"}],"javascript":[{"name":"PoseNet_image_single","url":"../javascript/PoseNet/PoseNet_image_single"},{"name":"PoseNet_part_selection","url":"../javascript/PoseNet/PoseNet_part_selection"},{"name":"PoseNet_webcam","url":"../javascript/PoseNet/PoseNet_webcam"}]},"Sentiment":{"p5js":[{"name":"Sentiment_Interactive","url":"../p5js/Sentiment/Sentiment_Interactive"}],"p5webeditor":[{"name":"Sentiment_Interactive","url":"https://editor.p5js.org/ml5/sketches/Sentiment_Interactive"}],"javascript":[{"name":"Sentiment_Interactive","url":"../javascript/Sentiment/Sentiment_Interactive"}]},"SketchRNN":{"p5js":[{"name":"SketchRNN_basic","url":"../p5js/SketchRNN/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"../p5js/SketchRNN/SketchRNN_interactive"}],"p5webeditor":[{"name":"SketchRNN_basic","url":"https://editor.p5js.org/ml5/sketches/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"https://editor.p5js.org/ml5/sketches/SketchRNN_interactive"}],"javascript":[{"name":"SketchRNN_basic","url":"../javascript/SketchRNN/SketchRNN_basic"},{"name":"SketchRNN_interactive","url":"../javascript/SketchRNN/SketchRNN_interactive"}]},"SoundClassification":{"p5js":[{"name":"SoundClassification_speechcommand","url":"../p5js/SoundClassification/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"../p5js/SoundClassification/SoundClassification_speechcommand_load"}],"p5webeditor":[{"name":"SoundClassification_speechcommand","url":"https://editor.p5js.org/ml5/sketches/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"https://editor.p5js.org/ml5/sketches/SoundClassification_speechcommand_load"}],"javascript":[{"name":"SoundClassification_speechcommand","url":"../javascript/SoundClassification/SoundClassification_speechcommand"},{"name":"SoundClassification_speechcommand_load","url":"../javascript/SoundClassification/SoundClassification_speechcommand_load"}]},"StyleTransfer":{"p5js":[{"name":"StyleTransfer_Image","url":"../p5js/StyleTransfer/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"../p5js/StyleTransfer/StyleTransfer_Video"}],"p5webeditor":[{"name":"StyleTransfer_Image","url":"https://editor.p5js.org/ml5/sketches/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"https://editor.p5js.org/ml5/sketches/StyleTransfer_Video"}],"javascript":[{"name":"StyleTransfer_Image","url":"../javascript/StyleTransfer/StyleTransfer_Image"},{"name":"StyleTransfer_Video","url":"../javascript/StyleTransfer/StyleTransfer_Video"}]},"TeachableMachine":{"p5js":[{"name":"ImageModel_TM","url":"../p5js/TeachableMachine/ImageModel_TM"},{"name":"SoundModel_TM","url":"../p5js/TeachableMachine/SoundModel_TM"}],"p5webeditor":[{"name":"ImageModel_TM","url":"https://editor.p5js.org/ml5/sketches/ImageModel_TM"},{"name":"SoundModel_TM","url":"https://editor.p5js.org/ml5/sketches/SoundModel_TM"}]},"UNET":{"p5js":[{"name":"UNET_webcam","url":"../p5js/UNET/UNET_webcam"}],"p5webeditor":[{"name":"UNET_webcam","url":"https://editor.p5js.org/ml5/sketches/UNET_webcam"}],"javascript":[{"name":"UNET_webcam","url":"../javascript/UNET/UNET_webcam"}]},"UniversalSentenceEncoder":{"p5js":[{"name":"UniversalSentenceEncoder_Basic","url":"../p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic"},{"name":"UniversalSentenceEncoder_WithTokenizer","url":"../p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer"}],"p5webeditor":[{"name":"UniversalSentenceEncoder_Basic","url":"https://editor.p5js.org/ml5/sketches/UniversalSentenceEncoder_Basic"},{"name":"UniversalSentenceEncoder_WithTokenizer","url":"https://editor.p5js.org/ml5/sketches/UniversalSentenceEncoder_WithTokenizer"}]},"Word2Vec":{"p5js":[{"name":"Word2Vec_Interactive","url":"../p5js/Word2Vec/Word2Vec_Interactive"}],"p5webeditor":[{"name":"Word2Vec_Interactive","url":"https://editor.p5js.org/ml5/sketches/Word2Vec_Interactive"}],"javascript":[{"name":"Word2Vec_Interactive","url":"../javascript/Word2Vec/Word2Vec_Interactive"}]},"YOLO":{"p5js":[{"name":"YOLO_single_image","url":"../p5js/YOLO/YOLO_single_image"},{"name":"YOLO_webcam","url":"../p5js/YOLO/YOLO_webcam"}],"p5webeditor":[{"name":"YOLO_single_image","url":"https://editor.p5js.org/ml5/sketches/YOLO_single_image"},{"name":"YOLO_webcam","url":"https://editor.p5js.org/ml5/sketches/YOLO_webcam"}],"javascript":[{"name":"YOLO_single_image","url":"../javascript/YOLO/YOLO_single_image"},{"name":"YOLO_webcam","url":"../javascript/YOLO/YOLO_webcam"}]},"ml5_boilerplate":{"p5js":[],"p5webeditor":[],"javascript":[]}} \ No newline at end of file diff --git a/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/index.html b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/index.html index d089c391c..e991cb694 100644 --- a/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/index.html +++ b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_Basic/index.html @@ -1,13 +1,13 @@ - Universal Sentence Encoder + Universal Sentence Encoder with Tokenizer -

Universal Sentence Encoder

+

Universal Sentence Encoder with Tokenizer

\ No newline at end of file diff --git a/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer/index.html b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer/index.html new file mode 100644 index 000000000..d089c391c --- /dev/null +++ b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer/index.html @@ -0,0 +1,13 @@ + + + + Universal Sentence Encoder + + + + + +

Universal Sentence Encoder

+ + + \ No newline at end of file diff --git a/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer/sketch.js b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer/sketch.js new file mode 100644 index 000000000..b7adec75a --- /dev/null +++ b/examples/p5js/UniversalSentenceEncoder/UniversalSentenceEncoder_WithTokenizer/sketch.js @@ -0,0 +1,37 @@ +let sentenceEncoder; +const sentence = 'Monday, Tuesday, Wednesday, Thursday, and Friday are days of the Week'; + + +function setup(){ + createCanvas(512, 512); + // background(220); + colorMode(HSB, 360, 100, 100); + rectMode(CENTER); + textAlign(CENTER); + sentenceEncoder = ml5.universalSentenceEncoder({withTokenizer:true}, modelLoaded) +} + +function modelLoaded(){ + console.log('model ready') + predict(); +} + +function predict(){ + console.log('predicting') + sentenceEncoder.encode(sentence, gotResults); +} + +function gotResults(err, result){ + if(err){ + return err; + } + console.log(result); + translate(40, 0); + result.forEach( (item, idx) => { + const rectHeight = map(item, 0, 7999, 0, 100); + fill(180, 100, 100); + rect(idx * 20, height/2 , 20, rectHeight); + }) + + +} diff --git a/src/UniversalSentenceEncoder/index.js b/src/UniversalSentenceEncoder/index.js index 93630d752..c20d192fa 100644 --- a/src/UniversalSentenceEncoder/index.js +++ b/src/UniversalSentenceEncoder/index.js @@ -2,22 +2,37 @@ import * as USE from '@tensorflow-models/universal-sentence-encoder'; import callCallback from '../utils/callcallback'; +const DEFAULTS = { + withTokenizer: false, +} + class UniversalSentenceEncoder { constructor(options, callback){ this.model = null; - this.config = {}; + this.tokenizer = null; + this.config = { + withTokenizer: options.withTokenizer || DEFAULTS.withTokenizer + }; - callCallback(this.loadModel(),callback); + callCallback(this.loadModel(), callback); } /** * load model */ async loadModel(){ + if(this.config.withTokenizer === true){ + this.tokenizer = await USE.loadTokenizer(); + } this.model = await USE.load(); return this; } + /** + * Encodes a string or array based on the USE + * @param {*} textString + * @param {*} callback + */ predict(textArray, callback){ return callCallback(this.predictInternal(textArray), callback); } @@ -34,6 +49,23 @@ class UniversalSentenceEncoder { } } + /** + * Encodes a string based on the loaded tokenizer if the withTokenizer:true + * @param {*} textString + * @param {*} callback + */ + encode(textString, callback){ + return callCallback(this.encodeInternal(textString), callback); + } + + async encodeInternal(textString){ + if(this.config.withTokenizer === true){ + return this.tokenizer.encode(textString); + } + console.error('withTokenizer must be set to true - please pass "withTokenizer:true" as an option in the constructor'); + return false; + } + } const universalSentenceEncoder = (optionsOr, cb) => {