Hi all,
Im not a developer but trying to learn the hard way! Im trying to write an MTA application that uses TensorflowJS but how do I register the module ???
Im using business application studio and executed npm install @tensorflow/tfjs @tensorflow-models/handpose and it has downloaded the modules into the node_modules folder and added them as dependencies in my package.json file.
I added the following code to my Component.js file
jQuery.myUniqueNamespace = { registerExternalLib: function(oShim) { if (sap.ui.loader && sap.ui.loader.config) { // official API since 1.56 sap.ui.loader.config({ shim: oShim }); } else { // internal API before 1.56 jQuery.sap.registerModuleShims(oShim); } }};
jQuery.myUniqueNamespace.registerExternalLib({ "sap/custom/plugins/gesturecontrol/node_modules/@tensorflow/tfjs/dist/tf": { "amd": true, "export": "tf" }});
jQuery.myUniqueNamespace.registerExternalLib({ "sap/custom/plugins/gesturecontrol/node_modules/@tensorflow-models/handpose/dist/handpose": { "amd": true, "export": "handpose" }});
I also added the following in my controller
sap.ui.define([ 'jquery.sap.global', "sap/dm/dme/podfoundation/controller/PluginViewController", "sap/ui/model/json/JSONModel", "sap/custom/plugins/gesturecontrol/node_modules/@tensorflow/tfjs/dist/tf", "sap/custom/plugins/gesturecontrol/node_modules/@tensorflow-models/handpose/dist/handpose"], function (jQuery, PluginViewController, JSONModel, tf, handpose) { "use strict";
sap.ui.define([ 'jquery.sap.global', "sap/dm/dme/podfoundation/controller/PluginViewController", "sap/ui/model/json/JSONModel", "sap/custom/plugins/gesturecontrol/node_modules/@tensorflow/tfjs/dist/tf", "sap/custom/plugins/gesturecontrol/node_modules/@tensorflow-models/handpose/dist/handpose"], function (jQuery, PluginViewController, JSONModel, tf, handpose) { "use strict";
When I test the code it throws a not found error
Uncaught (in promise) Error: failed to load 'sap/custom/plugins/gesturecontrol/node_modules/@tensorflow/tfjs/dist/tf.js'
Am i referencing the file location properly ? should I be loading it in a different way ?
I successfully built the app in a standalone ui5 app where I load the library in the index.html file with
<code><script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.0.0/dist/tf.min.js"></script>
but since the MTA app doesnt have an index.html file Im lost.
Any help is gratefully received.
Thanks
Kevin